Mercurial > dotfiles
diff vim/vimrc @ 435:b7682004288d
Move Vim stuff to autoload, add FZF tags lister.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Apr 2018 20:36:11 -0700 |
parents | 71a080d4d83c |
children | f1f95a19fffe |
line wrap: on
line diff
--- a/vim/vimrc Wed Apr 04 20:35:50 2018 -0700 +++ b/vim/vimrc Wed Apr 04 20:36:11 2018 -0700 @@ -19,23 +19,8 @@ endif let g:sourced_vimrc = 1 -" Get the platform we're running on. -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 = '/' -endif - -" Get our vim directory. -let s:vim_home = expand("<sfile>:h") - " Local pre-override. -let s:local_vimrc_pre = s:vim_home.'/vimrc-local-pre' +let s:local_vimrc_pre = ludo#localpath('vimrc-local-pre') if filereadable(s:local_vimrc_pre) execute 'source' s:local_vimrc_pre endif @@ -46,16 +31,16 @@ " Disable some plugins. let g:pathogen_disabled = get(g:, 'pathogen_disabled', []) -call ludo#setup_pathogen([s:vim_home.'/bundle', s:vim_home.'/local']) +call ludo#setup_pathogen([ludo#localpath('bundle'), ludo#localpath('local')]) " Load pathogen. runtime bundle/pathogen/autoload/pathogen.vim " Add the bundle directory, and potentially add the local one if it exists. " Note that we pass absolute paths to make pathogen prepend stuff before Vim's " system files otherwise stuff like indent plugins don't work. -let s:pathogen_bundles = [s:vim_home.s:path_sep.'bundle'.s:path_sep.'{}'] -if isdirectory(s:vim_home.s:path_sep.'local') - call add(s:pathogen_bundles, s:vim_home.s:path_sep.'local'.s:path_sep.'{}') +let s:pathogen_bundles = [ludo#localpath('bundle', '{}')] +if isdirectory(ludo#localpath('local')) + call add(s:pathogen_bundles, ludo#localpath('local', '{}')) endif call call('pathogen#infect', s:pathogen_bundles) @@ -143,8 +128,8 @@ " we edit the file, and then get rid of it. set nobackup set writebackup -execute('set backupdir='.s:vim_home.'/backup') -execute('set directory='.s:vim_home.'/temp') +execute('set backupdir='.ludo#localpath('backup')) +execute('set directory='.ludo#localpath('temp')) " Better command-line completion, but don't show some " stuff we don't care about. @@ -200,7 +185,7 @@ " And now, for some system-dependent settings: " - font to use -if s:vim_platform == "windows" +if ludo#platform() == "windows" set guifont=InputMono:h11,Hack:h12,Consolas:h12 else set guifont=InputMono:h11,Hack:h12,Monaco:h12 @@ -255,6 +240,8 @@ endif nnoremap <Leader>a :Ack!<Space> +nnoremap <leader>f :Ack! /<C-R><C-W>/ +vnoremap <leader>f "zy:Ack! /<C-R>z/ " }}} @@ -272,7 +259,7 @@ \ } " Make Ctrl-P cache stuff in our temp directory. -let g:ctrlp_cache_dir = s:vim_home.'/cache' +let g:ctrlp_cache_dir = ludo#localpath('cache') " Remember things. let g:ctrlp_clear_cache_on_exit = 0 @@ -297,7 +284,7 @@ " FZF {{{ -if s:vim_platform == 'mac' +if ludo#platform() == 'mac' if filereadable('/usr/local/opt/fzf/plugin/fzf.vim') " FZF installed via Homebrew. source /usr/local/opt/fzf/plugin/fzf.vim @@ -314,9 +301,9 @@ " Gutentags {{{ -let g:gutentags_cache_dir = s:vim_home.'/tags' +let g:gutentags_cache_dir = ludo#localpath('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_extra_args = ['--options='.ludo#localpath('ctagsrc')] let g:gutentags_ctags_exclude_wildignore = 0 " }}} @@ -656,9 +643,6 @@ vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o> vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o> -nnoremap <leader>fa :vimgrep /<C-R><C-W>/ -vnoremap <leader>fa "zy:vimgrep /<C-R>z/ - " Keep search matches in the middle of the window. nnoremap n nzvzz nnoremap N Nzvzz @@ -733,6 +717,10 @@ nnoremap <silent> <C-p> :Files<cr> nnoremap <silent> <C-o> :Buffers<cr> nnoremap <Tab> :History<cr> + + " Replace the default `Tags` command, which requires Perl, with + " something I can use, based on Python. + command! -bang -nargs=* Tags call ludo#run_fzf_tags(<q-args>, <bang>0) else call ludo#error( \"FZF is installed and enabled, but the Vim plugin ". @@ -820,10 +808,7 @@ " Local override {{{ -let s:local_vimrc = s:vim_home.'/vimrc-local' -if filereadable(s:local_vimrc) - execute 'source' s:local_vimrc -let s:local_vimrc = s:vim_home.'/vimrc-local' +let s:local_vimrc = ludo#localpath('vimrc-local') if filereadable(s:local_vimrc) execute 'source' s:local_vimrc endif