comparison vim/vimrc @ 410:5bbd5963591c

Some Vim config tweaks.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Dec 2017 09:11:19 -0800
parents c32b9b172314
children 4a2468f72e44
comparison
equal deleted inserted replaced
397:c32b9b172314 410:5bbd5963591c
186 186
187 " How to show invisible characters 187 " How to show invisible characters
188 set listchars=eol:$,tab:>-,trail:-,extends:>,precedes:<,nbsp:%,conceal:. 188 set listchars=eol:$,tab:>-,trail:-,extends:>,precedes:<,nbsp:%,conceal:.
189 189
190 " Nice auto-complete menu. 190 " Nice auto-complete menu.
191 set complete=.,w,b,u,t 191 set complete=.,w,b
192 set completeopt=longest,menuone,preview 192 set completeopt=longest,menuone,preview
193 193
194 " Column indicators. 194 " Column indicators.
195 set colorcolumn=72,79 195 set colorcolumn=72,79
196 196
276 if has('python') || has('python3') 276 if has('python') || has('python3')
277 let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'} 277 let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'}
278 let g:ctrlp_max_files = 0 278 let g:ctrlp_max_files = 0
279 let g:ctrlp_lazy_update = 350 279 let g:ctrlp_lazy_update = 350
280 endif 280 endif
281
282 " }}}
283
284 " FZF {{{
285
286
281 287
282 " }}} 288 " }}}
283 289
284 " Gutentags {{{ 290 " Gutentags {{{
285 291
465 autocmd FileType php setlocal matchpairs-=<:> 471 autocmd FileType php setlocal matchpairs-=<:>
466 augroup END 472 augroup END
467 473
468 augroup VimRCFileType_c 474 augroup VimRCFileType_c
469 au! 475 au!
470 autocmd FileType c,c++,cpp,cs setlocal foldmethod=syntax 476 autocmd FileType c,c++,cpp setlocal foldmethod=syntax
471 autocmd FileType c,c++,cpp,cs setlocal colorcolumn=120 477 autocmd FileType c,c++,cpp setlocal colorcolumn=120
478 augroup END
479
480 augroup VimRCFileType_csharp
481 au!
482 autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml
483 autocmd FileType cs setlocal foldmethod=syntax
484 autocmd FileType cs setlocal colorcolumn=120
472 augroup END 485 augroup END
473 486
474 augroup VimRCFileType_css 487 augroup VimRCFileType_css
475 au! 488 au!
476 autocmd BufNewFile,BufRead *.less setlocal filetype=less 489 autocmd BufNewFile,BufRead *.less setlocal filetype=less
546 " Toggle invisible characters 559 " Toggle invisible characters
547 nnoremap <leader>i :set list!<cr> 560 nnoremap <leader>i :set list!<cr>
548 561
549 " Clear search matches 562 " Clear search matches
550 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> 563 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
551
552 " Ctrl-P mappings.
553 nnoremap <silent> <C-p> :CtrlP<cr>
554 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
555 nnoremap <silent> <C-u> :CtrlPTag<cr>
556 nnoremap <silent> <C-y> :CtrlPBufTag<cr>
557 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
558 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
559 564
560 " Switch between FR and US keyboard layouts. 565 " Switch between FR and US keyboard layouts.
561 nnoremap <C-l>f :setlocal keymap=french<cr> 566 nnoremap <C-l>f :setlocal keymap=french<cr>
562 nnoremap <C-l>u :setlocal keymap=<cr> 567 nnoremap <C-l>u :setlocal keymap=<cr>
563 568
642 autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr> 647 autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr>
643 autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr> 648 autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr>
644 autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr> 649 autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr>
645 augroup END 650 augroup END
646 651
652 " ProjectRoot mappings
653 let s:no_auto_projectroot_buftypes = [
654 \'help', 'nofile', 'quickfix']
655
656 function! s:AutoProjectRootCD() abort
657 try
658 if index(s:no_auto_projectroot_buftypes, &buftype) == -1
659 ProjectRootCD
660 endif
661 catch
662 " Silently ignore invalid buffers
663 endtry
664 endfunction
665
666 augroup VimRC_ProjectRoot
667 autocmd!
668 autocmd BufEnter * call <SID>AutoProjectRootCD()
669 augroup END
670
671 nnoremap <leader>cd :ProjectRootCD<cr>
672
673 " Ctrl-P mappings.
674 if index(g:pathogen_disabled, 'ctrlp') < 0
675 nnoremap <silent> <C-p> :CtrlP<cr>
676 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
677 nnoremap <silent> <C-u> :CtrlPTag<cr>
678 nnoremap <silent> <C-y> :CtrlPBufTag<cr>
679 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
680 nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
681 endif
682
683 " FZF mappings.
684 if index(g:pathogen_disabled, 'fzf') < 0
685 nnoremap <silent> <C-p> :Files
686 nnoremap <silent> <C-o> :Buffers
687 endif
688
647 " }}} 689 " }}}
648 690
649 " Folding {{{ 691 " Folding {{{
650 692
651 " Start with one level of open. 693 " Start with one level of open.
653 695
654 " Don't fold too much. 696 " Don't fold too much.
655 set foldnestmax=2 697 set foldnestmax=2
656 698
657 " Folds are defined by markers in the text. 699 " Folds are defined by markers in the text.
658 set foldmethod=marker 700 set foldmethod=marker"{{{"}}}
659 701
660 " Toggle folds with <space>. 702 " Toggle folds with <space>.
661 nnoremap <space> za 703 nnoremap <space> za
662 704
663 " Create folds with <space> (in visual mode). 705 " Create folds with <space> (in visual mode).
697 function! s:ToggleNERDTree() abort 739 function! s:ToggleNERDTree() abort
698 NERDTreeToggle 740 NERDTreeToggle
699 endfunction 741 endfunction
700 742
701 function! s:FindInNERDTree() abort 743 function! s:FindInNERDTree() abort
702 NERDTreeFind 744 ProjectRootExe NERDTreeFind
703 normal zz 745 normal zz
704 endfunction 746 endfunction
705 747
706 " }}} 748 " }}}
707 749