summaryrefslogtreecommitdiff
path: root/.config/nvim/plugins/nerdtree.vim
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/plugins/nerdtree.vim')
-rw-r--r--.config/nvim/plugins/nerdtree.vim21
1 files changed, 19 insertions, 2 deletions
diff --git a/.config/nvim/plugins/nerdtree.vim b/.config/nvim/plugins/nerdtree.vim
index 8a7869a..57ffba2 100644
--- a/.config/nvim/plugins/nerdtree.vim
+++ b/.config/nvim/plugins/nerdtree.vim
@@ -3,10 +3,27 @@ let g:NERDTreeGitStatusShowIgnored=1
if !&diff
autocmd StdinReadPre * let s:std_in=1
- autocmd VimEnter * NERDTree | if argc() > 0 || exists('s:std_in') | wincmd p | endif
- autocmd VimEnter * if argc() > 0 | silent NERDTreeFind | wincmd p | endif
endif
+function NERDTreeInit()
+ if !&diff
+ let buffer_type = getbufvar(bufnr(), "&filetype")
+ if index(g:NERDTreeNoInitFiletypes, buffer_type) == -1
+ NERDTree
+
+ if argc() > 0 || exists('s:std_in')
+ wincmd p
+ endif
+
+ if argc() > 0
+ silent NERDTreeFind
+ wincmd p
+ endif
+ endif
+ endif
+endfunction
+autocmd VimEnter * call NERDTreeInit()
+
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif