From b5354fbf4c76ec86d4e917c01f957bd23138aa04 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 25 Sep 2021 02:44:24 +0200 Subject: [PATCH] Improve NERDTree settings --- home/.config/nvim/rc/plugins.d/airline.vim | 20 ++++++++++---------- home/.config/nvim/rc/plugins.d/nerdtree.vim | 10 ++++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/home/.config/nvim/rc/plugins.d/airline.vim b/home/.config/nvim/rc/plugins.d/airline.vim index 4a61840..47c7c88 100644 --- a/home/.config/nvim/rc/plugins.d/airline.vim +++ b/home/.config/nvim/rc/plugins.d/airline.vim @@ -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 diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim index eab8fe4..a619ec8 100644 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ b/home/.config/nvim/rc/plugins.d/nerdtree.vim @@ -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