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

@ -12,13 +12,13 @@ if empty($DISPLAY) " Use ASCII-only if we're in TTY
endif
" Disable airline in nerdtree buffer
augroup filetype_nerdtree
au!
au FileType nerdtree call s:disable_airline_on_nerdtree()
au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree()
augroup END
fu s:disable_airline_on_nerdtree() abort
let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1
call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')})
endfu
"augroup filetype_nerdtree
" au!
" au FileType nerdtree call s:disable_airline_on_nerdtree()
" au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree()
"augroup END
"
"fu s:disable_airline_on_nerdtree() abort
" let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1
" call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')})
"endfu

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