Dotfiles/site-modules/core/files/vim/plugin/nerdtree.vim
Ade Attwood 80239af169 refactor(core): start to make dotfiles public
This is the first commit that brings the privet dotfiles to a public
reop previously this was all one puppet module. Now this has been split
out so I can put all of the private files in a private puppet module
2020-09-20 06:22:17 +01:00

34 lines
802 B
VimL

" Check if NERDTree is open or active
function! s:isNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
" file, and we're not in vimdiff
function! s:syncTree()
if &modifiable && s:isNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
function! ToggleNerdTree()
if s:isNERDTreeOpen()
NERDTreeClose
return
endif
set eventignore=BufEnter
NERDTreeFind
set eventignore=
endfunction
function s:nerdtree_init()
nmap <silent> <Leader>o :call ToggleNerdTree()<CR>
autocmd BufEnter * call s:syncTree()
packadd nerdtree
endfunction
au User WincentSoftDefer call s:nerdtree_init()