Browse Source

Prevent opening buffers in NERDTree

master
Riyyi 6 years ago
parent
commit
9ff185ca51
  1. 17
      .config/vim/vimrc

17
.config/vim/vimrc

@ -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

Loading…
Cancel
Save