comparison vim/vimrc @ 495:232351531855

Vim config improvements - Support for gui vs non gui plugin exclusions rules - Move HasPlugin to an autoload function that can be used in vimrc-local - Don't load the local bundle if it doesn't exist - Handle VS vs UE for building projects
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 12 Nov 2021 10:51:57 -0800
parents b452486b97c5
children
comparison
equal deleted inserted replaced
494:76defcf6bf02 495:232351531855
29 syntax off 29 syntax off
30 filetype off 30 filetype off
31 31
32 " Disable some plugins. 32 " Disable some plugins.
33 let g:pathogen_disabled = get(g:, 'pathogen_disabled', []) 33 let g:pathogen_disabled = get(g:, 'pathogen_disabled', [])
34 call ludo#setup_pathogen([ludo#localpath('bundle'), ludo#localpath('local')]) 34 let s:bundles = [ludo#localpath('bundle')]
35 if isdirectory(ludo#localpath('local'))
36 call add(s:bundles, ludo#localpath('local'))
37 endif
38 call ludo#setup_pathogen(s:bundles)
35 39
36 " Load pathogen. 40 " Load pathogen.
37 runtime bundle/pathogen/autoload/pathogen.vim 41 runtime bundle/pathogen/autoload/pathogen.vim
38 " Add the bundle directory, and potentially add the local one if it exists. 42 " Add the bundle directory, and potentially add the local one if it exists.
39 " Note that we pass absolute paths to make pathogen prepend stuff before Vim's 43 " Note that we pass absolute paths to make pathogen prepend stuff before Vim's
51 set columns=999 55 set columns=999
52 if has("win32") 56 if has("win32")
53 au GUIEnter * simalt ~x 57 au GUIEnter * simalt ~x
54 endif 58 endif
55 endif 59 endif
56
57 function! s:HasPlugin(plugname, ...) abort
58 let l:dirname = 'plugin/'
59 if a:0 && a:1
60 let l:dirname = 'autoload/'
61 endif
62 return globpath(&runtimepath, l:dirname.a:plugname.'.vim') !=# ''
63 endfunction
64 60
65 " }}} 61 " }}}
66 62
67 " General Settings {{{ 63 " General Settings {{{
68 64
285 \'autoignore' 281 \'autoignore'
286 \] 282 \]
287 283
288 " Use PyMatch to go faster. 284 " Use PyMatch to go faster.
289 if (has('python3') || has('python')) 285 if (has('python3') || has('python'))
290 if s:HasPlugin('ctrlp-py-matcher') 286 if ludo#has_plugin('ctrlp-py-matcher')
291 let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'} 287 let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'}
292 let g:ctrlp_max_files = 0 288 let g:ctrlp_max_files = 0
293 let g:ctrlp_lazy_update = 350 289 let g:ctrlp_lazy_update = 350
294 elseif s:HasPlugin('cpsm', 1) 290 elseif ludo#has_plugin('cpsm', 1)
295 let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'} 291 let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'}
296 let g:ctrlp_max_files = 0 292 let g:ctrlp_max_files = 0
297 let g:ctrlp_lazy_update = 350 293 let g:ctrlp_lazy_update = 350
298 endif 294 endif
299 endif 295 endif
454 \ 'ycm_warns': 'warning', 450 \ 'ycm_warns': 'warning',
455 \ 'gutentags': 'warning', 451 \ 'gutentags': 'warning',
456 \ }, 452 \ },
457 \} 453 \}
458 454
459 if s:HasPlugin('fugitive') 455 if ludo#has_plugin('fugitive')
460 function! _LightlineFugitive() 456 function! _LightlineFugitive()
461 return fugitive#head() 457 return fugitive#head()
462 endfunction 458 endfunction
463 else 459 else
464 function! _LightlineFugitive() 460 function! _LightlineFugitive()
465 endfunction 461 endfunction
466 endif 462 endif
467 463
468 if s:HasPlugin('lawrencium') 464 if ludo#has_plugin('lawrencium')
469 function! _LightlineLawrencium() 465 function! _LightlineLawrencium()
470 return lawrencium#statusline() 466 return lawrencium#statusline()
471 endfunction 467 endfunction
472 else 468 else
473 function! _LightlineLawrencium() 469 function! _LightlineLawrencium()
485 else 481 else
486 return '' 482 return ''
487 endif 483 endif
488 endfunction 484 endfunction
489 485
490 if s:HasPlugin('gutentags') 486 if ludo#has_plugin('gutentags')
491 function! _LightlineGutentags() 487 function! _LightlineGutentags()
492 return gutentags#statusline('', '', '♨') 488 return gutentags#statusline('', '', '♨')
493 endfunction 489 endfunction
494 else 490 else
495 function! _LightlineGutentags() 491 function! _LightlineGutentags()
496 endfunction 492 endfunction
497 endif 493 endif
498 494
499 if s:HasPlugin('syntastic') 495 if ludo#has_plugin('syntastic')
500 function! _LightlineLinter() 496 function! _LightlineLinter()
501 return SyntasticStatuslineFlag() 497 return SyntasticStatuslineFlag()
502 endfunction 498 endfunction
503 else 499 else
504 function! _LightlineLinter() abort 500 function! _LightlineLinter() abort
513 \ all_errors 509 \ all_errors
514 \) 510 \)
515 endfunction 511 endfunction
516 endif 512 endif
517 513
518 if s:HasPlugin('youcompleteme') 514 if ludo#has_plugin('youcompleteme')
519 function! _LightlineYcmErrors() 515 function! _LightlineYcmErrors()
520 let l:cnt = youcompleteme#GetErrorCount() 516 let l:cnt = youcompleteme#GetErrorCount()
521 return l:cnt > 0 ? string(l:cnt) : '' 517 return l:cnt > 0 ? string(l:cnt) : ''
522 endfunction 518 endfunction
523 519
732 " Keep search matches in the middle of the window. 728 " Keep search matches in the middle of the window.
733 nnoremap n nzvzz 729 nnoremap n nzvzz
734 nnoremap N Nzvzz 730 nnoremap N Nzvzz
735 731
736 " YCM mappings. 732 " YCM mappings.
737 if s:HasPlugin('youcompleteme') 733 if ludo#has_plugin('youcompleteme')
738 augroup VimRC_YouCompleteMe 734 augroup VimRC_YouCompleteMe
739 autocmd! 735 autocmd!
740 autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv 736 autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv
741 autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv 737 autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv
742 autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv 738 autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv
746 autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr> 742 autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr>
747 augroup END 743 augroup END
748 endif 744 endif
749 745
750 " OmniSharp mappings 746 " OmniSharp mappings
751 if s:HasPlugin('OmniSharp') 747 if ludo#has_plugin('OmniSharp')
752 augroup VimRC_OmniSharp 748 augroup VimRC_OmniSharp
753 autocmd! 749 autocmd!
754 autocmd FileType cs setlocal omnifunc=OmniSharp#Complete 750 autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
755 autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck 751 autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
756 autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() 752 autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
786 augroup END 782 augroup END
787 783
788 nnoremap <leader>cd :ProjectRootCD<cr> 784 nnoremap <leader>cd :ProjectRootCD<cr>
789 785
790 " Ctrl-P mappings. 786 " Ctrl-P mappings.
791 if s:HasPlugin('ctrlp') 787 if ludo#has_plugin('ctrlp')
792 nnoremap <silent> <C-p> :CtrlP<cr> 788 nnoremap <silent> <C-p> :CtrlP<cr>
793 nnoremap <silent> <C-o> :CtrlPBuffer<cr> 789 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
794 nnoremap <silent> <C-u> :CtrlPTag<cr> 790 nnoremap <silent> <C-u> :CtrlPTag<cr>
795 nnoremap <silent> <C-y> :CtrlPBufTag<cr> 791 nnoremap <silent> <C-y> :CtrlPBufTag<cr>
796 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> 792 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
797 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr> 793 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
798 endif 794 endif
799 795
800 " FZF mappings. 796 " FZF mappings.
801 if s:HasPlugin('fzf') 797 if ludo#has_plugin('fzf')
802 if exists('*fzf#run') 798 if exists('*fzf#run')
803 nnoremap <silent> <C-p> :Files<cr> 799 nnoremap <silent> <C-p> :Files<cr>
804 nnoremap <silent> <C-o> :Buffers<cr> 800 nnoremap <silent> <C-o> :Buffers<cr>
805 nnoremap <Tab> :History<cr> 801 nnoremap <Tab> :History<cr>
806 802
814 \"isn't loaded... add it to your `vimrc-local-pre`.") 810 \"isn't loaded... add it to your `vimrc-local-pre`.")
815 endif 811 endif
816 endif 812 endif
817 813
818 " LeaderF mappings. 814 " LeaderF mappings.
819 if s:HasPlugin('leaderf') 815 if ludo#has_plugin('leaderf')
820 let g:Lf_ShortcutF = '<C-p>' 816 let g:Lf_ShortcutF = '<C-p>'
821 let g:Lf_ShortcutB = '<C-o>' 817 let g:Lf_ShortcutB = '<C-o>'
822 nnoremap <silent> <C-p> :LeaderfFile<cr> 818 nnoremap <silent> <C-p> :LeaderfFile<cr>
823 nnoremap <silent> <C-o> :LeaderfBuffer<cr> 819 nnoremap <silent> <C-o> :LeaderfBuffer<cr>
824 nnoremap <silent> <C-u> :LeaderfTag<cr> 820 nnoremap <silent> <C-u> :LeaderfTag<cr>
830 nnoremap <silent> <Leader>fh :LeaderfHelp<cr> 826 nnoremap <silent> <Leader>fh :LeaderfHelp<cr>
831 827
832 let g:Lf_StlSeparator = { 'left': '', 'right': '' } 828 let g:Lf_StlSeparator = { 'left': '', 'right': '' }
833 endif 829 endif
834 830
835 " Vimcrosoft mappings. 831 " Vimcrosoft/UE mappings.
836 if s:HasPlugin('vimcrosoft') 832 nnoremap <F7> :call ludo#build_vs_or_ue()<cr>
837 nnoremap <F7> :VimcrosoftBuildActiveProject<cr>
838 nnoremap <F8> :VimcrosoftBuildSln<cr>
839 endif
840 833
841 " }}} 834 " }}}
842 835
843 " Folding {{{ 836 " Folding {{{
844 837