# HG changeset patch # User Ludovic Chabant # Date 1518548906 28800 # Node ID e6b3048980c478e97510364e91075aecacd17242 # Parent c4077384f55f8937356a6f58ccb4304fba2d2b81 Vim tweaks - Properly check for whether a plugin is active. - Better function key shortcuts. - Remove `wildignore` from Gutentags command lines, add them to `ctagsrc`. diff -r c4077384f55f -r e6b3048980c4 vim/ctagsrc --- 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 diff -r c4077384f55f -r e6b3048980c4 vim/vimrc --- 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 :wincmd l " Switch buffers. -nnoremap :execute ("buffer " . bufname("#")) +nnoremap :execute ("buffer " . bufname("#")) " NERDTree. -nnoremap :call ToggleNERDTree() -nnoremap :call FindInNERDTree() +nnoremap :call ToggleNERDTree() +nnoremap :call FindInNERDTree() " Tagbar. -nnoremap :TagbarToggle -nnoremap :TagbarOpenAutoClose +nnoremap :TagbarToggle +nnoremap :TagbarOpenAutoClose " Gundo. -nnoremap :GundoToggle +nnoremap :GundoToggle + +" 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 :pop +" Go check out a tag. +nnoremap gzvzz +" Go check out a tag in a split window. +nnoremap vgzMzvzz +" Move to previous matching tag. +nnoremap :tprevious +" Move to next matching tag. +nnoremap :tnext " Common typos. nnoremap ; : @@ -614,43 +638,37 @@ nnoremap fa :vimgrep // vnoremap fa "zy:vimgrep /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 :pop -nnoremap gzvzz -nnoremap vgzMzvzz -nnoremap :tprevious -nnoremap :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 jj :YcmCompleter GoToImprecisezv - autocmd FileType cpp nnoremap jd :YcmCompleter GoToDefinitionzv - autocmd FileType cpp nnoremap jh :YcmCompleter GoToDeclarationzv - autocmd FileType cpp nnoremap ji :YcmCompleter GoToInclude - autocmd FileType cpp nnoremap jc :YcmCompleter GetDoc -augroup END +if s:HasPlugin('youcompleteme') + augroup VimRC_YouCompleteMe + autocmd! + autocmd FileType cpp nnoremap jj :YcmCompleter GoToImprecisezv + autocmd FileType cpp nnoremap jd :YcmCompleter GoToDefinitionzv + autocmd FileType cpp nnoremap jh :YcmCompleter GoToDeclarationzv + autocmd FileType cpp nnoremap ji :YcmCompleter GoToInclude + autocmd FileType cpp nnoremap jc :YcmCompleter GetDoc + autocmd FileType cpp nnoremap je :YcmShowDetailedDiagnostic + 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 jj :OmniSharpGotoDefinition - autocmd FileType cs nnoremap x :OmniSharpFixIssue - autocmd FileType cs nnoremap fx :OmniSharpFixUsings - autocmd FileType cs nnoremap tt :OmniSharpTypeLookup - autocmd FileType cs nnoremap dc :OmniSharpDocumentation -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 jj :OmniSharpGotoDefinition + autocmd FileType cs nnoremap x :OmniSharpFixIssue + autocmd FileType cs nnoremap fx :OmniSharpFixUsings + autocmd FileType cs nnoremap tt :OmniSharpTypeLookup + autocmd FileType cs nnoremap dc :OmniSharpDocumentation + augroup END +endif " ProjectRoot mappings let s:no_auto_projectroot_buftypes = [ @@ -674,7 +692,7 @@ nnoremap cd :ProjectRootCD " Ctrl-P mappings. -if index(g:pathogen_disabled, 'ctrlp') < 0 +if s:HasPlugin('ctrlp') nnoremap :CtrlP nnoremap :CtrlPBuffer nnoremap :CtrlPTag @@ -684,7 +702,7 @@ endif " FZF mappings. -if index(g:pathogen_disabled, 'fzf') < 0 +if s:HasPlugin('fzf') nnoremap :Files nnoremap :Buffers endif