nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 23d1746bbf309dc6b7dc964771af396d07b3a477
parent aa28ae7863131f4fd8ccfe5f46892cc307193436
Author: Martin Grenfell <martin.grenfell@gmail.com>
Date:   Wed, 21 Dec 2011 14:43:20 +0000

refactor tree window creation to remove duplication

create s:setCommonBufOptions() with the previously duplicated parts of
s:initNerdTreeInPlace() and s:createTreeWin()

Diffstat:
Mplugin/NERD_tree.vim | 101+++++++++++++++++++++++++++++++------------------------------------------------
1 file changed, 39 insertions(+), 62 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -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