refactor tree window creation to remove duplication
create s:setCommonBufOptions() with the previously duplicated parts of s:initNerdTreeInPlace() and s:createTreeWin()
This commit is contained in:
parent
aa28ae7863
commit
23d1746bbf
@ -2658,43 +2658,9 @@ function! s:initNerdTreeInPlace(dir)
|
||||
let b:NERDTreeRoot = s:TreeDirNode.New(path)
|
||||
call b:NERDTreeRoot.open()
|
||||
|
||||
"throwaway buffer options
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal nowrap
|
||||
setlocal foldcolumn=0
|
||||
setlocal nobuflisted
|
||||
setlocal nospell
|
||||
setlocal nolist
|
||||
if g:NERDTreeShowLineNumbers
|
||||
setlocal nu
|
||||
else
|
||||
setlocal nonu
|
||||
if v:version >= 703
|
||||
setlocal nornu
|
||||
endif
|
||||
endif
|
||||
|
||||
iabc <buffer>
|
||||
|
||||
if g:NERDTreeHighlightCursorline
|
||||
setlocal cursorline
|
||||
endif
|
||||
|
||||
call s:setupStatusline()
|
||||
|
||||
let b:treeShowHelp = 0
|
||||
let b:NERDTreeIgnoreEnabled = 1
|
||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
|
||||
call s:setCommonBufOptions()
|
||||
let b:NERDTreeType = "secondary"
|
||||
|
||||
call s:bindMappings()
|
||||
setfiletype nerdtree
|
||||
|
||||
call s:renderView()
|
||||
endfunction
|
||||
" FUNCTION: s:initNerdTreeMirror() {{{2
|
||||
@ -2894,33 +2860,7 @@ function! s:createTreeWin()
|
||||
endif
|
||||
|
||||
setlocal winfixwidth
|
||||
|
||||
"throwaway buffer options
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal nowrap
|
||||
setlocal foldcolumn=0
|
||||
setlocal nobuflisted
|
||||
setlocal nospell
|
||||
if g:NERDTreeShowLineNumbers
|
||||
setlocal nu
|
||||
else
|
||||
setlocal nonu
|
||||
if v:version >= 703
|
||||
setlocal nornu
|
||||
endif
|
||||
endif
|
||||
|
||||
iabc <buffer>
|
||||
|
||||
if g:NERDTreeHighlightCursorline
|
||||
setlocal cursorline
|
||||
endif
|
||||
|
||||
call s:setupStatusline()
|
||||
|
||||
call s:bindMappings()
|
||||
setfiletype nerdtree
|
||||
call s:setCommonBufOptions()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:dumpHelp {{{2
|
||||
@ -3399,6 +3339,43 @@ function! s:saveScreenState()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:setCommonBufOptions() {{{2
|
||||
function! s:setCommonBufOptions()
|
||||
"throwaway buffer options
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal nowrap
|
||||
setlocal foldcolumn=0
|
||||
setlocal nobuflisted
|
||||
setlocal nospell
|
||||
if g:NERDTreeShowLineNumbers
|
||||
setlocal nu
|
||||
else
|
||||
setlocal nonu
|
||||
if v:version >= 703
|
||||
setlocal nornu
|
||||
endif
|
||||
endif
|
||||
|
||||
iabc <buffer>
|
||||
|
||||
if g:NERDTreeHighlightCursorline
|
||||
setlocal cursorline
|
||||
endif
|
||||
|
||||
call s:setupStatusline()
|
||||
|
||||
|
||||
let b:treeShowHelp = 0
|
||||
let b:NERDTreeIgnoreEnabled = 1
|
||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
setfiletype nerdtree
|
||||
call s:bindMappings()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:setupStatusline() {{{2
|
||||
function! s:setupStatusline()
|
||||
if g:NERDTreeStatusline != -1
|
||||
|
Loading…
Reference in New Issue
Block a user