blob: 3a8ad5023196adb4c6e1e63b1bd4ff0e495b964c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
let g:NERDTreeShowHidden=1
let g:NERDTreeGitStatusShowIgnored=1
if !&diff
autocmd StdinReadPre * let s:std_in=1
endif
function NERDTreeInit()
if !&diff
let buffer_type = getbufvar(bufnr(), "&filetype")
if index(g:NERDTreeNoInitFiletypes, buffer_type) == -1
NERDTree
if argc() > 0 || exists('s:std_in')
wincmd p
endif
if argc() > 0
silent NERDTreeFind
wincmd p
endif
endif
endif
endfunction
autocmd VimEnter * call NERDTreeInit()
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()
" only when in non-meaningful window
if index(g:NERDTreeStatusLineTabSwitchFiletypes, &filetype) == -1
return
endif
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 <C-b> <cmd>NERDTreeToggle<CR>
|