changeset 414:72365ec18f54

Merge changes
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 18 Jan 2018 16:27:32 -0800
parents 4a2468f72e44 (diff) 63463782d1cd (current diff)
children e57b012539d5
files .hgsub .hgsubstate vim/bundle/minibufexpl/plugin/minibufexpl.vim vim/vimrc
diffstat 1 files changed, 75 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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 <buffer> <localleader>z :call <SID>ToggleCppFolding()<CR>
+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 <leader><space> :noh<cr>:call clearmatches()<cr>
 
-" Ctrl-P mappings.
-nnoremap <silent> <C-p> :CtrlP<cr>
-nnoremap <silent> <C-o> :CtrlPBuffer<cr>
-nnoremap <silent> <C-u> :CtrlPTag<cr>
-nnoremap <silent> <C-y> :CtrlPBufTag<cr>
-nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
-nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
-
 " Switch between FR and US keyboard layouts.
 nnoremap <C-l>f :setlocal keymap=french<cr>
 nnoremap <C-l>u :setlocal keymap=<cr>
@@ -644,6 +652,43 @@
   autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr>
 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 <SID>AutoProjectRootCD()
+augroup END
+
+nnoremap <leader>cd :ProjectRootCD<cr>
+
+" Ctrl-P mappings.
+if index(g:pathogen_disabled, 'ctrlp') < 0
+  nnoremap <silent> <C-p> :CtrlP<cr>
+  nnoremap <silent> <C-o> :CtrlPBuffer<cr>
+  nnoremap <silent> <C-u> :CtrlPTag<cr>
+  nnoremap <silent> <C-y> :CtrlPBufTag<cr>
+  nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
+  nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
+endif
+
+" FZF mappings.
+if index(g:pathogen_disabled, 'fzf') < 0
+  nnoremap <silent> <C-p> :Files
+  nnoremap <silent> <C-o> :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 <space>.
 nnoremap <space> za
@@ -663,6 +708,13 @@
 " Create folds with <space> (in visual mode).
 vnoremap <space> 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 {{{