changeset 303:01ec865443b6

Update NERDTree macros and tweak more Vim stuff.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 26 Jun 2015 13:54:24 -0700
parents cd3246751ccf
children 50fbd059a6a1 5b7acab16766
files vim/vimrc
diffstat 1 files changed, 17 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/vim/vimrc	Tue Jun 02 10:12:06 2015 -0700
+++ b/vim/vimrc	Fri Jun 26 13:54:24 2015 -0700
@@ -437,7 +437,7 @@
 nnoremap <silent> <C-u> :CtrlPTag<cr>
 nnoremap <silent> <C-y> :CtrlPQuickfix<cr>
 nnoremap <silent> <Tab> :CtrlPMRUFiles<cr>
-nnoremap <silent> <F9> :CtrlPBookmarkDir<cr>
+nnoremap <silent> <F8> :CtrlPBookmarkDir<cr>
 
 " Switch between FR and US keyboard layouts.
 nnoremap <C-l>f :setlocal keymap=french<cr>
@@ -454,6 +454,7 @@
 vnoremap / /\v
 
 " Next/previous quickfix and location messages.
+" This is meant to be similar to ]c and [c for the diff navigation.
 nnoremap ]q :cnext<cr>zvzz
 nnoremap [q :cprevious<cr>zvzz
 nnoremap ]l :lnext<cr>zvzz
@@ -463,7 +464,7 @@
 nnoremap ]] g,zz
 nnoremap [[ g;zz
 
-" Same with diff list.
+" Make the diff navigation also center things.
 nnoremap ]c ]czvzz
 nnoremap [c [czvzz
 
@@ -482,14 +483,13 @@
 
 " Jump to tags by keeping things better in view. Option for jumping to a tag
 " in a split window where everything is folded except what you need to see.
-function! JumpToTag()
-    execute "normal! \<c-]>zvzz"
-endfunction
-function! JumpToTagInSplit()
-    execute "normal! \<c-w>v\<c-]>zMzvzz"
-endfunction
-nnoremap <c-]> :silent! call JumpToTag()<cr>
-nnoremap <c-\> :silent! call JumpToTagInSplit()<cr>
+" Note that if a tag search yield multiple possible results, we will still run
+" some of that `zvzz` stuff, but that's OK, the main point is to not mess up
+" the result selection window either.
+nnoremap <c-]> <c-]>zvzz
+nnoremap <c-\> <c-w>v<c-]>zMzvzz
+nnoremap <F9>  :tprevious
+nnoremap <F10> :tnext
 
 " Keep search matches in the middle of the window.
 nnoremap n nzvzz
@@ -634,25 +634,18 @@
 endfunction
 
 function! s:ToggleNERDTree() abort
-    let l:was_open = nerdtree#isTreeOpen()
     NERDTreeToggle
-    if !l:was_open
-        wincmd p
-        NERDTreeCWD
-        wincmd p
-        NERDTreeFind
-    endif
 endfunction
 
 function! s:FindInNERDTree() abort
-    if !nerdtree#isTreeOpen()
-        call s:ToggleNERDTree()
+    if !g:NERDTree.IsOpen() || getbufvar('%', 'NERDTreeType') == ''
+        " If we're not in the NERDTree window, switch to it and find the
+        " current file in it.
+        NERDTreeFind
+        normal zz
     else
-        if getbufvar('%', 'NERDTreeType') != ''
-            wincmd p
-        else
-            NERDTreeFind
-        endif
+        " We're in the NERDTree window, go back to the previous one.
+        wincmd p
     endif
 endfunction