diff options
author | Nao Ueda <nao.uedder@gmail.com> | 2020-01-28 09:00:22 +0900 |
---|---|---|
committer | Nao Ueda <nao.uedder@gmail.com> | 2020-01-28 09:00:22 +0900 |
commit | 9ccd94ea6a20c8b34cc7954666559c185724e55e (patch) | |
tree | ad2710a218d7cef7321d36892ab8e4499a2e15b5 /_config | |
download | vimrc-9ccd94ea6a20c8b34cc7954666559c185724e55e.tar.gz vimrc-9ccd94ea6a20c8b34cc7954666559c185724e55e.tar.bz2 vimrc-9ccd94ea6a20c8b34cc7954666559c185724e55e.zip |
initial commit
Diffstat (limited to '_config')
-rw-r--r-- | _config/101-lightline.vim | 55 | ||||
-rw-r--r-- | _config/102-ack.vim | 12 | ||||
-rw-r--r-- | _config/103-nerdtree.vim | 5 | ||||
-rw-r--r-- | _config/104-open-browser.vim | 7 | ||||
-rw-r--r-- | _config/105-fzf.vim | 31 | ||||
-rw-r--r-- | _config/106-easymotion.vim | 8 | ||||
-rw-r--r-- | _config/200-lsp.vim | 23 | ||||
-rw-r--r-- | _config/201-ale.vim | 26 | ||||
-rw-r--r-- | _config/202-async.vim | 14 | ||||
-rw-r--r-- | _config/203-gitgutter.vim | 12 | ||||
-rw-r--r-- | _config/204-fugitive.vim | 27 |
11 files changed, 220 insertions, 0 deletions
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>) |