nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit a796715ac1839714cd7f16f19c2b914ebdc635e3
parent 02b3cec8272f227756f6877b6ba2b379ef7bad0f
Author: marty <marty@rodney.(none)>
Date:   Sun,  9 Aug 2009 21:29:28 +1200

add A mapping to maximize/restore tree window size

this commit is a modified patch from Guillaume Duranceau

Diffstat:
Mdoc/NERD_tree.txt | 12++++++++++++
Mplugin/NERD_tree.vim | 17+++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt
@@ -239,6 +239,7 @@ F.......Toggle whether files are displayed.......................|NERDTree-F|
 B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
 
 q.......Close the NERDTree window................................|NERDTree-q|
+A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A|
 ?.......Toggle the display of the quick help.....................|NERDTree-?|
 
 ------------------------------------------------------------------------------
@@ -547,6 +548,14 @@ Applies to: no restrictions.
 Closes the NERDtree window.
 
 ------------------------------------------------------------------------------
+                                                                  *NERDTree-A*
+Default key: A
+Map option: NERDTreeMapToggleZoom
+Applies to: no restrictions.
+
+Maximize (zoom) and minimize the NERDtree window.
+
+------------------------------------------------------------------------------
                                                                   *NERDTree-?*
 Default key: ?
 Map option: NERDTreeMapHelp
@@ -1002,6 +1011,8 @@ Next release:
       NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
     - fix a bug where the script ignored directories whose name ended in a dot,
       thanks to Aggelos Orfanakos for the patch.
+    - added a mapping to maximize/restore the size of nerd tree window, thanks
+      to Guillaume Duranceau for the patch. See :help NERDTree-z for details.
 
 3.1.1
     - fix a bug where a non-listed no-name buffer was getting created every
@@ -1094,6 +1105,7 @@ just downloaded pr0n instead.
     Alf Mikula
     Lucas S. Buchala
     Curtis Harvey
+    Guillaume Duranceau
 
 ==============================================================================
 8. License                                                   *NERDTreeLicense*
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -128,6 +128,7 @@ call s:initVariable("g:NERDTreeMapToggleBookmarks", "B")
 call s:initVariable("g:NERDTreeMapToggleFiles", "F")
 call s:initVariable("g:NERDTreeMapToggleFilters", "f")
 call s:initVariable("g:NERDTreeMapToggleHidden", "I")
+call s:initVariable("g:NERDTreeMapToggleZoom", "A")
 call s:initVariable("g:NERDTreeMapUpdir", "u")
 call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
 
@@ -2605,6 +2606,8 @@ function! s:dumpHelp()
         let @h=@h."\"\n\" ----------------------------\n"
         let @h=@h."\" Other mappings~\n"
         let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
+        let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n"
+        let @h=@h."\"    the NERDTree window\n"
         let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
         let @h=@h."\"\n\" ----------------------------\n"
         let @h=@h."\" Bookmark commands~\n"
@@ -3201,6 +3204,7 @@ function! s:bindMappings()
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapRefresh ." :call <SID>refreshCurrent()<cr>"
 
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapHelp ." :call <SID>displayHelp()<cr>"
+    exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleZoom ." :call <SID>toggleZoom()<cr>"
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleHidden ." :call <SID>toggleShowHidden()<cr>"
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFilters ." :call <SID>toggleIgnoreFilter()<cr>"
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFiles ." :call <SID>toggleShowFiles()<cr>"
@@ -3678,6 +3682,19 @@ function! s:toggleShowHidden()
     call s:centerView()
 endfunction
 
+" FUNCTION: s:toggleZoom() {{2
+" zoom (maximize/minimize) the NERDTree window
+function! s:toggleZoom()
+    if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
+        let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
+        exec "silent vertical resize ". size
+        let b:NERDTreeZoomed = 0
+    else
+        exec "vertical resize"
+        let b:NERDTreeZoomed = 1
+    endif
+endfunction
+
 "FUNCTION: s:upDir(keepState) {{{2
 "moves the tree up a level
 "