From 04ea2eb0f713105398aad9a9f3e011e68f098341 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 17 May 2008 14:40:27 +1200 Subject: [PATCH] apply Cory Echols' patch adds :NERDTreeClose command and sets the filetype for the tree buffer to "nerdtree" --- doc/NERD_tree.txt | 7 ++++++- plugin/NERD_tree.vim | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 86d1407..a3f764a 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -96,6 +96,9 @@ The following features and functionality are provided by the NERD tree: rendered again. If no NERD tree exists for this tab then this command acts the same as the |:NERDTree| command. +:NERDTreeClose + Close the NERD tree in this tab. + ------------------------------------------------------------------------------ 2.2. NERD tree Mappings *NERDTreeMappings* @@ -789,7 +792,9 @@ fridge for later ;) confused about drives on MF Windows * made the script way better at handling paths with strange characters in them (eg '$@; etc) - + - applied a patch from Cory Echols + * add the command :NERDTreeClose to close the tree for the current tab + * set the filetype for the NERD tree buffer to "nerdtree" 2.8.0 - added an option to enable/disable line numbers in the NERD tree window, diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ff6e9ec..15e73e3 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -139,6 +139,7 @@ endif "init the command that users start the nerd tree with command! -n=? -complete=dir NERDTree :call s:InitNerdTree('') command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('') +command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen() " SECTION: Auto commands {{{1 "============================================================ "Save the cursor position whenever we close the nerd tree @@ -1430,7 +1431,13 @@ function! s:CenterView() endif endif endfunction - +"FUNCTION: s:CloseTreeIfOpen() {{{2 +"Closes the NERD tree window if it is open +function! s:CloseTreeIfOpen() + if s:IsTreeOpen() + call s:CloseTree() + endif +endfunction "FUNCTION: s:CloseTree() {{{2 "Closes the NERD tree window function! s:CloseTree() @@ -1481,16 +1488,17 @@ function! s:CreateTreeWin() setlocal cursorline endif - " syntax highlighting - if has("syntax") && exists("g:syntax_on") && !has("syntax_items") - call s:SetupSyntaxHighlighting() - endif " for line continuation let cpo_save1 = &cpo set cpo&vim call s:BindMappings() + setfiletype nerdtree + " syntax highlighting + if has("syntax") && exists("g:syntax_on") && !has("syntax_items") + call s:SetupSyntaxHighlighting() + endif endfunction "FUNCTION: s:DrawTree {{{2