# HG changeset patch # User Ludovic Chabant # Date 1516321652 28800 # Node ID 72365ec18f549be401573e77e15a208e9917cdbc # Parent 4a2468f72e4408cce9aabe82616743ea74fe8104# Parent 63463782d1cd1bf567edde2a7612e328ec640ecb Merge changes diff -r 63463782d1cd -r 72365ec18f54 vim/vimrc --- a/vim/vimrc Wed Jan 10 00:05:36 2018 -0800 +++ b/vim/vimrc Thu Jan 18 16:27:32 2018 -0800 @@ -188,7 +188,7 @@ set listchars=eol:$,tab:>-,trail:-,extends:>,precedes:<,nbsp:%,conceal:. " Nice auto-complete menu. -set complete=.,w,b,u,t +set complete=.,w,b set completeopt=longest,menuone,preview " Column indicators. @@ -281,6 +281,12 @@ " }}} +" FZF {{{ + + + +" }}} + " Gutentags {{{ let g:gutentags_cache_dir = s:vim_home.'/tags' @@ -467,8 +473,18 @@ augroup VimRCFileType_c au! - autocmd FileType c,c++,cpp,cs setlocal foldmethod=syntax - autocmd FileType c,c++,cpp,cs setlocal colorcolumn=120 + autocmd FileType c,c++,cpp setlocal foldmethod=syntax + autocmd FileType c,c++,cpp setlocal colorcolumn=120 + autocmd FileType c,c++,cpp setlocal synmaxcol=200 + autocmd FileType c,c++,cpp nnoremap z :call ToggleCppFolding() +augroup END + +augroup VimRCFileType_csharp + au! + autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml + autocmd FileType cs setlocal foldmethod=syntax + autocmd FileType cs setlocal colorcolumn=120 + autocmd FileType cs setlocal synmaxcol=200 augroup END augroup VimRCFileType_css @@ -549,14 +565,6 @@ " Clear search matches nnoremap :noh:call clearmatches() -" Ctrl-P mappings. -nnoremap :CtrlP -nnoremap :CtrlPBuffer -nnoremap :CtrlPTag -nnoremap :CtrlPBufTag -nnoremap :CtrlPMRUFiles -nnoremap :CtrlPBookmarkDir - " Switch between FR and US keyboard layouts. nnoremap f :setlocal keymap=french nnoremap u :setlocal keymap= @@ -644,6 +652,43 @@ autocmd FileType cs nnoremap dc :OmniSharpDocumentation augroup END +" ProjectRoot mappings +let s:no_auto_projectroot_buftypes = [ + \'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 +endfunction + +augroup VimRC_ProjectRoot + autocmd! + autocmd BufEnter * call AutoProjectRootCD() +augroup END + +nnoremap cd :ProjectRootCD + +" Ctrl-P mappings. +if index(g:pathogen_disabled, 'ctrlp') < 0 + nnoremap :CtrlP + nnoremap :CtrlPBuffer + nnoremap :CtrlPTag + nnoremap :CtrlPBufTag + nnoremap :CtrlPMRUFiles + nnoremap :CtrlPBookmarkDir +endif + +" FZF mappings. +if index(g:pathogen_disabled, 'fzf') < 0 + nnoremap :Files + nnoremap :Buffers +endif + " }}} " Folding {{{ @@ -655,7 +700,7 @@ set foldnestmax=2 " Folds are defined by markers in the text. -set foldmethod=marker +set foldmethod=marker"{{{"}}} " Toggle folds with . nnoremap za @@ -663,6 +708,13 @@ " Create folds with (in visual mode). vnoremap zf +" See http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text +" Don't screw up folds when inserting text that might affect them, until +" leaving insert mode. Foldmethod is local to the window. Protect against +" screwing up folding when switching between windows. +autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif +autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif + " }}} " Abbreviations {{{ @@ -699,10 +751,20 @@ endfunction function! s:FindInNERDTree() abort - NERDTreeFind + ProjectRootExe NERDTreeFind normal zz endfunction +function! s:ToggleCppFolding() abort + if (&foldmethod == "syntax") + setlocal foldmethod=manual + setlocal nofoldenable + else + setlocal foldmethod=syntax + setlocal foldenable + endif +endfunction + " }}} " Local override {{{