Skip to content

Commit

Permalink
Refresh NERDTree and perform :CommandTFlush when window gains focus.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansobo committed Dec 16, 2011
1 parent ad94ead commit e26617a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions gvimrc
Expand Up @@ -24,6 +24,35 @@ if has("gui_macvim")
macmenu Window.Toggle\ Full\ Screen\ Mode key=<D-CR>
endif

if exists("loaded_nerd_tree")
augroup AuNERDTreeCmd
autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree()
endif

" NERDTree utility function
function s:UpdateNERDTree(...)
let stay = 0

if(exists("a:1"))
let stay = a:1
end

if exists("t:NERDTreeBufName")
let nr = bufwinnr(t:NERDTreeBufName)
if nr != -1
exe nr . "wincmd w"
exe substitute(mapcheck("R"), "<CR>", "", "")
if !stay
wincmd p
end
endif
endif

if exists(":CommandTFlush") == 2
CommandTFlush
endif
endfunction

"-------------------------------------------
" LOCAL CONFIG
"-------------------------------------------
Expand Down

0 comments on commit e26617a

Please sign in to comment.