Improve NERDTree settings

This commit is contained in:
ItsDrike 2021-09-25 02:44:24 +02:00
parent 8dedca10d2
commit b5354fbf4c
No known key found for this signature in database
GPG key ID: FB8CA11A2CF3A843
2 changed files with 16 additions and 14 deletions

View file

@ -10,15 +10,17 @@ if empty($DISPLAY) " Disable devicons for nerdtree in TTY
let g:webdevicons_enable_nerdtree = 0
endif
"Start NerdTree. If a file is specified, move the cursor to its window.
" If a directory is specified, start NERDTree and move the cursor to its window.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] |
\ endif
autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") |
\ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif
" Exit Vim if NerdTree is the only window left.
" If a file is specified, start NERDTree and keep the cursor in file window.
"autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") |
" \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif