summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--_config/101-lightline.vim55
-rw-r--r--_config/102-ack.vim12
-rw-r--r--_config/103-nerdtree.vim5
-rw-r--r--_config/104-open-browser.vim7
-rw-r--r--_config/105-fzf.vim31
-rw-r--r--_config/106-easymotion.vim8
-rw-r--r--_config/200-lsp.vim23
-rw-r--r--_config/201-ale.vim26
-rw-r--r--_config/202-async.vim14
-rw-r--r--_config/203-gitgutter.vim12
-rw-r--r--_config/204-fugitive.vim27
-rw-r--r--ftplugin/php.vim2
-rw-r--r--vimrc174
14 files changed, 400 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..331388f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.netrwhist
+autoload/
+plugged/
+tmp/
diff --git a/_config/101-lightline.vim b/_config/101-lightline.vim
new file mode 100644
index 0000000..fa3b439
--- /dev/null
+++ b/_config/101-lightline.vim
@@ -0,0 +1,55 @@
+if empty(globpath(&rtp, 'autoload/lightline.vim'))
+ finish
+endif
+
+let g:lightline = {
+\ 'colorscheme': 'wombat',
+\ 'active': {
+\ 'left': [['mode', 'paste', 'gitbranch'], ['filename', 'modified']],
+\ 'right': [['lineinfo'], ['percent'], ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok']]
+\ },
+\ 'component_expand': {
+\ 'linter_warnings': 'LightlineLinterWarnings',
+\ 'linter_errors': 'LightlineLinterErrors',
+\ 'linter_ok': 'LightlineLinterOK'
+\ },
+\ 'component_type': {
+\ 'readonly': 'error',
+\ 'linter_warnings': 'warning',
+\ 'linter_errors': 'error'
+\ },
+\ 'component_function': {
+\ 'gitbranch': 'fugitive#head'
+\ },
+\ }
+
+function! LightlineLinterWarnings() abort
+ let l:counts = ale#statusline#Count(bufnr(''))
+ let l:all_errors = l:counts.error + l:counts.style_error
+ let l:all_non_errors = l:counts.total - l:all_errors
+ return l:counts.total == 0 ? '' : printf('%d ◆', all_non_errors)
+endfunction
+
+function! LightlineLinterErrors() abort
+ let l:counts = ale#statusline#Count(bufnr(''))
+ let l:all_errors = l:counts.error + l:counts.style_error
+ let l:all_non_errors = l:counts.total - l:all_errors
+ return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
+endfunction
+
+function! LightlineLinterOK() abort
+ let l:counts = ale#statusline#Count(bufnr(''))
+ let l:all_errors = l:counts.error + l:counts.style_error
+ let l:all_non_errors = l:counts.total - l:all_errors
+ return l:counts.total == 0 ? '✓ ' : ''
+endfunction
+
+" Update and show lightline but only if it's visible (e.g., not in Goyo)
+function! s:MaybeUpdateLightline()
+ if exists('#lightline')
+ call lightline#update()
+ end
+endfunction
+
+autocmd User ALELint call s:MaybeUpdateLightline()
+
diff --git a/_config/102-ack.vim b/_config/102-ack.vim
new file mode 100644
index 0000000..a2689c9
--- /dev/null
+++ b/_config/102-ack.vim
@@ -0,0 +1,12 @@
+if empty(globpath(&rtp, 'autoload/ack.vim'))
+ finish
+endif
+
+" ack.vim
+" let g:ackprg = 'rg --vimgrep --no-heading --hidden --no-ignore-vcs'
+if executable('rg')
+ let g:ackprg = 'rg --vimgrep --no-heading --hidden -g "!{.git,node_modules}/*" '
+elseif executable('git')
+ let g:ackprg = 'git grep -I --line-number '
+endif
+
diff --git a/_config/103-nerdtree.vim b/_config/103-nerdtree.vim
new file mode 100644
index 0000000..ec52b48
--- /dev/null
+++ b/_config/103-nerdtree.vim
@@ -0,0 +1,5 @@
+if empty(globpath(&rtp, 'autoload/nerdtree.vim'))
+ finish
+endif
+
+nmap <Leader>d :NERDTreeToggle<CR>
diff --git a/_config/104-open-browser.vim b/_config/104-open-browser.vim
new file mode 100644
index 0000000..830ac93
--- /dev/null
+++ b/_config/104-open-browser.vim
@@ -0,0 +1,7 @@
+if empty(globpath(&rtp, 'autoload/openbrowser.vim'))
+ finish
+endif
+
+let g:netrw_nogx = 1 " disable netrw's gx mapping.
+nmap gx <Plug>(openbrowser-smart-search)
+vmap gx <Plug>(openbrowser-smart-search)
diff --git a/_config/105-fzf.vim b/_config/105-fzf.vim
new file mode 100644
index 0000000..61043b5
--- /dev/null
+++ b/_config/105-fzf.vim
@@ -0,0 +1,31 @@
+if empty(globpath(&rtp, 'autoload/fzf/vim.vim'))
+ finish
+endif
+
+" fzf
+" let $FZF_DEFAULT_COMMAND = 'rg --files --follow --hidden --no-ignore-vcs -g "!{.git,node_modules}/*" 2>/dev/null'
+"
+if executable('rg')
+ let $FZF_DEFAULT_COMMAND = 'rg --files --follow --hidden -g "!{.git,node_modules}/*" 2>/dev/null'
+ nmap <Leader>f :Files<CR>
+
+ command! -bang -nargs=* Rg
+ \ call fzf#vim#grep(
+ \ 'rg --column --line-number --no-heading --color=always --smart-case --hidden -g "!{.git,node_modules}/*" '.shellescape(<q-args>), 1,
+ \ <bang>0 ? fzf#vim#with_preview('up:60%')
+ \ : fzf#vim#with_preview('right:50%:hidden', '?'),
+ \ <bang>0)
+ nmap <Leader>r :Rg<CR>
+else
+ nmap <Leader>f :GFiles<CR>
+endif
+
+if executable('ag')
+ autocmd VimEnter * command! -bang -nargs=* Ag
+ \ call fzf#vim#ag(<q-args>, '--hidden --ignore .git --skip-vcs-ignores', <bang>0)
+ nmap <Leader>a :Ag<CR>
+endif
+
+nmap <Leader>; :Buffers<CR>
+imap <c-x><c-f> <plug>(fzf-complete-path)
+
diff --git a/_config/106-easymotion.vim b/_config/106-easymotion.vim
new file mode 100644
index 0000000..d309384
--- /dev/null
+++ b/_config/106-easymotion.vim
@@ -0,0 +1,8 @@
+if empty(globpath(&rtp, 'autoload/EasyMotion.vim'))
+ finish
+endif
+
+let g:EasyMotion_do_mapping = 0 " Disable default mappings
+let g:EasyMotion_smartcase = 1
+nmap s <Plug>(easymotion-overwin-f)
+
diff --git a/_config/200-lsp.vim b/_config/200-lsp.vim
new file mode 100644
index 0000000..e7521c8
--- /dev/null
+++ b/_config/200-lsp.vim
@@ -0,0 +1,23 @@
+if empty(globpath(&rtp, 'autoload/lsp.vim'))
+ finish
+endif
+
+let g:lsp_diagnostics_enabled = 0
+let g:lsp_diagnostics_echo_cursor = 1
+let g:lsp_signs_error = {'text': '✗'}
+let g:lsp_signs_warning = {'text': '▲'}
+let g:lsp_signs_hint = {'text': '! '} " icons require GUI
+" let g:lsp_ultisnips_integration = 1
+" for debug
+" let g:lsp_log_verbose = 1
+" let g:lsp_log_file = expand('~/vim-lsp.log')
+" let g:asyncomplete_log_file = expand('~/asyncomplete.log')
+autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
+
+nmap <C-]> <plug>(lsp-definition)
+nmap gd <plug>(lsp-definition)
+nmap gD <plug>(lsp-references)
+nmap K <plug>(lsp-hover)
+nmap ]s <plug>(lsp-next-error)
+nmap [s <plug>(lsp-previous-error)
+
diff --git a/_config/201-ale.vim b/_config/201-ale.vim
new file mode 100644
index 0000000..8872dd7
--- /dev/null
+++ b/_config/201-ale.vim
@@ -0,0 +1,26 @@
+if empty(globpath(&rtp, 'autoload/ale.vim'))
+ finish
+endif
+
+let g:ale_sign_warning = '▲'
+let g:ale_sign_error = '✗'
+
+highlight link ALEWarningSign String
+highlight link ALEErrorSign Title
+" let g:ale_linter_aliases = {'jsx': ['css', 'javascript']}
+" npm install -g eslint eslint-plugin-react
+let g:ale_linters = {
+\ 'css': [],
+\}
+let g:ale_fixers = {
+\ '*': ['remove_trailing_lines', 'trim_whitespace'],
+\ 'javascript': ['eslint'],
+\ 'php': ['php_cs_fixer'],
+\}
+
+let g:ale_php_phpstan_level = '0'
+
+let g:ale_python_pylint_options = '--load-plugins pylint_django'
+
+nnoremap <silent> ]w :ALENext<CR>
+nnoremap <silent> [w :ALEPrevious<CR>
diff --git a/_config/202-async.vim b/_config/202-async.vim
new file mode 100644
index 0000000..aaf2741
--- /dev/null
+++ b/_config/202-async.vim
@@ -0,0 +1,14 @@
+if empty(globpath(&rtp, 'autoload/async/job.vim'))
+ finish
+endif
+
+let g:asyncomplete_remove_duplicates = 1
+let g:asyncomplete_smart_completion = 1
+let g:asyncomplete_auto_popup = 2
+
+" let g:asyncomplete_preprocessor =
+" \ [function('asyncomplete#preprocessor#ezfilter#filter')]
+"
+" let g:asyncomplete#preprocessor#ezfilter#config = {}
+" let g:asyncomplete#preprocessor#ezfilter#config['*'] =
+" \ {ctx, items -> filter(items, 's:fuzzy(v:val.word, ctx.base) != 0')}
diff --git a/_config/203-gitgutter.vim b/_config/203-gitgutter.vim
new file mode 100644
index 0000000..5288a33
--- /dev/null
+++ b/_config/203-gitgutter.vim
@@ -0,0 +1,12 @@
+if empty(globpath(&rtp, 'autoload/gitgutter.vim'))
+ finish
+endif
+
+set updatetime=200
+let g:gitgutter_sign_added = '│'
+let g:gitgutter_sign_modified = '│'
+let g:gitgutter_sign_removed = '_ '
+let g:gitgutter_sign_removed_first_line = '‾'
+let g:gitgutter_sign_modified_removed = '│'
+
+nmap <silent> <C-l> :noh<CR>:GitGutterEnable<CR>:redraw<CR>
diff --git a/_config/204-fugitive.vim b/_config/204-fugitive.vim
new file mode 100644
index 0000000..4099a6b
--- /dev/null
+++ b/_config/204-fugitive.vim
@@ -0,0 +1,27 @@
+if empty(globpath(&rtp, 'autoload/fugitive.vim'))
+ finish
+endif
+
+" DiffRev command
+" https://github.com/tpope/vim-fugitive/issues/132#issuecomment-290644034
+let s:git_status_dictionary = {
+ \ "A": "Added",
+ \ "B": "Broken",
+ \ "C": "Copied",
+ \ "D": "Deleted",
+ \ "M": "Modified",
+ \ "R": "Renamed",
+ \ "T": "Changed",
+ \ "U": "Unmerged",
+ \ "X": "Unknown"
+ \ }
+function! s:get_diff_files(rev)
+ let list = map(split(system(
+ \ 'git diff --name-status '.a:rev), '\n'),
+ \ '{"filename":matchstr(v:val, "\\S\\+$"),"text":s:git_status_dictionary[matchstr(v:val, "^\\w")]}'
+ \ )
+ call setqflist(list)
+ copen
+endfunction
+
+command! -nargs=1 DiffRev call s:get_diff_files(<q-args>)
diff --git a/ftplugin/php.vim b/ftplugin/php.vim
new file mode 100644
index 0000000..88e69e0
--- /dev/null
+++ b/ftplugin/php.vim
@@ -0,0 +1,2 @@
+" let g:lsp_diagnostics_enabled = 1
+" :ALEDisable
diff --git a/vimrc b/vimrc
new file mode 100644
index 0000000..bce25e2
--- /dev/null
+++ b/vimrc
@@ -0,0 +1,174 @@
+if empty(glob('~/.vim/autoload/plug.vim'))
+ silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
+ \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
+ autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
+endif
+
+"#####表示設定#####
+set number "行番号を表示する
+set title "編集中のファイル名を表示
+set showmatch "括弧入力時の対応する括弧を表示
+syntax on "コードの色分け
+set expandtab
+set shiftwidth=4
+set tabstop=4 "インデントをスペース4つ分に設定
+set smartindent "オートインデント
+
+let g:indentLine_setConceal = 0
+set conceallevel=0 " json とかで quote を表示する
+
+"#####検索設定#####
+set ignorecase "大文字/小文字の区別なく検索する
+set smartcase "検索文字列に大文字が含まれている場合は区別して検索する
+set wrapscan "検索時に最後まで行ったら最初に戻る
+set hlsearch
+set incsearch
+
+"####バックスペース制御
+set backspace=2
+
+" 改行時にコメントアウトしない
+set formatoptions-=ro
+
+" ファイル編集時に別ファイルを開ける
+set hidden
+
+set completeopt+=preview,menuone
+
+" syntax on
+set background=dark
+
+" swap ファイルの場所
+if empty(glob('~/.vim/tmp'))
+ silent !mkdir -p ~/.vim/tmp
+endif
+
+set directory=~/.vim/tmp
+
+nmap <silent> <Leader>t :term ++close zsh -i<CR>
+nmap <silent> <Leader>T :vert term ++close zsh -i<CR>
+nmap <silent> <C-t> <C-o>
+nmap <silent> <C-l> :noh<CR>:redraw<CR>
+
+let mapleader = "\<Space>"
+let maplocalleader = "\<Bslash>"
+
+" filetype javascriptreact -> javascript.jsx
+au BufRead,BufNewFile *.jsx set filetype=javascript.jsx
+
+" custom command
+command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
+ \ | diffthis | wincmd p | diffthis
+
+" git commit 時にはプラグインは読み込まない
+" if $HOME != $USERPROFILE && $GIT_EXEC_PATH != ''
+"
+" call plug#begin('~/.vim/plugged')
+" Plug 'tpope/vim-fugitive'
+" call plug#end()
+"
+" finish
+" end
+
+let g:plug_shallow = 0
+
+call plug#begin('~/.vim/plugged')
+
+" for language server
+" see: https://github.com/prabirshrestha/vim-lsp/wiki/Servers
+" see: https://github.com/prabirshrestha/asyncomplete.vim
+"
+Plug 'SirVer/ultisnips'
+Plug 'prabirshrestha/async.vim'
+Plug 'prabirshrestha/asyncomplete.vim'
+Plug 'prabirshrestha/asyncomplete-lsp.vim'
+Plug 'prabirshrestha/vim-lsp'
+Plug 'mattn/vim-lsp-settings'
+Plug 'thomasfaingnaert/vim-lsp-snippets'
+Plug 'thomasfaingnaert/vim-lsp-ultisnips'
+Plug 'yami-beta/asyncomplete-omni.vim'
+Plug 'machakann/asyncomplete-ezfilter.vim'
+" ALE
+Plug 'w0rp/ale'
+
+" php
+" Plug 'felixfbecker/php-language-server', {'do': 'composer install && composer run-script parse-stubs'}
+" theme
+Plug 'tomasr/molokai'
+Plug 'cocopon/iceberg.vim'
+Plug 'w0ng/vim-hybrid'
+Plug 'nightsense/cosmic_latte'
+Plug 'arcticicestudio/nord-vim'
+
+" for lit-html
+Plug 'jonsmithers/vim-html-template-literals'
+Plug 'pangloss/vim-javascript'
+Plug 'leafgarland/typescript-vim'
+
+Plug 'tpope/vim-unimpaired'
+Plug 'tpope/vim-abolish'
+Plug 'vim-airline/vim-airline'
+Plug 'itchyny/lightline.vim'
+Plug 'qpkorr/vim-bufkill'
+" Plug 'exu/pgsql.vim'
+
+" to treat whitespace
+Plug 'ntpeters/vim-better-whitespace'
+
+Plug 'tpope/vim-surround'
+Plug 'tpope/vim-repeat'
+
+" auto detect indent
+Plug 'tpope/vim-sleuth'
+
+" Plug 'docunext/closetag.vim'
+Plug 'joom/vim-commentary'
+Plug 'yggdroot/indentline'
+
+" file manager
+Plug 'scrooloose/nerdtree'
+
+" treat file
+Plug 'tpope/vim-eunuch'
+
+" for git
+Plug 'tpope/vim-fugitive'
+Plug 'tpope/vim-rhubarb'
+Plug 'airblade/vim-gitgutter'
+Plug 'tommcdo/vim-fubitive'
+"git clone https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install
+Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
+Plug 'junegunn/fzf.vim'
+
+"apt install ripgrep
+Plug 'mileszs/ack.vim'
+Plug 'andymass/vim-matchup'
+
+" for markdown
+Plug 'plasticboy/vim-markdown'
+Plug 'kannokanno/previm'
+
+" open url or so
+Plug 'tyru/open-browser.vim'
+" for comment
+Plug 'scrooloose/nerdcommenter'
+
+" sneak
+" Plug 'justinmk/vim-sneak'
+
+" easymotion
+Plug 'easymotion/vim-easymotion'
+
+" Plug 'thinca/vim-quickrun'
+
+call plug#end()
+
+colorscheme nord
+
+" function! s:fuzzy(lhs, rhs) abort
+" return a:lhs =~ join(map(split(a:rhs, '\zs'), "printf('[\\x%02x].*', char2nr(v:val))"), '')
+" endfunction
+"
+
+" 各種設定の読み込み
+call map(sort(split(globpath(&runtimepath, '_config/*.vim'))), {->[execute('exec "so" v:val')]})