diff --git a/nvim/init.vim b/nvim/init.vim index 122fbf09..deeca8ed 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -27,9 +27,11 @@ Plug 'HerringtonDarkholme/yats.vim' " TS Syntax call plug#end() inoremap jk nmap :NERDTreeToggle -" open NERDTree automatically + +" Start NERDTree. If a file is specified, move the cursor to its window. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * NERDTree +autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif + " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif