From 2243a7fd58faafb5cb4d2ab3947b3adab8eeb475 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 18 Jan 2023 13:38:08 +0100 Subject: [nvim] reorganize config and plugins --- .config/nvim/plugins/nerdtree.vim | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .config/nvim/plugins/nerdtree.vim (limited to '.config/nvim/plugins/nerdtree.vim') diff --git a/.config/nvim/plugins/nerdtree.vim b/.config/nvim/plugins/nerdtree.vim new file mode 100644 index 0000000..8a7869a --- /dev/null +++ b/.config/nvim/plugins/nerdtree.vim @@ -0,0 +1,33 @@ +let g:NERDTreeShowHidden=1 +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 + +autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + +" set status line on tab switch +function NERDTreeStatusLineTabSwitch() + let tab_nr = tabpagenr() + let buffer_list = tabpagebuflist(tab_nr) + + " default to 2 + let meaningful_window_nr = 2 + + for buffer_nr in buffer_list + let buffer_type = getbufvar(buffer_nr, "&filetype") + if index(g:NERDTreeStatusLineTabSwitchFiletypes, buffer_type) == -1 + let meaningful_window_nr = bufwinnr(buffer_nr) + break + endif + endfor + + exe meaningful_window_nr .. "wincmd w" +endfunction +autocmd TabLeave * call NERDTreeStatusLineTabSwitch() + +map NERDTreeToggle -- cgit v1.2.3