Mercurial > dotfiles
changeset 420:e6b3048980c4
Vim tweaks
- Properly check for whether a plugin is active.
- Better function key shortcuts.
- Remove `wildignore` from Gutentags command lines, add them to `ctagsrc`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 13 Feb 2018 11:08:26 -0800 |
parents | c4077384f55f |
children | 5747c8045e8a |
files | vim/ctagsrc vim/vimrc |
diffstat | 2 files changed, 78 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/vim/ctagsrc Sun Jan 21 12:51:19 2018 -0800 +++ b/vim/ctagsrc Tue Feb 13 11:08:26 2018 -0800 @@ -1,4 +1,4 @@ ---c-kinds=-nev +--c-kinds=-ev --c++-kinds=-nev --c#-kinds=-ne --python-kinds=cfm @@ -11,7 +11,26 @@ --exclude=.hg --exclude=.git ---exclude=libs +--exclude=.DS_Store +--exclude=Thumbs.db +--exclude=*.so +--exclude=*.dll +--exclude=*.exe +--exclude=*.lib +--exclude=*.pdb +--exclude=*.pyc +--exclude=*.pyo +--exclude=*.swp +--exclude=*.o +--exclude=*.dll +--exclude=*.fb +--exclude=*.exe +--exclude=*.elf +--exclude=*.jpg +--exclude=*.png +--exclude=venv --exclude=build +--exclude=static +--exclude=node_modules +--exclude=libs --exclude=dist ---exclude=venv
--- a/vim/vimrc Sun Jan 21 12:51:19 2018 -0800 +++ b/vim/vimrc Tue Feb 13 11:08:26 2018 -0800 @@ -69,6 +69,10 @@ endif endif +function! s:HasPlugin(plugname) abort + return globpath(&runtimepath, 'plugin/'.a:plugname.'.vim') !=# '' +endfunction + " }}} " General Settings {{{ @@ -292,6 +296,7 @@ let g:gutentags_cache_dir = s:vim_home.'/tags' let g:gutentags_ctags_exclude = ['venv', 'build', 'static', 'node_modules'] let g:gutentags_ctags_extra_args = ['--options='.s:vim_home.'/ctagsrc'] +let g:gutentags_ctags_exclude_wildignore = 0 " }}} @@ -528,18 +533,37 @@ nnoremap <C-right> :wincmd l<cr> " Switch buffers. -nnoremap <F2> :execute ("buffer " . bufname("#"))<cr> +nnoremap <F1> :execute ("buffer " . bufname("#"))<cr> " NERDTree. -nnoremap <F3> :call <SID>ToggleNERDTree()<cr> -nnoremap <F4> :call <SID>FindInNERDTree()<cr> +nnoremap <F2> :call <SID>ToggleNERDTree()<cr> +nnoremap <C-F2> :call <SID>FindInNERDTree()<cr> " Tagbar. -nnoremap <F5> :TagbarToggle<cr> -nnoremap <F6> :TagbarOpenAutoClose<cr> +nnoremap <F3> :TagbarToggle<cr> +nnoremap <C-F3> :TagbarOpenAutoClose<cr> " Gundo. -nnoremap <F7> :GundoToggle<cr> +nnoremap <F4> :GundoToggle<cr> + +" F5 to F8 are available for context-dependent mappings. + +" Jump to tags by keeping things better in view. Option for jumping to a tag +" in a split window where everything is folded except what you need to see. +" Note that if a tag search yield multiple possible results, we will still run +" some of that `zvzz` stuff, but that's OK, the main point is to not mess up +" the result selection window either. +" +" Go back after checking out a tag. +nnoremap <F9> :pop<CR> +" Go check out a tag. +nnoremap <F10> g<C-]>zvzz +" Go check out a tag in a split window. +nnoremap <S-F10> <C-W>vg<C-]>zMzvzz +" Move to previous matching tag. +nnoremap <C-F9> :tprevious<CR> +" Move to next matching tag. +nnoremap <C-F10> :tnext<CR> " Common typos. nnoremap ; : @@ -614,43 +638,37 @@ nnoremap <leader>fa :vimgrep /<C-R><C-W>/ vnoremap <leader>fa "zy:vimgrep /<C-R>z/ -" Jump to tags by keeping things better in view. Option for jumping to a tag -" in a split window where everything is folded except what you need to see. -" Note that if a tag search yield multiple possible results, we will still run -" some of that `zvzz` stuff, but that's OK, the main point is to not mess up -" the result selection window either. -nnoremap <F9> :pop<cr> -nnoremap <F10> g<C-]>zvzz -nnoremap <s-F10> <c-w>vg<C-]>zMzvzz -nnoremap <c-F9> :tprevious -nnoremap <c-F10> :tnext - " Keep search matches in the middle of the window. nnoremap n nzvzz nnoremap N Nzvzz " YCM mappings. -augroup VimRC_YouCompleteMe - autocmd! - autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv - autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv - autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv - autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr> - autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr> -augroup END +if s:HasPlugin('youcompleteme') + augroup VimRC_YouCompleteMe + autocmd! + autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv + autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv + autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv + autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr> + autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr> + autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr> + augroup END +endif " OmniSharp mappings -augroup VimRC_OmniSharp - autocmd! - autocmd FileType cs setlocal omnifunc=OmniSharp#Complete - autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck - autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() - autocmd FileType cs nnoremap <Leader>jj :OmniSharpGotoDefinition<cr> - autocmd FileType cs nnoremap <Leader>x :OmniSharpFixIssue<cr> - autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr> - autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr> - autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr> -augroup END +if s:HasPlugin('OmniSharp') + augroup VimRC_OmniSharp + autocmd! + autocmd FileType cs setlocal omnifunc=OmniSharp#Complete + autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck + autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() + autocmd FileType cs nnoremap <Leader>jj :OmniSharpGotoDefinition<cr> + autocmd FileType cs nnoremap <Leader>x :OmniSharpFixIssue<cr> + autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr> + autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr> + autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr> + augroup END +endif " ProjectRoot mappings let s:no_auto_projectroot_buftypes = [ @@ -674,7 +692,7 @@ nnoremap <leader>cd :ProjectRootCD<cr> " Ctrl-P mappings. -if index(g:pathogen_disabled, 'ctrlp') < 0 +if s:HasPlugin('ctrlp') nnoremap <silent> <C-p> :CtrlP<cr> nnoremap <silent> <C-o> :CtrlPBuffer<cr> nnoremap <silent> <C-u> :CtrlPTag<cr> @@ -684,7 +702,7 @@ endif " FZF mappings. -if index(g:pathogen_disabled, 'fzf') < 0 +if s:HasPlugin('fzf') nnoremap <silent> <C-p> :Files nnoremap <silent> <C-o> :Buffers endif