comparison vim/vimrc @ 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 d8086f81b9c8
comparison
equal deleted inserted replaced
419:c4077384f55f 420:e6b3048980c4
66 set columns=999 66 set columns=999
67 if has("win32") 67 if has("win32")
68 au GUIEnter * simalt ~x 68 au GUIEnter * simalt ~x
69 endif 69 endif
70 endif 70 endif
71
72 function! s:HasPlugin(plugname) abort
73 return globpath(&runtimepath, 'plugin/'.a:plugname.'.vim') !=# ''
74 endfunction
71 75
72 " }}} 76 " }}}
73 77
74 " General Settings {{{ 78 " General Settings {{{
75 79
290 " Gutentags {{{ 294 " Gutentags {{{
291 295
292 let g:gutentags_cache_dir = s:vim_home.'/tags' 296 let g:gutentags_cache_dir = s:vim_home.'/tags'
293 let g:gutentags_ctags_exclude = ['venv', 'build', 'static', 'node_modules'] 297 let g:gutentags_ctags_exclude = ['venv', 'build', 'static', 'node_modules']
294 let g:gutentags_ctags_extra_args = ['--options='.s:vim_home.'/ctagsrc'] 298 let g:gutentags_ctags_extra_args = ['--options='.s:vim_home.'/ctagsrc']
299 let g:gutentags_ctags_exclude_wildignore = 0
295 300
296 " }}} 301 " }}}
297 302
298 " Syntastic {{{ 303 " Syntastic {{{
299 304
526 nnoremap <C-down> :wincmd j<cr> 531 nnoremap <C-down> :wincmd j<cr>
527 nnoremap <C-left> :wincmd h<cr> 532 nnoremap <C-left> :wincmd h<cr>
528 nnoremap <C-right> :wincmd l<cr> 533 nnoremap <C-right> :wincmd l<cr>
529 534
530 " Switch buffers. 535 " Switch buffers.
531 nnoremap <F2> :execute ("buffer " . bufname("#"))<cr> 536 nnoremap <F1> :execute ("buffer " . bufname("#"))<cr>
532 537
533 " NERDTree. 538 " NERDTree.
534 nnoremap <F3> :call <SID>ToggleNERDTree()<cr> 539 nnoremap <F2> :call <SID>ToggleNERDTree()<cr>
535 nnoremap <F4> :call <SID>FindInNERDTree()<cr> 540 nnoremap <C-F2> :call <SID>FindInNERDTree()<cr>
536 541
537 " Tagbar. 542 " Tagbar.
538 nnoremap <F5> :TagbarToggle<cr> 543 nnoremap <F3> :TagbarToggle<cr>
539 nnoremap <F6> :TagbarOpenAutoClose<cr> 544 nnoremap <C-F3> :TagbarOpenAutoClose<cr>
540 545
541 " Gundo. 546 " Gundo.
542 nnoremap <F7> :GundoToggle<cr> 547 nnoremap <F4> :GundoToggle<cr>
548
549 " F5 to F8 are available for context-dependent mappings.
550
551 " Jump to tags by keeping things better in view. Option for jumping to a tag
552 " in a split window where everything is folded except what you need to see.
553 " Note that if a tag search yield multiple possible results, we will still run
554 " some of that `zvzz` stuff, but that's OK, the main point is to not mess up
555 " the result selection window either.
556 "
557 " Go back after checking out a tag.
558 nnoremap <F9> :pop<CR>
559 " Go check out a tag.
560 nnoremap <F10> g<C-]>zvzz
561 " Go check out a tag in a split window.
562 nnoremap <S-F10> <C-W>vg<C-]>zMzvzz
563 " Move to previous matching tag.
564 nnoremap <C-F9> :tprevious<CR>
565 " Move to next matching tag.
566 nnoremap <C-F10> :tnext<CR>
543 567
544 " Common typos. 568 " Common typos.
545 nnoremap ; : 569 nnoremap ; :
546 570
547 " Split windows 571 " Split windows
612 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o> 636 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
613 637
614 nnoremap <leader>fa :vimgrep /<C-R><C-W>/ 638 nnoremap <leader>fa :vimgrep /<C-R><C-W>/
615 vnoremap <leader>fa "zy:vimgrep /<C-R>z/ 639 vnoremap <leader>fa "zy:vimgrep /<C-R>z/
616 640
617 " Jump to tags by keeping things better in view. Option for jumping to a tag
618 " in a split window where everything is folded except what you need to see.
619 " Note that if a tag search yield multiple possible results, we will still run
620 " some of that `zvzz` stuff, but that's OK, the main point is to not mess up
621 " the result selection window either.
622 nnoremap <F9> :pop<cr>
623 nnoremap <F10> g<C-]>zvzz
624 nnoremap <s-F10> <c-w>vg<C-]>zMzvzz
625 nnoremap <c-F9> :tprevious
626 nnoremap <c-F10> :tnext
627
628 " Keep search matches in the middle of the window. 641 " Keep search matches in the middle of the window.
629 nnoremap n nzvzz 642 nnoremap n nzvzz
630 nnoremap N Nzvzz 643 nnoremap N Nzvzz
631 644
632 " YCM mappings. 645 " YCM mappings.
633 augroup VimRC_YouCompleteMe 646 if s:HasPlugin('youcompleteme')
634 autocmd! 647 augroup VimRC_YouCompleteMe
635 autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv 648 autocmd!
636 autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv 649 autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv
637 autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv 650 autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv
638 autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr> 651 autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv
639 autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr> 652 autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr>
640 augroup END 653 autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr>
654 autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr>
655 augroup END
656 endif
641 657
642 " OmniSharp mappings 658 " OmniSharp mappings
643 augroup VimRC_OmniSharp 659 if s:HasPlugin('OmniSharp')
644 autocmd! 660 augroup VimRC_OmniSharp
645 autocmd FileType cs setlocal omnifunc=OmniSharp#Complete 661 autocmd!
646 autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck 662 autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
647 autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() 663 autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
648 autocmd FileType cs nnoremap <Leader>jj :OmniSharpGotoDefinition<cr> 664 autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
649 autocmd FileType cs nnoremap <Leader>x :OmniSharpFixIssue<cr> 665 autocmd FileType cs nnoremap <Leader>jj :OmniSharpGotoDefinition<cr>
650 autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr> 666 autocmd FileType cs nnoremap <Leader>x :OmniSharpFixIssue<cr>
651 autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr> 667 autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr>
652 autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr> 668 autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr>
653 augroup END 669 autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr>
670 augroup END
671 endif
654 672
655 " ProjectRoot mappings 673 " ProjectRoot mappings
656 let s:no_auto_projectroot_buftypes = [ 674 let s:no_auto_projectroot_buftypes = [
657 \'help', 'nofile', 'quickfix'] 675 \'help', 'nofile', 'quickfix']
658 676
672 augroup END 690 augroup END
673 691
674 nnoremap <leader>cd :ProjectRootCD<cr> 692 nnoremap <leader>cd :ProjectRootCD<cr>
675 693
676 " Ctrl-P mappings. 694 " Ctrl-P mappings.
677 if index(g:pathogen_disabled, 'ctrlp') < 0 695 if s:HasPlugin('ctrlp')
678 nnoremap <silent> <C-p> :CtrlP<cr> 696 nnoremap <silent> <C-p> :CtrlP<cr>
679 nnoremap <silent> <C-o> :CtrlPBuffer<cr> 697 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
680 nnoremap <silent> <C-u> :CtrlPTag<cr> 698 nnoremap <silent> <C-u> :CtrlPTag<cr>
681 nnoremap <silent> <C-y> :CtrlPBufTag<cr> 699 nnoremap <silent> <C-y> :CtrlPBufTag<cr>
682 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> 700 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
683 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr> 701 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
684 endif 702 endif
685 703
686 " FZF mappings. 704 " FZF mappings.
687 if index(g:pathogen_disabled, 'fzf') < 0 705 if s:HasPlugin('fzf')
688 nnoremap <silent> <C-p> :Files 706 nnoremap <silent> <C-p> :Files
689 nnoremap <silent> <C-o> :Buffers 707 nnoremap <silent> <C-o> :Buffers
690 endif 708 endif
691 709
692 " }}} 710 " }}}