Prevent opening buffers in NERDTree

This commit is contained in:
Riyyi
2018-12-01 17:28:58 +01:00
parent 52cd473d54
commit 9ff185ca51
+17
View File
@@ -102,6 +102,11 @@ augroup CloseVimTree
autocmd! bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif autocmd! bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END augroup END
augroup PreventBuffer
autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%')
autocmd BufWinEnter * call PreventBuffersInNERDTree()
augroup END
"" Functions "" Functions
function! CloseTab() function! CloseTab()
@@ -120,6 +125,18 @@ function! CloseTab()
endif endif
endfunction endfunction
function! PreventBuffersInNERDTree()
if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree'
\ && exists('t:nerdtree_winnr') && bufwinnr('%') == t:nerdtree_winnr
\ && &buftype == ''
let bufnum = bufnr('%')
close
execute 'b ' . bufnum
execute ':NERDTree'
execute "normal! \<c-w>\<c-w>"
endif
endfunction
"" Keybindings "" Keybindings
" Tab/Shift+Tab functionality " Tab/Shift+Tab functionality