# HG changeset patch # User Ludovic Chabant # Date 1522292850 25200 # Node ID 67f14a8c23043171d9096eb757a3dbe15acc99e9 # Parent 350f7a55ff3304b2f42f230d5c88ac3c05e0aadb Improve Vim configuration. diff -r 350f7a55ff33 -r 67f14a8c2304 vim/autoload/ludo.vim --- a/vim/autoload/ludo.vim Wed Mar 28 20:07:21 2018 -0700 +++ b/vim/autoload/ludo.vim Wed Mar 28 20:07:30 2018 -0700 @@ -1,16 +1,41 @@ +let g:ludo_trace = 0 + +" Debug logging. +function! ludo#trace(msg) abort + if g:ludo_trace + echom a:msg + endif +endfunction + +" Warning message. +function! ludo#warn(msg) abort + echohl WarningMsg + echomsg "ludo: Warning: ".a:msg + echohl None +endfunction + +" Error message. +function! ludo#error(msg) abort + echohl ErrorMsg + echomsg "ludo: Error: ".a:msg + echohl None +endfunction + " Loads `pathogenrc` files in each bundle directory and, if found, " builds an exclude list based on the glob patterns found in them. " function! ludo#setup_pathogen(bundle_dirs) abort for bundle_dir in a:bundle_dirs - let l:rcfile = bundle_dir.'/pathogenrc' + let l:rcfile = bundle_dir.'.pathogenrc' if !filereadable(l:rcfile) + call ludo#trace("No bundle configuration file: ".l:rcfile) continue endif let l:included = [] let l:excluded = [] + call ludo#trace("Reading bundle configuration file: ".l:rcfile) let l:rclines = readfile(l:rcfile) for line in l:rclines if line[0] == '#' @@ -45,5 +70,6 @@ endif endfor endfor + call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', ')) endfunction diff -r 350f7a55ff33 -r 67f14a8c2304 vim/vimrc --- a/vim/vimrc Wed Mar 28 20:07:21 2018 -0700 +++ b/vim/vimrc Wed Mar 28 20:07:30 2018 -0700 @@ -23,6 +23,9 @@ if has("win32") || has("win64") || has("dos32") let s:vim_platform = "windows" let s:path_sep = "\\" +elseif has("mac") + let s:vim_platform = "mac" + let s:path_sep = '/' else let s:vim_platform = "unix" let s:path_sep = '/' @@ -67,7 +70,7 @@ endif function! s:HasPlugin(plugname) abort - return globpath(&runtimepath, 'plugin/'.a:plugname.'.vim') !=# '' + return globpath(&runtimepath, 'plugin/'.a:plugname.'.vim') !=# '' endfunction " }}} @@ -255,8 +258,8 @@ " Ctrl-P should however ignore some stuff. let g:ctrlp_custom_ignore = { - \ 'dir': '\v[\/](\.git|\.hg|\.svn|venv|static|node_modules|_cache|_counter)$' - \ } + \ 'dir': '\v[\/](\.git|\.hg|\.svn|venv|static|node_modules|_cache|_counter)$' + \ } " Make Ctrl-P cache stuff in our temp directory. let g:ctrlp_cache_dir = s:vim_home.'/cache' @@ -274,17 +277,28 @@ \] " Use PyMatch to go faster. -if has('python3') || has('python') - let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'} - let g:ctrlp_max_files = 0 - let g:ctrlp_lazy_update = 350 +if (has('python3') || has('python')) && s:HasPlugin('ctrlp-py-matcher') + let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'} + let g:ctrlp_max_files = 0 + let g:ctrlp_lazy_update = 350 endif " }}} " FZF {{{ +if s:vim_platform == 'mac' + if filereadable('/usr/local/opt/fzf/plugin/fzf.vim') + " FZF installed via Homebrew. + source /usr/local/opt/fzf/plugin/fzf.vim + endif +endif +let g:fzf_action = { + \'ctrl-t': 'tab split', + \'ctrl-v': 'vsplit', + \'ctrl-x': 'split', + \} " }}} @@ -641,30 +655,30 @@ " YCM mappings. 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 + 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 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 + 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 @@ -672,37 +686,43 @@ \'help', 'nofile', 'quickfix'] function! s:AutoProjectRootCD() abort - try - if index(s:no_auto_projectroot_buftypes, &buftype) == -1 - ProjectRootCD - endif - catch - " Silently ignore invalid buffers - endtry + try + if index(s:no_auto_projectroot_buftypes, &buftype) == -1 + ProjectRootCD + endif + catch + " Silently ignore invalid buffers + endtry endfunction augroup VimRC_ProjectRoot - autocmd! - autocmd BufEnter * call AutoProjectRootCD() + autocmd! + autocmd BufEnter * call AutoProjectRootCD() augroup END nnoremap cd :ProjectRootCD " Ctrl-P mappings. if s:HasPlugin('ctrlp') - nnoremap :CtrlP - nnoremap :CtrlPBuffer - nnoremap :CtrlPTag - nnoremap :CtrlPBufTag - nnoremap :CtrlPMRUFiles - nnoremap :CtrlPBookmarkDir + nnoremap :CtrlP + nnoremap :CtrlPBuffer + nnoremap :CtrlPTag + nnoremap :CtrlPBufTag + nnoremap :CtrlPMRUFiles + nnoremap :CtrlPBookmarkDir endif " FZF mappings. if s:HasPlugin('fzf') - nnoremap :Files - nnoremap :Buffers - nnoremap :History + if exists('*fzf#run') + nnoremap :Files + nnoremap :Buffers + nnoremap :History + else + call ludo#error( + \"FZF is installed and enabled, but the Vim plugin ". + \"isn't loaded... add it to your `vimrc-local-pre`.") + endif endif " }}} @@ -772,13 +792,13 @@ endfunction function! s:ToggleCppFolding() abort - if (&foldmethod == "syntax") - setlocal foldmethod=manual - setlocal nofoldenable - else - setlocal foldmethod=syntax - setlocal foldenable - endif + if (&foldmethod == "syntax") + setlocal foldmethod=manual + setlocal nofoldenable + else + setlocal foldmethod=syntax + setlocal foldenable + endif endfunction " }}}