make fugitive commands available in nerdtree bufs

Previously s:Detect() wasnt getting called for nerdtree buffers. I have
added two autocmd events to nerdtree - NERDTreeInit and
NERDTreeNewRoot. These are called when a tree is created, and when the
user changes the root.

Catch these events and call s:Detect() with the tree root path.
This commit is contained in:
Martin Grenfell 2012-03-30 16:09:25 +01:00 committed by Tim Pope
parent 51de95ddee
commit 89e771ea96

View File

@ -162,6 +162,7 @@ augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost * call s:Detect(expand('<amatch>:p'))
autocmd FileType netrw call s:Detect(expand('<afile>:p'))
autocmd User NERDTreeInit,NERDTreeNewRoot call s:Detect(b:NERDTreeRoot.path.str())
autocmd VimEnter * if expand('<amatch>')==''|call s:Detect(getcwd())|endif
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
augroup END