From 70ba0d60ec64de98318c9010a8e62122fdedf8f4 Mon Sep 17 00:00:00 2001 From: George Ang Date: Sat, 18 Jun 2011 23:56:31 +0800 Subject: [PATCH 001/680] separate syntax file for better combacibility with plugins that reloads vimrc files(such as perdirvimrc) after BufRead. --- plugin/NERD_tree.vim | 190 +++++++++++++++++++++---------------------- syntax/nerdtree.vim | 88 ++++++++++++++++++++ 2 files changed, 183 insertions(+), 95 deletions(-) create mode 100644 syntax/nerdtree.vim diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ee13ab02..539043bd 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2688,9 +2688,9 @@ function! s:initNerdTreeInPlace(dir) call s:bindMappings() setfiletype nerdtree " syntax highlighting - if has("syntax") && exists("g:syntax_on") - call s:setupSyntaxHighlighting() - endif + "if has("syntax") && exists("g:syntax_on") + "call s:setupSyntaxHighlighting() + "endif call s:renderView() endfunction @@ -2919,9 +2919,9 @@ function! s:createTreeWin() call s:bindMappings() setfiletype nerdtree " syntax highlighting - if has("syntax") && exists("g:syntax_on") - call s:setupSyntaxHighlighting() - endif + "if has("syntax") && exists("g:syntax_on") + "call s:setupSyntaxHighlighting() + "endif endfunction "FUNCTION: s:dumpHelp {{{2 @@ -3407,95 +3407,95 @@ function! s:setupStatusline() endif endfunction "FUNCTION: s:setupSyntaxHighlighting() {{{2 -function! s:setupSyntaxHighlighting() - "NERDTreeFlags are syntax items that should be invisible, but give clues as to - "how things should be highlighted - syn match NERDTreeFlag #\~# - syn match NERDTreeFlag #\[RO\]# - - "highlighting for the .. (up dir) line at the top of the tree - execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" - - "highlighting for the ~/+ symbols for the directory nodes - syn match NERDTreeClosable #\~\<# - syn match NERDTreeClosable #\~\.# - syn match NERDTreeOpenable #+\<# - syn match NERDTreeOpenable #+\.#he=e-1 - - "highlighting for the tree structural parts - syn match NERDTreePart #|# - syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart - - "quickhelp syntax elements - syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 - syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 - syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag - syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey - syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey - syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 - syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand - - "highlighting for readonly files - syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile - - "highlighting for sym links - syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash - - "highlighing for directory nodes and file nodes - syn match NERDTreeDirSlash #/# - syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable - syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeCWD #^[# - syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader - syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader - syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader - - if g:NERDChristmasTree - hi def link NERDTreePart Special - hi def link NERDTreePartFile Type - hi def link NERDTreeFile Normal - hi def link NERDTreeExecFile Title - hi def link NERDTreeDirSlash Identifier - hi def link NERDTreeClosable Type - else - hi def link NERDTreePart Normal - hi def link NERDTreePartFile Normal - hi def link NERDTreeFile Normal - hi def link NERDTreeClosable Title - endif - - hi def link NERDTreeBookmarksHeader statement - hi def link NERDTreeBookmarksLeader ignore - hi def link NERDTreeBookmarkName Identifier - hi def link NERDTreeBookmark normal - - hi def link NERDTreeHelp String - hi def link NERDTreeHelpKey Identifier - hi def link NERDTreeHelpCommand Identifier - hi def link NERDTreeHelpTitle Macro - hi def link NERDTreeToggleOn Question - hi def link NERDTreeToggleOff WarningMsg - - hi def link NERDTreeDir Directory - hi def link NERDTreeUp Directory - hi def link NERDTreeCWD Statement - hi def link NERDTreeLink Macro - hi def link NERDTreeOpenable Title - hi def link NERDTreeFlag ignore - hi def link NERDTreeRO WarningMsg - hi def link NERDTreeBookmark Statement - - hi def link NERDTreeCurrentNode Search -endfunction +"function! s:setupSyntaxHighlighting() + ""NERDTreeFlags are syntax items that should be invisible, but give clues as to + ""how things should be highlighted + "syn match NERDTreeFlag #\~# + "syn match NERDTreeFlag #\[RO\]# + + ""highlighting for the .. (up dir) line at the top of the tree + "execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" + + ""highlighting for the ~/+ symbols for the directory nodes + "syn match NERDTreeClosable #\~\<# + "syn match NERDTreeClosable #\~\.# + "syn match NERDTreeOpenable #+\<# + "syn match NERDTreeOpenable #+\.#he=e-1 + + ""highlighting for the tree structural parts + "syn match NERDTreePart #|# + "syn match NERDTreePart #`# + "syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + + ""quickhelp syntax elements + "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 + "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 + "syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag + "syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey + "syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey + "syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 + "syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand + + ""highlighting for readonly files + "syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile + + ""highlighting for sym links + "syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash + + ""highlighing for directory nodes and file nodes + "syn match NERDTreeDirSlash #/# + "syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable + "syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark + "syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + "syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + "syn match NERDTreeCWD #^[# + "syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader + "syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader + "syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader + + "if g:NERDChristmasTree + "hi def link NERDTreePart Special + "hi def link NERDTreePartFile Type + "hi def link NERDTreeFile Normal + "hi def link NERDTreeExecFile Title + "hi def link NERDTreeDirSlash Identifier + "hi def link NERDTreeClosable Type + "else + "hi def link NERDTreePart Normal + "hi def link NERDTreePartFile Normal + "hi def link NERDTreeFile Normal + "hi def link NERDTreeClosable Title + "endif + + "hi def link NERDTreeBookmarksHeader statement + "hi def link NERDTreeBookmarksLeader ignore + "hi def link NERDTreeBookmarkName Identifier + "hi def link NERDTreeBookmark normal + + "hi def link NERDTreeHelp String + "hi def link NERDTreeHelpKey Identifier + "hi def link NERDTreeHelpCommand Identifier + "hi def link NERDTreeHelpTitle Macro + "hi def link NERDTreeToggleOn Question + "hi def link NERDTreeToggleOff WarningMsg + + "hi def link NERDTreeDir Directory + "hi def link NERDTreeUp Directory + "hi def link NERDTreeCWD Statement + "hi def link NERDTreeLink Macro + "hi def link NERDTreeOpenable Title + "hi def link NERDTreeFlag ignore + "hi def link NERDTreeRO WarningMsg + "hi def link NERDTreeBookmark Statement + + "hi def link NERDTreeCurrentNode Search +"endfunction "FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2 "returns the given line with all the tree parts stripped off diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim new file mode 100644 index 00000000..636d2af7 --- /dev/null +++ b/syntax/nerdtree.vim @@ -0,0 +1,88 @@ +let s:tree_up_dir_line = '.. (up a dir)' +"NERDTreeFlags are syntax items that should be invisible, but give clues as to +"how things should be highlighted +syn match NERDTreeFlag #\~# +syn match NERDTreeFlag #\[RO\]# + +"highlighting for the .. (up dir) line at the top of the tree +execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" + +"highlighting for the ~/+ symbols for the directory nodes +syn match NERDTreeClosable #\~\<# +syn match NERDTreeClosable #\~\.# +syn match NERDTreeOpenable #+\<# +syn match NERDTreeOpenable #+\.#he=e-1 + +"highlighting for the tree structural parts +syn match NERDTreePart #|# +syn match NERDTreePart #`# +syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + +"quickhelp syntax elements +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 +syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag +syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey +syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey +syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 +syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand + +"highlighting for readonly files +syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile + +"highlighting for sym links +syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash + +"highlighing for directory nodes and file nodes +syn match NERDTreeDirSlash #/# +syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable +syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark +syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile +syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile +syn match NERDTreeCWD #^[# +syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader + +if exists("g:NERDChristmasTree") && g:NERDChristmasTree + hi def link NERDTreePart Special + hi def link NERDTreePartFile Type + hi def link NERDTreeFile Normal + hi def link NERDTreeExecFile Title + hi def link NERDTreeDirSlash Identifier + hi def link NERDTreeClosable Type +else + hi def link NERDTreePart Normal + hi def link NERDTreePartFile Normal + hi def link NERDTreeFile Normal + hi def link NERDTreeClosable Title +endif + +hi def link NERDTreeBookmarksHeader statement +hi def link NERDTreeBookmarksLeader ignore +hi def link NERDTreeBookmarkName Identifier +hi def link NERDTreeBookmark normal + +hi def link NERDTreeHelp String +hi def link NERDTreeHelpKey Identifier +hi def link NERDTreeHelpCommand Identifier +hi def link NERDTreeHelpTitle Macro +hi def link NERDTreeToggleOn Question +hi def link NERDTreeToggleOff WarningMsg + +hi def link NERDTreeDir Directory +hi def link NERDTreeUp Directory +hi def link NERDTreeCWD Statement +hi def link NERDTreeLink Macro +hi def link NERDTreeOpenable Title +hi def link NERDTreeFlag ignore +hi def link NERDTreeRO WarningMsg +hi def link NERDTreeBookmark Statement + +hi def link NERDTreeCurrentNode Search From 0b0c76626bbb6b674018ac63fe050d039131f618 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Thu, 7 Jul 2011 02:38:01 -0700 Subject: [PATCH 002/680] Added support for windows network shares (\\box\share format paths) --- plugin/NERD_tree.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b5d014be..96f048a5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1880,7 +1880,7 @@ let s:Path = {} function! s:Path.AbsolutePathFor(str) let prependCWD = 0 if s:running_windows - let prependCWD = a:str !~# '^.:\(\\\|\/\)' + let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)' else let prependCWD = a:str !~# '^/' endif @@ -2109,7 +2109,12 @@ endfunction "If running windows, cache the drive letter for this path function! s:Path.extractDriveLetter(fullpath) if s:running_windows - let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '') + if a:fullpath =~ '^\(\\\\\|\/\/\)' + let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') + let self.drive = substitute(self.drive, '/', '\', "g") + else + let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '') + endif else let self.drive = '' endif @@ -2489,6 +2494,9 @@ function! s:Path.WinToUnixPath(pathstr) "remove the x:\ of the front let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") + "remove the \\ network share from the front + let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "") + "convert all \ chars to / let toReturn = substitute(toReturn, '\', '/', "g") @@ -4114,4 +4122,4 @@ endfunction "reset &cpo back to users setting let &cpo = s:old_cpo -" vim: set sw=4 sts=4 et fdm=marker: +" vim: set sw=4 sts=4 et fdm=marker: \ No newline at end of file From bc745b6e99888c97c7e8f6ff3b7e8f605cab5af1 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Thu, 7 Jul 2011 02:51:13 -0700 Subject: [PATCH 003/680] Fixed resolve() double endslash defect --- plugin/NERD_tree.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 96f048a5..aae0f18c 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2297,7 +2297,7 @@ function! s:Path.readInfoFromDisk(fullpath) let lastPathComponent = self.getLastPathComponent(0) "get the path to the new node with the parent dir fully resolved - let hardPath = resolve(self.strTrunk()) . '/' . lastPathComponent + let hardPath = resolve(self.strTrunk()) . lastPathComponent "if the last part of the path is a symlink then flag it as such let self.isSymLink = (resolve(hardPath) != hardPath) @@ -2472,9 +2472,13 @@ function! s:Path._str() endfunction "FUNCTION: Path.strTrunk() {{{3 -"Gets the path without the last segment on the end. +"Gets the path without the last segment on the end, always with an endslash function! s:Path.strTrunk() - return self.drive . '/' . join(self.pathSegments[0:-2], '/') + let toReturn = self.drive . '/' . join(self.pathSegments[0:-2], '/') + if toReturn !~# '\/$' + let toReturn .= '/' + endif + return toReturn endfunction "FUNCTION: Path.WinToUnixPath(pathstr){{{3 @@ -4122,4 +4126,4 @@ endfunction "reset &cpo back to users setting let &cpo = s:old_cpo -" vim: set sw=4 sts=4 et fdm=marker: \ No newline at end of file +" vim: set sw=4 sts=4 et fdm=marker: From 86364c21505ece4d5f6f509215efe7b159d1502a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20K=2E=20Lema=C5=84ski?= Date: Fri, 5 Aug 2011 17:42:41 +0300 Subject: [PATCH 004/680] wycats's "disallow insert mode" https://github.com/wycats/nerdtree/commit/3bb112d916a3e78f2e6528b869cdad1f7d826114 --- plugin/NERD_tree.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 738ab9e5..74627356 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -66,6 +66,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) +call s:initVariable("g:NERDTreeStopInsert", 0) call s:initVariable("g:NERDTreeDirArrows", 0) if !exists("g:NERDTreeSortOrder") @@ -169,6 +170,12 @@ command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() augroup NERDTree "Save the cursor position whenever we close the nerd tree exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call saveScreenState()" + + if g:NERDTreeStopInsert + "disallow insert mode in the NERDTree + exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert" + endif + "cache bookmarks when vim loads autocmd VimEnter * call s:Bookmark.CacheBookmarks(0) From 077e330b64f68fa247b284c2c62c0b943cc18be8 Mon Sep 17 00:00:00 2001 From: Matt Gauger Date: Thu, 25 Aug 2011 13:39:02 -0500 Subject: [PATCH 005/680] Spelling --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 738ab9e5..a23116d5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -561,7 +561,7 @@ function! s:MenuController._echoPrompt() endfunction "FUNCTION: MenuController._current(key) {{{3 -"get the MenuItem that is curently selected +"get the MenuItem that is currently selected function! s:MenuController._current() return self.menuItems[self.selection] endfunction From 12f692f4369526f408e724fa74a0da527ebe2f2f Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 30 Aug 2011 12:03:49 +0100 Subject: [PATCH 006/680] always disallow insert mode Remove the NERDTreeStopInsert option and always activate the functionality. If, later on, it becomes apparent that some people might not want this functionality then we can re-add the option, but in the meantime, simplify things by removing the option. --- plugin/NERD_tree.vim | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 74627356..2f783575 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -66,7 +66,6 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -call s:initVariable("g:NERDTreeStopInsert", 0) call s:initVariable("g:NERDTreeDirArrows", 0) if !exists("g:NERDTreeSortOrder") @@ -171,10 +170,8 @@ augroup NERDTree "Save the cursor position whenever we close the nerd tree exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call saveScreenState()" - if g:NERDTreeStopInsert - "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert" - endif + "disallow insert mode in the NERDTree + exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert" "cache bookmarks when vim loads autocmd VimEnter * call s:Bookmark.CacheBookmarks(0) From 1c568a49161f53aab9a715a0331bad8ea705b9a9 Mon Sep 17 00:00:00 2001 From: Scott Stevenson Date: Wed, 31 Aug 2011 12:33:59 +0100 Subject: [PATCH 007/680] Add nolist to buffer options. --- plugin/NERD_tree.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2f783575..03571d46 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2,7 +2,7 @@ " File: NERD_tree.vim " Description: vim global plugin that provides a nice tree explorer " Maintainer: Martin Grenfell -" Last Change: 1 December, 2009 +" Last Change: 31 August, 2011 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -2666,6 +2666,7 @@ function! s:initNerdTreeInPlace(dir) setlocal foldcolumn=0 setlocal nobuflisted setlocal nospell + setlocal nolist if g:NERDTreeShowLineNumbers setlocal nu else From 796a40b5d770331056f1207bde733659b36b8a0c Mon Sep 17 00:00:00 2001 From: Anderson Freitas Date: Tue, 6 Sep 2011 21:01:57 -0300 Subject: [PATCH 008/680] New options in the file system menu: - Reveal In Finder - Open with system editor - Quicklook Current only when using MacVim under MacOSX --- nerdtree_plugin/fs_menu.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e3a1265b..0e2f7287 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -18,6 +18,13 @@ let g:loaded_nerdtree_fs_menu = 1 call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) + +if has("gui_mac") || has("gui_macvim") + call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) + call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif @@ -193,4 +200,25 @@ function! NERDTreeCopyNode() redraw endfunction +function! NERDTreeQuickLook() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + endif +endfunction + +function! NERDTreeRevealInFinder() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let x = system("open -R '" . treenode.path.str() . "'") + endif +endfunction + +function! NERDTreeExecuteFile() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let x = system("open '" . treenode.path.str() . "'") + endif +endfunction + " vim: set sw=4 sts=4 et fdm=marker: From 49b88757b019143ec6604b35c399de8f9bd2d954 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 15 Dec 2011 17:35:18 +0000 Subject: [PATCH 009/680] enable NERDTreeDirArrows by default except on windows --- plugin/NERD_tree.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 94e930e8..a52045ec 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -27,6 +27,8 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpo set cpo&vim +let s:running_windows = has("win16") || has("win32") || has("win64") + "Function: s:initVariable() function {{{2 "This function is used to initialise a given variable to a given value. The "variable is only initialised if it does not exist prior @@ -66,7 +68,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -call s:initVariable("g:NERDTreeDirArrows", 0) +call s:initVariable("g:NERDTreeDirArrows", !s:running_windows) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] @@ -92,8 +94,6 @@ endif call s:initVariable("g:NERDTreeWinPos", "left") call s:initVariable("g:NERDTreeWinSize", 31) -let s:running_windows = has("win16") || has("win32") || has("win64") - "init the shell commands that will be used to copy nodes, and remove dir trees " "Note: the space after the command is important From af833e3006622705ec669355747b7c241691981a Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 21 Dec 2011 12:51:32 +0000 Subject: [PATCH 010/680] remove the now unused s:setupSyntaxHighlighting() --- plugin/NERD_tree.vim | 99 -------------------------------------------- 1 file changed, 99 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index e411ab2a..065ecf3a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2693,10 +2693,6 @@ function! s:initNerdTreeInPlace(dir) call s:bindMappings() setfiletype nerdtree - " syntax highlighting - "if has("syntax") && exists("g:syntax_on") - "call s:setupSyntaxHighlighting() - "endif call s:renderView() endfunction @@ -2924,10 +2920,6 @@ function! s:createTreeWin() call s:bindMappings() setfiletype nerdtree - " syntax highlighting - "if has("syntax") && exists("g:syntax_on") - "call s:setupSyntaxHighlighting() - "endif endfunction "FUNCTION: s:dumpHelp {{{2 @@ -3412,97 +3404,6 @@ function! s:setupStatusline() let &l:statusline = g:NERDTreeStatusline endif endfunction -"FUNCTION: s:setupSyntaxHighlighting() {{{2 -"function! s:setupSyntaxHighlighting() - ""NERDTreeFlags are syntax items that should be invisible, but give clues as to - ""how things should be highlighted - "syn match NERDTreeFlag #\~# - "syn match NERDTreeFlag #\[RO\]# - - ""highlighting for the .. (up dir) line at the top of the tree - "execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" - - ""highlighting for the ~/+ symbols for the directory nodes - "syn match NERDTreeClosable #\~\<# - "syn match NERDTreeClosable #\~\.# - "syn match NERDTreeOpenable #+\<# - "syn match NERDTreeOpenable #+\.#he=e-1 - - ""highlighting for the tree structural parts - "syn match NERDTreePart #|# - "syn match NERDTreePart #`# - "syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart - - ""quickhelp syntax elements - "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 - "syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 - "syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag - "syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey - "syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey - "syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 - "syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand - - ""highlighting for readonly files - "syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile - - ""highlighting for sym links - "syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash - - ""highlighing for directory nodes and file nodes - "syn match NERDTreeDirSlash #/# - "syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable - "syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark - "syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - "syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - "syn match NERDTreeCWD #^[# - "syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader - "syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader - "syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader - - "if g:NERDChristmasTree - "hi def link NERDTreePart Special - "hi def link NERDTreePartFile Type - "hi def link NERDTreeFile Normal - "hi def link NERDTreeExecFile Title - "hi def link NERDTreeDirSlash Identifier - "hi def link NERDTreeClosable Type - "else - "hi def link NERDTreePart Normal - "hi def link NERDTreePartFile Normal - "hi def link NERDTreeFile Normal - "hi def link NERDTreeClosable Title - "endif - - "hi def link NERDTreeBookmarksHeader statement - "hi def link NERDTreeBookmarksLeader ignore - "hi def link NERDTreeBookmarkName Identifier - "hi def link NERDTreeBookmark normal - - "hi def link NERDTreeHelp String - "hi def link NERDTreeHelpKey Identifier - "hi def link NERDTreeHelpCommand Identifier - "hi def link NERDTreeHelpTitle Macro - "hi def link NERDTreeToggleOn Question - "hi def link NERDTreeToggleOff WarningMsg - - "hi def link NERDTreeDir Directory - "hi def link NERDTreeUp Directory - "hi def link NERDTreeCWD Statement - "hi def link NERDTreeLink Macro - "hi def link NERDTreeOpenable Title - "hi def link NERDTreeFlag ignore - "hi def link NERDTreeRO WarningMsg - "hi def link NERDTreeBookmark Statement - - "hi def link NERDTreeCurrentNode Search -"endfunction - "FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2 "returns the given line with all the tree parts stripped off " From dcccd0e532c44196195e352ae43745f47c8615d4 Mon Sep 17 00:00:00 2001 From: Min-Young Wu Date: Thu, 15 Dec 2011 15:14:31 -0800 Subject: [PATCH 011/680] Defaulting bookmark name to file/dir name Note that for directories, there is a trailing slash --- doc/NERD_tree.txt | 2 ++ plugin/NERD_tree.vim | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index cc5796a2..3fa91f25 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -155,6 +155,8 @@ Note that the following commands are only available in the NERD tree buffer. :Bookmark Bookmark the current node as . If there is already a bookmark, it is overwritten. must not contain spaces. + If is not provided, it defaults to the file or directory name. + For directories, a trailing slash is present. :BookmarkToRoot Make the directory corresponding to the new root. If a treenode diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 065ecf3a..fbaee5e3 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3546,7 +3546,7 @@ function! s:bindMappings() "bind all the user custom maps call s:KeyMap.BindAll() - command! -buffer -nargs=1 Bookmark :call bookmarkNode('') + command! -buffer -nargs=? Bookmark :call bookmarkNode('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') @@ -3558,11 +3558,15 @@ endfunction " FUNCTION: s:bookmarkNode(name) {{{2 " Associate the current node with the given name -function! s:bookmarkNode(name) +function! s:bookmarkNode(...) let currentNode = s:TreeFileNode.GetSelected() if currentNode != {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(1) + endif try - call currentNode.bookmark(a:name) + call currentNode.bookmark(name) call s:renderView() catch /^NERDTree.IllegalBookmarkNameError/ call s:echo("bookmark names must not contain spaces") From b528910e7a62f12ead1c345a2759da41edc84ddb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 21 Dec 2011 13:19:49 +0000 Subject: [PATCH 012/680] dont add a trailing slash to auto-named bookmarked dirs this breaks the highlighting of the nerdtree buffer, and seems dodgy --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fbaee5e3..27b80648 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3563,7 +3563,7 @@ function! s:bookmarkNode(...) if currentNode != {} let name = a:1 if empty(name) - let name = currentNode.path.getLastPathComponent(1) + let name = currentNode.path.getLastPathComponent(0) endif try call currentNode.bookmark(name) From 23d1746bbf309dc6b7dc964771af396d07b3a477 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 21 Dec 2011 14:43:20 +0000 Subject: [PATCH 013/680] refactor tree window creation to remove duplication create s:setCommonBufOptions() with the previously duplicated parts of s:initNerdTreeInPlace() and s:createTreeWin() --- plugin/NERD_tree.vim | 101 +++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 62 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 830ee85b..cabbc1d2 100644 --- 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 - - 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 - - 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 + + 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 From 01f683c3c40d00a5b6874634277ee062839869da Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Wed, 21 Dec 2011 11:55:04 -0500 Subject: [PATCH 014/680] stayInCurrentTab fix --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index cabbc1d2..768d2c49 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -399,7 +399,7 @@ function! s:Bookmark.openInNewTab(options) exec "tabedit " . self.path.str({'format': 'Edit'}) endif - if has_key(a:options, 'stayInCurrentTab') + if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] exec "tabnext " . currentTab endif endfunction From 0747198ee307942ba4dc365ef31cb8be96dfdf53 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 24 Dec 2011 10:58:45 +0000 Subject: [PATCH 015/680] remove Rakefile - pathogen is now the recommended way to install --- Rakefile | 75 -------------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 Rakefile diff --git a/Rakefile b/Rakefile deleted file mode 100644 index f6c72b81..00000000 --- a/Rakefile +++ /dev/null @@ -1,75 +0,0 @@ -# written by travis jeffery -# contributions by scrooloose - -require 'rake' -require 'find' -require 'pathname' - -IGNORE = [/\.gitignore$/, /Rakefile$/] - -files = `git ls-files`.split("\n") -files.reject! { |f| IGNORE.any? { |re| f.match(re) } } - -desc 'Zip up the project files' -task :zip do - zip_name = File.basename(File.dirname(__FILE__)) - zip_name.gsub!(/ /, '_') - zip_name = "#{zip_name}.zip" - - if File.exist?(zip_name) - abort("Zip file #{zip_name} already exists. Remove it first.") - end - - puts "Creating zip file: #{zip_name}" - system("zip #{zip_name} #{files.join(" ")}") -end - -desc 'Install plugin and documentation' -task :install do - vimfiles = if ENV['VIMFILES'] - ENV['VIMFILES'] - elsif RUBY_PLATFORM =~ /(win|w)32$/ - File.expand_path("~/vimfiles") - else - File.expand_path("~/.vim") - end - files.each do |file| - target_file = File.join(vimfiles, file) - FileUtils.mkdir_p File.dirname(target_file) - FileUtils.cp file, target_file - - puts "Installed #{file} to #{target_file}" - end - -end - -desc 'Pulls from origin' -task :pull do - puts "Updating local repo..." - system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull") -end - -desc 'Calls pull task and then install task' -task :update => ['pull', 'install'] do - puts "Update of vim script complete." -end - -desc 'Uninstall plugin and documentation' -task :uninstall do - vimfiles = if ENV['VIMFILES'] - ENV['VIMFILES'] - elsif RUBY_PLATFORM =~ /(win|w)32$/ - File.expand_path("~/vimfiles") - else - File.expand_path("~/.vim") - end - files.each do |file| - target_file = File.join(vimfiles, file) - FileUtils.rm target_file - - puts "Uninstalled #{target_file}" - end - -end - -task :default => ['update'] From 1b4dfc87453361220c373c159832b0787bf4789a Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 24 Dec 2011 10:58:57 +0000 Subject: [PATCH 016/680] add first version of readme --- README.markdown | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 README.markdown diff --git a/README.markdown b/README.markdown new file mode 100644 index 00000000..930b1ba7 --- /dev/null +++ b/README.markdown @@ -0,0 +1,73 @@ +The NERD Tree +============= + +Intro +----- + +The NERD tree allows you to explore your filesystem and to open files and +directories. It presents the filesystem to you in the form of a tree which you +manipulate with the keyboard and/or mouse. It also allows you to perform +simple filesystem operations. + +The following features and functionality are provided by the NERD tree: + + * Files and directories are displayed in a hierarchical tree structure + * Different highlighting is provided for the following types of nodes: + * files + * directories + * sym-links + * windows .lnk files + * read-only files + * executable files + * Many (customisable) mappings are provided to manipulate the tree: + * Mappings to open/close/explore directory nodes + * Mappings to open files in new/existing windows/tabs + * Mappings to change the current root of the tree + * Mappings to navigate around the tree + * ... + * Directories and files can be bookmarked. + * Most NERD tree navigation can also be done with the mouse + * Filtering of tree content (can be toggled at runtime) + * custom file filters to prevent e.g. vim backup files being displayed + * optional displaying of hidden files (. files) + * files can be "turned off" so that only directories are displayed + * The position and size of the NERD tree window can be customised + * The order in which the nodes in the tree are listed can be customised. + * A model of your filesystem is created/maintained as you explore it. This + has several advantages: + * All filesystem information is cached and is only re-read on demand + * If you revisit a part of the tree that you left earlier in your + session, the directory nodes will be opened/closed as you left them + * The script remembers the cursor position and window position in the NERD + tree so you can toggle it off (or just close the tree window) and then + reopen it (with NERDTreeToggle) the NERD tree window will appear exactly + as you left it + * You can have a separate NERD tree for each tab, share trees across tabs, + or a mix of both. + * By default the script overrides the default file browser (netw), so if + you :edit a directory a (slighly modified) NERD tree will appear in the + current window + * A programmable menu system is provided (simulates right clicking on a node) + * one default menu plugin is provided to perform basic filesytem + operations (create/delete/move/copy files/directories) + * There's an API for adding your own keymappings + +Installation +------------ + +[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree. + + cd ~/.vim/bundle + git clone https://github.com/scrooloose/nerdtree.git + +Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`. + + +Faq +--- + +Q. Can I have the nerdtree on every tab automatically? +A. Nope. If this is something you want then chances are you aren't using tabs + and buffers as they were intended to be used. Read this + http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers + From 4dd1bc9ef648f4019e0fd9ebb62cd03052e713a7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 27 Dec 2011 21:52:43 +0000 Subject: [PATCH 017/680] make a minor formatting fix for the readme --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index 930b1ba7..1f49814e 100644 --- a/README.markdown +++ b/README.markdown @@ -67,6 +67,7 @@ Faq --- Q. Can I have the nerdtree on every tab automatically? + A. Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers From b3b394c3290665c837670c3e2a0f73a14b8e0ad6 Mon Sep 17 00:00:00 2001 From: Benjamin Geiger Date: Wed, 15 Jun 2011 17:26:21 -0400 Subject: [PATCH 018/680] Open NERDTreeFind tree at CWD if current file is below it. --- plugin/NERD_tree.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index cabbc1d2..b0b76414 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2562,7 +2562,18 @@ function! s:findAndRevealPath() endtry if !s:treeExistsForTab() - call s:initNerdTree(p.getParent().str()) + try + let cwd = s:Path.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call s:echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call s:initNerdTree(cwd.str()) + else + call s:initNerdTree(p.getParent().str()) + endif else if !p.isUnder(s:TreeFileNode.GetRootForTab().path) call s:initNerdTree(p.getParent().str()) From 7ff9def95b4784258dbd1589dd62ff0712974e59 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 27 Dec 2011 22:18:14 +0000 Subject: [PATCH 019/680] fix mixed indenting --- plugin/NERD_tree.vim | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b0b76414..2fc73c4e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2562,18 +2562,18 @@ function! s:findAndRevealPath() endtry if !s:treeExistsForTab() - try - let cwd = s:Path.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("current directory does not exist.") - let cwd = p.getParent() - endtry - - if p.isUnder(cwd) - call s:initNerdTree(cwd.str()) - else + try + let cwd = s:Path.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call s:echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call s:initNerdTree(cwd.str()) + else call s:initNerdTree(p.getParent().str()) - endif + endif else if !p.isUnder(s:TreeFileNode.GetRootForTab().path) call s:initNerdTree(p.getParent().str()) From 4411344f7c18e2c4d7c1b1be6c3e7c6f1e19a262 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 27 Dec 2011 22:22:10 +0000 Subject: [PATCH 020/680] update the doc for the new NERDTreeFind behaviour --- doc/NERD_tree.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 3fa91f25..ae66f3ff 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -129,9 +129,13 @@ The following features and functionality are provided by the NERD tree: Close the NERD tree in this tab. :NERDTreeFind *:NERDTreeFind* - Find the current file in the tree. If no tree exists for the current tab, - or the file is not under the current root, then initialize a new tree where - the root is the directory of the current file. + Find the current file in the tree. + + If not tree exists and the current file is under vim's CWD, then init a + tree at the CWD and reveal the file. Otherwise init a tree in the current + file's directory. + + In any case, the current file is revealed and the cursor is placed on it. ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* From 4bd0def6fb642e428a887ef83f11a8a267209004 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 27 Dec 2011 22:53:38 +0000 Subject: [PATCH 021/680] add a note about vim-nerdtree-tabs to the readme --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 1f49814e..9878756f 100644 --- a/README.markdown +++ b/README.markdown @@ -72,3 +72,5 @@ A. Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers + If you are interested in this behavour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + From 205367ab3f46dcc88b6ebb819a276e793a21e995 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 28 Dec 2011 13:16:57 +0000 Subject: [PATCH 022/680] update changelog/credits and bump to version 4.2.0 --- README.markdown | 13 +++++++++++++ doc/NERD_tree.txt | 33 +++++++++++++++++++++++++++++++-- plugin/NERD_tree.vim | 4 ++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 9878756f..a68dc020 100644 --- a/README.markdown +++ b/README.markdown @@ -74,3 +74,16 @@ A. Nope. If this is something you want then chances are you aren't using tabs If you are interested in this behavour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) +Changelog +--------- + +4.2.0 (2011-12-28) + + * Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) + * shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) + * Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson) + * tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) + * if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) + * use 'file' completion when doing copying, create, and move operations (EvanDotPro) + * lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) + diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index ae66f3ff..174229d9 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1116,8 +1116,22 @@ The latest dev versions are on github ============================================================================== 6. Changelog *NERDTreeChangelog* -4.x.x - - Fix a bug with :NERDTreeFind and symlinks. Thanks to Vitaly Bogdanov. +4.2.0 + - Add NERDTreeDirArrows option to make the UI use pretty arrow chars + instead of the old +~| chars to define the tree structure (sickill) + - shift the syntax highlighting out into its own syntax file (gnap) + - add some mac specific options to the filesystem menu - for macvim + only (andersonfreitas) + - Add NERDTreeMinimalUI option to remove some non functional parts of the + nerdtree ui (camthompson) + - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the + new behaviour (benjamingeiger) + - if no name is given to :Bookmark, make it default to the name of the + target file/dir (minyoung) + - use 'file' completion when doing copying, create, and move + operations (EvanDotPro) + - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly + Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) 4.1.0 features: @@ -1254,6 +1268,21 @@ just downloaded pr0n instead. jfilip1024 Chris Chambers Vitaly Bogdanov + Patrick O'Loughlin (paddyoloughlin) + Cam Thompson (camthompson) + Marcin Kulik (sickill) + Steve DeWald (sdewald) + Ivan Necas (iNecas) + George Ang (gnap) + Evan Coury (EvanDotPro) + Andrew Radev (AndrewRadev) + Matt Gauger (mathias) + Scott Stevenson (scottstvnsn) + Anderson Freitas (andersonfreitas) + Kamil K. Lemański (kml) + Yehuda Katz (wycats) + Min-Young Wu (minyoung) + Benjamin Geiger (benjamingeiger) ============================================================================== 8. License *NERDTreeLicense* diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2fc73c4e..bc347756 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2,7 +2,7 @@ " File: NERD_tree.vim " Description: vim global plugin that provides a nice tree explorer " Maintainer: Martin Grenfell -" Last Change: 31 August, 2011 +" Last Change: 28 December, 2011 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -10,7 +10,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -let s:NERD_tree_version = '4.1.0' +let s:NERD_tree_version = '4.2.0' " SECTION: Script init stuff {{{1 "============================================================ From b5fd460560ca8fa3762f26aa6f57477623dac2d6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 29 Dec 2011 00:17:14 +0000 Subject: [PATCH 023/680] rework the keymap API Add "scope" to it. This allows the user to specify that keymaps should apply to files/directories/bookmarks or everything. This will reduce the amount of 'if empty(node)' checks that are done --- plugin/NERD_tree.vim | 106 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index bc347756..ffcbd0a7 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -485,10 +485,21 @@ let s:KeyMap = {} function! s:KeyMap.All() if !exists("s:keyMaps") let s:keyMaps = [] + let g:keyMaps = s:keyMaps endif return s:keyMaps endfunction +"FUNCTION: KeyMap.FindFor(key, scope) {{{3 +function! s:KeyMap.FindFor(key, scope) + for i in s:KeyMap.All() + if i.key == a:key && i.scope == a:scope + return i + endif + endfor + return {} +endfunction + "FUNCTION: KeyMap.BindAll() {{{3 function! s:KeyMap.BindAll() for i in s:KeyMap.All() @@ -498,17 +509,102 @@ endfunction "FUNCTION: KeyMap.bind() {{{3 function! s:KeyMap.bind() - exec "nnoremap ". self.key ." :call ". self.callback ."()" + exec "nnoremap ". self.key ." :call KeyMap_Invoke('". self.key ."')" +endfunction + +"FUNCTION: KeyMap.bind() {{{3 +"Call the KeyMaps callback function +function! s:KeyMap.invoke(...) + if a:0 + call function(self.callback)(a:1) + else + call function(self.callback)() + endif +endfunction + + +"FUNCTION: KeyMap.Invoke() {{{3 +"Find a keymapping for a:key and the current scope invoke it. +" +"Scope is determined as follows: +" * if the cursor is on a dir node then "DirNode" +" * if the cursor is on a file node then "FileNode" +" * if the cursor is on a bookmark then "Bookmark" +" +"If a keymap has the scope of "all" then it will be called if no other keymap +"is found for a:key and the scope. +function! s:KeyMap.Invoke(key) + let node = s:TreeFileNode.GetSelected() + if !empty(node) + + "try file node + if !node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "FileNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try dir node + if node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "DirNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try generic node + let km = s:KeyMap.FindFor(a:key, "Node") + if !empty(km) + return km.invoke(node) + endif + + endif + + "try bookmark + let bm = s:Bookmark.GetSelected() + if !empty(bm) + let km = s:KeyMap.FindFor(a:key, "Bookmark") + if !empty(km) + return km.invoke(bm) + endif + endif + + "try all + let km = s:KeyMap.FindFor(a:key, "all") + if !empty(km) + return km.invoke() + endif +endfunction + +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! s:KeyMap_Invoke(key) + call s:KeyMap.Invoke(a:key) endfunction "FUNCTION: KeyMap.Create(options) {{{3 function! s:KeyMap.Create(options) let newKeyMap = copy(self) - let newKeyMap.key = a:options['key'] - let newKeyMap.quickhelpText = a:options['quickhelpText'] - let newKeyMap.callback = a:options['callback'] - call add(s:KeyMap.All(), newKeyMap) + let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) + let newKeyMap.key = opts['key'] + let newKeyMap.quickhelpText = opts['quickhelpText'] + let newKeyMap.callback = opts['callback'] + let newKeyMap.scope = opts['scope'] + + call s:KeyMap.Add(newKeyMap) endfunction + +"FUNCTION: KeyMap.Add(keymap) {{{3 +function! s:KeyMap.Add(keymap) + let oldmap = s:KeyMap.FindFor(a:keymap.key, a:keymap.scope) + if !empty(oldmap) + call remove(s:KeyMap.All(), index(s:KeyMap.All(), oldmap)) + endif + + call add(s:KeyMap.All(), a:keymap) +endfunction + "CLASS: MenuController {{{2 "============================================================ let s:MenuController = {} From a1d528ae926371db99021f88f1f7a65471fa4b7a Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 10:31:34 +0000 Subject: [PATCH 024/680] make the standard mappings use the key api --- plugin/NERD_tree.vim | 508 +++++++++++++++++++++---------------------- 1 file changed, 248 insertions(+), 260 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ffcbd0a7..18766763 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -116,9 +116,9 @@ call s:initVariable("g:NERDTreeMapMenu", "m") call s:initVariable("g:NERDTreeMapHelp", "?") call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") call s:initVariable("g:NERDTreeMapJumpLastChild", "J") -call s:initVariable("g:NERDTreeMapJumpNextSibling", "") +call s:initVariable("g:NERDTreeMapJumpNextSibling", "C-j") call s:initVariable("g:NERDTreeMapJumpParent", "p") -call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") +call s:initVariable("g:NERDTreeMapJumpPrevSibling", "C-k") call s:initVariable("g:NERDTreeMapJumpRoot", "P") call s:initVariable("g:NERDTreeMapOpenExpl", "e") call s:initVariable("g:NERDTreeMapOpenInTab", "t") @@ -509,10 +509,15 @@ endfunction "FUNCTION: KeyMap.bind() {{{3 function! s:KeyMap.bind() - exec "nnoremap ". self.key ." :call KeyMap_Invoke('". self.key ."')" + let mapkey = self.key + if mapkey =~ '^[CM]-' + let mapkey = '<' . mapkey . '>' + endif + + exec 'nnoremap '. mapkey .' :call KeyMap_Invoke("'. self.key .'")' endfunction -"FUNCTION: KeyMap.bind() {{{3 +"FUNCTION: KeyMap.invoke() {{{3 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) if a:0 @@ -2857,6 +2862,48 @@ endfunction function! s:treeExistsForTab() return exists("t:NERDTreeBufName") endfunction +" Function: s:SID() {{{2 +function s:SID() + if !exists("s:sid") + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun +"FUNCTION: s:upDir(keepState) {{{2 +"moves the tree up a level +" +"Args: +"keepState: 1 if the current root should be left open when the tree is +"re-rendered +function! s:upDir(keepState) + let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) + if cwd ==# "/" || cwd =~# '^[^/]..$' + call s:echo("already at top dir") + else + if !a:keepState + call b:NERDTreeRoot.close() + endif + + let oldRoot = b:NERDTreeRoot + + if empty(b:NERDTreeRoot.parent) + let path = b:NERDTreeRoot.path.getParent() + let newRoot = s:TreeDirNode.New(path) + call newRoot.open() + call newRoot.transplantChild(b:NERDTreeRoot) + let b:NERDTreeRoot = newRoot + else + let b:NERDTreeRoot = b:NERDTreeRoot.parent + endif + + if g:NERDTreeChDirMode ==# 2 + call b:NERDTreeRoot.path.changeToDir() + endif + + call s:renderView() + call oldRoot.putCursorHere(0, 0) + endif +endfunction " Function: s:unique(list) {{{2 " returns a:list without duplicates function! s:unique(list) @@ -3244,13 +3291,11 @@ endfunction " FUNCTION: s:jumpToChild(direction) {{{2 " Args: " direction: 0 if going to first child, 1 if going to last -function! s:jumpToChild(direction) - let currentNode = s:TreeFileNode.GetSelected() - if currentNode ==# {} || currentNode.isRoot() - call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - return +function! s:jumpToChild(currentNode, direction) + if a:currentNode.isRoot() + return s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child") end - let dirNode = currentNode.parent + let dirNode = a:currentNode.parent let childNodes = dirNode.getVisibleChildren() let targetNode = childNodes[0] @@ -3258,8 +3303,8 @@ function! s:jumpToChild(direction) let targetNode = childNodes[len(childNodes) - 1] endif - if targetNode.equals(currentNode) - let siblingDir = currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) + if targetNode.equals(a:currentNode) + let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) if siblingDir != {} let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 let targetNode = siblingDir.getChildByIndex(indx, 1) @@ -3272,6 +3317,50 @@ function! s:jumpToChild(direction) endfunction +" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2 +" moves the cursor to the sibling of the current node in the given direction +" +" Args: +" forward: 1 if the cursor should move to the next sibling, 0 if it should +" move back to the previous sibling +function! s:jumpToSibling(currentNode, forward) + let sibling = a:currentNode.findSibling(a:forward) + + if !empty(sibling) + call sibling.putCursorHere(1, 0) + call s:centerView() + endif +endfunction + + + +" FUNCTION: s:openEntrySplit(vertical, forceKeepWindowOpen) {{{2 +function! s:openEntrySplit(vertical, forceKeepWindowOpen) + let treenode = s:TreeFileNode.GetSelected() + if treenode != {} + if a:vertical + call treenode.openVSplit() + else + call treenode.openSplit() + endif + if !a:forceKeepWindowOpen + call s:closeTreeIfQuitOnOpen() + endif + else + call s:echo("select a node first") + endif +endfunction + +"FUNCTION: s:previewNode(node, openNewWin) {{{2 +function! s:previewNode(node, openNewWin) + let currentBuf = bufnr("") + if a:openNewWin > 0 + call s:openEntrySplit(a:openNewWin ==# 2,1) + else + call s:activateNode(a:node) + end + call s:exec(bufwinnr(currentBuf) . "wincmd w") +endfunction "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2 "prints out the given msg and, if the user responds by pushing 'y' then the "buffer with the given bufnum is deleted @@ -3550,26 +3639,25 @@ function! s:toggle(dir) endfunction "SECTION: Interface bindings {{{1 "============================================================ -"FUNCTION: s:activateNode(forceKeepWindowOpen) {{{2 -"If the current node is a file, open it in the previous window (or a new one -"if the previous is modified). If it is a directory then it is opened. -" -"args: -"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set -function! s:activateNode(forceKeepWindowOpen) + +"FUNCTION: s:activateAll() {{{2 +"handle the user activating the updir line +function! s:activateAll() if getline(".") ==# s:tree_up_dir_line return s:upDir(0) endif +endfunction - let treenode = s:TreeFileNode.GetSelected() - if treenode != {} - call treenode.activate(a:forceKeepWindowOpen) - else - let bookmark = s:Bookmark.GetSelected() - if !empty(bookmark) - call bookmark.activate() - endif - endif +"FUNCTION: s:activateNode() {{{2 +"handle the user activating a tree node +function! s:activateNode(node) + call a:node.activate(0) +endfunction + +"FUNCTION: s:activateBookmark() {{{2 +"handle the user activating a bookmark +function! s:activateBookmark(bm) + call a:bm.activate(0) endfunction "FUNCTION: s:bindMappings() {{{2 @@ -3579,54 +3667,60 @@ function! s:bindMappings() nnoremap :call checkForActivate() nnoremap <2-leftmouse> :call activateNode(0) - exec "nnoremap ". g:NERDTreeMapActivateNode . " :call activateNode(0)" - exec "nnoremap ". g:NERDTreeMapOpenSplit ." :call openEntrySplit(0,0)" - exec "nnoremap :call activateNode(0)" + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Node", 'callback': s."activateNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" - exec "nnoremap ". g:NERDTreeMapPreview ." :call previewNode(0)" - exec "nnoremap ". g:NERDTreeMapPreviewSplit ." :call previewNode(1)" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) - exec "nnoremap ". g:NERDTreeMapOpenVSplit ." :call openEntrySplit(1,0)" - exec "nnoremap ". g:NERDTreeMapPreviewVSplit ." :call previewNode(2)" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) - exec "nnoremap ". g:NERDTreeMapOpenRecursively ." :call openNodeRecursively()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) - exec "nnoremap ". g:NERDTreeMapUpdirKeepOpen ." :call upDir(1)" - exec "nnoremap ". g:NERDTreeMapUpdir ." :call upDir(0)" - exec "nnoremap ". g:NERDTreeMapChangeRoot ." :call chRoot()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) - exec "nnoremap ". g:NERDTreeMapChdir ." :call chCwd()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) - exec "nnoremap ". g:NERDTreeMapQuit ." :call closeTreeWindow()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) - exec "nnoremap ". g:NERDTreeMapRefreshRoot ." :call refreshRoot()" - exec "nnoremap ". g:NERDTreeMapRefresh ." :call refreshCurrent()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) - exec "nnoremap ". g:NERDTreeMapHelp ." :call displayHelp()" - exec "nnoremap ". g:NERDTreeMapToggleZoom ." :call toggleZoom()" - exec "nnoremap ". g:NERDTreeMapToggleHidden ." :call toggleShowHidden()" - exec "nnoremap ". g:NERDTreeMapToggleFilters ." :call toggleIgnoreFilter()" - exec "nnoremap ". g:NERDTreeMapToggleFiles ." :call toggleShowFiles()" - exec "nnoremap ". g:NERDTreeMapToggleBookmarks ." :call toggleShowBookmarks()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) - exec "nnoremap ". g:NERDTreeMapCloseDir ." :call closeCurrentDir()" - exec "nnoremap ". g:NERDTreeMapCloseChildren ." :call closeChildren()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) - exec "nnoremap ". g:NERDTreeMapMenu ." :call showMenu()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) - exec "nnoremap ". g:NERDTreeMapJumpParent ." :call jumpToParent()" - exec "nnoremap ". g:NERDTreeMapJumpNextSibling ." :call jumpToSibling(1)" - exec "nnoremap ". g:NERDTreeMapJumpPrevSibling ." :call jumpToSibling(0)" - exec "nnoremap ". g:NERDTreeMapJumpFirstChild ." :call jumpToFirstChild()" - exec "nnoremap ". g:NERDTreeMapJumpLastChild ." :call jumpToLastChild()" - exec "nnoremap ". g:NERDTreeMapJumpRoot ." :call jumpToRoot()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) - exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call openInNewTab(0)" - exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call openInNewTab(1)" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) - exec "nnoremap ". g:NERDTreeMapOpenExpl ." :call openExplorer()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) - exec "nnoremap ". g:NERDTreeMapDeleteBookmark ." :call deleteBookmark()" + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) "bind all the user custom maps call s:KeyMap.BindAll() @@ -3661,9 +3755,7 @@ function! s:bookmarkNode(...) endif endfunction "FUNCTION: s:checkForActivate() {{{2 -"Checks if the click should open the current node, if so then activate() is -"called (directories are automatically opened if the symbol beside them is -"clicked) +"Checks if the click should open the current node function! s:checkForActivate() let currentNode = s:TreeFileNode.GetSelected() if currentNode != {} @@ -3686,31 +3778,19 @@ function! s:checkForActivate() endif endfunction -" FUNCTION: s:chCwd() {{{2 -function! s:chCwd() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - +" FUNCTION: s:chCwd(node) {{{2 +function! s:chCwd(node) try - call treenode.path.changeToDir() + call a:node.path.changeToDir() catch /^NERDTree.PathChangeError/ call s:echoWarning("could not change cwd") endtry endfunction -" FUNCTION: s:chRoot() {{{2 +" FUNCTION: s:chRoot(node) {{{2 " changes the current root to the selected one -function! s:chRoot() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - - call treenode.makeRoot() +function! s:chRoot(node) + call a:node.makeRoot() call s:renderView() call b:NERDTreeRoot.putCursorHere(0, 0) endfunction @@ -3730,35 +3810,23 @@ function! s:clearBookmarks(bookmarks) endif call s:renderView() endfunction -" FUNCTION: s:closeChildren() {{{2 +" FUNCTION: s:closeChildren(node) {{{2 " closes all childnodes of the current node -function! s:closeChildren() - let currentNode = s:TreeDirNode.GetSelected() - if currentNode ==# {} - call s:echo("Select a node first") - return - endif - - call currentNode.closeChildren() +function! s:closeChildren(node) + call a:node.closeChildren() call s:renderView() - call currentNode.putCursorHere(0, 0) + call a:node.putCursorHere(0, 0) endfunction -" FUNCTION: s:closeCurrentDir() {{{2 +" FUNCTION: s:closeCurrentDir(node) {{{2 " closes the parent dir of the current node -function! s:closeCurrentDir() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - - let parent = treenode.parent +function! s:closeCurrentDir(node) + let parent = a:node.parent if parent ==# {} || parent.isRoot() call s:echo("cannot close tree root") else - call treenode.parent.close() + call a:node.parent.close() call s:renderView() - call treenode.parent.putCursorHere(0, 0) + call a:node.parent.putCursorHere(0, 0) endif endfunction " FUNCTION: s:closeTreeWindow() {{{2 @@ -3774,20 +3842,14 @@ function! s:closeTreeWindow() endif endif endfunction -" FUNCTION: s:deleteBookmark() {{{2 +" FUNCTION: s:deleteBookmark(bm) {{{2 " if the cursor is on a bookmark, prompt to delete -function! s:deleteBookmark() - let bookmark = s:Bookmark.GetSelected() - if bookmark ==# {} - call s:echo("Put the cursor on a bookmark") - return - endif - - echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):" +function! s:deleteBookmark(bm) + echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" if nr2char(getchar()) ==# 'y' try - call bookmark.delete() + call a:bm.delete() call s:renderView() redraw catch /^NERDTree/ @@ -3825,29 +3887,24 @@ endfunction " FUNCTION: s:jumpToFirstChild() {{{2 " wrapper for the jump to child method -function! s:jumpToFirstChild() - call s:jumpToChild(0) +function! s:jumpToFirstChild(node) + call s:jumpToChild(a:node, 0) endfunction " FUNCTION: s:jumpToLastChild() {{{2 " wrapper for the jump to child method -function! s:jumpToLastChild() - call s:jumpToChild(1) +function! s:jumpToLastChild(node) + call s:jumpToChild(a:node, 1) endfunction -" FUNCTION: s:jumpToParent() {{{2 +" FUNCTION: s:jumpToParent(node) {{{2 " moves the cursor to the parent of the current node -function! s:jumpToParent() - let currentNode = s:TreeFileNode.GetSelected() - if !empty(currentNode) - if !empty(currentNode.parent) - call currentNode.parent.putCursorHere(1, 0) - call s:centerView() - else - call s:echo("cannot jump to parent") - endif +function! s:jumpToParent(node) + if !empty(a:node.parent) + call a:node.parent.putCursorHere(1, 0) + call s:centerView() else - call s:echo("put the cursor on a node first") + call s:echo("cannot jump to parent") endif endfunction @@ -3858,24 +3915,14 @@ function! s:jumpToRoot() call s:centerView() endfunction -" FUNCTION: s:jumpToSibling() {{{2 -" moves the cursor to the sibling of the current node in the given direction -" -" Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! s:jumpToSibling(forward) - let currentNode = s:TreeFileNode.GetSelected() - if !empty(currentNode) - let sibling = currentNode.findSibling(a:forward) +" FUNCTION: s:jumpToNextSibling(node) {{{2 +function! s:jumpToNextSibling(node) + call s:jumpToSibling(a:node, 1) +endfunction - if !empty(sibling) - call sibling.putCursorHere(1, 0) - call s:centerView() - endif - else - call s:echo("put the cursor on a node first") - endif +" FUNCTION: s:jumpToPrevSibling(node) {{{2 +function! s:jumpToPrevSibling(node) + call s:jumpToSibling(a:node, 0) endfunction " FUNCTION: s:openBookmark(name) {{{2 @@ -3896,83 +3943,57 @@ function! s:openBookmark(name) call targetNode.open() endif endfunction -" FUNCTION: s:openEntrySplit(vertical, forceKeepWindowOpen) {{{2 -"Opens the currently selected file from the explorer in a -"new window -" -"args: -"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set -function! s:openEntrySplit(vertical, forceKeepWindowOpen) - let treenode = s:TreeFileNode.GetSelected() - if treenode != {} - if a:vertical - call treenode.openVSplit() - else - call treenode.openSplit() - endif - if !a:forceKeepWindowOpen - call s:closeTreeIfQuitOnOpen() - endif - else - call s:echo("select a node first") - endif + +" FUNCTION: s:openHSplit(node) {{{2 +function! s:openHSplit(node) + call a:node.openSplit() endfunction -" FUNCTION: s:openExplorer() {{{2 -function! s:openExplorer() - let treenode = s:TreeDirNode.GetSelected() - if treenode != {} - call treenode.openExplorer() - else - call s:echo("select a node first") - endif +" FUNCTION: s:openVSplit(node) {{{2 +function! s:openVSplit(node) + call a:node.openVSplit() endfunction -" FUNCTION: s:openInNewTab(stayCurrentTab) {{{2 -" Opens the selected node or bookmark in a new tab -" Args: -" stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim -" will go to the tab where the new file is opened -function! s:openInNewTab(stayCurrentTab) - let target = s:TreeFileNode.GetSelected() - if target == {} - let target = s:Bookmark.GetSelected() - endif +" FUNCTION: s:openExplorer(node) {{{2 +function! s:openExplorer(node) + call a:node.openExplorer() +endfunction - if target != {} - call target.openInNewTab({'stayInCurrentTab': a:stayCurrentTab}) - endif +" FUNCTION: s:openInNewTab(target) {{{2 +function! s:openInNewTab(target) + call a:target.openInNewTab({}) endfunction -" FUNCTION: s:openNodeRecursively() {{{2 -function! s:openNodeRecursively() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} || treenode.path.isDirectory ==# 0 - call s:echo("Select a directory node first" ) - else - call s:echo("Recursively opening node. Please wait...") - call treenode.openRecursively() - call s:renderView() - redraw - call s:echo("Recursively opening node. Please wait... DONE") - endif +" FUNCTION: s:openInNewTabSilent(target) {{{2 +function! s:openInNewTabSilent(target) + call a:target.openInNewTab({'stayInCurrentTab': 1}) +endfunction +" FUNCTION: s:openNodeRecursively(node) {{{2 +function! s:openNodeRecursively(node) + call s:echo("Recursively opening node. Please wait...") + call a:node.openRecursively() + call s:renderView() + redraw + call s:echo("Recursively opening node. Please wait... DONE") endfunction -"FUNCTION: s:previewNode() {{{2 -"Args: -" openNewWin: if 0, use the previous window, if 1 open in new split, if 2 -" open in a vsplit -function! s:previewNode(openNewWin) - let currentBuf = bufnr("") - if a:openNewWin > 0 - call s:openEntrySplit(a:openNewWin ==# 2,1) - else - call s:activateNode(1) - end - call s:exec(bufwinnr(currentBuf) . "wincmd w") +"FUNCTION: s:previewNodeCurrent(node) {{{2 +function! s:previewNodeCurrent(node) + call s:previewNode(a:node, 0) +endfunction + +"FUNCTION: s:previewNodeHSplit(node) {{{2 +function! s:previewNodeHSplit(node) + call s:previewNode(a:node, 1) endfunction +"FUNCTION: s:previewNodeVSplit(node) {{{2 +function! s:previewNodeVSplit(node) + call s:previewNode(a:node, 2) +endfunction + + " FUNCTION: s:revealBookmark(name) {{{2 " put the cursor on the node associate with the given name function! s:revealBookmark(name) @@ -3994,29 +4015,22 @@ function! s:refreshRoot() call s:echo("Refreshing the root node. This could take a while... DONE") endfunction -" FUNCTION: s:refreshCurrent() {{{2 +" FUNCTION: s:refreshCurrent(node) {{{2 " refreshes the root for the current node -function! s:refreshCurrent() - let treenode = s:TreeDirNode.GetSelected() - if treenode ==# {} - call s:echo("Refresh failed. Select a node first") - return +function! s:refreshCurrent(node) + let node = a:node + if !node.path.isDirectory + let node = node.parent endif call s:echo("Refreshing node. This could take a while...") - call treenode.refresh() + call node.refresh() call s:renderView() redraw call s:echo("Refreshing node. This could take a while... DONE") endfunction -" FUNCTION: s:showMenu() {{{2 -function! s:showMenu() - let curNode = s:TreeFileNode.GetSelected() - if curNode ==# {} - call s:echo("Put the cursor on a node first" ) - return - endif - +" FUNCTION: s:showMenu(node) {{{2 +function! s:showMenu(node) let mc = s:MenuController.New(s:MenuItem.AllEnabled()) call mc.showMenu() endfunction @@ -4057,7 +4071,7 @@ function! s:toggleShowHidden() call s:centerView() endfunction -" FUNCTION: s:toggleZoom() {{2 +" FUNCTION: s:toggleZoom() {{{2 " zoom (maximize/minimize) the NERDTree window function! s:toggleZoom() if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed @@ -4070,40 +4084,14 @@ function! s:toggleZoom() endif endfunction -"FUNCTION: s:upDir(keepState) {{{2 -"moves the tree up a level -" -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! s:upDir(keepState) - let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) - if cwd ==# "/" || cwd =~# '^[^/]..$' - call s:echo("already at top dir") - else - if !a:keepState - call b:NERDTreeRoot.close() - endif - - let oldRoot = b:NERDTreeRoot - - if empty(b:NERDTreeRoot.parent) - let path = b:NERDTreeRoot.path.getParent() - let newRoot = s:TreeDirNode.New(path) - call newRoot.open() - call newRoot.transplantChild(b:NERDTreeRoot) - let b:NERDTreeRoot = newRoot - else - let b:NERDTreeRoot = b:NERDTreeRoot.parent - endif - - if g:NERDTreeChDirMode ==# 2 - call b:NERDTreeRoot.path.changeToDir() - endif +" FUNCTION: s:upDirCurrentRootOpen() {{{2 +function! s:upDirCurrentRootOpen() + call s:upDir(1) +endfunction - call s:renderView() - call oldRoot.putCursorHere(0, 0) - endif +" FUNCTION: s:upDirCurrentRootClosed() {{{2 +function! s:upDirCurrentRootClosed() + call s:upDir(0) endfunction From b0e2ed1cc7d4091699fb5d1dbd69364bc33eff38 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 15:33:37 +0000 Subject: [PATCH 025/680] remove a trivial piece of old debugging code --- plugin/NERD_tree.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 18766763..9597e46a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -485,7 +485,6 @@ let s:KeyMap = {} function! s:KeyMap.All() if !exists("s:keyMaps") let s:keyMaps = [] - let g:keyMaps = s:keyMaps endif return s:keyMaps endfunction From 73e2d8ca7ed0d3eb4fce2c3220b9ce0e64ce57fc Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 16:05:19 +0000 Subject: [PATCH 026/680] update the doc for the new key api functionality --- doc/NERD_tree.txt | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 174229d9..395aafab 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -991,22 +991,32 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* "quickhelpText" - the text that will appear in the quickhelp (see |NERDTree-?|) + Additionally, a "scope" argument may be supplied. This constrains the + mapping so that it is only activated if the cursor is on a certain object. + That object is then passed into the handling method. Possible values are: + "FileNode" - a file node + "DirNode" - a directory node + "Node" - a file or directory node + "Bookmark" - A bookmark + "all" - the keymap is not constrained to any scope (default). When + thei is used, the handling function is not passed any arguments. + + Example: > call NERDTreeAddKeyMap({ - \ 'key': 'b', - \ 'callback': 'NERDTreeEchoCurrentNode', + \ 'key': 'foo', + \ 'callback': 'NERDTreeCDHandler', \ 'quickhelpText': 'echo full path of current node' }) + \ 'scope': 'DirNode' - function! NERDTreeEchoCurrentNode() - let n = g:NERDTreeFileNode.GetSelected() - if n != {} - echomsg 'Current node: ' . n.path.str() - endif + function! NERDTreeCDHandler(dirnode) + call a:dirnode.changeToDir() endfunction < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. - It adds a (rather useless) mapping on 'b' which echos the full path to the - current node. + It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of + the current dir node. Note this mapping will only fire when the cursor is + on a directory node. ------------------------------------------------------------------------------ 4.2. Menu API *NERDTreeMenuAPI* @@ -1116,6 +1126,9 @@ The latest dev versions are on github ============================================================================== 6. Changelog *NERDTreeChangelog* +Next + - add 'scope' argument to the key map API + 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) From 0c12f6fe1055e75afbac250ae59af7712088feab Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 16:08:10 +0000 Subject: [PATCH 027/680] update quickhelp for custom mappings dont display quickhelp for a mapping if there is no text to display - this prevents all the default mappings from being displayed under the "custom mappings" section. --- plugin/NERD_tree.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 9597e46a..2de401cd 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3091,13 +3091,13 @@ function! s:dumpHelp() let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" "add quickhelp entries for each custom key map - if len(s:KeyMap.All()) - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Custom mappings~\n" - for i in s:KeyMap.All() + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Custom mappings~\n" + for i in s:KeyMap.All() + if !empty(i.quickhelpText) let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" - endfor - endif + endif + endfor let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Other mappings~\n" From 62c94e272f414f74c92c99b35d0421365dc7973f Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 22:43:18 +0000 Subject: [PATCH 028/680] fix the mouse mappings --- plugin/NERD_tree.vim | 61 +++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2de401cd..cedf0ac2 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3663,8 +3663,8 @@ endfunction function! s:bindMappings() " set up mappings and commands for this buffer nnoremap :call handleMiddleMouse() - nnoremap :call checkForActivate() - nnoremap <2-leftmouse> :call activateNode(0) + nnoremap :call handleLeftClick() + exec "nnoremap <2-leftmouse> :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" let s = '' . s:SID() . '_' @@ -3753,29 +3753,6 @@ function! s:bookmarkNode(...) call s:echo("select a node first") endif endfunction -"FUNCTION: s:checkForActivate() {{{2 -"Checks if the click should open the current node -function! s:checkForActivate() - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - let startToCur = strpart(getline(line(".")), 0, col(".")) - - if currentNode.path.isDirectory - if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$' - call s:activateNode(0) - return - endif - endif - - if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 - let char = strpart(startToCur, strlen(startToCur)-1, 1) - if char !~# s:tree_markup_reg - call s:activateNode(0) - return - endif - endif - endif -endfunction " FUNCTION: s:chCwd(node) {{{2 function! s:chCwd(node) @@ -3868,6 +3845,38 @@ function! s:displayHelp() call s:centerView() endfunction +"FUNCTION: s:handleLeftClick() {{{2 +"Checks if the click should open the current node +function! s:handleLeftClick() + let currentNode = s:TreeFileNode.GetSelected() + if currentNode != {} + + "the dir arrows are multibyte chars, and vim's string functions only + "deal with single bytes - so split the line up with the hack below and + "take the line substring manually + let line = split(getline(line(".")), '\zs') + let startToCur = "" + for i in range(0,virtcol(".")-1) + let startToCur .= line[i] + endfor + + if currentNode.path.isDirectory + if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$' + call s:activateNode(currentNode) + return + endif + endif + + if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 + let char = strpart(startToCur, strlen(startToCur)-1, 1) + if char !~# s:tree_markup_reg + call s:activateAll() + return + endif + endif + endif +endfunction + " FUNCTION: s:handleMiddleMouse() {{{2 function! s:handleMiddleMouse() let curNode = s:TreeFileNode.GetSelected() @@ -3877,7 +3886,7 @@ function! s:handleMiddleMouse() endif if curNode.path.isDirectory - call s:openExplorer() + call s:openExplorer(curNode) else call s:openEntrySplit(0,0) endif From 44256276832fcfa24b55670c1767bd212262b8fd Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 3 Jan 2012 23:30:57 +0000 Subject: [PATCH 029/680] refactor option checking to simplify and remove duplication --- plugin/NERD_tree.vim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index db33fb97..2e613164 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -399,7 +399,7 @@ function! s:Bookmark.openInNewTab(options) exec "tabedit " . self.path.str({'format': 'Edit'}) endif - if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] + if s:has_opt(a:options, 'stayInCurrentTab') exec "tabnext " . currentTab endif endfunction @@ -1341,13 +1341,13 @@ endfunction function! s:TreeFileNode.openInNewTab(options) let currentTab = tabpagenr() - if !has_key(a:options, 'keepTreeOpen') + if !s:has_opt(a:options, 'keepTreeOpen') call s:closeTreeIfQuitOnOpen() endif exec "tabedit " . self.path.str({'format': 'Edit'}) - if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] + if s:has_opt(a:options, 'stayInCurrentTab') exec "tabnext " . currentTab endif @@ -1803,14 +1803,14 @@ unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) let currentTab = tabpagenr() - if !has_key(a:options, 'keepTreeOpen') || !a:options['keepTreeOpen'] + if !s:has_opt(a:options, 'keepTreeOpen') call s:closeTreeIfQuitOnOpen() endif tabnew call s:initNerdTree(self.path.str()) - if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] + if s:has_opt(a:options, 'stayInCurrentTab') exec "tabnext " . currentTab endif endfunction @@ -2482,7 +2482,7 @@ function! s:Path.str(...) let toReturn = self._str() endif - if has_key(options, 'escape') && options['escape'] + if s:has_opt(options, 'escape') let toReturn = shellescape(toReturn) endif @@ -2686,6 +2686,12 @@ function! s:findAndRevealPath() call s:putCursorInTreeWin() call b:NERDTreeRoot.reveal(p) endfunction + +" FUNCTION: s:has_opt(options, name) {{{2 +function! s:has_opt(options, name) + return has_key(a:options, a:name) && a:options[a:name] == 1 +endfunction + "FUNCTION: s:initNerdTree(name) {{{2 "Initialise the nerd tree for this tab. The tree will start in either the "given directory, or the directory associated with the given bookmark From aca917b4ca18f21f81ae104038cd2eacd505c5ea Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 00:13:38 +0000 Subject: [PATCH 030/680] make a small fix for the left mouse button --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2e613164..0585a658 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3876,7 +3876,7 @@ function! s:handleLeftClick() if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 let char = strpart(startToCur, strlen(startToCur)-1, 1) if char !~# s:tree_markup_reg - call s:activateAll() + call s:activateNode(currentNode) return endif endif From a63c8a2ec8ab03cef906c21f40fad7d00deeba10 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 00:13:57 +0000 Subject: [PATCH 031/680] use the keymap api for the mouse mappings --- plugin/NERD_tree.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 0585a658..9b8d70a6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -509,11 +509,13 @@ endfunction "FUNCTION: KeyMap.bind() {{{3 function! s:KeyMap.bind() let mapkey = self.key - if mapkey =~ '^[CM]-' + if mapkey =~? '^\([CM]-\|middlerelease\|2-leftmouse\|leftrelease\)' let mapkey = '<' . mapkey . '>' endif - exec 'nnoremap '. mapkey .' :call KeyMap_Invoke("'. self.key .'")' + let premap = self.key == "leftrelease" ? " " : " " + + exec 'nnoremap '. mapkey . premap . ':call KeyMap_Invoke("'. self.key .'")' endfunction "FUNCTION: KeyMap.invoke() {{{3 @@ -3667,13 +3669,15 @@ endfunction "FUNCTION: s:bindMappings() {{{2 function! s:bindMappings() - " set up mappings and commands for this buffer - nnoremap :call handleMiddleMouse() - nnoremap :call handleLeftClick() - exec "nnoremap <2-leftmouse> :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" - let s = '' . s:SID() . '_' + call NERDTreeAddKeyMap({ 'key': 'middlerelease', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': 'leftrelease', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Node", 'callback': s."activateNode" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "all", 'callback': s."activateAll" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Node", 'callback': s."activateNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) From 98b2fa5104f4203949e16067afdaf6203b17e180 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 09:27:06 +0000 Subject: [PATCH 032/680] make a syntax fix for certain versions of vim It seems that some versions of vim done like the syntax of: function("foo")() so refactor it slightly. --- plugin/NERD_tree.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 9b8d70a6..d2158802 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -521,10 +521,11 @@ endfunction "FUNCTION: KeyMap.invoke() {{{3 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) + let Callback = function(self.callback) if a:0 - call function(self.callback)(a:1) + call Callback(a:1) else - call function(self.callback)() + call Callback() endif endfunction From ebb2835c456a3dfc42b36448fb68bd07688e54ca Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 09:43:07 +0000 Subject: [PATCH 033/680] fix a bug where keymaps were failing with :set ignorecase --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index d2158802..24a7756f 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -492,7 +492,7 @@ endfunction "FUNCTION: KeyMap.FindFor(key, scope) {{{3 function! s:KeyMap.FindFor(key, scope) for i in s:KeyMap.All() - if i.key == a:key && i.scope == a:scope + if i.key ==# a:key && i.scope ==# a:scope return i endif endfor From c431d38d976cdcca943c19650863b25e5c2375ba Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 10:39:07 +0000 Subject: [PATCH 034/680] dont use VimEnter to cache bookmarks and load plugins Just call these functions directly at the bottom of the nerdtree script. This simplifies things and fixes #99. --- plugin/NERD_tree.vim | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 24a7756f..9c9ff903 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -172,12 +172,6 @@ augroup NERDTree "disallow insert mode in the NERDTree exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert" - - "cache bookmarks when vim loads - autocmd VimEnter * call s:Bookmark.CacheBookmarks(0) - - "load all nerdtree plugins after vim starts - autocmd VimEnter * runtime! nerdtree_plugin/**/*.vim augroup END if g:NERDTreeHijackNetrw @@ -2843,6 +2837,13 @@ function! s:nextBufferName() let s:next_buffer_number += 1 return name endfunction +" FUNCTION: s:postSourceActions() {{{2 +function! s:postSourceActions() + call s:Bookmark.CacheBookmarks(0) + + "load all nerdtree plugins + runtime! nerdtree_plugin/**/*.vim +endfunction " FUNCTION: s:tabpagevar(tabnr, var) {{{2 function! s:tabpagevar(tabnr, var) let currentTab = tabpagenr() @@ -4113,6 +4114,8 @@ function! s:upDirCurrentRootClosed() call s:upDir(0) endfunction +" Post Source Actions {{{1 +call s:postSourceActions() "reset &cpo back to users setting let &cpo = s:old_cpo From 1848a2cf9d5725e264a1d3c95eba7ebb6ecf7c4b Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 10:44:17 +0000 Subject: [PATCH 035/680] fix a bug when activating bookmarks --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 9c9ff903..c661f775 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3666,7 +3666,7 @@ endfunction "FUNCTION: s:activateBookmark() {{{2 "handle the user activating a bookmark function! s:activateBookmark(bm) - call a:bm.activate(0) + call a:bm.activate() endfunction "FUNCTION: s:bindMappings() {{{2 From 33a64260cd5540dc55df32df87ca8fb1f4e1648d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 11:11:12 +0000 Subject: [PATCH 036/680] add NERDTreeCustomIgnoreFilter hook this gives users a chance to filter out nodes using whatever logic they please --- doc/NERD_tree.txt | 1 + plugin/NERD_tree.vim | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 395aafab..5598dae0 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1128,6 +1128,7 @@ The latest dev versions are on github Next - add 'scope' argument to the key map API + - add NERDTreeCustomIgnoreFilter hook - needs doc 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c661f775..649632e6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2306,6 +2306,10 @@ function! s:Path.ignore() return 1 endif + if exists("*NERDTreeCustomIgnoreFilter") && NERDTreeCustomIgnoreFilter(self) + return 1 + endif + return 0 endfunction From a55e9eca405ff15a65d59554d9d1d1f8cdcfbdd8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 11:44:54 +0000 Subject: [PATCH 037/680] update faq in the readme --- README.markdown | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index a68dc020..19217ba4 100644 --- a/README.markdown +++ b/README.markdown @@ -66,13 +66,28 @@ Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`. Faq --- -Q. Can I have the nerdtree on every tab automatically? +__Q. Can I have the nerdtree on every tab automatically?__ A. Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers - If you are interested in this behavour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + +__Q. How can I open a NERDTree automatically when vim starts up?__ + +A. Stick this in your vimrc: `autocmd vimenter * NERDTree` + +__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__ + +A. Stick this in your vimrc `autocmd vimenter * if !argc() | NERDTree | endif` + +__Q. How can I close vim if the only window left open is a NERDTree?__ + +A. Stick this in your vimrc: + + `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif` + Changelog --------- From 3be5f5ddd86d27ecf364add831c1d60f4b4ef984 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 4 Jan 2012 13:52:44 +0000 Subject: [PATCH 038/680] fix a bug for files that begin with +/-/~ chars First, set the tree parts regex appropriately depending on g:NERDTreeDirArrows. Second, fix an edge case when trying to edit a file like +foo where the + meant 'foo' was being interpreted as an arg to the :edit cmd --- plugin/NERD_tree.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 649632e6..a4f8611e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -149,7 +149,12 @@ endif let s:NERDTreeBufName = 'NERD_tree_' let s:tree_wid = 2 -let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]\+' + +if g:NERDTreeDirArrows + let s:tree_markup_reg = '^ *\([▾▸] \)\?' +else + let s:tree_markup_reg = '^[ `|]*[\-+~]' +endif let s:tree_up_dir_line = '.. (up a dir)' "the number to add to the nerd tree buffer name to make the buf name unique @@ -2532,6 +2537,12 @@ function! s:Path._strForEdit() "return a relative path if we can if stridx(p, cwd) ==# 0 let p = strpart(p, strlen(cwd)) + + "handle the edge case where the file begins with a + (vim interprets + "the +foo in `:e +foo` as an option to :edit) + if p[0] == "+" + let p = '\' . p + endif endif if p ==# '' From 4337022524ff8cfc8918e4c0b3e0f5c192136792 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 5 Jan 2012 08:24:15 +0000 Subject: [PATCH 039/680] dont convert windows paths to lower case when :editing This fixes #89. --- plugin/NERD_tree.vim | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a4f8611e..92a5a5ea 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2522,20 +2522,18 @@ endfunction "Return: the string for this path that is suitable to be used with the :edit "command function! s:Path._strForEdit() - let p = self.str({'format': 'UI'}) - let cwd = getcwd() + let p = escape(self.str({'format': 'UI'}), s:escape_chars) + let cwd = getcwd() . s:Path.Slash() + "return a relative path if we can + let isRelative = 0 if s:running_windows - let p = tolower(self.str()) - let cwd = tolower(getcwd()) + let isRelative = stridx(tolower(p), tolower(cwd)) == 0 + else + let isRelative = stridx(p, cwd) == 0 endif - let p = escape(p, s:escape_chars) - - let cwd = cwd . s:Path.Slash() - - "return a relative path if we can - if stridx(p, cwd) ==# 0 + if isRelative let p = strpart(p, strlen(cwd)) "handle the edge case where the file begins with a + (vim interprets @@ -2550,7 +2548,6 @@ function! s:Path._strForEdit() endif return p - endfunction "FUNCTION: Path._strForGlob() {{{3 function! s:Path._strForGlob() From 54fab2f2e55e9a413e2a1f5aec0f9129036d2168 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 5 Jan 2012 11:41:51 +0000 Subject: [PATCH 040/680] add dir and file flags to NERDTreeIgnore regexes This allows users to specify whether each regex in NERDTreeIgnore should apply to only files or only dirs. --- doc/NERD_tree.txt | 9 +++++++++ plugin/NERD_tree.vim | 24 ++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 5598dae0..a6a03905 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -780,6 +780,14 @@ For example if you put the following line in your vimrc: > < then all files ending in .vim or ~ will be ignored. +There are 2 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only files or only dirs. +These flags are "[[dir]]" and "[[file]]". Example: > + let NERDTreeIgnore=['.d$[[dir]]', '.o$[[file]]'] +< +This will cause all dirs ending in ".d" to be ignored and all files ending in +".o" to be ignored. + Note: to tell the NERD tree not to ignore any files you must use the following line: > let NERDTreeIgnore=[] @@ -1129,6 +1137,7 @@ The latest dev versions are on github Next - add 'scope' argument to the key map API - add NERDTreeCustomIgnoreFilter hook - needs doc + - add magic [[dir]] and [[file]] flags to NERDTreeIgnore 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 92a5a5ea..b1a64451 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2291,19 +2291,17 @@ endfunction "FUNCTION: Path.ignore() {{{3 "returns true if this path should be ignored function! s:Path.ignore() - let lastPathComponent = self.getLastPathComponent(0) - "filter out the user specified paths to ignore if b:NERDTreeIgnoreEnabled for i in g:NERDTreeIgnore - if lastPathComponent =~# i + if self._ignorePatternMatches(i) return 1 endif endfor endif "dont show hidden files unless instructed to - if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~# '^\.' + if b:NERDTreeShowHidden ==# 0 && self.getLastPathComponent(0) =~# '^\.' return 1 endif @@ -2318,6 +2316,24 @@ function! s:Path.ignore() return 0 endfunction +"FUNCTION: Path._ignorePatternMatches(pattern) {{{3 +"returns true if this path matches the given ignore pattern +function! s:Path._ignorePatternMatches(pattern) + let pat = a:pattern + if strpart(pat,len(pat)-7) == '[[dir]]' + if !self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-7) + elseif strpart(pat,len(pat)-8) == '[[file]]' + if self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-8) + endif + + return self.getLastPathComponent(0) =~# pat +endfunction "FUNCTION: Path.isUnder(path) {{{3 "return 1 if this path is somewhere under the given path in the filesystem. " From b7cdc191ca25aef5525a39acfdc938dee5a26674 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 5 Jan 2012 10:54:21 +0000 Subject: [PATCH 041/680] refactor the TreeFileNode*open* methods Make these all go through .open() and pass in args to control the behaviour. Deprecate the old `openSplit`, `openVSplit` and `openInNewTab` methods and make them private. This makes the API a lot cleaner - it was getting pretty messy in this regard. --- plugin/NERD_tree.vim | 198 ++++++++++++++++++++++++++++++------------- 1 file changed, 140 insertions(+), 58 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b1a64451..74cb0ca2 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -905,12 +905,9 @@ endfunction "classes. "============================================================ let s:TreeFileNode = {} -"FUNCTION: TreeFileNode.activate(forceKeepWinOpen) {{{3 -function! s:TreeFileNode.activate(forceKeepWinOpen) - call self.open() - if !a:forceKeepWinOpen - call s:closeTreeIfQuitOnOpen() - end +"FUNCTION: TreeFileNode.activate(...) {{{3 +function! s:TreeFileNode.activate(...) + call self.open(a:0 ? a:1 : {}) endfunction "FUNCTION: TreeFileNode.bookmark(name) {{{3 "bookmark this node with a:name @@ -1216,45 +1213,82 @@ function! s:TreeFileNode.New(path) endfunction "FUNCTION: TreeFileNode.open() {{{3 -"Open the file represented by the given node in the current window, splitting -"the window if needed +"Args: +"A dictionary containing the following keys (all optional): +" 'split': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'preview': open the file, but keep the cursor in the tree win " -"ARGS: -"treenode: file node to open -function! s:TreeFileNode.open() +function! s:TreeFileNode.open(...) + let opts = a:0 ? a:1 : {} + + let currentBuf = bufnr("") + let currentTab = tabpagenr() + + if s:has_opt(opts, 'reuse') && self._putCursorInBufWin() + return + endif + + if has_key(opts, 'split') + if opts['split'] == 'v' + call self._openVSplit() + elseif opts['split'] == 'h' + call self._openSplit() + else + call self._openInNewTab(opts) + endif + else + call self._open() + endif + + if !s:has_opt(opts, 'forceKeepWinOpen') + call s:closeTreeIfQuitOnOpen() + endif + + if s:has_opt(opts, 'preview') + call s:exec('normal ' . currentTab . 'gt') + call s:exec(bufwinnr(currentBuf) . 'wincmd w') + endif +endfunction + +"FUNCTION: TreeFileNode._open() {{{3 +function! s:TreeFileNode._open() + if b:NERDTreeType ==# "secondary" exec 'edit ' . self.path.str({'format': 'Edit'}) return endif - "if the file is already open in this tab then just stick the cursor in it - let winnr = bufwinnr('^' . self.path.str() . '$') - if winnr != -1 - call s:exec(winnr . "wincmd w") - + if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 + call self._openSplit() else - if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 - call self.openSplit() - else - try - if !s:isWindowUsable(winnr("#")) - call s:exec(s:firstUsableWindow() . "wincmd w") - else - call s:exec('wincmd p') - endif - exec ("edit " . self.path.str({'format': 'Edit'})) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - echo v:exception - endtry - endif + try + if !s:isWindowUsable(winnr("#")) + call s:exec(s:firstUsableWindow() . "wincmd w") + else + call s:exec('wincmd p') + endif + exec ("edit " . self.path.str({'format': 'Edit'})) + catch /^Vim\%((\a\+)\)\=:E37/ + call s:putCursorInTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + echo v:exception + endtry endif endfunction "FUNCTION: TreeFileNode.openSplit() {{{3 "Open this node in a new window function! s:TreeFileNode.openSplit() + call s:deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') + call self.open({'split': 'h'}) +endfunction +"FUNCTION: TreeFileNode._openSplit() {{{3 +"Open this node in a new window +function! s:TreeFileNode._openSplit() if b:NERDTreeType ==# "secondary" exec "split " . self.path.str({'format': 'Edit'}) @@ -1321,6 +1355,12 @@ endfunction "FUNCTION: TreeFileNode.openVSplit() {{{3 "Open this node in a new vertical window function! s:TreeFileNode.openVSplit() + call s:deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') + call self.open({'split': 'v'}) +endfunction +"FUNCTION: TreeFileNode._openVSplit() {{{3 +"Open this node in a new vertical window +function! s:TreeFileNode._openVSplit() if b:NERDTreeType ==# "secondary" exec "vnew " . self.path.str({'format': 'Edit'}) return @@ -1341,19 +1381,42 @@ function! s:TreeFileNode.openVSplit() endfunction "FUNCTION: TreeFileNode.openInNewTab(options) {{{3 function! s:TreeFileNode.openInNewTab(options) + echomsg 'TreeFileNode.openInNewTab is deprecated' + call self.open(extend({'split': 't'}, a:options)) +endfunction +"FUNCTION: TreeFileNode._openInNewTab(options) {{{3 +function! s:TreeFileNode._openInNewTab(options) let currentTab = tabpagenr() - - if !s:has_opt(a:options, 'keepTreeOpen') - call s:closeTreeIfQuitOnOpen() - endif - exec "tabedit " . self.path.str({'format': 'Edit'}) if s:has_opt(a:options, 'stayInCurrentTab') exec "tabnext " . currentTab endif - endfunction +"FUNCTION: TreeFileNode._putCursorInBufWin(){{{3 +"put the cursor in the first window we find for this file +" +"return 1 if we were successful +function! s:TreeFileNode._putCursorInBufWin(...) + "check the current tab for the window + let winnr = bufwinnr('^' . self.path.str() . '$') + if winnr != -1 + call s:exec(winnr . "wincmd w") + return 1 + else + "check other tabs + let tabnr = self.path.tabnr() + if tabnr + call s:exec('normal! ' . tabnr . 'gt') + let winnr = bufwinnr('^' . self.path.str() . '$') + call s:exec(winnr . "wincmd w") + return 1 + endif + endif + return 0 +endfunction + + "FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 "Places the cursor on the line number this node is rendered on " @@ -1778,7 +1841,7 @@ endfunction " "Return: the number of child nodes read unlet s:TreeDirNode.open -function! s:TreeDirNode.open() +function! s:TreeDirNode.open(...) let self.isOpen = 1 if self.children ==# [] return self._initChildren(0) @@ -2603,6 +2666,21 @@ function! s:Path.strTrunk() return self.drive . '/' . join(self.pathSegments[0:-2], '/') endfunction +" FUNCTION: Path.tabnr() {{{3 +" return the number of the first tab that is displaying this file +" +" return 0 if no tab was found +function! s:Path.tabnr() + let str = self.str() + for t in range(tabpagenr('$')) + for b in tabpagebuflist(t+1) + if str == expand('#' . b . ':p') + return t+1 + endif + endfor + endfor + return 0 +endfunction "FUNCTION: Path.WinToUnixPath(pathstr){{{3 "Takes in a windows path and returns the unix equiv " @@ -2669,6 +2747,20 @@ endfunction function! s:completeBookmarks(A,L,P) return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction +" FUNCTION: s:deprecated(func, [msg]) {{{2 +" Issue a deprecation warning for a:func. If a second arg is given, use this +" as the deprecation message +function! s:deprecated(func, ...) + let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' + + if !exists('s:deprecationWarnings') + let s:deprecationWarnings = {} + endif + if !has_key(s:deprecationWarnings, a:func) + let s:deprecationWarnings[a:func] = 1 + echomsg msg + endif +endfunction " FUNCTION: s:exec(cmd) {{{2 " same as :exec cmd but eventignore=all is set for the duration function! s:exec(cmd) @@ -3388,16 +3480,6 @@ function! s:openEntrySplit(vertical, forceKeepWindowOpen) endif endfunction -"FUNCTION: s:previewNode(node, openNewWin) {{{2 -function! s:previewNode(node, openNewWin) - let currentBuf = bufnr("") - if a:openNewWin > 0 - call s:openEntrySplit(a:openNewWin ==# 2,1) - else - call s:activateNode(a:node) - end - call s:exec(bufwinnr(currentBuf) . "wincmd w") -endfunction "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2 "prints out the given msg and, if the user responds by pushing 'y' then the "buffer with the given bufnum is deleted @@ -3688,7 +3770,7 @@ endfunction "FUNCTION: s:activateNode() {{{2 "handle the user activating a tree node function! s:activateNode(node) - call a:node.activate(0) + call a:node.activate({'reuse': 1}) endfunction "FUNCTION: s:activateBookmark() {{{2 @@ -3994,12 +4076,12 @@ endfunction " FUNCTION: s:openHSplit(node) {{{2 function! s:openHSplit(node) - call a:node.openSplit() + call a:node.activate({'split': 'h'}) endfunction " FUNCTION: s:openVSplit(node) {{{2 function! s:openVSplit(node) - call a:node.openVSplit() + call a:node.activate({'split': 'v'}) endfunction " FUNCTION: s:openExplorer(node) {{{2 @@ -4009,12 +4091,12 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{2 function! s:openInNewTab(target) - call a:target.openInNewTab({}) + call a:target.activate({'split': 't'}) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{2 function! s:openInNewTabSilent(target) - call a:target.openInNewTab({'stayInCurrentTab': 1}) + call a:target.activate({'split': 't', 'stayInCurrentTab': 1}) endfunction " FUNCTION: s:openNodeRecursively(node) {{{2 @@ -4028,17 +4110,17 @@ endfunction "FUNCTION: s:previewNodeCurrent(node) {{{2 function! s:previewNodeCurrent(node) - call s:previewNode(a:node, 0) + call a:node.open({'preview': 1}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{2 function! s:previewNodeHSplit(node) - call s:previewNode(a:node, 1) + call a:node.open({'preview': 1, 'split': 'h'}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{2 function! s:previewNodeVSplit(node) - call s:previewNode(a:node, 2) + call a:node.open({'preview': 1, 'split': 'v'}) endfunction From 9832d4a84a672ea17773139b7757b936461037f7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 13:38:31 +0000 Subject: [PATCH 042/680] fix Bookmark so it uses the new TreeFileNode.open method --- plugin/NERD_tree.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 74cb0ca2..10e416a5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -192,13 +192,15 @@ endif "============================================================ let s:Bookmark = {} " FUNCTION: Bookmark.activate() {{{3 -function! s:Bookmark.activate() +function! s:Bookmark.activate(...) + let opts = a:0 ? a:1 : {} + if self.path.isDirectory call self.toRoot() else if self.validate() let n = s:TreeFileNode.New(self.path) - call n.open() + call n.open(opts) call s:closeTreeIfQuitOnOpen() endif endif From 92248f92cad07a9400adb5906c98e14288315766 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 14:47:10 +0000 Subject: [PATCH 043/680] make TreeDirNode use the new open() interface --- plugin/NERD_tree.vim | 69 +++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 10e416a5..0e8003ef 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1574,10 +1574,11 @@ function! s:TreeDirNode.AbsoluteTreeRoot() endwhile return currentNode endfunction -"FUNCTION: TreeDirNode.activate(forceKeepWinOpen) {{{3 +"FUNCTION: TreeDirNode.activate([options]) {{{3 unlet s:TreeDirNode.activate -function! s:TreeDirNode.activate(forceKeepWinOpen) - call self.toggleOpen() +function! s:TreeDirNode.activate(...) + let opts = a:0 ? a:1 : {} + call self.toggleOpen(opts) call s:renderView() call self.putCursorHere(0, 0) endfunction @@ -1838,17 +1839,42 @@ function! s:TreeDirNode.New(path) return newTreeNode endfunction -"FUNCTION: TreeDirNode.open() {{{3 -"Reads in all this nodes children +"FUNCTION: TreeDirNode.open([opts]) {{{3 +"Open the dir in the current tree or in a new tree elsewhere. +" +"Args: +" +"A dictionary containing the following keys (all optional): +" 'split': 't' if the tree should be opened in a new tab +" 'keepopen': dont close the tree window +" 'preview': open the file, but keep the cursor in the tree win " -"Return: the number of child nodes read unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) - let self.isOpen = 1 - if self.children ==# [] - return self._initChildren(0) + let opts = a:0 ? a:1 : {} + + if has_key(opts, 'split') && opts['split'] == 't' + let currentBuf = bufnr("") + let currentTab = tabpagenr() + + call self._openInNewTab() + + if s:has_opt(opts, 'preview') + call s:exec('normal ' . currentTab . 'gt') + call s:exec(bufwinnr(currentBuf) . 'wincmd w') + endif + + if !s:has_opt(opts, 'keepTreeOpen') + call s:closeTreeIfQuitOnOpen() + endif + else - return 0 + let self.isOpen = 1 + if self.children ==# [] + return self._initChildren(0) + else + return 0 + endif endif endfunction @@ -1868,18 +1894,14 @@ endfunction "FUNCTION: TreeDirNode.openInNewTab(options) {{{3 unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) - let currentTab = tabpagenr() - - if !s:has_opt(a:options, 'keepTreeOpen') - call s:closeTreeIfQuitOnOpen() - endif - + call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') + call self.open({'split': 't'}) +endfunction +"FUNCTION: TreeDirNode._openInNewTab() {{{3 +unlet s:TreeDirNode._openInNewTab +function! s:TreeDirNode._openInNewTab() tabnew call s:initNerdTree(self.path.str()) - - if s:has_opt(a:options, 'stayInCurrentTab') - exec "tabnext " . currentTab - endif endfunction "FUNCTION: TreeDirNode.openRecursively() {{{3 "Opens this treenode and all of its children whose paths arent 'ignored' @@ -2019,13 +2041,14 @@ function! s:TreeDirNode.sortChildren() call sort(self.children, CompareFunc) endfunction -"FUNCTION: TreeDirNode.toggleOpen() {{{3 +"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3 "Opens this directory if it is closed and vice versa -function! s:TreeDirNode.toggleOpen() +function! s:TreeDirNode.toggleOpen(...) + let opts = a:0 ? a:1 : {} if self.isOpen ==# 1 call self.close() else - call self.open() + call self.open(opts) endif endfunction From af13711fac56e18118f07b0e2e1b20c817b38fff Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 14:54:19 +0000 Subject: [PATCH 044/680] rename 'preview' to 'stay' and standardize the 'keepopen' name --- plugin/NERD_tree.vim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 0e8003ef..95f629cf 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1222,7 +1222,7 @@ endfunction " new tab) " 'reuse': if a window is displaying the file then jump the cursor there " 'keepopen': dont close the tree window -" 'preview': open the file, but keep the cursor in the tree win +" 'stay': open the file, but keep the cursor in the tree win " function! s:TreeFileNode.open(...) let opts = a:0 ? a:1 : {} @@ -1246,11 +1246,11 @@ function! s:TreeFileNode.open(...) call self._open() endif - if !s:has_opt(opts, 'forceKeepWinOpen') + if !s:has_opt(opts, 'keepopen') call s:closeTreeIfQuitOnOpen() endif - if s:has_opt(opts, 'preview') + if s:has_opt(opts, 'stay') call s:exec('normal ' . currentTab . 'gt') call s:exec(bufwinnr(currentBuf) . 'wincmd w') endif @@ -1847,7 +1847,7 @@ endfunction "A dictionary containing the following keys (all optional): " 'split': 't' if the tree should be opened in a new tab " 'keepopen': dont close the tree window -" 'preview': open the file, but keep the cursor in the tree win +" 'stay': open the file, but keep the cursor in the tree win " unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) @@ -1859,12 +1859,12 @@ function! s:TreeDirNode.open(...) call self._openInNewTab() - if s:has_opt(opts, 'preview') + if s:has_opt(opts, 'stay') call s:exec('normal ' . currentTab . 'gt') call s:exec(bufwinnr(currentBuf) . 'wincmd w') endif - if !s:has_opt(opts, 'keepTreeOpen') + if !s:has_opt(opts, 'keepopen') call s:closeTreeIfQuitOnOpen() endif @@ -4135,17 +4135,17 @@ endfunction "FUNCTION: s:previewNodeCurrent(node) {{{2 function! s:previewNodeCurrent(node) - call a:node.open({'preview': 1}) + call a:node.open({'stay': 1}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{2 function! s:previewNodeHSplit(node) - call a:node.open({'preview': 1, 'split': 'h'}) + call a:node.open({'stay': 1, 'split': 'h'}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{2 function! s:previewNodeVSplit(node) - call a:node.open({'preview': 1, 'split': 'v'}) + call a:node.open({'stay': 1, 'split': 'v'}) endfunction From 04dbae2cb4df3b92e0b62803f1a7486ec6c19fc5 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 15:02:55 +0000 Subject: [PATCH 045/680] remove s:openEntrySplit as it is not needed anymore --- plugin/NERD_tree.vim | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 95f629cf..f170f301 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3486,25 +3486,6 @@ function! s:jumpToSibling(currentNode, forward) endif endfunction - - -" FUNCTION: s:openEntrySplit(vertical, forceKeepWindowOpen) {{{2 -function! s:openEntrySplit(vertical, forceKeepWindowOpen) - let treenode = s:TreeFileNode.GetSelected() - if treenode != {} - if a:vertical - call treenode.openVSplit() - else - call treenode.openSplit() - endif - if !a:forceKeepWindowOpen - call s:closeTreeIfQuitOnOpen() - endif - else - call s:echo("select a node first") - endif -endfunction - "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2 "prints out the given msg and, if the user responds by pushing 'y' then the "buffer with the given bufnum is deleted @@ -4035,11 +4016,10 @@ function! s:handleMiddleMouse() if curNode.path.isDirectory call s:openExplorer(curNode) else - call s:openEntrySplit(0,0) + call curNode.open({'split': 'h'}) endif endfunction - " FUNCTION: s:jumpToFirstChild() {{{2 " wrapper for the jump to child method function! s:jumpToFirstChild(node) From 57ccede2509ed5c421cc7baacc9fade973069cd6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 15:05:47 +0000 Subject: [PATCH 046/680] trivial comment change --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index f170f301..413f6e79 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -4229,7 +4229,7 @@ function! s:upDirCurrentRootClosed() call s:upDir(0) endfunction -" Post Source Actions {{{1 +" SECTION: Post Source Actions {{{1 call s:postSourceActions() "reset &cpo back to users setting From e027681803ea1da3ba1adb0cb92ad74c4f1fb20e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 6 Jan 2012 19:24:35 +0000 Subject: [PATCH 047/680] wrap a couple of wincmd calls in s:exec this is to prevent autocmds from being fired when the tree is closed --- plugin/NERD_tree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 413f6e79..d48d39d7 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3121,9 +3121,9 @@ function! s:closeTree() if winnr("$") != 1 if winnr() == s:getTreeWinNum() - wincmd p + call s:exec("wincmd p") let bufnr = bufnr("") - wincmd p + call s:exec("wincmd p") else let bufnr = bufnr("") endif From ba3d43138a867c9116641e8b99d4e10bb72c2ec3 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Fri, 6 Jan 2012 19:36:26 +0000 Subject: [PATCH 048/680] Added comment to clarify which part of the path is the 'drive' for windows network shares --- plugin/NERD_tree.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index aae0f18c..44abf7f6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2110,6 +2110,7 @@ endfunction function! s:Path.extractDriveLetter(fullpath) if s:running_windows if a:fullpath =~ '^\(\\\\\|\/\/\)' + "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') let self.drive = substitute(self.drive, '/', '\', "g") else From 3620029ae0c82d4ad83f2ddfe26e55235c975933 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 8 Jan 2012 17:24:30 +0000 Subject: [PATCH 049/680] make Bookmark use the new open() interface --- plugin/NERD_tree.vim | 54 ++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index feba553f..405f9812 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -193,17 +193,7 @@ endif let s:Bookmark = {} " FUNCTION: Bookmark.activate() {{{3 function! s:Bookmark.activate(...) - let opts = a:0 ? a:1 : {} - - if self.path.isDirectory - call self.toRoot() - else - if self.validate() - let n = s:TreeFileNode.New(self.path) - call n.open(opts) - call s:closeTreeIfQuitOnOpen() - endif - endif + call self.open(a:0 ? a:1 : {}) endfunction " FUNCTION: Bookmark.AddBookmark(name, path) {{{3 " Class method to add a new bookmark to the list, if a previous bookmark exists @@ -389,6 +379,33 @@ function! s:Bookmark.New(name, path) let newBookmark.path = a:path return newBookmark endfunction +" FUNCTION: Bookmark.open([options]) {{{3 +"Args: +"A dictionary containing the following keys (all optional): +" 'split': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +" +function! s:Bookmark.open(...) + let opts = a:0 ? a:1 : {} + + if self.path.isDirectory + if has_key(opts, 'split') + let n = s:TreeDirNode.New(self.path) + call n.open(opts) + else + call self.toRoot() + endif + else + if self.validate() + let n = s:TreeFileNode.New(self.path) + call n.open(opts) + endif + endif +endfunction " FUNCTION: Bookmark.openInNewTab(options) {{{3 " Create a new bookmark object with the given name and path object function! s:Bookmark.openInNewTab(options) @@ -3817,6 +3834,9 @@ function! s:bindMappings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) @@ -4092,14 +4112,14 @@ function! s:openBookmark(name) endif endfunction -" FUNCTION: s:openHSplit(node) {{{2 -function! s:openHSplit(node) - call a:node.activate({'split': 'h'}) +" FUNCTION: s:openHSplit(target) {{{2 +function! s:openHSplit(target) + call a:target.activate({'split': 'h'}) endfunction -" FUNCTION: s:openVSplit(node) {{{2 -function! s:openVSplit(node) - call a:node.activate({'split': 'v'}) +" FUNCTION: s:openVSplit(target) {{{2 +function! s:openVSplit(target) + call a:target.activate({'split': 'v'}) endfunction " FUNCTION: s:openExplorer(node) {{{2 From 4f1a205c8358c97ab9a7199fdb7e6b5e22c46db4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 9 Jan 2012 15:59:21 +0000 Subject: [PATCH 050/680] add Opener class to handle opening nodes/bookmarks Move the code to split windows and open nodes and bookmarks out into a dedicated class. This will remove duplication and remove and centralise a concern from the other classes. --- plugin/NERD_tree.vim | 505 +++++++++++++++++++++++-------------------- 1 file changed, 269 insertions(+), 236 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 405f9812..f86e378b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -392,34 +392,18 @@ endfunction function! s:Bookmark.open(...) let opts = a:0 ? a:1 : {} - if self.path.isDirectory - if has_key(opts, 'split') - let n = s:TreeDirNode.New(self.path) - call n.open(opts) - else - call self.toRoot() - endif + if self.path.isDirectory && !has_key(opts, 'split') + call self.toRoot() else - if self.validate() - let n = s:TreeFileNode.New(self.path) - call n.open(opts) - endif + let opener = s:Opener.New(self.path, opts) + call opener.open(self) endif endfunction " FUNCTION: Bookmark.openInNewTab(options) {{{3 " Create a new bookmark object with the given name and path object function! s:Bookmark.openInNewTab(options) - let currentTab = tabpagenr() - if self.path.isDirectory - tabnew - call s:initNerdTree(self.name) - else - exec "tabedit " . self.path.str({'format': 'Edit'}) - endif - - if s:has_opt(a:options, 'stayInCurrentTab') - exec "tabnext " . currentTab - endif + call s:deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') + call self.open(a:options) endfunction " Function: Bookmark.setPath(path) {{{3 " makes this bookmark point to the given path @@ -1232,210 +1216,30 @@ function! s:TreeFileNode.New(path) endfunction "FUNCTION: TreeFileNode.open() {{{3 -"Args: -"A dictionary containing the following keys (all optional): -" 'split': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' or 'h' or 't' (for open in -" new tab) -" 'reuse': if a window is displaying the file then jump the cursor there -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win -" function! s:TreeFileNode.open(...) + echomsg self.path.str() let opts = a:0 ? a:1 : {} - - let currentBuf = bufnr("") - let currentTab = tabpagenr() - - if s:has_opt(opts, 'reuse') && self._putCursorInBufWin() - return - endif - - if has_key(opts, 'split') - if opts['split'] == 'v' - call self._openVSplit() - elseif opts['split'] == 'h' - call self._openSplit() - else - call self._openInNewTab(opts) - endif - else - call self._open() - endif - - if !s:has_opt(opts, 'keepopen') - call s:closeTreeIfQuitOnOpen() - endif - - if s:has_opt(opts, 'stay') - call s:exec('normal ' . currentTab . 'gt') - call s:exec(bufwinnr(currentBuf) . 'wincmd w') - endif + let opener = s:Opener.New(self.path, opts) + call opener.open(self) endfunction -"FUNCTION: TreeFileNode._open() {{{3 -function! s:TreeFileNode._open() - - if b:NERDTreeType ==# "secondary" - exec 'edit ' . self.path.str({'format': 'Edit'}) - return - endif - - if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 - call self._openSplit() - else - try - if !s:isWindowUsable(winnr("#")) - call s:exec(s:firstUsableWindow() . "wincmd w") - else - call s:exec('wincmd p') - endif - exec ("edit " . self.path.str({'format': 'Edit'})) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - echo v:exception - endtry - endif -endfunction "FUNCTION: TreeFileNode.openSplit() {{{3 "Open this node in a new window function! s:TreeFileNode.openSplit() call s:deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') call self.open({'split': 'h'}) endfunction -"FUNCTION: TreeFileNode._openSplit() {{{3 -"Open this node in a new window -function! s:TreeFileNode._openSplit() - - if b:NERDTreeType ==# "secondary" - exec "split " . self.path.str({'format': 'Edit'}) - return - endif - - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call s:exec(back) - - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately - if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below - endif - - let splitMode = onlyOneWin ? "vertical" : "" - - " Open the new window - try - exec(splitMode." sp " . self.path.str({'format': 'Edit'})) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - "do nothing - endtry - - "resize the tree window if no other window was open before - if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call s:exec(there) - exec("silent ". splitMode ." resize ". size) - call s:exec('wincmd p') - endif - - " Restore splitmode settings - let &splitbelow=savesplitbelow - let &splitright=savesplitright -endfunction "FUNCTION: TreeFileNode.openVSplit() {{{3 "Open this node in a new vertical window function! s:TreeFileNode.openVSplit() call s:deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') call self.open({'split': 'v'}) endfunction -"FUNCTION: TreeFileNode._openVSplit() {{{3 -"Open this node in a new vertical window -function! s:TreeFileNode._openVSplit() - if b:NERDTreeType ==# "secondary" - exec "vnew " . self.path.str({'format': 'Edit'}) - return - endif - - let winwidth = winwidth(".") - if winnr("$")==#1 - let winwidth = g:NERDTreeWinSize - endif - - call s:exec("wincmd p") - exec "vnew " . self.path.str({'format': 'Edit'}) - - "resize the nerd tree back to the original size - call s:putCursorInTreeWin() - exec("silent vertical resize ". winwidth) - call s:exec('wincmd p') -endfunction "FUNCTION: TreeFileNode.openInNewTab(options) {{{3 function! s:TreeFileNode.openInNewTab(options) echomsg 'TreeFileNode.openInNewTab is deprecated' call self.open(extend({'split': 't'}, a:options)) endfunction -"FUNCTION: TreeFileNode._openInNewTab(options) {{{3 -function! s:TreeFileNode._openInNewTab(options) - let currentTab = tabpagenr() - exec "tabedit " . self.path.str({'format': 'Edit'}) - - if s:has_opt(a:options, 'stayInCurrentTab') - exec "tabnext " . currentTab - endif -endfunction -"FUNCTION: TreeFileNode._putCursorInBufWin(){{{3 -"put the cursor in the first window we find for this file -" -"return 1 if we were successful -function! s:TreeFileNode._putCursorInBufWin(...) - "check the current tab for the window - let winnr = bufwinnr('^' . self.path.str() . '$') - if winnr != -1 - call s:exec(winnr . "wincmd w") - return 1 - else - "check other tabs - let tabnr = self.path.tabnr() - if tabnr - call s:exec('normal! ' . tabnr . 'gt') - let winnr = bufwinnr('^' . self.path.str() . '$') - call s:exec(winnr . "wincmd w") - return 1 - endif - endif - return 0 -endfunction - - "FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 "Places the cursor on the line number this node is rendered on " @@ -1870,21 +1674,9 @@ unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) let opts = a:0 ? a:1 : {} - if has_key(opts, 'split') && opts['split'] == 't' - let currentBuf = bufnr("") - let currentTab = tabpagenr() - - call self._openInNewTab() - - if s:has_opt(opts, 'stay') - call s:exec('normal ' . currentTab . 'gt') - call s:exec(bufwinnr(currentBuf) . 'wincmd w') - endif - - if !s:has_opt(opts, 'keepopen') - call s:closeTreeIfQuitOnOpen() - endif - + if has_key(opts, 'split') && !empty(opts['split']) + let opener = s:Opener.New(self.path, opts) + call opener.open(self) else let self.isOpen = 1 if self.children ==# [] @@ -1899,23 +1691,14 @@ endfunction " opens an explorer window for this node in the previous window (could be a " nerd tree or a netrw) function! s:TreeDirNode.openExplorer() - let oldwin = winnr() - call s:exec('wincmd p') - if oldwin ==# winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2) - call s:exec('wincmd p') - call self.openSplit() - else - exec ("silent edit " . self.path.str({'format': 'Edit'})) - endif + call self.open({'split': 'p'}) endfunction "FUNCTION: TreeDirNode.openInNewTab(options) {{{3 -unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') call self.open({'split': 't'}) endfunction "FUNCTION: TreeDirNode._openInNewTab() {{{3 -unlet s:TreeDirNode._openInNewTab function! s:TreeDirNode._openInNewTab() tabnew call s:initNerdTree(self.path.str()) @@ -2086,6 +1869,243 @@ function! s:TreeDirNode.transplantChild(newNode) endfor endfunction "============================================================ +"CLASS: Opener {{{2 +"============================================================ +let s:Opener = {} +"FUNCTION: Opener._gotoTargetWin() {{{3 +function! s:Opener._gotoTargetWin() + if b:NERDTreeType ==# "secondary" + if self._split == 'v' + vsplit + elseif self._split == 'h' + split + elseif self._split == 't' + tabnew + endif + else + + if self._split == 'v' + call self._newVSplit() + elseif self._split == 'h' + call self._newSplit() + elseif self._split == 't' + tabnew + elseif self._split == 'p' + call self._previousWindow() + endif + endif +endfunction + +"FUNCTION: Opener.New(path, opts) {{{3 +"Args: +" +"a:path: The path object that is to be opened. +" +"a:opts: +" +"A dictionary containing the following keys (all optional): +" 'split': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +function! s:Opener.New(path, opts) + let newObj = copy(self) + + let newObj._path = a:path + let newObj._stay = s:has_opt(a:opts, 'stay') + let newObj._reuse = s:has_opt(a:opts, 'reuse') + let newObj._keepopen = s:has_opt(a:opts, 'keepopen') + let newObj._split = has_key(a:opts, 'split') ? a:opts['split'] : '' + call newObj._saveCursorPos() + + return newObj +endfunction + +"FUNCTION: Opener._newSplit() {{{3 +function! s:Opener._newSplit() + " Save the user's settings for splitbelow and splitright + let savesplitbelow=&splitbelow + let savesplitright=&splitright + + " 'there' will be set to a command to move from the split window + " back to the explorer window + " + " 'back' will be set to a command to move from the explorer window + " back to the newly split window + " + " 'right' and 'below' will be set to the settings needed for + " splitbelow and splitright IF the explorer is the only window. + " + let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" + let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" + let right= g:NERDTreeWinPos ==# "left" + let below=0 + + " Attempt to go to adjacent window + call s:exec(back) + + let onlyOneWin = (winnr("$") ==# 1) + + " If no adjacent window, set splitright and splitbelow appropriately + if onlyOneWin + let &splitright=right + let &splitbelow=below + else + " found adjacent window - invert split direction + let &splitright=!right + let &splitbelow=!below + endif + + let splitMode = onlyOneWin ? "vertical" : "" + + " Open the new window + try + exec(splitMode." sp ") + catch /^Vim\%((\a\+)\)\=:E37/ + call s:putCursorInTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + "do nothing + endtry + + "resize the tree window if no other window was open before + if onlyOneWin + let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call s:exec(there) + exec("silent ". splitMode ." resize ". size) + call s:exec('wincmd p') + endif + + " Restore splitmode settings + let &splitbelow=savesplitbelow + let &splitright=savesplitright +endfunction + +"FUNCTION: Opener._newVSplit() {{{3 +function! s:Opener._newVSplit() + let winwidth = winwidth(".") + if winnr("$")==#1 + let winwidth = g:NERDTreeWinSize + endif + + call s:exec("wincmd p") + vnew + + "resize the nerd tree back to the original size + call s:putCursorInTreeWin() + exec("silent vertical resize ". winwidth) + call s:exec('wincmd p') +endfunction + +"FUNCTION: Opener.open(target) {{{3 +function! s:Opener.open(target) + if self._path.isDirectory + call self._openDirectory(a:target) + else + call self._openFile() + endif +endfunction + +"FUNCTION: Opener._openFile() {{{3 +function! s:Opener._openFile() + if self._reuse && self._reuseWindow() + return + endif + + if b:NERDTreeType ==# "secondary" + call self._gotoTargetWin() + call self._path.edit() + else + call self._gotoTargetWin() + call self._path.edit() + + if self._keepopen + call s:closeTreeIfQuitOnOpen() + endif + + if self._stay + call self._restoreCursorPos() + endif + endif +endfunction + +"FUNCTION: Opener._openDirectory(node) {{{3 +function! s:Opener._openDirectory(node) + if b:NERDTreeType ==# "secondary" + call self._gotoTargetWin() + call s:initNerdTreeInPlace(a:node.path.str()) + else + call self._gotoTargetWin() + if empty(self._split) + call a:node.makeRoot() + call s:renderView() + call a:node.putCursorHere(0, 0) + elseif self._split == 't' + call s:initNerdTree(a:node.path.str()) + else + call s:initNerdTreeInPlace(a:node.path.str()) + endif + endif +endfunction + +"FUNCTION: Opener._previousWindow() {{{3 +function! s:Opener._previousWindow() + if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 + call self._newSplit() + else + try + if !s:isWindowUsable(winnr("#")) + call s:exec(s:firstUsableWindow() . "wincmd w") + else + call s:exec('wincmd p') + endif + exec ("edit " . self._path.str({'format': 'Edit'})) + catch /^Vim\%((\a\+)\)\=:E37/ + call s:putCursorInTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + echo v:exception + endtry + endif +endfunction + +"FUNCTION: Opener._restoreCursorPos(){{{3 +function! s:Opener._restoreCursorPos() + call s:exec('normal ' . self._tabnr . 'gt') + call s:exec(bufwinnr(self._bufnr) . 'wincmd w') +endfunction + +"FUNCTION: Opener._reuseWindow(){{{3 +"put the cursor in the first window we find for this file +" +"return 1 if we were successful +function! s:Opener._reuseWindow() + "check the current tab for the window + let winnr = bufwinnr('^' . self._path.str() . '$') + if winnr != -1 + call s:exec(winnr . "wincmd w") + return 1 + else + "check other tabs + let tabnr = self._path.tabnr() + if tabnr + call s:exec('normal! ' . tabnr . 'gt') + let winnr = bufwinnr('^' . self._path.str() . '$') + call s:exec(winnr . "wincmd w") + return 1 + endif + endif + return 0 +endfunction + +"FUNCTION: Opener._saveCursorPos(){{{3 +function! s:Opener._saveCursorPos() + let self._bufnr = bufnr("") + let self._tabnr = tabpagenr() +endfunction + "CLASS: Path {{{2 "============================================================ let s:Path = {} @@ -2317,6 +2337,10 @@ function! s:Path.displayString() return self.cachedDisplayString endfunction +"FUNCTION: Path.edit() {{{3 +function! s:Path.edit() + exec "edit " . self.str({'format': 'Edit'}) +endfunction "FUNCTION: Path.extractDriveLetter(fullpath) {{{3 " "If running windows, cache the drive letter for this path @@ -3803,16 +3827,22 @@ function! s:activateAll() endif endfunction -"FUNCTION: s:activateNode() {{{2 +"FUNCTION: s:activateDirNode() {{{2 "handle the user activating a tree node -function! s:activateNode(node) +function! s:activateDirNode(node) call a:node.activate({'reuse': 1}) endfunction +"FUNCTION: s:activateFileNode() {{{2 +"handle the user activating a tree node +function! s:activateFileNode(node) + call a:node.activate({'reuse': 1, 'split': 'p'}) +endfunction + "FUNCTION: s:activateBookmark() {{{2 "handle the user activating a bookmark function! s:activateBookmark(bm) - call a:bm.activate() + call a:bm.activate(!a:bm.path.isDirectory ? {'split': 'p'} : {}) endfunction "FUNCTION: s:bindMappings() {{{2 @@ -3821,12 +3851,15 @@ function! s:bindMappings() call NERDTreeAddKeyMap({ 'key': 'middlerelease', 'scope': "all", 'callback': s."handleMiddleMouse" }) call NERDTreeAddKeyMap({ 'key': 'leftrelease', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Node", 'callback': s."activateNode" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "FileNode", 'callback': s."activateFileNode" }) call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Bookmark", 'callback': s."activateBookmark" }) call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "all", 'callback': s."activateAll" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Node", 'callback': s."activateNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" @@ -4108,7 +4141,7 @@ function! s:openBookmark(name) if targetNode.path.isDirectory call targetNode.openExplorer() else - call targetNode.open() + call targetNode.open({'split': 'p'}) endif endfunction @@ -4148,7 +4181,7 @@ endfunction "FUNCTION: s:previewNodeCurrent(node) {{{2 function! s:previewNodeCurrent(node) - call a:node.open({'stay': 1}) + call a:node.open({'stay': 1, 'split': 'p'}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{2 From 3b325f6812ed035122797b98fa5c9a6a14ceccd1 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 9 Jan 2012 16:22:07 +0000 Subject: [PATCH 051/680] rename 'split' to 'where' in the open() interface --- plugin/NERD_tree.vim | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index f86e378b..c88f3932 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -382,9 +382,9 @@ endfunction " FUNCTION: Bookmark.open([options]) {{{3 "Args: "A dictionary containing the following keys (all optional): -" 'split': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' or 'h' or 't' (for open in -" new tab) +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' (vertical split), 'h' +" (horizontal split), 't' (new tab) or 'p' (previous window). " 'reuse': if a window is displaying the file then jump the cursor there " 'keepopen': dont close the tree window " 'stay': open the file, but keep the cursor in the tree win @@ -392,7 +392,7 @@ endfunction function! s:Bookmark.open(...) let opts = a:0 ? a:1 : {} - if self.path.isDirectory && !has_key(opts, 'split') + if self.path.isDirectory && !has_key(opts, 'where') call self.toRoot() else let opener = s:Opener.New(self.path, opts) @@ -1227,18 +1227,18 @@ endfunction "Open this node in a new window function! s:TreeFileNode.openSplit() call s:deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') - call self.open({'split': 'h'}) + call self.open({'where': 'h'}) endfunction "FUNCTION: TreeFileNode.openVSplit() {{{3 "Open this node in a new vertical window function! s:TreeFileNode.openVSplit() call s:deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') - call self.open({'split': 'v'}) + call self.open({'where': 'v'}) endfunction "FUNCTION: TreeFileNode.openInNewTab(options) {{{3 function! s:TreeFileNode.openInNewTab(options) echomsg 'TreeFileNode.openInNewTab is deprecated' - call self.open(extend({'split': 't'}, a:options)) + call self.open(extend({'where': 't'}, a:options)) endfunction "FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 "Places the cursor on the line number this node is rendered on @@ -1666,7 +1666,7 @@ endfunction "Args: " "A dictionary containing the following keys (all optional): -" 'split': 't' if the tree should be opened in a new tab +" 'where': 't' if the tree should be opened in a new tab " 'keepopen': dont close the tree window " 'stay': open the file, but keep the cursor in the tree win " @@ -1674,7 +1674,7 @@ unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) let opts = a:0 ? a:1 : {} - if has_key(opts, 'split') && !empty(opts['split']) + if has_key(opts, 'where') && !empty(opts['where']) let opener = s:Opener.New(self.path, opts) call opener.open(self) else @@ -1691,12 +1691,12 @@ endfunction " opens an explorer window for this node in the previous window (could be a " nerd tree or a netrw) function! s:TreeDirNode.openExplorer() - call self.open({'split': 'p'}) + call self.open({'where': 'p'}) endfunction "FUNCTION: TreeDirNode.openInNewTab(options) {{{3 function! s:TreeDirNode.openInNewTab(options) call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') - call self.open({'split': 't'}) + call self.open({'where': 't'}) endfunction "FUNCTION: TreeDirNode._openInNewTab() {{{3 function! s:TreeDirNode._openInNewTab() @@ -1875,22 +1875,22 @@ let s:Opener = {} "FUNCTION: Opener._gotoTargetWin() {{{3 function! s:Opener._gotoTargetWin() if b:NERDTreeType ==# "secondary" - if self._split == 'v' + if self._where == 'v' vsplit - elseif self._split == 'h' + elseif self._where == 'h' split - elseif self._split == 't' + elseif self._where == 't' tabnew endif else - if self._split == 'v' + if self._where == 'v' call self._newVSplit() - elseif self._split == 'h' + elseif self._where == 'h' call self._newSplit() - elseif self._split == 't' + elseif self._where == 't' tabnew - elseif self._split == 'p' + elseif self._where == 'p' call self._previousWindow() endif endif @@ -1904,7 +1904,7 @@ endfunction "a:opts: " "A dictionary containing the following keys (all optional): -" 'split': Specifies whether the node should be opened in new split/tab or in +" 'where': Specifies whether the node should be opened in new split/tab or in " the previous window. Can be either 'v' or 'h' or 't' (for open in " new tab) " 'reuse': if a window is displaying the file then jump the cursor there @@ -1917,7 +1917,7 @@ function! s:Opener.New(path, opts) let newObj._stay = s:has_opt(a:opts, 'stay') let newObj._reuse = s:has_opt(a:opts, 'reuse') let newObj._keepopen = s:has_opt(a:opts, 'keepopen') - let newObj._split = has_key(a:opts, 'split') ? a:opts['split'] : '' + let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' call newObj._saveCursorPos() return newObj @@ -2038,11 +2038,11 @@ function! s:Opener._openDirectory(node) call s:initNerdTreeInPlace(a:node.path.str()) else call self._gotoTargetWin() - if empty(self._split) + if empty(self._where) call a:node.makeRoot() call s:renderView() call a:node.putCursorHere(0, 0) - elseif self._split == 't' + elseif self._where == 't' call s:initNerdTree(a:node.path.str()) else call s:initNerdTreeInPlace(a:node.path.str()) @@ -3836,13 +3836,13 @@ endfunction "FUNCTION: s:activateFileNode() {{{2 "handle the user activating a tree node function! s:activateFileNode(node) - call a:node.activate({'reuse': 1, 'split': 'p'}) + call a:node.activate({'reuse': 1, 'where': 'p'}) endfunction "FUNCTION: s:activateBookmark() {{{2 "handle the user activating a bookmark function! s:activateBookmark(bm) - call a:bm.activate(!a:bm.path.isDirectory ? {'split': 'p'} : {}) + call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) endfunction "FUNCTION: s:bindMappings() {{{2 @@ -4082,7 +4082,7 @@ function! s:handleMiddleMouse() if curNode.path.isDirectory call s:openExplorer(curNode) else - call curNode.open({'split': 'h'}) + call curNode.open({'where': 'h'}) endif endfunction @@ -4141,18 +4141,18 @@ function! s:openBookmark(name) if targetNode.path.isDirectory call targetNode.openExplorer() else - call targetNode.open({'split': 'p'}) + call targetNode.open({'where': 'p'}) endif endfunction " FUNCTION: s:openHSplit(target) {{{2 function! s:openHSplit(target) - call a:target.activate({'split': 'h'}) + call a:target.activate({'where': 'h'}) endfunction " FUNCTION: s:openVSplit(target) {{{2 function! s:openVSplit(target) - call a:target.activate({'split': 'v'}) + call a:target.activate({'where': 'v'}) endfunction " FUNCTION: s:openExplorer(node) {{{2 @@ -4162,12 +4162,12 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{2 function! s:openInNewTab(target) - call a:target.activate({'split': 't'}) + call a:target.activate({'where': 't'}) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{2 function! s:openInNewTabSilent(target) - call a:target.activate({'split': 't', 'stayInCurrentTab': 1}) + call a:target.activate({'where': 't', 'stayInCurrentTab': 1}) endfunction " FUNCTION: s:openNodeRecursively(node) {{{2 @@ -4181,17 +4181,17 @@ endfunction "FUNCTION: s:previewNodeCurrent(node) {{{2 function! s:previewNodeCurrent(node) - call a:node.open({'stay': 1, 'split': 'p'}) + call a:node.open({'stay': 1, 'where': 'p'}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{2 function! s:previewNodeHSplit(node) - call a:node.open({'stay': 1, 'split': 'h'}) + call a:node.open({'stay': 1, 'where': 'h'}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{2 function! s:previewNodeVSplit(node) - call a:node.open({'stay': 1, 'split': 'v'}) + call a:node.open({'stay': 1, 'where': 'v'}) endfunction From 5e53df769d5cd0fe2ac6179242daf6c5bd60c056 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 9 Jan 2012 16:25:13 +0000 Subject: [PATCH 052/680] fix a bug with the T (open in new tab silently) mapping --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c88f3932..8ab3d891 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -4167,7 +4167,7 @@ endfunction " FUNCTION: s:openInNewTabSilent(target) {{{2 function! s:openInNewTabSilent(target) - call a:target.activate({'where': 't', 'stayInCurrentTab': 1}) + call a:target.activate({'where': 't', 'stay': 1}) endfunction " FUNCTION: s:openNodeRecursively(node) {{{2 From 6b7c9aa5c84a8b1d513599fd236df5c0772ff8c8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 9 Jan 2012 16:30:06 +0000 Subject: [PATCH 053/680] update the method comment for TreeDirNode.open --- plugin/NERD_tree.vim | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8ab3d891..4afb0c70 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1663,13 +1663,7 @@ endfunction "FUNCTION: TreeDirNode.open([opts]) {{{3 "Open the dir in the current tree or in a new tree elsewhere. " -"Args: -" -"A dictionary containing the following keys (all optional): -" 'where': 't' if the tree should be opened in a new tab -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win -" +"If opening in the current tree, return the number of cached nodes. unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) let opts = a:0 ? a:1 : {} From 588e71c1e986f9a60dc40faf5b41c8ef7f94e8db Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 09:09:38 +0000 Subject: [PATCH 054/680] unlet TreeDirNode.openInNewTab since we are overriding it Older versions of vim require you to unlet a dictionary function if you are replacing it (i.e. overriding it in a prototype OO scenario). The unlet call got lost in the recent refactoring. --- plugin/NERD_tree.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 4afb0c70..82af7a4e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1688,6 +1688,7 @@ function! s:TreeDirNode.openExplorer() call self.open({'where': 'p'}) endfunction "FUNCTION: TreeDirNode.openInNewTab(options) {{{3 +unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') call self.open({'where': 't'}) From 6782ec01047fc5ee48599932d72fb4c0961671d1 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 13:06:15 +0000 Subject: [PATCH 055/680] make the default keymap generation happen only once Previously we are doing this every time a nerdtree window was created - which is wrong and was removing custom mappings from users that overrode default key mappings. Now we only generate the defaults once. --- plugin/NERD_tree.vim | 139 ++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 82af7a4e..2bac9183 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2821,6 +2821,76 @@ endfunction function! s:completeBookmarks(A,L,P) return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction +" FUNCTION: s:createDefaultBindings() {{{2 +function! s:createDefaultBindings() + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': 'middlerelease', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': 'leftrelease', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "all", 'callback': s."activateAll" }) + + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) + +endfunction " FUNCTION: s:deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message @@ -3034,6 +3104,7 @@ endfunction " FUNCTION: s:postSourceActions() {{{2 function! s:postSourceActions() call s:Bookmark.CacheBookmarks(0) + call s:createDefaultBindings() "load all nerdtree plugins runtime! nerdtree_plugin/**/*.vim @@ -3842,74 +3913,6 @@ endfunction "FUNCTION: s:bindMappings() {{{2 function! s:bindMappings() - let s = '' . s:SID() . '_' - - call NERDTreeAddKeyMap({ 'key': 'middlerelease', 'scope': "all", 'callback': s."handleMiddleMouse" }) - call NERDTreeAddKeyMap({ 'key': 'leftrelease', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "all", 'callback': s."activateAll" }) - - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Node", 'callback': s."activateNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) - exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) - "bind all the user custom maps call s:KeyMap.BindAll() From 53bc77644c8149ae995918b9d6f544cc31813346 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 13:08:08 +0000 Subject: [PATCH 056/680] refactor KeyMap so we dont use index() on an array of objects Dont do `remove(array_of_prototype_obs, index(...)))`. In the past this has been found to cause seg faults when the objects get large. --- plugin/NERD_tree.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2bac9183..9fd56589 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -520,6 +520,15 @@ function! s:KeyMap.bind() exec 'nnoremap '. mapkey . premap . ':call KeyMap_Invoke("'. self.key .'")' endfunction +"FUNCTION: KeyMap.Remove(key, scope) {{{3 +function! s:KeyMap.Remove(key, scope) + let maps = s:KeyMap.All() + for i in range(len(maps)) + if maps[i].key ==# a:key && maps[i].scope ==# a:scope + return remove(maps, i) + endif + endfor +endfunction "FUNCTION: KeyMap.invoke() {{{3 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) @@ -606,11 +615,7 @@ endfunction "FUNCTION: KeyMap.Add(keymap) {{{3 function! s:KeyMap.Add(keymap) - let oldmap = s:KeyMap.FindFor(a:keymap.key, a:keymap.scope) - if !empty(oldmap) - call remove(s:KeyMap.All(), index(s:KeyMap.All(), oldmap)) - endif - + call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) call add(s:KeyMap.All(), a:keymap) endfunction From e51a40c0d8294131510b77c89ccaa348a59bc5a7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 13:44:19 +0000 Subject: [PATCH 057/680] make the mouse work as expected with NERDTreeMouseMode This was broken at some point - fix it. --- plugin/NERD_tree.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 9fd56589..4b0614c6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -151,7 +151,7 @@ let s:NERDTreeBufName = 'NERD_tree_' let s:tree_wid = 2 if g:NERDTreeDirArrows - let s:tree_markup_reg = '^ *\([▾▸] \)\?' + let s:tree_markup_reg = '^\([▾▸] \| \+[▾▸] \| \+\)' else let s:tree_markup_reg = '^[ `|]*[\-+~]' endif @@ -4058,8 +4058,8 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$' - call s:activateNode(currentNode) + if startToCur =~# s:tree_markup_reg && startToCur =~# '[+~▾▸] \?$' + call currentNode.activate() return endif endif @@ -4067,7 +4067,11 @@ function! s:handleLeftClick() if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 let char = strpart(startToCur, strlen(startToCur)-1, 1) if char !~# s:tree_markup_reg - call s:activateNode(currentNode) + if currentNode.path.isDirectory + call currentNode.activate() + else + call currentNode.activate({'reuse': 1, 'where': 'p'}) + endif return endif endif From 6d83575490e006f1c926c3bef2c9f07910a5ffb5 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 13:46:46 +0000 Subject: [PATCH 058/680] remove a now misleading comment --- plugin/NERD_tree.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 4b0614c6..2e8493e6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3918,7 +3918,6 @@ endfunction "FUNCTION: s:bindMappings() {{{2 function! s:bindMappings() - "bind all the user custom maps call s:KeyMap.BindAll() command! -buffer -nargs=? Bookmark :call bookmarkNode('') From 5c01c5acd8b7dca981efe806e452f04be6f2fd9a Mon Sep 17 00:00:00 2001 From: Twinside Date: Wed, 11 Jan 2012 15:20:57 +0100 Subject: [PATCH 059/680] Deactivating folds in NERDtree buffer --- plugin/NERD_tree.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2e8493e6..11272d85 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3793,6 +3793,8 @@ function! s:setCommonBufOptions() setlocal bufhidden=hide setlocal nowrap setlocal foldcolumn=0 + setlocal foldmethod=manual + setlocal nofoldenable setlocal nobuflisted setlocal nospell if g:NERDTreeShowLineNumbers From 6d0183ea782e8a35587448368f2dd82c6b3323e5 Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Wed, 11 Jan 2012 09:31:03 -0500 Subject: [PATCH 060/680] Revert "Fixed resolve() double endslash defect" This reverts commit bc745b6e99888c97c7e8f6ff3b7e8f605cab5af1. This broke symlink detection on systems where vim's resolve() removes the trailing slash from a path. --- plugin/NERD_tree.vim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2e8493e6..79302b8a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2555,7 +2555,7 @@ function! s:Path.readInfoFromDisk(fullpath) let lastPathComponent = self.getLastPathComponent(0) "get the path to the new node with the parent dir fully resolved - let hardPath = resolve(self.strTrunk()) . lastPathComponent + let hardPath = resolve(self.strTrunk()) . '/' . lastPathComponent "if the last part of the path is a symlink then flag it as such let self.isSymLink = (resolve(hardPath) != hardPath) @@ -2733,13 +2733,9 @@ function! s:Path._str() endfunction "FUNCTION: Path.strTrunk() {{{3 -"Gets the path without the last segment on the end, always with an endslash +"Gets the path without the last segment on the end. function! s:Path.strTrunk() - let toReturn = self.drive . '/' . join(self.pathSegments[0:-2], '/') - if toReturn !~# '\/$' - let toReturn .= '/' - endif - return toReturn + return self.drive . '/' . join(self.pathSegments[0:-2], '/') endfunction " FUNCTION: Path.tabnr() {{{3 From ba74b99fd716b62e4073a1c23d62e0a3a4bc34de Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Wed, 11 Jan 2012 10:55:39 -0500 Subject: [PATCH 061/680] Add s:Path.Resolve function to address trailing slash issues. The core issue is that in some versions of vim resolve() will remove trailing slashes, while in others it will not. This lead to commit bc745b6e99888c97c7e8f6ff3b7e8f605cab5af1 attempting to address a double slash problem. However, that broke symlink detection on systems where resolve() removes trailing slashes. This new function just calls vim's resolve() function, but removes trailing slashes if they exist. --- plugin/NERD_tree.vim | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 79302b8a..7abafb0e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2521,6 +2521,16 @@ function! s:Path.Slash() return s:running_windows ? '\' : '/' endfunction +"FUNCTION: Path.Resolve() {{{3 +"Invoke the vim resolve() function and return the result +"This is necessary because in some versions of vim resolve() removes trailing +"slashes while in other versions it doesn't. This always removes the trailing +"slash +function! s:Path.Resolve(path) + let tmp = resolve(a:path) + return tmp =~# '/$' ? substitute(tmp, '/$', '', '') : tmp +endfunction + "FUNCTION: Path.readInfoFromDisk(fullpath) {{{3 " " @@ -2555,12 +2565,12 @@ function! s:Path.readInfoFromDisk(fullpath) let lastPathComponent = self.getLastPathComponent(0) "get the path to the new node with the parent dir fully resolved - let hardPath = resolve(self.strTrunk()) . '/' . lastPathComponent + let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent "if the last part of the path is a symlink then flag it as such - let self.isSymLink = (resolve(hardPath) != hardPath) + let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) if self.isSymLink - let self.symLinkDest = resolve(fullpath) + let self.symLinkDest = s:Path.Resolve(fullpath) "if the link is a dir then slap a / on the end of its dest if isdirectory(self.symLinkDest) @@ -2971,7 +2981,7 @@ function! s:initNerdTree(name) if dir =~# '^\.' let dir = getcwd() . s:Path.Slash() . dir endif - let dir = resolve(dir) + let dir = s:Path.Resolve(dir) try let path = s:Path.New(dir) From b843635a502193272bf60584ada39235847f5cdb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 19:53:04 +0000 Subject: [PATCH 062/680] fix NERDTreeQuitOnOpen option --- plugin/NERD_tree.vim | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 11272d85..4932c119 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1872,6 +1872,25 @@ endfunction "CLASS: Opener {{{2 "============================================================ let s:Opener = {} + +"FUNCTION: Opener._checkToCloseTree(newtab) {{{3 +"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see +"if the tree should be closed now. +" +"Args: +"a:newtab - boolean. If set, only close the tree now if we are opening the +"target in a new tab. This is needed because we have to close tree before we +"leave the tab +function! s:Opener._checkToCloseTree(newtab) + if self._keepopen + return + endif + + if (a:newtab && self._where == 't') || !a:newtab + call s:closeTreeIfQuitOnOpen() + endif +endfunction + "FUNCTION: Opener._gotoTargetWin() {{{3 function! s:Opener._gotoTargetWin() if b:NERDTreeType ==# "secondary" @@ -1883,6 +1902,7 @@ function! s:Opener._gotoTargetWin() tabnew endif else + call self._checkToCloseTree(1) if self._where == 'v' call self._newVSplit() @@ -1893,6 +1913,8 @@ function! s:Opener._gotoTargetWin() elseif self._where == 'p' call self._previousWindow() endif + + call self._checkToCloseTree(0) endif endfunction @@ -1918,6 +1940,7 @@ function! s:Opener.New(path, opts) let newObj._reuse = s:has_opt(a:opts, 'reuse') let newObj._keepopen = s:has_opt(a:opts, 'keepopen') let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' + let newObj._treetype = b:NERDTreeType call newObj._saveCursorPos() return newObj @@ -2014,16 +2037,13 @@ function! s:Opener._openFile() return endif - if b:NERDTreeType ==# "secondary" - call self._gotoTargetWin() + call self._gotoTargetWin() + + if self._treetype ==# "secondary" call self._path.edit() else - call self._gotoTargetWin() call self._path.edit() - if self._keepopen - call s:closeTreeIfQuitOnOpen() - endif if self._stay call self._restoreCursorPos() @@ -2033,7 +2053,7 @@ endfunction "FUNCTION: Opener._openDirectory(node) {{{3 function! s:Opener._openDirectory(node) - if b:NERDTreeType ==# "secondary" + if self._treetype ==# "secondary" call self._gotoTargetWin() call s:initNerdTreeInPlace(a:node.path.str()) else @@ -2086,11 +2106,13 @@ function! s:Opener._reuseWindow() let winnr = bufwinnr('^' . self._path.str() . '$') if winnr != -1 call s:exec(winnr . "wincmd w") + call self._checkToCloseTree(0) return 1 else "check other tabs let tabnr = self._path.tabnr() if tabnr + call self._checkToCloseTree(1) call s:exec('normal! ' . tabnr . 'gt') let winnr = bufwinnr('^' . self._path.str() . '$') call s:exec(winnr . "wincmd w") From e5682d3948b8d11bc020392746fb79b816672240 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 19:55:27 +0000 Subject: [PATCH 063/680] dont close the tree window when using the 'preview' maps --- plugin/NERD_tree.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 4932c119..685f9d16 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -4211,20 +4211,19 @@ endfunction "FUNCTION: s:previewNodeCurrent(node) {{{2 function! s:previewNodeCurrent(node) - call a:node.open({'stay': 1, 'where': 'p'}) + call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{2 function! s:previewNodeHSplit(node) - call a:node.open({'stay': 1, 'where': 'h'}) + call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{2 function! s:previewNodeVSplit(node) - call a:node.open({'stay': 1, 'where': 'v'}) + call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) endfunction - " FUNCTION: s:revealBookmark(name) {{{2 " put the cursor on the node associate with the given name function! s:revealBookmark(name) From 20f7ab8adec793db96e551de742f7b4f04f4bcd5 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 Jan 2012 20:03:56 +0000 Subject: [PATCH 064/680] map to the default o mapping (again) this was broken in one of the recent "epic refactor" commits --- plugin/NERD_tree.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 685f9d16..cbe5cc0b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2864,7 +2864,6 @@ function! s:createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) - exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) @@ -3942,6 +3941,9 @@ endfunction "FUNCTION: s:bindMappings() {{{2 function! s:bindMappings() + "make do the same as the default 'o' mapping + exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" + call s:KeyMap.BindAll() command! -buffer -nargs=? Bookmark :call bookmarkNode('') From 597cccce0f94f932592de1729367f3d19f1a5e1d Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Wed, 25 Jan 2012 15:57:41 -0500 Subject: [PATCH 065/680] Add calls to NERDTreeAddKeyMap for previewing Bookmarks These calls to NERDTreeAddKeyMap use the same callback as when these keys are mapped with a 'scope' of "Node." This should not pose a problem though as s:previewNodeCurrent, s:previewNodeHSplit and s:previewNodeVSplit all just call the passed in node's open() method, which gets passed on to an Opener object. --- plugin/NERD_tree.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 20507855..bc3de5e6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2881,6 +2881,10 @@ function! s:createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) From f29d6a4f0ffda654e620bf9606357f807867c332 Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Thu, 26 Jan 2012 16:50:55 -0500 Subject: [PATCH 066/680] Escape mappings that use '<>' notation. KeyMap.bind() does not gracefully handle use of '<>' notation. For example, trying to call NERDTreeAddKeyMap() with a 'key' argument of 'e'. There were some workarounds KeyMap.bind() to help with this by specifically allowing you to leave off the '<>' parts for '', '' and mouse mappings and it would add them back for you before creating the mapping. This commit reverts some of that logic and simply says that if the key starts with '<', replace it with . --- plugin/NERD_tree.vim | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 20507855..c1d6fe66 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -510,14 +510,18 @@ endfunction "FUNCTION: KeyMap.bind() {{{3 function! s:KeyMap.bind() - let mapkey = self.key - if mapkey =~? '^\([CM]-\|middlerelease\|2-leftmouse\|leftrelease\)' - let mapkey = '<' . mapkey . '>' + " If the key we're trying to map is a special key we must escape the + " leading '<', otherwise vim will replace it with the actual keycode + " :he <> + if self.key =~# '^<' + let keymapInvokeString = substitute(self.key, '^<', '', '') + else + let keymapInvokeString = self.key endif - let premap = self.key == "leftrelease" ? " " : " " + let premap = self.key == "" ? " " : " " - exec 'nnoremap '. mapkey . premap . ':call KeyMap_Invoke("'. self.key .'")' + exec 'nnoremap '. self.key . premap . ':call KeyMap_Invoke("'. keymapInvokeString .'")' endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{3 @@ -2858,12 +2862,12 @@ endfunction function! s:createDefaultBindings() let s = '' . s:SID() . '_' - call NERDTreeAddKeyMap({ 'key': 'middlerelease', 'scope': "all", 'callback': s."handleMiddleMouse" }) - call NERDTreeAddKeyMap({ 'key': 'leftrelease', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '2-leftmouse', 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) From 7fbb77c0675b1cea9efbfa2852feb8a3a7c12ac7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Jan 2012 23:59:07 +0000 Subject: [PATCH 067/680] fix the ctrl-j/ctrl-k mappings --- plugin/NERD_tree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c1d6fe66..1c2131a1 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -116,9 +116,9 @@ call s:initVariable("g:NERDTreeMapMenu", "m") call s:initVariable("g:NERDTreeMapHelp", "?") call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") call s:initVariable("g:NERDTreeMapJumpLastChild", "J") -call s:initVariable("g:NERDTreeMapJumpNextSibling", "C-j") +call s:initVariable("g:NERDTreeMapJumpNextSibling", "") call s:initVariable("g:NERDTreeMapJumpParent", "p") -call s:initVariable("g:NERDTreeMapJumpPrevSibling", "C-k") +call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") call s:initVariable("g:NERDTreeMapJumpRoot", "P") call s:initVariable("g:NERDTreeMapOpenExpl", "e") call s:initVariable("g:NERDTreeMapOpenInTab", "t") From 30cc73d6edba303f3c32ec8210b1d7bbe3e21460 Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Fri, 27 Jan 2012 00:12:33 -0500 Subject: [PATCH 068/680] Make handling of '<>' notation more robust. Previous case could fail with something like ''. Cases like that should be handled correctly now. --- plugin/NERD_tree.vim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 1c2131a1..a0d9127b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -510,11 +510,14 @@ endfunction "FUNCTION: KeyMap.bind() {{{3 function! s:KeyMap.bind() - " If the key we're trying to map is a special key we must escape the - " leading '<', otherwise vim will replace it with the actual keycode + " If the key sequence we're trying to map contains any '<>' notation, we + " must replace each of the '<' characters with '' to ensure the string + " is not translated into its corresponding keycode during the later part + " of the map command below " :he <> - if self.key =~# '^<' - let keymapInvokeString = substitute(self.key, '^<', '', '') + let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)' + if self.key =~# specialNotationRegex + let keymapInvokeString = substitute(self.key, specialNotationRegex, '\1', 'g') else let keymapInvokeString = self.key endif From ff0816979cfa267ae15855dddf8564f2c2559281 Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Tue, 14 Feb 2012 12:38:23 +0200 Subject: [PATCH 069/680] Remove second "edit" from Opener --- plugin/NERD_tree.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a0d9127b..a9d6ccac 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2088,7 +2088,6 @@ function! s:Opener._previousWindow() else call s:exec('wincmd p') endif - exec ("edit " . self._path.str({'format': 'Edit'})) catch /^Vim\%((\a\+)\)\=:E37/ call s:putCursorInTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." From 71465f79b157d09bc0f7c6033f47695eae8f429d Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Tue, 14 Feb 2012 12:38:52 +0200 Subject: [PATCH 070/680] Don't output a message on opening a file node --- plugin/NERD_tree.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a9d6ccac..b8b894bf 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1229,7 +1229,6 @@ endfunction "FUNCTION: TreeFileNode.open() {{{3 function! s:TreeFileNode.open(...) - echomsg self.path.str() let opts = a:0 ? a:1 : {} let opener = s:Opener.New(self.path, opts) call opener.open(self) From 0b3b8f78331b14956fbc54d9b00d5bbad96ebea5 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 16 Feb 2012 16:11:44 +0000 Subject: [PATCH 071/680] add NERDTreeFocus function --- plugin/NERD_tree.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b8b894bf..e11bbeb9 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3254,6 +3254,14 @@ function! NERDTreeRender() call s:renderView() endfunction +function! NERDTreeFocus() + if s:isTreeOpen() + call s:putCursorInTreeWin() + else + call s:toggle("") + endif +endfunction + " SECTION: View Functions {{{1 "============================================================ "FUNCTION: s:centerView() {{{2 From aa1e7d642f6309576b8d283b5de43b0b0a44483d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 16 Feb 2012 16:31:50 +0000 Subject: [PATCH 072/680] fix previewing of directory nodes Previously if we used the gi/gs mappings on a dir node/bookmark the cursor would end up in the new window. Now it stays in the current window as expected --- plugin/NERD_tree.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 78885c08..b21804c3 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2074,6 +2074,10 @@ function! s:Opener._openDirectory(node) call s:initNerdTreeInPlace(a:node.path.str()) endif endif + + if self._stay + call self._restoreCursorPos() + endif endfunction "FUNCTION: Opener._previousWindow() {{{3 From 678bb2816874d92bca4eea46e0f5f40a15ddab68 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 17 Feb 2012 15:31:37 +0000 Subject: [PATCH 073/680] add NERDTreeFocus command - calls the NERDTreeFocus() function --- plugin/NERD_tree.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b21804c3..3ec87a00 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -169,6 +169,7 @@ command! -n=0 -bar NERDTreeClose :call s:closeTreeIfOpen() command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark call s:initNerdTree('') command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror() command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() +command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() " SECTION: Auto commands {{{1 "============================================================ augroup NERDTree From 94b2db2de6fb3f4d72cca3b506ad6074fbafc63b Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Sat, 17 Mar 2012 09:35:16 -0400 Subject: [PATCH 074/680] Replace virtcol() with len() in handleLeftClick(). When 'virtualedit' is set, the column where the cursor resides can no longer be relied on for determining the number of elements in the 'line' list for iterating. Replacing virtcol() with len() seems to work correctly and not result in E684 errors. Fixes Issue #144 --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3ec87a00..a2e88ead 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -4106,7 +4106,7 @@ function! s:handleLeftClick() "take the line substring manually let line = split(getline(line(".")), '\zs') let startToCur = "" - for i in range(0,virtcol(".")-1) + for i in range(0,len(line)-1) let startToCur .= line[i] endfor From 2cb0fc78fb4c7a1db5f51c042a447cc50f09983d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 2 Apr 2012 14:51:19 +0100 Subject: [PATCH 075/680] add autocmds for fugitive integration Add 2 autocmds - NERDTreeInit and NERDTreeNewRoot. These are called when a tree is created and when the root is changed. The goal is to give the fugitive plugin something to listen for so it can add the G* commands to nerdtree buffers in git repo dirs. --- plugin/NERD_tree.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3ec87a00..05c4b462 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1211,6 +1211,8 @@ function! s:TreeFileNode.makeRoot() if g:NERDTreeChDirMode ==# 2 exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'}) endif + + silent doautocmd User NERDTreeNewRoot endfunction "FUNCTION: TreeFileNode.New(path) {{{3 "Returns a new TreeNode object with the given path and parent @@ -3052,11 +3054,12 @@ function! s:initNerdTree(name) let b:NERDTreeShowHidden = g:NERDTreeShowHidden let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks let b:NERDTreeRoot = newRoot - let b:NERDTreeType = "primary" call s:renderView() call b:NERDTreeRoot.putCursorHere(0, 0) + + silent doautocmd User NERDTreeInit endfunction "FUNCTION: s:initNerdTreeInPlace(dir) {{{2 @@ -3086,6 +3089,8 @@ function! s:initNerdTreeInPlace(dir) let b:NERDTreeType = "secondary" call s:renderView() + + silent doautocmd User NERDTreeInit endfunction " FUNCTION: s:initNerdTreeMirror() {{{2 function! s:initNerdTreeMirror() From 121607b351cd5c72d781630f2e76f1b633e79df6 Mon Sep 17 00:00:00 2001 From: "A.G. Russell Knives" Date: Thu, 14 Jun 2012 09:57:24 -0500 Subject: [PATCH 076/680] ignore wildignore setting --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 05c4b462..b3daada4 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1617,7 +1617,7 @@ function! s:TreeDirNode._initChildren(silent) "get an array of all the files in the nodes dir let dir = self.path let globDir = dir.str({'format': 'Glob'}) - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + let filesStr = globpath(globDir, '*',1) . "\n" . globpath(globDir, '.*',1) let files = split(filesStr, "\n") if !a:silent && len(files) > g:NERDTreeNotificationThreshold From 87208d210b0293fff61f864390b38da160e66f6d Mon Sep 17 00:00:00 2001 From: Frank S Date: Wed, 27 Jun 2012 20:07:52 -0700 Subject: [PATCH 077/680] Fixed typo. changing s:clearBoomarks to s:clearBookmarks. --- plugin/NERD_tree.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 05c4b462..5a698c2f 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -969,8 +969,8 @@ function! s:compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction -"FUNCTION: TreeFileNode.clearBoomarks() {{{3 -function! s:TreeFileNode.clearBoomarks() +"FUNCTION: TreeFileNode.clearBookmarks() {{{3 +function! s:TreeFileNode.clearBookmarks() for i in s:Bookmark.Bookmarks() if i.path.equals(self.path) call i.delete() @@ -4031,7 +4031,7 @@ function! s:clearBookmarks(bookmarks) if a:bookmarks ==# '' let currentNode = s:TreeFileNode.GetSelected() if currentNode != {} - call currentNode.clearBoomarks() + call currentNode.clearBookmarks() endif else for name in split(a:bookmarks, ' ') From 29e687978b0dc5ce006e74fa0917f8c229b4ecc1 Mon Sep 17 00:00:00 2001 From: pendulm Date: Thu, 5 Jul 2012 22:26:57 +0800 Subject: [PATCH 078/680] add option NERDTreeCasadeOpenSingleChildDir and function TreeDirNode.openAlong for Issues #179. --- doc/NERD_tree.txt | 18 ++++++++++++++++++ plugin/NERD_tree.vim | 29 ++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index a6a03905..e6c7404c 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -654,6 +654,10 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of + ~ chars when displaying directories. +|'NERDTreeCasadeOpenSingleChildDir'| + Casade open while selected directory has only + one child that also is a directory. + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* @@ -965,6 +969,20 @@ option: > let NERDTreeDirArrows=1 < +------------------------------------------------------------------------------ + *'NERDTreeCasadeOpenSingleChildDir'* +Values: 0 or 1 +Default: 0. + +This option tell NERDTree open the child directory if the selected opening +directory has only one child that is a directory, and do same to sub-directory +recursively. NERDTree will stop till it find a empty directory or this +directory has more than one child. This option may be useful for Java projects. +Use one of the follow lines to set this option: > + let NERDTreeCasadeOpenSingleChildDir=0 + let NERDTreeCasadeOpenSingleChildDir=1 +< + ============================================================================== 4. The NERD tree API *NERDTreeAPI* diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 212b71f0..78676306 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -69,6 +69,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) call s:initVariable("g:NERDTreeDirArrows", !s:running_windows) +call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 0) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] @@ -1694,7 +1695,26 @@ function! s:TreeDirNode.open(...) endif endif endfunction - +"FUNCTION: TreeDirNode.openAlong([opts]) {{{3 +"recursive open the dir if it has only one directory child. +" +"return the level of opened directories. +function! s:TreeDirNode.openAlong(...) + let opts = a:0 ? a:1 : {} + let level = 0 + + let node = self + while node.path.isDirectory + call node.open(opts) + let level += 1 + if node.getVisibleChildCount() == 1 + let node = node.getChildByIndex(0, 1) + else + break + endif + endwhile + return level +endfunction " FUNCTION: TreeDirNode.openExplorer() {{{3 " opens an explorer window for this node in the previous window (could be a " nerd tree or a netrw) @@ -1857,10 +1877,13 @@ function! s:TreeDirNode.toggleOpen(...) if self.isOpen ==# 1 call self.close() else - call self.open(opts) + if g:NERDTreeCasadeOpenSingleChildDir == 0 + call self.open(opts) + else + call self.openAlong(opts) + endif endif endfunction - "FUNCTION: TreeDirNode.transplantChild(newNode) {{{3 "Replaces the child of this with the given node (where the child node's full "path matches a:newNode's fullpath). The search for the matching node is From b64f4428c18c528cc21b7bd6fec41f33428f85c7 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 5 Jul 2012 15:51:13 +0100 Subject: [PATCH 079/680] default NERDTreeCasadeOpenSingleChildDir to 1 --- doc/NERD_tree.txt | 2 +- plugin/NERD_tree.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index e6c7404c..4915e0c8 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -972,7 +972,7 @@ option: > ------------------------------------------------------------------------------ *'NERDTreeCasadeOpenSingleChildDir'* Values: 0 or 1 -Default: 0. +Default: 1. This option tell NERDTree open the child directory if the selected opening directory has only one child that is a directory, and do same to sub-directory diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 78676306..60460251 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -69,7 +69,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) call s:initVariable("g:NERDTreeDirArrows", !s:running_windows) -call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 0) +call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] From a1433c485eb254838c1db52e087d5ec4d1e77cfd Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 5 Jul 2012 15:56:11 +0100 Subject: [PATCH 080/680] update the doc for NERDTreeCasadeOpenSingleChildDir --- doc/NERD_tree.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 4915e0c8..adcf5a54 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -974,11 +974,10 @@ option: > Values: 0 or 1 Default: 1. -This option tell NERDTree open the child directory if the selected opening -directory has only one child that is a directory, and do same to sub-directory -recursively. NERDTree will stop till it find a empty directory or this -directory has more than one child. This option may be useful for Java projects. -Use one of the follow lines to set this option: > +When opening dir nodes, this option tells NERDTree to recursively open dirs +that have only one child which is also a dir. NERDTree will stop when it finds +a dir that contains anything but another single dir. This option may be useful +for Java projects. Use one of the follow lines to set this option: > let NERDTreeCasadeOpenSingleChildDir=0 let NERDTreeCasadeOpenSingleChildDir=1 < From 0a16b24268cb0b597fd8ac815d0baf05d54ff560 Mon Sep 17 00:00:00 2001 From: ZeusTheTrueGod Date: Sun, 26 Aug 2012 08:51:26 +0000 Subject: [PATCH 081/680] Better flow for renaming and deleting files Previously when you delete or moved a file via md or mm commands the NERDTree was asking you about what to do with the remaining buffer of the just deleted or moved file. I always press 'y' in this cases so I've decided to add a new parameter, NERDTreeAutoDeleteBuffer which you can set to 1 in order to skip this confirmation. --- doc/NERD_tree.txt | 18 ++++++++++++++++++ nerdtree_plugin/fs_menu.vim | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index adcf5a54..e48bd38c 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -658,6 +658,10 @@ NERD tree. These options should be set in your vimrc. Casade open while selected directory has only one child that also is a directory. +|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove + a buffer when a file is being deleted or renamed + via a context menu command. + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* @@ -982,6 +986,20 @@ for Java projects. Use one of the follow lines to set this option: > let NERDTreeCasadeOpenSingleChildDir=1 < +------------------------------------------------------------------------------ + *'NERDTreeAutoDeleteBuffer'* +Values: 0 or 1 +Default: 0. + +When using a context menu to delete or rename a file you may also want to delete +the buffer which is no more valid. If the option is not set you will see a +confirmation if you really want to delete an old buffer. If you always press 'y' +then it worths to set this option to 1. Use one of the follow lines to set this +option: > + let NERDTreeAutoDeleteBuffer=0 + let NERDTreeAutoDeleteBuffer=1 +< + ============================================================================== 4. The NERD tree API *NERDTreeAPI* diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 0e2f7287..2fd38689 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -15,6 +15,11 @@ if exists("g:loaded_nerdtree_fs_menu") endif let g:loaded_nerdtree_fs_menu = 1 +"Automatically delete the buffer after deleting or renaming a file +if !exists("g:NERDTreeAutoDeleteBuffer") + let g:NERDTreeAutoDeleteBuffer = 0 +endif + call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) @@ -52,11 +57,10 @@ endfunction " del the buffer function! s:promptToDelBuffer(bufnum, msg) echo a:msg - if nr2char(getchar()) ==# 'y' + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' exec "silent bdelete! " . a:bufnum endif endfunction - "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() From 6b687977d955b3f0cfb26731652f98823b8907d8 Mon Sep 17 00:00:00 2001 From: ZeusTheTrueGod Date: Sun, 26 Aug 2012 13:19:52 +0000 Subject: [PATCH 082/680] Better handling file renaming and deleting If you are renaming a file via the mm hotkey and it is already opened then all tabs and windows containing the old file will be replaced with a new file. Current tab and windows structure is not changed anymore If you are deleting a file via the md hotkey and it is already open, i.e. presents in buffer lists then a buffer will be removed but a window and tab will be kept with a ':enew' file --- nerdtree_plugin/fs_menu.vim | 40 ++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 2fd38689..d5745d5b 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -58,7 +58,41 @@ endfunction function! s:promptToDelBuffer(bufnum, msg) echo a:msg if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum + " 1. ensure that all windows which display the just deleted filename + " now display an empty buffer (so a layout is preserved). + " Is not it better to close single tabs with this file only ? + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif" + exec "tabnext " . s:originalTabNumber + exec s:originalWindowNumber . "wincmd w" + " 3. We don't need a previous buffer anymore + exec "bwipeout! " . a:bufnum + endif +endfunction + +"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1 +"prints out the given msg and, if the user responds by pushing 'y' then the +"buffer with the given bufnum is replaced with a new one +" +"Args: +"bufnum: the buffer that may be deleted +"msg: a message that will be echoed to the user asking them if they wish to +" del the buffer +function! s:promptToRenameBuffer(bufnum, msg, newFileName) + echo a:msg + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + " 1. ensure that a new buffer is loaded + exec "badd " . a:newFileName + " 2. ensure that all windows which display the just deleted filename + " display a buffer for a new filename. + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . a:newFileName . "' | endif" + exec "tabnext " . s:originalTabNumber + exec s:originalWindowNumber . "wincmd w" + " 3. We don't need a previous buffer anymore + exec "bwipeout! " . a:bufnum endif endfunction "FUNCTION: NERDTreeAddNode(){{{1 @@ -112,8 +146,8 @@ function! NERDTreeMoveNode() "if the node is open in a buffer, ask the user if they want to "close that buffer if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:promptToDelBuffer(bufnum, prompt) + let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)" + call s:promptToRenameBuffer(bufnum, prompt, newNodePath) endif call curNode.putCursorHere(1, 0) From 92a31a6fb25d9866ddf243c154485b0a5744c6b4 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Wed, 3 Oct 2012 12:39:56 -0700 Subject: [PATCH 083/680] Fix typo in copy action --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 0e2f7287..f026d348 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -26,7 +26,7 @@ if has("gui_mac") || has("gui_macvim") endif if g:NERDTreePath.CopyingSupported() - call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) + call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif "FUNCTION: s:echo(msg){{{1 From 16268c9c21511ae1d2dcbc306266bb2daab49248 Mon Sep 17 00:00:00 2001 From: Joseph Thomson Date: Mon, 29 Oct 2012 16:30:29 +0000 Subject: [PATCH 084/680] Fix call to globpath() for Vim 7.2 and below. globpath() takes an extra optional parameter in Vim 7.3, but this breaks NERD tree on earlier versions. --- plugin/NERD_tree.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 88730bf1..ad1669f7 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1618,7 +1618,13 @@ function! s:TreeDirNode._initChildren(silent) "get an array of all the files in the nodes dir let dir = self.path let globDir = dir.str({'format': 'Glob'}) - let filesStr = globpath(globDir, '*',1) . "\n" . globpath(globDir, '.*',1) + + if version >= 703 + let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1) + else + let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + endif + let files = split(filesStr, "\n") if !a:silent && len(files) > g:NERDTreeNotificationThreshold From ce6c347f858fe013a4551b50b5722694caf7dd82 Mon Sep 17 00:00:00 2001 From: Techlive Zheng Date: Mon, 5 Nov 2012 01:19:44 +0800 Subject: [PATCH 085/680] Make NERDTreeFind work on hidden files --- plugin/NERD_tree.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ad1669f7..3e7c1bbc 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2999,6 +2999,11 @@ function! s:findAndRevealPath() return endtry + if p.getLastPathComponent(0) =~# '^\.' + let showhidden=g:NERDTreeShowHidden + let g:NERDTreeShowHidden = 1 + endif + if !s:treeExistsForTab() try let cwd = s:Path.New(getcwd()) @@ -3023,6 +3028,10 @@ function! s:findAndRevealPath() endif call s:putCursorInTreeWin() call b:NERDTreeRoot.reveal(p) + + if p.getLastPathComponent(0) =~# '^\.' + let g:NERDTreeShowHidden = showhidden + endif endfunction " FUNCTION: s:has_opt(options, name) {{{2 From c59ac8fba14bfd6d0ba3efe293f5d4a7f5507656 Mon Sep 17 00:00:00 2001 From: Techlive Zheng Date: Mon, 5 Nov 2012 01:21:53 +0800 Subject: [PATCH 086/680] Make NERDTreeFind use an existing NERDTree window --- plugin/NERD_tree.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3e7c1bbc..1a37c033 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3019,7 +3019,13 @@ function! s:findAndRevealPath() endif else if !p.isUnder(s:TreeFileNode.GetRootForTab().path) - call s:initNerdTree(p.getParent().str()) + if !s:isTreeOpen() + call s:createTreeWin() + else + call s:putCursorInTreeWin() + endif + let b:NERDTreeShowHidden = g:NERDTreeShowHidden + call s:chRoot(s:TreeDirNode.New(p.getParent())) else if !s:isTreeOpen() call s:toggle("") From 072d46880aa724e9a5370af7c262092fc41a016b Mon Sep 17 00:00:00 2001 From: Techlive Zheng Date: Mon, 5 Nov 2012 01:23:41 +0800 Subject: [PATCH 087/680] Add a NERDTreeCWD command to change tree root to CWD --- doc/NERD_tree.txt | 13 +++++++++++++ plugin/NERD_tree.vim | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index e48bd38c..47f34726 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -137,6 +137,10 @@ The following features and functionality are provided by the NERD tree: In any case, the current file is revealed and the cursor is placed on it. +:NERDTreeCWD *:NERDTreeCWD* + Change tree root to current directory. If no NERD tree exists for this + tab, a new tree will be opened. + ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* @@ -247,6 +251,7 @@ r.......Recursively refresh the current directory................|NERDTree-r| R.......Recursively refresh the current root.....................|NERDTree-R| m.......Display the NERD tree menu...............................|NERDTree-m| cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| +CD......Change tree root to the CWD..............................|NERDTree-CD| I.......Toggle whether hidden files displayed....................|NERDTree-I| f.......Toggle whether the file filters are used.................|NERDTree-f| @@ -514,6 +519,14 @@ Applies to: files and directories. Change vims current working directory to that of the selected node. +------------------------------------------------------------------------------ + *NERDTree-CD* +Default key: CD +Map option: NERDTreeMapCWD +Applies to: no restrictions. + +Change tree root to vims current working directory. + ------------------------------------------------------------------------------ *NERDTree-I* Default key: I diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ad1669f7..032809a9 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -140,6 +140,7 @@ call s:initVariable("g:NERDTreeMapToggleHidden", "I") call s:initVariable("g:NERDTreeMapToggleZoom", "A") call s:initVariable("g:NERDTreeMapUpdir", "u") call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") +call s:initVariable("g:NERDTreeMapCWD", "CD") "SECTION: Script level variable declaration{{{2 if s:running_windows @@ -171,6 +172,7 @@ command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror() command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() +command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() " SECTION: Auto commands {{{1 "============================================================ augroup NERDTree @@ -2936,6 +2938,8 @@ function! s:createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': s."chRootCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) @@ -3305,6 +3309,11 @@ function! NERDTreeFocus() endif endfunction +function! NERDTreeCWD() + call NERDTreeFocus() + call s:chRootCwd() +endfunction + " SECTION: View Functions {{{1 "============================================================ "FUNCTION: s:centerView() {{{2 @@ -3445,6 +3454,7 @@ function! s:dumpHelp() let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" let @h=@h."\" selected dir\n" + let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Tree filtering mappings~\n" @@ -4055,6 +4065,21 @@ function! s:chRoot(node) call b:NERDTreeRoot.putCursorHere(0, 0) endfunction +" FUNCTION: s:chRootCwd() {{{2 +" changes the current root to CWD +function! s:chRootCwd() + try + let cwd = s:Path.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call s:echo("current directory does not exist.") + return + endtry + if cwd.str() == s:TreeFileNode.GetRootForTab().path.str() + return + endif + call s:chRoot(s:TreeDirNode.New(cwd)) +endfunction + " FUNCTION: s:clearBookmarks(bookmarks) {{{2 function! s:clearBookmarks(bookmarks) if a:bookmarks ==# '' From 30a770aab0cacaea991a1b9ded1c9fdfbe8e5131 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 12 Nov 2012 09:55:50 +0000 Subject: [PATCH 088/680] add Path.isUnixHiddenFile and refactor to use it --- plugin/NERD_tree.vim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3e7c1bbc..31248969 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2486,6 +2486,13 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction + +"FUNCTION: Path.isUnixHiddenFile() {{{3 +"check for unix hidden files +function! s:Path.isUnixHiddenFile() + return self.getLastPathComponent(0) =~# '^\.' +endfunction + "FUNCTION: Path.ignore() {{{3 "returns true if this path should be ignored function! s:Path.ignore() @@ -2499,7 +2506,7 @@ function! s:Path.ignore() endif "dont show hidden files unless instructed to - if b:NERDTreeShowHidden ==# 0 && self.getLastPathComponent(0) =~# '^\.' + if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile() return 1 endif @@ -2999,7 +3006,7 @@ function! s:findAndRevealPath() return endtry - if p.getLastPathComponent(0) =~# '^\.' + if p.isUnixHiddenFile() let showhidden=g:NERDTreeShowHidden let g:NERDTreeShowHidden = 1 endif @@ -3029,7 +3036,7 @@ function! s:findAndRevealPath() call s:putCursorInTreeWin() call b:NERDTreeRoot.reveal(p) - if p.getLastPathComponent(0) =~# '^\.' + if p.isUnixHiddenFile() let g:NERDTreeShowHidden = showhidden endif endfunction From bb1390c0c7bf85ade6e119b69824501bf9db4555 Mon Sep 17 00:00:00 2001 From: Chris Perl Date: Mon, 10 Dec 2012 14:44:01 -0500 Subject: [PATCH 089/680] Fix s:Path.Resolve to it handles '/' properly --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 34f7fb7b..aefb56d9 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2600,7 +2600,7 @@ endfunction "slash function! s:Path.Resolve(path) let tmp = resolve(a:path) - return tmp =~# '/$' ? substitute(tmp, '/$', '', '') : tmp + return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp endfunction "FUNCTION: Path.readInfoFromDisk(fullpath) {{{3 From 154f7aae7b880264544eb1b6089ba1c5243789f1 Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Mon, 31 Dec 2012 16:15:55 -0200 Subject: [PATCH 090/680] Added a frequently asked question to README --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 19217ba4..60869dea 100644 --- a/README.markdown +++ b/README.markdown @@ -82,6 +82,10 @@ __Q. How can I open a NERDTree automatically when vim starts up if no files were A. Stick this in your vimrc `autocmd vimenter * if !argc() | NERDTree | endif` +__Q. How can I map a specific key or shortcut to open NERDTree?__ + +A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): `map :NERDTreeToggle` + __Q. How can I close vim if the only window left open is a NERDTree?__ A. Stick this in your vimrc: From fb4a5a116addead2b829a26fbc5aa481e50d84e9 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 01:08:06 +0000 Subject: [PATCH 091/680] decompose the giant NERD_tree.vim file * Move the classes out into `plugin/nerdtree/`. * Move the other functions out into `autoload/nerdtree.vim`. Stuff still to do: * extract out at least one view class from `autoload/nerdtree` - something like NERDTreeWindow * figure out which functions in autoload/nerdtree should be scoped to the script instead of public --- autoload/nerdtree.vim | 1623 ++++++++++ plugin/NERD_tree.vim | 4307 +-------------------------- plugin/nerdtree/bookmark.vim | 293 ++ plugin/nerdtree/key_map.vim | 147 + plugin/nerdtree/menu_controller.vim | 178 ++ plugin/nerdtree/menu_item.vim | 112 + plugin/nerdtree/opener.vim | 263 ++ plugin/nerdtree/path.vim | 695 +++++ plugin/nerdtree/tree_dir_node.vim | 513 ++++ plugin/nerdtree/tree_file_node.vim | 469 +++ 10 files changed, 4333 insertions(+), 4267 deletions(-) create mode 100644 autoload/nerdtree.vim create mode 100644 plugin/nerdtree/bookmark.vim create mode 100644 plugin/nerdtree/key_map.vim create mode 100644 plugin/nerdtree/menu_controller.vim create mode 100644 plugin/nerdtree/menu_item.vim create mode 100644 plugin/nerdtree/opener.vim create mode 100644 plugin/nerdtree/path.vim create mode 100644 plugin/nerdtree/tree_dir_node.vim create mode 100644 plugin/nerdtree/tree_file_node.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim new file mode 100644 index 00000000..b32edb27 --- /dev/null +++ b/autoload/nerdtree.vim @@ -0,0 +1,1623 @@ +if exists("g:loaded_nerdtree_autoload") + finish +endif +let g:loaded_nerdtree_autoload = 1 + +function! nerdtree#version() + return '4.2.0' +endfunction + +"the number to add to the nerd tree buffer name to make the buf name unique +let s:next_buffer_number = 1 + +" SECTION: General Functions {{{1 +"============================================================ +"FUNCTION: nerdtree#bufInWindows(bnum){{{2 +"[[STOLEN FROM VTREEEXPLORER.VIM]] +"Determine the number of windows open to this buffer number. +"Care of Yegappan Lakshman. Thanks! +" +"Args: +"bnum: the subject buffers buffer number +function! nerdtree#bufInWindows(bnum) + let cnt = 0 + let winnum = 1 + while 1 + let bufnum = winbufnr(winnum) + if bufnum < 0 + break + endif + if bufnum ==# a:bnum + let cnt = cnt + 1 + endif + let winnum = winnum + 1 + endwhile + + return cnt +endfunction + +" FUNCTION: nerdtree#bufNamePrefix() {{{2 +function! nerdtree#bufNamePrefix() + return 'NERD_tree_' +endfunction + +"FUNCTION: nerdtree#checkForBrowse(dir) {{{2 +"inits a secondary nerd tree in the current buffer if appropriate +function! nerdtree#checkForBrowse(dir) + if a:dir != '' && isdirectory(a:dir) + call nerdtree#initNerdTreeInPlace(a:dir) + endif +endfunction + +" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 +" completion function for the bookmark commands +function! nerdtree#completeBookmarks(A,L,P) + return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') +endfunction + +"FUNCTION: nerdtree#compareBookmarks(dir) {{{2 +function! nerdtree#compareBookmarks(first, second) + return a:first.compareTo(a:second) +endfunction + +"FUNCTION: nerdtree#compareNodes(dir) {{{2 +function! nerdtree#compareNodes(n1, n2) + return a:n1.path.compareTo(a:n2.path) +endfunction + +" FUNCTION: nerdtree#createDefaultBindings() {{{2 +function! nerdtree#createDefaultBindings() + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': s."chRootCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) +endfunction + +" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 +" Issue a deprecation warning for a:func. If a second arg is given, use this +" as the deprecation message +function! nerdtree#deprecated(func, ...) + let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' + + if !exists('s:deprecationWarnings') + let s:deprecationWarnings = {} + endif + if !has_key(s:deprecationWarnings, a:func) + let s:deprecationWarnings[a:func] = 1 + echomsg msg + endif +endfunction + +"FUNCTION: nerdtree#escChars(dir) {{{2 +function! nerdtree#escChars() + if nerdtree#runningWindows() + return " `\|\"#%&,?()\*^<>" + endif + + return " \\`\|\"#%&,?()\*^<>[]" +endfunction + +" FUNCTION: nerdtree#exec(cmd) {{{2 +" same as :exec cmd but eventignore=all is set for the duration +function! nerdtree#exec(cmd) + let old_ei = &ei + set ei=all + exec a:cmd + let &ei = old_ei +endfunction + +" FUNCTION: nerdtree#findAndRevealPath() {{{2 +function! nerdtree#findAndRevealPath() + try + let p = g:NERDTreePath.New(expand("%:p")) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("no file for the current buffer") + return + endtry + + if p.isUnixHiddenFile() + let showhidden=g:NERDTreeShowHidden + let g:NERDTreeShowHidden = 1 + endif + + if !nerdtree#treeExistsForTab() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call nerdtree#initNerdTree(cwd.str()) + else + call nerdtree#initNerdTree(p.getParent().str()) + endif + else + if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) + if !nerdtree#isTreeOpen() + call nerdtree#createTreeWin() + else + call nerdtree#putCursorInTreeWin() + endif + let b:NERDTreeShowHidden = g:NERDTreeShowHidden + call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) + else + if !nerdtree#isTreeOpen() + call nerdtree#toggle("") + endif + endif + endif + call nerdtree#putCursorInTreeWin() + call b:NERDTreeRoot.reveal(p) + + if p.isUnixHiddenFile() + let g:NERDTreeShowHidden = showhidden + endif +endfunction + +" FUNCTION: nerdtree#has_opt(options, name) {{{2 +function! nerdtree#has_opt(options, name) + return has_key(a:options, a:name) && a:options[a:name] == 1 +endfunction + +"FUNCTION: nerdtree#initNerdTree(name) {{{2 +"Initialise the nerd tree for this tab. The tree will start in either the +"given directory, or the directory associated with the given bookmark +" +"Args: +"name: the name of a bookmark or a directory +function! nerdtree#initNerdTree(name) + let path = {} + if g:NERDTreeBookmark.BookmarkExistsFor(a:name) + let path = g:NERDTreeBookmark.BookmarkFor(a:name).path + else + let dir = a:name ==# '' ? getcwd() : a:name + + "hack to get an absolute path if a relative path is given + if dir =~# '^\.' + let dir = getcwd() . g:NERDTreePath.Slash() . dir + endif + let dir = g:NERDTreePath.Resolve(dir) + + try + let path = g:NERDTreePath.New(dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("No bookmark or directory found for: " . a:name) + return + endtry + endif + if !path.isDirectory + let path = path.getParent() + endif + + "if instructed to, then change the vim CWD to the dir the NERDTree is + "inited in + if g:NERDTreeChDirMode != 0 + call path.changeToDir() + endif + + if nerdtree#treeExistsForTab() + if nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif + unlet t:NERDTreeBufName + endif + + let newRoot = g:NERDTreeDirNode.New(path) + call newRoot.open() + + call nerdtree#createTreeWin() + let b:treeShowHelp = 0 + let b:NERDTreeIgnoreEnabled = 1 + let b:NERDTreeShowFiles = g:NERDTreeShowFiles + let b:NERDTreeShowHidden = g:NERDTreeShowHidden + let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks + let b:NERDTreeRoot = newRoot + let b:NERDTreeType = "primary" + + call nerdtree#renderView() + call b:NERDTreeRoot.putCursorHere(0, 0) + + silent doautocmd User NERDTreeInit +endfunction + +"FUNCTION: nerdtree#initNerdTreeInPlace(dir) {{{2 +function! nerdtree#initNerdTreeInPlace(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("Invalid directory name:" . a:name) + return + endtry + + "we want the directory buffer to disappear when we do the :edit below + setlocal bufhidden=wipe + + let previousBuf = expand("#") + + "we need a unique name for each secondary tree buffer to ensure they are + "all independent + exec "silent edit " . nerdtree#nextBufferName() + + let b:NERDTreePreviousBuf = bufnr(previousBuf) + + let b:NERDTreeRoot = g:NERDTreeDirNode.New(path) + call b:NERDTreeRoot.open() + + call nerdtree#setCommonBufOptions() + let b:NERDTreeType = "secondary" + + call nerdtree#renderView() + + silent doautocmd User NERDTreeInit +endfunction + +" FUNCTION: nerdtree#initNerdTreeMirror() {{{2 +function! nerdtree#initNerdTreeMirror() + + "get the names off all the nerd tree buffers + let treeBufNames = [] + for i in range(1, tabpagenr("$")) + let nextName = nerdtree#tabpagevar(i, 'NERDTreeBufName') + if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) + call add(treeBufNames, nextName) + endif + endfor + let treeBufNames = nerdtree#unique(treeBufNames) + + "map the option names (that the user will be prompted with) to the nerd + "tree buffer names + let options = {} + let i = 0 + while i < len(treeBufNames) + let bufName = treeBufNames[i] + let treeRoot = getbufvar(bufName, "NERDTreeRoot") + let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName + let i = i + 1 + endwhile + + "work out which tree to mirror, if there is more than 1 then ask the user + let bufferName = '' + if len(keys(options)) > 1 + let choices = ["Choose a tree to mirror"] + let choices = extend(choices, sort(keys(options))) + let choice = inputlist(choices) + if choice < 1 || choice > len(options) || choice ==# '' + return + endif + + let bufferName = options[sort(keys(options))[choice-1]] + elseif len(keys(options)) ==# 1 + let bufferName = values(options)[0] + else + call nerdtree#echo("No trees to mirror") + return + endif + + if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif + + let t:NERDTreeBufName = bufferName + call nerdtree#createTreeWin() + exec 'buffer ' . bufferName + if !&hidden + call nerdtree#renderView() + endif +endfunction + +" FUNCTION: nerdtree#nextBufferName() {{{2 +" returns the buffer name for the next nerd tree +function! nerdtree#nextBufferName() + let name = nerdtree#bufNamePrefix() . s:next_buffer_number + let s:next_buffer_number += 1 + return name +endfunction + +" FUNCTION: nerdtree#postSourceActions() {{{2 +function! nerdtree#postSourceActions() + call g:NERDTreeBookmark.CacheBookmarks(0) + call nerdtree#createDefaultBindings() + + "load all nerdtree plugins + runtime! nerdtree_plugin/**/*.vim +endfunction + +"FUNCTION: nerdtree#runningWindows(dir) {{{2 +function! nerdtree#runningWindows() + return has("win16") || has("win32") || has("win64") +endfunction + +" Function: s:SID() {{{2 +function s:SID() + if !exists("s:sid") + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun + +" FUNCTION: nerdtree#tabpagevar(tabnr, var) {{{2 +function! nerdtree#tabpagevar(tabnr, var) + let currentTab = tabpagenr() + let old_ei = &ei + set ei=all + + exec "tabnext " . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec "tabnext " . currentTab + + let &ei = old_ei + + return v +endfunction + +" Function: nerdtree#treeExistsForBuffer() {{{2 +" Returns 1 if a nerd tree root exists in the current buffer +function! nerdtree#treeExistsForBuf() + return exists("b:NERDTreeRoot") +endfunction + +" Function: nerdtree#treeExistsForTab() {{{2 +" Returns 1 if a nerd tree root exists in the current tab +function! nerdtree#treeExistsForTab() + return exists("t:NERDTreeBufName") +endfunction + +"FUNCTION: nerdtree#treeMarkupReg(dir) {{{2 +function! nerdtree#treeMarkupReg() + if g:NERDTreeDirArrows + return '^\([▾▸] \| \+[▾▸] \| \+\)' + endif + + return '^[ `|]*[\-+~]' +endfunction + +"FUNCTION: nerdtree#treeUpDirLine(dir) {{{2 +function! nerdtree#treeUpDirLine() + return '.. (up a dir)' +endfunction + +"FUNCTION: nerdtree#treeWid(dir) {{{2 +function! nerdtree#treeWid() + return 2 +endfunction + +"FUNCTION: nerdtree#upDir(keepState) {{{2 +"moves the tree up a level +" +"Args: +"keepState: 1 if the current root should be left open when the tree is +"re-rendered +function! nerdtree#upDir(keepState) + let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) + if cwd ==# "/" || cwd =~# '^[^/]..$' + call nerdtree#echo("already at top dir") + else + if !a:keepState + call b:NERDTreeRoot.close() + endif + + let oldRoot = b:NERDTreeRoot + + if empty(b:NERDTreeRoot.parent) + let path = b:NERDTreeRoot.path.getParent() + let newRoot = g:NERDTreeDirNode.New(path) + call newRoot.open() + call newRoot.transplantChild(b:NERDTreeRoot) + let b:NERDTreeRoot = newRoot + else + let b:NERDTreeRoot = b:NERDTreeRoot.parent + endif + + if g:NERDTreeChDirMode ==# 2 + call b:NERDTreeRoot.path.changeToDir() + endif + + call nerdtree#renderView() + call oldRoot.putCursorHere(0, 0) + endif +endfunction + +" Function: nerdtree#unique(list) {{{2 +" returns a:list without duplicates +function! nerdtree#unique(list) + let uniqlist = [] + for elem in a:list + if index(uniqlist, elem) ==# -1 + let uniqlist += [elem] + endif + endfor + return uniqlist +endfunction + +" SECTION: View Functions {{{1 +"============================================================ +" +"FUNCTION: nerdtree#centerView() {{{2 +"centers the nerd tree window around the cursor (provided the nerd tree +"options permit) +function! nerdtree#centerView() + if g:NERDTreeAutoCenter + let current_line = winline() + let lines_to_top = current_line + let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line + if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold + normal! zz + endif + endif +endfunction + +"FUNCTION: nerdtree#closeTree() {{{2 +"Closes the primary NERD tree window for this tab +function! nerdtree#closeTree() + if !nerdtree#isTreeOpen() + throw "NERDTree.NoTreeFoundError: no NERDTree is open" + endif + + if winnr("$") != 1 + if winnr() == nerdtree#getTreeWinNum() + call nerdtree#exec("wincmd p") + let bufnr = bufnr("") + call nerdtree#exec("wincmd p") + else + let bufnr = bufnr("") + endif + + call nerdtree#exec(nerdtree#getTreeWinNum() . " wincmd w") + close + call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") + else + close + endif +endfunction + +"FUNCTION: nerdtree#closeTreeIfOpen() {{{2 +"Closes the NERD tree window if it is open +function! nerdtree#closeTreeIfOpen() + if nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif +endfunction + +"FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2 +"Closes the NERD tree window if the close on open option is set +function! nerdtree#closeTreeIfQuitOnOpen() + if g:NERDTreeQuitOnOpen && nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif +endfunction + +"FUNCTION: nerdtree#createTreeWin() {{{2 +"Inits the NERD tree window. ie. opens it, sizes it, sets all the local +"options etc +function! nerdtree#createTreeWin() + "create the nerd tree window + let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " + let splitSize = g:NERDTreeWinSize + + if !exists('t:NERDTreeBufName') + let t:NERDTreeBufName = nerdtree#nextBufferName() + silent! exec splitLocation . 'vertical ' . splitSize . ' new' + silent! exec "edit " . t:NERDTreeBufName + else + silent! exec splitLocation . 'vertical ' . splitSize . ' split' + silent! exec "buffer " . t:NERDTreeBufName + endif + + setlocal winfixwidth + call nerdtree#setCommonBufOptions() +endfunction + +"FUNCTION: nerdtree#dumpHelp {{{2 +"prints out the quick help +function! nerdtree#dumpHelp() + let old_h = @h + if b:treeShowHelp ==# 1 + let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" + let @h=@h."\" ============================\n" + let @h=@h."\" File node mappings~\n" + let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let @h=@h."\" ,\n" + if b:NERDTreeType ==# "primary" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + else + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" + endif + if b:NERDTreeType ==# "primary" + let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" + endif + let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let @h=@h."\" middle-click,\n" + let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" + let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" + let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" + let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Directory node mappings~\n" + let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" + let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" + let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" + let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let @h=@h."\" current node recursively\n" + let @h=@h."\" middle-click,\n" + let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Bookmark table mappings~\n" + let @h=@h."\" double-click,\n" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Tree navigation mappings~\n" + let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" + let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" + let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" + let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" + let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Filesystem mappings~\n" + let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let @h=@h."\" selected dir\n" + let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" + let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let @h=@h."\" but leave old root open\n" + let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" + let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" + let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" + let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let @h=@h."\" selected dir\n" + let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Tree filtering mappings~\n" + let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" + + "add quickhelp entries for each custom key map + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Custom mappings~\n" + for i in g:NERDTreeKeyMap.All() + if !empty(i.quickhelpText) + let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" + endif + endfor + + 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" + let @h=@h."\" :Bookmark \n" + let @h=@h."\" :BookmarkToRoot \n" + let @h=@h."\" :RevealBookmark \n" + let @h=@h."\" :OpenBookmark \n" + let @h=@h."\" :ClearBookmarks []\n" + let @h=@h."\" :ClearAllBookmarks\n" + silent! put h + elseif g:NERDTreeMinimalUI == 0 + let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" + silent! put h + endif + + let @h = old_h +endfunction + +"FUNCTION: nerdtree#echo {{{2 +"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages +" +"Args: +"msg: the message to echo +function! nerdtree#echo(msg) + redraw + echomsg "NERDTree: " . a:msg +endfunction + +"FUNCTION: nerdtree#echoError {{{2 +"Wrapper for nerdtree#echo, sets the message type to errormsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoError(msg) + echohl errormsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#echoWarning {{{2 +"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoWarning(msg) + echohl warningmsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#firstUsableWindow(){{{2 +"find the window number of the first normal window +function! nerdtree#firstUsableWindow() + let i = 1 + while i <= winnr("$") + let bnum = winbufnr(i) + if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + \ && !getwinvar(i, '&previewwindow') + \ && (!getbufvar(bnum, '&modified') || &hidden) + return i + endif + + let i += 1 + endwhile + return -1 +endfunction + +"FUNCTION: nerdtree#getPath(ln) {{{2 +"Gets the full path to the node that is rendered on the given line number +" +"Args: +"ln: the line number to get the path for +" +"Return: +"A path if a node was selected, {} if nothing is selected. +"If the 'up a dir' line was selected then the path to the parent of the +"current root is returned +function! nerdtree#getPath(ln) + let line = getline(a:ln) + + let rootLine = g:NERDTreeFileNode.GetRootLineNum() + + "check to see if we have the root node + if a:ln == rootLine + return b:NERDTreeRoot.path + endif + + if !g:NERDTreeDirArrows + " in case called from outside the tree + if line !~# '^ *[|`▸▾ ]' || line =~# '^$' + return {} + endif + endif + + if line ==# nerdtree#treeUpDirLine() + return b:NERDTreeRoot.path.getParent() + endif + + let indent = nerdtree#indentLevelFor(line) + + "remove the tree parts and the leading space + let curFile = nerdtree#stripMarkupFromLine(line, 0) + + let wasdir = 0 + if curFile =~# '/$' + let wasdir = 1 + let curFile = substitute(curFile, '/\?$', '/', "") + endif + + let dir = "" + let lnum = a:ln + while lnum > 0 + let lnum = lnum - 1 + let curLine = getline(lnum) + let curLineStripped = nerdtree#stripMarkupFromLine(curLine, 1) + + "have we reached the top of the tree? + if lnum == rootLine + let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir + break + endif + if curLineStripped =~# '/$' + let lpindent = nerdtree#indentLevelFor(curLine) + if lpindent < indent + let indent = indent - 1 + + let dir = substitute (curLineStripped,'^\\', "", "") . dir + continue + endif + endif + endwhile + let curFile = b:NERDTreeRoot.path.drive . dir . curFile + let toReturn = g:NERDTreePath.New(curFile) + return toReturn +endfunction + +"FUNCTION: nerdtree#getTreeWinNum() {{{2 +"gets the nerd tree window number for this tab +function! nerdtree#getTreeWinNum() + if exists("t:NERDTreeBufName") + return bufwinnr(t:NERDTreeBufName) + else + return -1 + endif +endfunction + +"FUNCTION: nerdtree#indentLevelFor(line) {{{2 +function! nerdtree#indentLevelFor(line) + let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() + " check if line includes arrows + if match(a:line, '[▸▾]') > -1 + " decrement level as arrow uses 3 ascii chars + let level = level - 1 + endif + return level +endfunction + +"FUNCTION: nerdtree#isTreeOpen() {{{2 +function! nerdtree#isTreeOpen() + return nerdtree#getTreeWinNum() != -1 +endfunction + +"FUNCTION: nerdtree#isWindowUsable(winnumber) {{{2 +"Returns 0 if opening a file from the tree in the given window requires it to +"be split, 1 otherwise +" +"Args: +"winnumber: the number of the window in question +function! nerdtree#isWindowUsable(winnumber) + "gotta split if theres only one window (i.e. the NERD tree) + if winnr("$") ==# 1 + return 0 + endif + + let oldwinnr = winnr() + call nerdtree#exec(a:winnumber . "wincmd p") + let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') + let modified = &modified + call nerdtree#exec(oldwinnr . "wincmd p") + + "if its a special window e.g. quickfix or another explorer plugin then we + "have to split + if specialWindow + return 0 + endif + + if &hidden + return 1 + endif + + return !modified || nerdtree#bufInWindows(winbufnr(a:winnumber)) >= 2 +endfunction + +" FUNCTION: nerdtree#jumpToChild(direction) {{{2 +" Args: +" direction: 0 if going to first child, 1 if going to last +function! nerdtree#jumpToChild(currentNode, direction) + if a:currentNode.isRoot() + return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child") + end + let dirNode = a:currentNode.parent + let childNodes = dirNode.getVisibleChildren() + + let targetNode = childNodes[0] + if a:direction + let targetNode = childNodes[len(childNodes) - 1] + endif + + if targetNode.equals(a:currentNode) + let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) + if siblingDir != {} + let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 + let targetNode = siblingDir.getChildByIndex(indx, 1) + endif + endif + + call targetNode.putCursorHere(1, 0) + + call nerdtree#centerView() +endfunction + +" FUNCTION: nerdtree#jumpToSibling(currentNode, forward) {{{2 +" moves the cursor to the sibling of the current node in the given direction +" +" Args: +" forward: 1 if the cursor should move to the next sibling, 0 if it should +" move back to the previous sibling +function! nerdtree#jumpToSibling(currentNode, forward) + let sibling = a:currentNode.findSibling(a:forward) + + if !empty(sibling) + call sibling.putCursorHere(1, 0) + call nerdtree#centerView() + endif +endfunction + +"FUNCTION: nerdtree#promptToDelBuffer(bufnum, msg){{{2 +"prints out the given msg and, if the user responds by pushing 'y' then the +"buffer with the given bufnum is deleted +" +"Args: +"bufnum: the buffer that may be deleted +"msg: a message that will be echoed to the user asking them if they wish to +" del the buffer +function! nerdtree#promptToDelBuffer(bufnum, msg) + echo a:msg + if nr2char(getchar()) ==# 'y' + exec "silent bdelete! " . a:bufnum + endif +endfunction + +"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 +"Places the cursor at the top of the bookmarks table +function! nerdtree#putCursorOnBookmarkTable() + if !b:NERDTreeShowBookmarks + throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" + endif + + if g:NERDTreeMinimalUI + return cursor(1, 2) + endif + + let rootNodeLine = g:NERDTreeFileNode.GetRootLineNum() + + let line = 1 + while getline(line) !~# '^>-\+Bookmarks-\+$' + let line = line + 1 + if line >= rootNodeLine + throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" + endif + endwhile + call cursor(line, 2) +endfunction + +"FUNCTION: nerdtree#putCursorInTreeWin(){{{2 +"Places the cursor in the nerd tree window +function! nerdtree#putCursorInTreeWin() + if !nerdtree#isTreeOpen() + throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" + endif + + call nerdtree#exec(nerdtree#getTreeWinNum() . "wincmd w") +endfunction + +"FUNCTION: nerdtree#renderBookmarks {{{2 +function! nerdtree#renderBookmarks() + + if g:NERDTreeMinimalUI == 0 + call setline(line(".")+1, ">----------Bookmarks----------") + call cursor(line(".")+1, col(".")) + endif + + for i in g:NERDTreeBookmark.Bookmarks() + call setline(line(".")+1, i.str()) + call cursor(line(".")+1, col(".")) + endfor + + call setline(line(".")+1, '') + call cursor(line(".")+1, col(".")) +endfunction + +"FUNCTION: nerdtree#renderView {{{2 +"The entry function for rendering the tree +function! nerdtree#renderView() + setlocal modifiable + + "remember the top line of the buffer and the current line so we can + "restore the view exactly how it was + let curLine = line(".") + let curCol = col(".") + let topLine = line("w0") + + "delete all lines in the buffer (being careful not to clobber a register) + silent 1,$delete _ + + call nerdtree#dumpHelp() + + "delete the blank line before the help and add one after it + if g:NERDTreeMinimalUI == 0 + call setline(line(".")+1, "") + call cursor(line(".")+1, col(".")) + endif + + if b:NERDTreeShowBookmarks + call nerdtree#renderBookmarks() + endif + + "add the 'up a dir' line + if !g:NERDTreeMinimalUI + call setline(line(".")+1, nerdtree#treeUpDirLine()) + call cursor(line(".")+1, col(".")) + endif + + "draw the header line + let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + call setline(line(".")+1, header) + call cursor(line(".")+1, col(".")) + + "draw the tree + let old_o = @o + let @o = b:NERDTreeRoot.renderToString() + silent put o + let @o = old_o + + "delete the blank line at the top of the buffer + silent 1,1delete _ + + "restore the view + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(topLine, 1) + normal! zt + call cursor(curLine, curCol) + let &scrolloff = old_scrolloff + + setlocal nomodifiable +endfunction + +"FUNCTION: nerdtree#renderViewSavingPosition {{{2 +"Renders the tree and ensures the cursor stays on the current node or the +"current nodes parent if it is no longer available upon re-rendering +function! nerdtree#renderViewSavingPosition() + let currentNode = g:NERDTreeFileNode.GetSelected() + + "go up the tree till we find a node that will be visible or till we run + "out of nodes + while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() + let currentNode = currentNode.parent + endwhile + + call nerdtree#renderView() + + if currentNode != {} + call currentNode.putCursorHere(0, 0) + endif +endfunction +" +"FUNCTION: nerdtree#restoreScreenState() {{{2 +" +"Sets the screen state back to what it was when nerdtree#saveScreenState was last +"called. +" +"Assumes the cursor is in the NERDTree window +function! nerdtree#restoreScreenState() + if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize") + return + endif + exec("silent vertical resize ".b:NERDTreeOldWindowSize) + + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(b:NERDTreeOldTopLine, 0) + normal! zt + call setpos(".", b:NERDTreeOldPos) + let &scrolloff=old_scrolloff +endfunction + +"FUNCTION: nerdtree#saveScreenState() {{{2 +"Saves the current cursor position in the current buffer and the window +"scroll position +function! nerdtree#saveScreenState() + let win = winnr() + try + call nerdtree#putCursorInTreeWin() + let b:NERDTreeOldPos = getpos(".") + let b:NERDTreeOldTopLine = line("w0") + let b:NERDTreeOldWindowSize = winwidth("") + call nerdtree#exec(win . "wincmd w") + catch /^NERDTree.InvalidOperationError/ + endtry +endfunction + +"FUNCTION: nerdtree#setCommonBufOptions() {{{2 +function! nerdtree#setCommonBufOptions() + "throwaway buffer options + setlocal noswapfile + setlocal buftype=nofile + setlocal bufhidden=hide + setlocal nowrap + setlocal foldcolumn=0 + setlocal foldmethod=manual + setlocal nofoldenable + setlocal nobuflisted + setlocal nospell + if g:NERDTreeShowLineNumbers + setlocal nu + else + setlocal nonu + if v:version >= 703 + setlocal nornu + endif + endif + + iabc + + if g:NERDTreeHighlightCursorline + setlocal cursorline + endif + + call nerdtree#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 nerdtree#bindMappings() +endfunction + +"FUNCTION: nerdtree#setupStatusline() {{{2 +function! nerdtree#setupStatusline() + if g:NERDTreeStatusline != -1 + let &l:statusline = g:NERDTreeStatusline + endif +endfunction + +"FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2 +"returns the given line with all the tree parts stripped off +" +"Args: +"line: the subject line +"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = +"any spaces before the actual text of the node) +function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) + let line = a:line + "remove the tree parts and the leading space + let line = substitute (line, nerdtree#treeMarkupReg(),"","") + + "strip off any read only flag + let line = substitute (line, ' \[RO\]', "","") + + "strip off any bookmark flags + let line = substitute (line, ' {[^}]*}', "","") + + "strip off any executable flags + let line = substitute (line, '*\ze\($\| \)', "","") + + let wasdir = 0 + if line =~# '/$' + let wasdir = 1 + endif + let line = substitute (line,' -> .*',"","") " remove link to + if wasdir ==# 1 + let line = substitute (line, '/\?$', '/', "") + endif + + if a:removeLeadingSpaces + let line = substitute (line, '^ *', '', '') + endif + + return line +endfunction + +"FUNCTION: nerdtree#toggle(dir) {{{2 +"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is +"closed it is restored or initialized (if it doesnt exist) +" +"Args: +"dir: the full path for the root node (is only used if the NERD tree is being +"initialized. +function! nerdtree#toggle(dir) + if nerdtree#treeExistsForTab() + if !nerdtree#isTreeOpen() + call nerdtree#createTreeWin() + if !&hidden + call nerdtree#renderView() + endif + call nerdtree#restoreScreenState() + else + call nerdtree#closeTree() + endif + else + call nerdtree#initNerdTree(a:dir) + endif +endfunction + +"SECTION: Interface bindings {{{1 +"============================================================ + +"FUNCTION: s:activateAll() {{{2 +"handle the user activating the updir line +function! s:activateAll() + if getline(".") ==# nerdtree#treeUpDirLine() + return nerdtree#upDir(0) + endif +endfunction +"FUNCTION: s:activateDirNode() {{{2 +"handle the user activating a tree node +function! s:activateDirNode(node) + call a:node.activate({'reuse': 1}) +endfunction + +"FUNCTION: s:activateFileNode() {{{2 +"handle the user activating a tree node +function! s:activateFileNode(node) + call a:node.activate({'reuse': 1, 'where': 'p'}) +endfunction + +"FUNCTION: s:activateBookmark() {{{2 +"handle the user activating a bookmark +function! s:activateBookmark(bm) + call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) +endfunction + +"FUNCTION: nerdtree#bindMappings() {{{2 +function! nerdtree#bindMappings() + "make do the same as the default 'o' mapping + exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" + + call g:NERDTreeKeyMap.BindAll() + + command! -buffer -nargs=? Bookmark :call bookmarkNode('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') + command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call nerdtree#renderView() + command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call nerdtree#renderView() + command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() +endfunction + +" FUNCTION: s:bookmarkNode(name) {{{2 +" Associate the current node with the given name +function! s:bookmarkNode(...) + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(0) + endif + try + call currentNode.bookmark(name) + call nerdtree#renderView() + catch /^NERDTree.IllegalBookmarkNameError/ + call nerdtree#echo("bookmark names must not contain spaces") + endtry + else + call nerdtree#echo("select a node first") + endif +endfunction + +" FUNCTION: s:chCwd(node) {{{2 +function! s:chCwd(node) + try + call a:node.path.changeToDir() + catch /^NERDTree.PathChangeError/ + call nerdtree#echoWarning("could not change cwd") + endtry +endfunction + +" FUNCTION: s:chRoot(node) {{{2 +" changes the current root to the selected one +function! s:chRoot(node) + call a:node.makeRoot() + call nerdtree#renderView() + call b:NERDTreeRoot.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:chRootCwd() {{{2 +" changes the current root to CWD +function! s:chRootCwd() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + return + endtry + if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() + return + endif + call nerdtree#chRoot(g:NERDTreeDirNode.New(cwd)) +endfunction + +" FUNCTION: s:clearBookmarks(bookmarks) {{{2 +function! s:clearBookmarks(bookmarks) + if a:bookmarks ==# '' + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + call currentNode.clearBookmarks() + endif + else + for name in split(a:bookmarks, ' ') + let bookmark = g:NERDTreeBookmark.BookmarkFor(name) + call bookmark.delete() + endfor + endif + call nerdtree#renderView() +endfunction + +" FUNCTION: s:closeChildren(node) {{{2 +" closes all childnodes of the current node +function! s:closeChildren(node) + call a:node.closeChildren() + call nerdtree#renderView() + call a:node.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:closeCurrentDir(node) {{{2 +" closes the parent dir of the current node +function! s:closeCurrentDir(node) + let parent = a:node.parent + if parent ==# {} || parent.isRoot() + call nerdtree#echo("cannot close tree root") + else + call a:node.parent.close() + call nerdtree#renderView() + call a:node.parent.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: s:closeTreeWindow() {{{2 +" close the tree window +function! s:closeTreeWindow() + if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 + exec "buffer " . b:NERDTreePreviousBuf + else + if winnr("$") > 1 + call nerdtree#closeTree() + else + call nerdtree#echo("Cannot close last window") + endif + endif +endfunction + +" FUNCTION: s:deleteBookmark(bm) {{{2 +" if the cursor is on a bookmark, prompt to delete +function! s:deleteBookmark(bm) + echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" + + if nr2char(getchar()) ==# 'y' + try + call a:bm.delete() + call nerdtree#renderView() + redraw + catch /^NERDTree/ + call nerdtree#echoWarning("Could not remove bookmark") + endtry + else + call nerdtree#echo("delete aborted" ) + endif + +endfunction + +" FUNCTION: s:displayHelp() {{{2 +" toggles the help display +function! s:displayHelp() + let b:treeShowHelp = b:treeShowHelp ? 0 : 1 + call nerdtree#renderView() + call nerdtree#centerView() +endfunction + +"FUNCTION: s:handleLeftClick() {{{2 +"Checks if the click should open the current node +function! s:handleLeftClick() + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + + "the dir arrows are multibyte chars, and vim's string functions only + "deal with single bytes - so split the line up with the hack below and + "take the line substring manually + let line = split(getline(line(".")), '\zs') + let startToCur = "" + for i in range(0,len(line)-1) + let startToCur .= line[i] + endfor + + if currentNode.path.isDirectory + if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' + call currentNode.activate() + return + endif + endif + + if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 + let char = strpart(startToCur, strlen(startToCur)-1, 1) + if char !~# nerdtree#treeMarkupReg() + if currentNode.path.isDirectory + call currentNode.activate() + else + call currentNode.activate({'reuse': 1, 'where': 'p'}) + endif + return + endif + endif + endif +endfunction + +" FUNCTION: s:handleMiddleMouse() {{{2 +function! s:handleMiddleMouse() + let curNode = g:NERDTreeFileNode.GetSelected() + if curNode ==# {} + call nerdtree#echo("Put the cursor on a node first" ) + return + endif + + if curNode.path.isDirectory + call nerdtree#openExplorer(curNode) + else + call curNode.open({'where': 'h'}) + endif +endfunction + +" FUNCTION: s:jumpToFirstChild() {{{2 +" wrapper for the jump to child method +function! s:jumpToFirstChild(node) + call nerdtree#jumpToChild(a:node, 0) +endfunction + +" FUNCTION: s:jumpToLastChild() {{{2 +" wrapper for the jump to child method +function! s:jumpToLastChild(node) + call nerdtree#jumpToChild(a:node, 1) +endfunction + +" FUNCTION: s:jumpToParent(node) {{{2 +" moves the cursor to the parent of the current node +function! s:jumpToParent(node) + if !empty(a:node.parent) + call a:node.parent.putCursorHere(1, 0) + call nerdtree#centerView() + else + call nerdtree#echo("cannot jump to parent") + endif +endfunction + +" FUNCTION: s:jumpToRoot() {{{2 +" moves the cursor to the root node +function! s:jumpToRoot() + call b:NERDTreeRoot.putCursorHere(1, 0) + call nerdtree#centerView() +endfunction + +" FUNCTION: s:jumpToNextSibling(node) {{{2 +function! s:jumpToNextSibling(node) + call nerdtree#jumpToSibling(a:node, 1) +endfunction + +" FUNCTION: s:jumpToPrevSibling(node) {{{2 +function! s:jumpToPrevSibling(node) + call nerdtree#jumpToSibling(a:node, 0) +endfunction + +" FUNCTION: s:openBookmark(name) {{{2 +" put the cursor on the given bookmark and, if its a file, open it +function! s:openBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + call targetNode.putCursorHere(0, 1) + redraw! + catch /^NERDTree.BookmarkedNodeNotFoundError/ + call nerdtree#echo("note - target node is not cached") + let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + let targetNode = g:NERDTreeFileNode.New(bookmark.path) + endtry + if targetNode.path.isDirectory + call targetNode.openExplorer() + else + call targetNode.open({'where': 'p'}) + endif +endfunction + +" FUNCTION: s:openHSplit(target) {{{2 +function! s:openHSplit(target) + call a:target.activate({'where': 'h'}) +endfunction + +" FUNCTION: s:openVSplit(target) {{{2 +function! s:openVSplit(target) + call a:target.activate({'where': 'v'}) +endfunction + +" FUNCTION: s:openExplorer(node) {{{2 +function! s:openExplorer(node) + call a:node.openExplorer() +endfunction + +" FUNCTION: s:openInNewTab(target) {{{2 +function! s:openInNewTab(target) + call a:target.activate({'where': 't'}) +endfunction + +" FUNCTION: s:openInNewTabSilent(target) {{{2 +function! s:openInNewTabSilent(target) + call a:target.activate({'where': 't', 'stay': 1}) +endfunction + +" FUNCTION: s:openNodeRecursively(node) {{{2 +function! s:openNodeRecursively(node) + call nerdtree#echo("Recursively opening node. Please wait...") + call a:node.openRecursively() + call nerdtree#renderView() + redraw + call nerdtree#echo("Recursively opening node. Please wait... DONE") +endfunction + +"FUNCTION: s:previewNodeCurrent(node) {{{2 +function! s:previewNodeCurrent(node) + call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeHSplit(node) {{{2 +function! s:previewNodeHSplit(node) + call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeVSplit(node) {{{2 +function! s:previewNodeVSplit(node) + call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) +endfunction + +" FUNCTION: s:revealBookmark(name) {{{2 +" put the cursor on the node associate with the given name +function! s:revealBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + call targetNode.putCursorHere(0, 1) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echo("Bookmark isnt cached under the current root") + endtry +endfunction + +" FUNCTION: s:refreshRoot() {{{2 +" Reloads the current root. All nodes below this will be lost and the root dir +" will be reloaded. +function! s:refreshRoot() + call nerdtree#echo("Refreshing the root node. This could take a while...") + call b:NERDTreeRoot.refresh() + call nerdtree#renderView() + redraw + call nerdtree#echo("Refreshing the root node. This could take a while... DONE") +endfunction + +" FUNCTION: s:refreshCurrent(node) {{{2 +" refreshes the root for the current node +function! s:refreshCurrent(node) + let node = a:node + if !node.path.isDirectory + let node = node.parent + endif + + call nerdtree#echo("Refreshing node. This could take a while...") + call node.refresh() + call nerdtree#renderView() + redraw + call nerdtree#echo("Refreshing node. This could take a while... DONE") +endfunction + +" FUNCTION: s:showMenu(node) {{{2 +function! s:showMenu(node) + let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) + call mc.showMenu() +endfunction + +" FUNCTION: s:toggleIgnoreFilter() {{{2 +" toggles the use of the NERDTreeIgnore option +function! s:toggleIgnoreFilter() + let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled + call nerdtree#renderViewSavingPosition() + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowBookmarks() {{{2 +" toggles the display of bookmarks +function! s:toggleShowBookmarks() + let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks + if b:NERDTreeShowBookmarks + call nerdtree#renderView() + call nerdtree#putCursorOnBookmarkTable() + else + call nerdtree#renderViewSavingPosition() + endif + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowFiles() {{{2 +" toggles the display of hidden files +function! s:toggleShowFiles() + let b:NERDTreeShowFiles = !b:NERDTreeShowFiles + call nerdtree#renderViewSavingPosition() + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowHidden() {{{2 +" toggles the display of hidden files +function! s:toggleShowHidden() + let b:NERDTreeShowHidden = !b:NERDTreeShowHidden + call nerdtree#renderViewSavingPosition() + call nerdtree#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:upDirCurrentRootOpen() {{{2 +function! s:upDirCurrentRootOpen() + call nerdtree#upDir(1) +endfunction + +" FUNCTION: s:upDirCurrentRootClosed() {{{2 +function! s:upDirCurrentRootClosed() + call nerdtree#upDir(0) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index aefb56d9..08ae9975 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -10,8 +10,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -let s:NERD_tree_version = '4.2.0' - +" " SECTION: Script init stuff {{{1 "============================================================ if exists("loaded_nerd_tree") @@ -27,8 +26,6 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpo set cpo&vim -let s:running_windows = has("win16") || has("win32") || has("win64") - "Function: s:initVariable() function {{{2 "This function is used to initialise a given variable to a given value. The "variable is only initialised if it does not exist prior @@ -68,7 +65,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -call s:initVariable("g:NERDTreeDirArrows", !s:running_windows) +call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") @@ -80,10 +77,6 @@ else endif endif -"we need to use this number many times for sorting... so we calculate it only -"once here -let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') - if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when @@ -98,7 +91,7 @@ call s:initVariable("g:NERDTreeWinSize", 31) "init the shell commands that will be used to copy nodes, and remove dir trees " "Note: the space after the command is important -if s:running_windows +if nerdtree#runningWindows() call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') else call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') @@ -142,4301 +135,81 @@ call s:initVariable("g:NERDTreeMapUpdir", "u") call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") call s:initVariable("g:NERDTreeMapCWD", "CD") -"SECTION: Script level variable declaration{{{2 -if s:running_windows - let s:escape_chars = " `\|\"#%&,?()\*^<>" -else - let s:escape_chars = " \\`\|\"#%&,?()\*^<>[]" -endif -let s:NERDTreeBufName = 'NERD_tree_' - -let s:tree_wid = 2 - -if g:NERDTreeDirArrows - let s:tree_markup_reg = '^\([▾▸] \| \+[▾▸] \| \+\)' -else - let s:tree_markup_reg = '^[ `|]*[\-+~]' -endif -let s:tree_up_dir_line = '.. (up a dir)' - -"the number to add to the nerd tree buffer name to make the buf name unique -let s:next_buffer_number = 1 +"SECTION: Load class files{{{2 +runtime plugin/nerdtree/path.vim +runtime plugin/nerdtree/menu_controller.vim +runtime plugin/nerdtree/menu_item.vim +runtime plugin/nerdtree/key_map.vim +runtime plugin/nerdtree/bookmark.vim +runtime plugin/nerdtree/tree_file_node.vim +runtime plugin/nerdtree/tree_dir_node.vim +runtime plugin/nerdtree/opener.vim " SECTION: Commands {{{1 "============================================================ "init the command that users start the nerd tree with -command! -n=? -complete=dir -bar NERDTree :call s:initNerdTree('') -command! -n=? -complete=dir -bar NERDTreeToggle :call s:toggle('') -command! -n=0 -bar NERDTreeClose :call s:closeTreeIfOpen() -command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark call s:initNerdTree('') -command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror() -command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() +command! -n=? -complete=dir -bar NERDTree :call nerdtree#initNerdTree('') +command! -n=? -complete=dir -bar NERDTreeToggle :call nerdtree#toggle('') +command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() +command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call nerdtree#initNerdTree('') +command! -n=0 -bar NERDTreeMirror call nerdtree#initNerdTreeMirror() +command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() " SECTION: Auto commands {{{1 "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call saveScreenState()" + exec "autocmd BufWinLeave ". nerdtree#bufNamePrefix() ."* call nerdtree#saveScreenState()" "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert" + exec "autocmd BufEnter ". nerdtree#bufNamePrefix() ."* stopinsert" augroup END if g:NERDTreeHijackNetrw augroup NERDTreeHijackNetrw autocmd VimEnter * silent! autocmd! FileExplorer - au BufEnter,VimEnter * call s:checkForBrowse(expand("")) + au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("")) augroup END endif -"SECTION: Classes {{{1 -"============================================================ -"CLASS: Bookmark {{{2 +" SECTION: Public API {{{1 "============================================================ -let s:Bookmark = {} -" FUNCTION: Bookmark.activate() {{{3 -function! s:Bookmark.activate(...) - call self.open(a:0 ? a:1 : {}) -endfunction -" FUNCTION: Bookmark.AddBookmark(name, path) {{{3 -" Class method to add a new bookmark to the list, if a previous bookmark exists -" with the same name, just update the path for that bookmark -function! s:Bookmark.AddBookmark(name, path) - for i in s:Bookmark.Bookmarks() - if i.name ==# a:name - let i.path = a:path - return - endif - endfor - call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) - call s:Bookmark.Sort() -endfunction -" Function: Bookmark.Bookmarks() {{{3 -" Class method to get all bookmarks. Lazily initializes the bookmarks global -" variable -function! s:Bookmark.Bookmarks() - if !exists("g:NERDTreeBookmarks") - let g:NERDTreeBookmarks = [] - endif - return g:NERDTreeBookmarks -endfunction -" Function: Bookmark.BookmarkExistsFor(name) {{{3 -" class method that returns 1 if a bookmark with the given name is found, 0 -" otherwise -function! s:Bookmark.BookmarkExistsFor(name) - try - call s:Bookmark.BookmarkFor(a:name) - return 1 - catch /^NERDTree.BookmarkNotFoundError/ - return 0 - endtry -endfunction -" Function: Bookmark.BookmarkFor(name) {{{3 -" Class method to get the bookmark that has the given name. {} is return if no -" bookmark is found -function! s:Bookmark.BookmarkFor(name) - for i in s:Bookmark.Bookmarks() - if i.name ==# a:name - return i - endif - endfor - throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' -endfunction -" Function: Bookmark.BookmarkNames() {{{3 -" Class method to return an array of all bookmark names -function! s:Bookmark.BookmarkNames() - let names = [] - for i in s:Bookmark.Bookmarks() - call add(names, i.name) - endfor - return names -endfunction -" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3 -" Class method to read all bookmarks from the bookmarks file intialize -" bookmark objects for each one. -" -" Args: -" silent - dont echo an error msg if invalid bookmarks are found -function! s:Bookmark.CacheBookmarks(silent) - if filereadable(g:NERDTreeBookmarksFile) - let g:NERDTreeBookmarks = [] - let g:NERDTreeInvalidBookmarks = [] - let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) - let invalidBookmarksFound = 0 - for i in bookmarkStrings - - "ignore blank lines - if i != '' - - let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') - let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') - - try - let bookmark = s:Bookmark.New(name, s:Path.New(path)) - call add(g:NERDTreeBookmarks, bookmark) - catch /^NERDTree.InvalidArgumentsError/ - call add(g:NERDTreeInvalidBookmarks, i) - let invalidBookmarksFound += 1 - endtry - endif - endfor - if invalidBookmarksFound - call s:Bookmark.Write() - if !a:silent - call s:echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") - endif - endif - call s:Bookmark.Sort() - endif -endfunction -" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3 -" Compare these two bookmarks for sorting purposes -function! s:Bookmark.compareTo(otherbookmark) - return a:otherbookmark.name < self.name -endfunction -" FUNCTION: Bookmark.ClearAll() {{{3 -" Class method to delete all bookmarks. -function! s:Bookmark.ClearAll() - for i in s:Bookmark.Bookmarks() - call i.delete() - endfor - call s:Bookmark.Write() -endfunction -" FUNCTION: Bookmark.delete() {{{3 -" Delete this bookmark. If the node for this bookmark is under the current -" root, then recache bookmarks for its Path object -function! s:Bookmark.delete() - let node = {} - try - let node = self.getNode(1) - catch /^NERDTree.BookmarkedNodeNotFoundError/ - endtry - call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) - if !empty(node) - call node.path.cacheDisplayString() - endif - call s:Bookmark.Write() -endfunction -" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3 -" Gets the treenode for this bookmark -" -" Args: -" searchFromAbsoluteRoot: specifies whether we should search from the current -" tree root, or the highest cached node -function! s:Bookmark.getNode(searchFromAbsoluteRoot) - let searchRoot = a:searchFromAbsoluteRoot ? s:TreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot - let targetNode = searchRoot.findNode(self.path) - if empty(targetNode) - throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name - endif - return targetNode -endfunction -" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3 -" Class method that finds the bookmark with the given name and returns the -" treenode for it. -function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) - let bookmark = s:Bookmark.BookmarkFor(a:name) - return bookmark.getNode(a:searchFromAbsoluteRoot) -endfunction -" FUNCTION: Bookmark.GetSelected() {{{3 -" returns the Bookmark the cursor is over, or {} -function! s:Bookmark.GetSelected() - let line = getline(".") - let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') - if name != line - try - return s:Bookmark.BookmarkFor(name) - catch /^NERDTree.BookmarkNotFoundError/ - return {} - endtry - endif - return {} -endfunction - -" Function: Bookmark.InvalidBookmarks() {{{3 -" Class method to get all invalid bookmark strings read from the bookmarks -" file -function! s:Bookmark.InvalidBookmarks() - if !exists("g:NERDTreeInvalidBookmarks") - let g:NERDTreeInvalidBookmarks = [] - endif - return g:NERDTreeInvalidBookmarks -endfunction -" FUNCTION: Bookmark.mustExist() {{{3 -function! s:Bookmark.mustExist() - if !self.path.exists() - call s:Bookmark.CacheBookmarks(1) - throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". - \ self.name ."\" points to a non existing location: \"". self.path.str() - endif +function! NERDTreeAddMenuItem(options) + call g:NERDTreeMenuItem.Create(a:options) endfunction -" FUNCTION: Bookmark.New(name, path) {{{3 -" Create a new bookmark object with the given name and path object -function! s:Bookmark.New(name, path) - if a:name =~# ' ' - throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name - endif - let newBookmark = copy(self) - let newBookmark.name = a:name - let newBookmark.path = a:path - return newBookmark -endfunction -" FUNCTION: Bookmark.open([options]) {{{3 -"Args: -"A dictionary containing the following keys (all optional): -" 'where': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' (vertical split), 'h' -" (horizontal split), 't' (new tab) or 'p' (previous window). -" 'reuse': if a window is displaying the file then jump the cursor there -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win -" -function! s:Bookmark.open(...) +function! NERDTreeAddMenuSeparator(...) let opts = a:0 ? a:1 : {} - - if self.path.isDirectory && !has_key(opts, 'where') - call self.toRoot() - else - let opener = s:Opener.New(self.path, opts) - call opener.open(self) - endif -endfunction -" FUNCTION: Bookmark.openInNewTab(options) {{{3 -" Create a new bookmark object with the given name and path object -function! s:Bookmark.openInNewTab(options) - call s:deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') - call self.open(a:options) -endfunction -" Function: Bookmark.setPath(path) {{{3 -" makes this bookmark point to the given path -function! s:Bookmark.setPath(path) - let self.path = a:path -endfunction -" Function: Bookmark.Sort() {{{3 -" Class method that sorts all bookmarks -function! s:Bookmark.Sort() - let CompareFunc = function("s:compareBookmarks") - call sort(s:Bookmark.Bookmarks(), CompareFunc) -endfunction -" Function: Bookmark.str() {{{3 -" Get the string that should be rendered in the view for this bookmark -function! s:Bookmark.str() - let pathStrMaxLen = winwidth(s:getTreeWinNum()) - 4 - len(self.name) - if &nu - let pathStrMaxLen = pathStrMaxLen - &numberwidth - endif - - let pathStr = self.path.str({'format': 'UI'}) - if len(pathStr) > pathStrMaxLen - let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) - endif - return '>' . self.name . ' ' . pathStr -endfunction -" FUNCTION: Bookmark.toRoot() {{{3 -" Make the node for this bookmark the new tree root -function! s:Bookmark.toRoot() - if self.validate() - try - let targetNode = self.getNode(1) - catch /^NERDTree.BookmarkedNodeNotFoundError/ - let targetNode = s:TreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) - endtry - call targetNode.makeRoot() - call s:renderView() - call targetNode.putCursorHere(0, 0) - endif -endfunction -" FUNCTION: Bookmark.ToRoot(name) {{{3 -" Make the node for this bookmark the new tree root -function! s:Bookmark.ToRoot(name) - let bookmark = s:Bookmark.BookmarkFor(a:name) - call bookmark.toRoot() -endfunction - - -"FUNCTION: Bookmark.validate() {{{3 -function! s:Bookmark.validate() - if self.path.exists() - return 1 - else - call s:Bookmark.CacheBookmarks(1) - call s:renderView() - call s:echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") - return 0 - endif -endfunction - -" Function: Bookmark.Write() {{{3 -" Class method to write all bookmarks to the bookmarks file -function! s:Bookmark.Write() - let bookmarkStrings = [] - for i in s:Bookmark.Bookmarks() - call add(bookmarkStrings, i.name . ' ' . i.path.str()) - endfor - - "add a blank line before the invalid ones - call add(bookmarkStrings, "") - - for j in s:Bookmark.InvalidBookmarks() - call add(bookmarkStrings, j) - endfor - call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) -endfunction -"CLASS: KeyMap {{{2 -"============================================================ -let s:KeyMap = {} -"FUNCTION: KeyMap.All() {{{3 -function! s:KeyMap.All() - if !exists("s:keyMaps") - let s:keyMaps = [] - endif - return s:keyMaps -endfunction - -"FUNCTION: KeyMap.FindFor(key, scope) {{{3 -function! s:KeyMap.FindFor(key, scope) - for i in s:KeyMap.All() - if i.key ==# a:key && i.scope ==# a:scope - return i - endif - endfor - return {} -endfunction - -"FUNCTION: KeyMap.BindAll() {{{3 -function! s:KeyMap.BindAll() - for i in s:KeyMap.All() - call i.bind() - endfor -endfunction - -"FUNCTION: KeyMap.bind() {{{3 -function! s:KeyMap.bind() - " If the key sequence we're trying to map contains any '<>' notation, we - " must replace each of the '<' characters with '' to ensure the string - " is not translated into its corresponding keycode during the later part - " of the map command below - " :he <> - let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)' - if self.key =~# specialNotationRegex - let keymapInvokeString = substitute(self.key, specialNotationRegex, '\1', 'g') - else - let keymapInvokeString = self.key - endif - - let premap = self.key == "" ? " " : " " - - exec 'nnoremap '. self.key . premap . ':call KeyMap_Invoke("'. keymapInvokeString .'")' -endfunction - -"FUNCTION: KeyMap.Remove(key, scope) {{{3 -function! s:KeyMap.Remove(key, scope) - let maps = s:KeyMap.All() - for i in range(len(maps)) - if maps[i].key ==# a:key && maps[i].scope ==# a:scope - return remove(maps, i) - endif - endfor -endfunction -"FUNCTION: KeyMap.invoke() {{{3 -"Call the KeyMaps callback function -function! s:KeyMap.invoke(...) - let Callback = function(self.callback) - if a:0 - call Callback(a:1) - else - call Callback() - endif -endfunction - - -"FUNCTION: KeyMap.Invoke() {{{3 -"Find a keymapping for a:key and the current scope invoke it. -" -"Scope is determined as follows: -" * if the cursor is on a dir node then "DirNode" -" * if the cursor is on a file node then "FileNode" -" * if the cursor is on a bookmark then "Bookmark" -" -"If a keymap has the scope of "all" then it will be called if no other keymap -"is found for a:key and the scope. -function! s:KeyMap.Invoke(key) - let node = s:TreeFileNode.GetSelected() - if !empty(node) - - "try file node - if !node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "FileNode") - if !empty(km) - return km.invoke(node) - endif - endif - - "try dir node - if node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "DirNode") - if !empty(km) - return km.invoke(node) - endif - endif - - "try generic node - let km = s:KeyMap.FindFor(a:key, "Node") - if !empty(km) - return km.invoke(node) - endif - - endif - - "try bookmark - let bm = s:Bookmark.GetSelected() - if !empty(bm) - let km = s:KeyMap.FindFor(a:key, "Bookmark") - if !empty(km) - return km.invoke(bm) - endif - endif - - "try all - let km = s:KeyMap.FindFor(a:key, "all") - if !empty(km) - return km.invoke() - endif -endfunction - -"this is needed since I cant figure out how to invoke dict functions from a -"key map -function! s:KeyMap_Invoke(key) - call s:KeyMap.Invoke(a:key) -endfunction - -"FUNCTION: KeyMap.Create(options) {{{3 -function! s:KeyMap.Create(options) - let newKeyMap = copy(self) - let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) - let newKeyMap.key = opts['key'] - let newKeyMap.quickhelpText = opts['quickhelpText'] - let newKeyMap.callback = opts['callback'] - let newKeyMap.scope = opts['scope'] - - call s:KeyMap.Add(newKeyMap) -endfunction - -"FUNCTION: KeyMap.Add(keymap) {{{3 -function! s:KeyMap.Add(keymap) - call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) - call add(s:KeyMap.All(), a:keymap) -endfunction - -"CLASS: MenuController {{{2 -"============================================================ -let s:MenuController = {} -"FUNCTION: MenuController.New(menuItems) {{{3 -"create a new menu controller that operates on the given menu items -function! s:MenuController.New(menuItems) - let newMenuController = copy(self) - if a:menuItems[0].isSeparator() - let newMenuController.menuItems = a:menuItems[1:-1] - else - let newMenuController.menuItems = a:menuItems - endif - return newMenuController -endfunction - -"FUNCTION: MenuController.showMenu() {{{3 -"start the main loop of the menu and get the user to choose/execute a menu -"item -function! s:MenuController.showMenu() - call self._saveOptions() - - try - let self.selection = 0 - - let done = 0 - while !done - redraw! - call self._echoPrompt() - let key = nr2char(getchar()) - let done = self._handleKeypress(key) - endwhile - finally - call self._restoreOptions() - endtry - - if self.selection != -1 - let m = self._current() - call m.execute() - endif -endfunction - -"FUNCTION: MenuController._echoPrompt() {{{3 -function! s:MenuController._echoPrompt() - echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" - echo "==========================================================" - - for i in range(0, len(self.menuItems)-1) - if self.selection == i - echo "> " . self.menuItems[i].text - else - echo " " . self.menuItems[i].text - endif - endfor -endfunction - -"FUNCTION: MenuController._current(key) {{{3 -"get the MenuItem that is currently selected -function! s:MenuController._current() - return self.menuItems[self.selection] -endfunction - -"FUNCTION: MenuController._handleKeypress(key) {{{3 -"change the selection (if appropriate) and return 1 if the user has made -"their choice, 0 otherwise -function! s:MenuController._handleKeypress(key) - if a:key == 'j' - call self._cursorDown() - elseif a:key == 'k' - call self._cursorUp() - elseif a:key == nr2char(27) "escape - let self.selection = -1 - return 1 - elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j - return 1 - else - let index = self._nextIndexFor(a:key) - if index != -1 - let self.selection = index - if len(self._allIndexesFor(a:key)) == 1 - return 1 - endif - endif - endif - - return 0 -endfunction - -"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3 -"get indexes to all menu items with the given shortcut -function! s:MenuController._allIndexesFor(shortcut) - let toReturn = [] - - for i in range(0, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut - call add(toReturn, i) - endif - endfor - - return toReturn -endfunction - -"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3 -"get the index to the next menu item with the given shortcut, starts from the -"current cursor location and wraps around to the top again if need be -function! s:MenuController._nextIndexFor(shortcut) - for i in range(self.selection+1, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut - return i - endif - endfor - - for i in range(0, self.selection) - if self.menuItems[i].shortcut == a:shortcut - return i - endif - endfor - - return -1 -endfunction - -"FUNCTION: MenuController._setCmdheight() {{{3 -"sets &cmdheight to whatever is needed to display the menu -function! s:MenuController._setCmdheight() - let &cmdheight = len(self.menuItems) + 3 -endfunction - -"FUNCTION: MenuController._saveOptions() {{{3 -"set any vim options that are required to make the menu work (saving their old -"values) -function! s:MenuController._saveOptions() - let self._oldLazyredraw = &lazyredraw - let self._oldCmdheight = &cmdheight - set nolazyredraw - call self._setCmdheight() -endfunction - -"FUNCTION: MenuController._restoreOptions() {{{3 -"restore the options we saved in _saveOptions() -function! s:MenuController._restoreOptions() - let &cmdheight = self._oldCmdheight - let &lazyredraw = self._oldLazyredraw -endfunction - -"FUNCTION: MenuController._cursorDown() {{{3 -"move the cursor to the next menu item, skipping separators -function! s:MenuController._cursorDown() - let done = 0 - while !done - if self.selection < len(self.menuItems)-1 - let self.selection += 1 - else - let self.selection = 0 - endif - - if !self._current().isSeparator() - let done = 1 - endif - endwhile -endfunction - -"FUNCTION: MenuController._cursorUp() {{{3 -"move the cursor to the previous menu item, skipping separators -function! s:MenuController._cursorUp() - let done = 0 - while !done - if self.selection > 0 - let self.selection -= 1 - else - let self.selection = len(self.menuItems)-1 - endif - - if !self._current().isSeparator() - let done = 1 - endif - endwhile -endfunction - -"CLASS: MenuItem {{{2 -"============================================================ -let s:MenuItem = {} -"FUNCTION: MenuItem.All() {{{3 -"get all top level menu items -function! s:MenuItem.All() - if !exists("s:menuItems") - let s:menuItems = [] - endif - return s:menuItems -endfunction - -"FUNCTION: MenuItem.AllEnabled() {{{3 -"get all top level menu items that are currently enabled -function! s:MenuItem.AllEnabled() - let toReturn = [] - for i in s:MenuItem.All() - if i.enabled() - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: MenuItem.Create(options) {{{3 -"make a new menu item and add it to the global list -function! s:MenuItem.Create(options) - let newMenuItem = copy(self) - - let newMenuItem.text = a:options['text'] - let newMenuItem.shortcut = a:options['shortcut'] - let newMenuItem.children = [] - - let newMenuItem.isActiveCallback = -1 - if has_key(a:options, 'isActiveCallback') - let newMenuItem.isActiveCallback = a:options['isActiveCallback'] - endif - - let newMenuItem.callback = -1 - if has_key(a:options, 'callback') - let newMenuItem.callback = a:options['callback'] - endif - - if has_key(a:options, 'parent') - call add(a:options['parent'].children, newMenuItem) - else - call add(s:MenuItem.All(), newMenuItem) - endif - - return newMenuItem -endfunction - -"FUNCTION: MenuItem.CreateSeparator(options) {{{3 -"make a new separator menu item and add it to the global list -function! s:MenuItem.CreateSeparator(options) - let standard_options = { 'text': '--------------------', - \ 'shortcut': -1, - \ 'callback': -1 } - let options = extend(a:options, standard_options, "force") - - return s:MenuItem.Create(options) -endfunction - -"FUNCTION: MenuItem.CreateSubmenu(options) {{{3 -"make a new submenu and add it to global list -function! s:MenuItem.CreateSubmenu(options) - let standard_options = { 'callback': -1 } - let options = extend(a:options, standard_options, "force") - - return s:MenuItem.Create(options) + call g:NERDTreeMenuItem.CreateSeparator(opts) endfunction -"FUNCTION: MenuItem.enabled() {{{3 -"return 1 if this menu item should be displayed -" -"delegates off to the isActiveCallback, and defaults to 1 if no callback was -"specified -function! s:MenuItem.enabled() - if self.isActiveCallback != -1 - return {self.isActiveCallback}() - endif - return 1 -endfunction - -"FUNCTION: MenuItem.execute() {{{3 -"perform the action behind this menu item, if this menuitem has children then -"display a new menu for them, otherwise deletegate off to the menuitem's -"callback -function! s:MenuItem.execute() - if len(self.children) - let mc = s:MenuController.New(self.children) - call mc.showMenu() - else - if self.callback != -1 - call {self.callback}() - endif - endif -endfunction - -"FUNCTION: MenuItem.isSeparator() {{{3 -"return 1 if this menuitem is a separator -function! s:MenuItem.isSeparator() - return self.callback == -1 && self.children == [] -endfunction - -"FUNCTION: MenuItem.isSubmenu() {{{3 -"return 1 if this menuitem is a submenu -function! s:MenuItem.isSubmenu() - return self.callback == -1 && !empty(self.children) +function! NERDTreeAddSubmenu(options) + return g:NERDTreeMenuItem.Create(a:options) endfunction -"CLASS: TreeFileNode {{{2 -"This class is the parent of the TreeDirNode class and constitures the -"'Component' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:TreeFileNode = {} -"FUNCTION: TreeFileNode.activate(...) {{{3 -function! s:TreeFileNode.activate(...) - call self.open(a:0 ? a:1 : {}) +function! NERDTreeAddKeyMap(options) + call g:NERDTreeKeyMap.Create(a:options) endfunction -"FUNCTION: TreeFileNode.bookmark(name) {{{3 -"bookmark this node with a:name -function! s:TreeFileNode.bookmark(name) - - "if a bookmark exists with the same name and the node is cached then save - "it so we can update its display string - let oldMarkedNode = {} - try - let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1) - catch /^NERDTree.BookmarkNotFoundError/ - catch /^NERDTree.BookmarkedNodeNotFoundError/ - endtry - call s:Bookmark.AddBookmark(a:name, self.path) - call self.path.cacheDisplayString() - call s:Bookmark.Write() - - if !empty(oldMarkedNode) - call oldMarkedNode.path.cacheDisplayString() - endif -endfunction -"FUNCTION: TreeFileNode.cacheParent() {{{3 -"initializes self.parent if it isnt already -function! s:TreeFileNode.cacheParent() - if empty(self.parent) - let parentPath = self.path.getParent() - if parentPath.equals(self.path) - throw "NERDTree.CannotCacheParentError: already at root" - endif - let self.parent = s:TreeFileNode.New(parentPath) - endif -endfunction -"FUNCTION: TreeFileNode.compareNodes {{{3 -"This is supposed to be a class level method but i cant figure out how to -"get func refs to work from a dict.. -" -"A class level method that compares two nodes -" -"Args: -"n1, n2: the 2 nodes to compare -function! s:compareNodes(n1, n2) - return a:n1.path.compareTo(a:n2.path) +function! NERDTreeRender() + call nerdtree#renderView() endfunction -"FUNCTION: TreeFileNode.clearBookmarks() {{{3 -function! s:TreeFileNode.clearBookmarks() - for i in s:Bookmark.Bookmarks() - if i.path.equals(self.path) - call i.delete() - end - endfor - call self.path.cacheDisplayString() -endfunction -"FUNCTION: TreeFileNode.copy(dest) {{{3 -function! s:TreeFileNode.copy(dest) - call self.path.copy(a:dest) - let newPath = s:Path.New(a:dest) - let parent = b:NERDTreeRoot.findNode(newPath.getParent()) - if !empty(parent) - call parent.refresh() - return parent.findNode(newPath) +function! NERDTreeFocus() + if nerdtree#isTreeOpen() + call nerdtree#putCursorInTreeWin() else - return {} - endif -endfunction - -"FUNCTION: TreeFileNode.delete {{{3 -"Removes this node from the tree and calls the Delete method for its path obj -function! s:TreeFileNode.delete() - call self.path.delete() - call self.parent.removeChild(self) -endfunction - -"FUNCTION: TreeFileNode.displayString() {{{3 -" -"Returns a string that specifies how the node should be represented as a -"string -" -"Return: -"a string that can be used in the view to represent this node -function! s:TreeFileNode.displayString() - return self.path.displayString() -endfunction - -"FUNCTION: TreeFileNode.equals(treenode) {{{3 -" -"Compares this treenode to the input treenode and returns 1 if they are the -"same node. -" -"Use this method instead of == because sometimes when the treenodes contain -"many children, vim seg faults when doing == -" -"Args: -"treenode: the other treenode to compare to -function! s:TreeFileNode.equals(treenode) - return self.path.str() ==# a:treenode.path.str() -endfunction - -"FUNCTION: TreeFileNode.findNode(path) {{{3 -"Returns self if this node.path.Equals the given path. -"Returns {} if not equal. -" -"Args: -"path: the path object to compare against -function! s:TreeFileNode.findNode(path) - if a:path.equals(self.path) - return self - endif - return {} -endfunction -"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction. This sibling -"must be a directory and may/may not have children as specified. -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no appropriate sibling could be found -function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) - "if we have no parent then we can have no siblings - if self.parent != {} - let nextSibling = self.findSibling(a:direction) - - while nextSibling != {} - if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen - return nextSibling - endif - let nextSibling = nextSibling.findSibling(a:direction) - endwhile - endif - - return {} -endfunction -"FUNCTION: TreeFileNode.findSibling(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no sibling could be found -function! s:TreeFileNode.findSibling(direction) - "if we have no parent then we can have no siblings - if self.parent != {} - - "get the index of this node in its parents children - let siblingIndx = self.parent.getChildIndex(self.path) - - if siblingIndx != -1 - "move a long to the next potential sibling node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - - "keep moving along to the next sibling till we find one that is valid - let numSiblings = self.parent.getChildCount() - while siblingIndx >= 0 && siblingIndx < numSiblings - - "if the next node is not an ignored node (i.e. wont show up in the - "view) then return it - if self.parent.children[siblingIndx].path.ignore() ==# 0 - return self.parent.children[siblingIndx] - endif - - "go to next node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - endwhile - endif - endif - - return {} -endfunction - -"FUNCTION: TreeFileNode.getLineNum(){{{3 -"returns the line number this node is rendered on, or -1 if it isnt rendered -function! s:TreeFileNode.getLineNum() - "if the node is the root then return the root line no. - if self.isRoot() - return s:TreeFileNode.GetRootLineNum() + call nerdtree#toggle("") endif - - let totalLines = line("$") - - "the path components we have matched so far - let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] - "the index of the component we are searching for - let curPathComponent = 1 - - let fullpath = self.path.str({'format': 'UI'}) - - - let lnum = s:TreeFileNode.GetRootLineNum() - while lnum > 0 - let lnum = lnum + 1 - "have we reached the bottom of the tree? - if lnum ==# totalLines+1 - return -1 - endif - - let curLine = getline(lnum) - - let indent = s:indentLevelFor(curLine) - if indent ==# curPathComponent - let curLine = s:stripMarkupFromLine(curLine, 1) - - let curPath = join(pathcomponents, '/') . '/' . curLine - if stridx(fullpath, curPath, 0) ==# 0 - if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' - let curLine = substitute(curLine, '/ *$', '', '') - call add(pathcomponents, curLine) - let curPathComponent = curPathComponent + 1 - - if fullpath ==# curPath - return lnum - endif - endif - endif - endif - endwhile - return -1 -endfunction - -"FUNCTION: TreeFileNode.GetRootForTab(){{{3 -"get the root node for this tab -function! s:TreeFileNode.GetRootForTab() - if s:treeExistsForTab() - return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot') - end - return {} -endfunction -"FUNCTION: TreeFileNode.GetRootLineNum(){{{3 -"gets the line number of the root node -function! s:TreeFileNode.GetRootLineNum() - let rootLine = 1 - while getline(rootLine) !~# '^\(/\|<\)' - let rootLine = rootLine + 1 - endwhile - return rootLine endfunction -"FUNCTION: TreeFileNode.GetSelected() {{{3 -"gets the treenode that the cursor is currently over -function! s:TreeFileNode.GetSelected() - try - let path = s:getPath(line(".")) - if path ==# {} - return {} - endif - return b:NERDTreeRoot.findNode(path) - catch /NERDTree/ - return {} - endtry -endfunction -"FUNCTION: TreeFileNode.isVisible() {{{3 -"returns 1 if this node should be visible according to the tree filters and -"hidden file filters (and their on/off status) -function! s:TreeFileNode.isVisible() - return !self.path.ignore() +function! NERDTreeCWD() + call NERDTreeFocus() + call nerdtree#chRootCwd() endfunction -"FUNCTION: TreeFileNode.isRoot() {{{3 -"returns 1 if this node is b:NERDTreeRoot -function! s:TreeFileNode.isRoot() - if !s:treeExistsForBuf() - throw "NERDTree.NoTreeError: No tree exists for the current buffer" - endif - - return self.equals(b:NERDTreeRoot) -endfunction - -"FUNCTION: TreeFileNode.makeRoot() {{{3 -"Make this node the root of the tree -function! s:TreeFileNode.makeRoot() - if self.path.isDirectory - let b:NERDTreeRoot = self - else - call self.cacheParent() - let b:NERDTreeRoot = self.parent - endif - - call b:NERDTreeRoot.open() - - "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 - exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'}) - endif - - silent doautocmd User NERDTreeNewRoot -endfunction -"FUNCTION: TreeFileNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -function! s:TreeFileNode.New(path) - if a:path.isDirectory - return s:TreeDirNode.New(a:path) - else - let newTreeNode = copy(self) - let newTreeNode.path = a:path - let newTreeNode.parent = {} - return newTreeNode - endif -endfunction - -"FUNCTION: TreeFileNode.open() {{{3 -function! s:TreeFileNode.open(...) - let opts = a:0 ? a:1 : {} - let opener = s:Opener.New(self.path, opts) - call opener.open(self) -endfunction - -"FUNCTION: TreeFileNode.openSplit() {{{3 -"Open this node in a new window -function! s:TreeFileNode.openSplit() - call s:deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') - call self.open({'where': 'h'}) -endfunction -"FUNCTION: TreeFileNode.openVSplit() {{{3 -"Open this node in a new vertical window -function! s:TreeFileNode.openVSplit() - call s:deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') - call self.open({'where': 'v'}) -endfunction -"FUNCTION: TreeFileNode.openInNewTab(options) {{{3 -function! s:TreeFileNode.openInNewTab(options) - echomsg 'TreeFileNode.openInNewTab is deprecated' - call self.open(extend({'where': 't'}, a:options)) -endfunction -"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 -"Places the cursor on the line number this node is rendered on -" -"Args: -"isJump: 1 if this cursor movement should be counted as a jump by vim -"recurseUpward: try to put the cursor on the parent if the this node isnt -"visible -function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) - let ln = self.getLineNum() - if ln != -1 - if a:isJump - mark ' - endif - call cursor(ln, col(".")) - else - if a:recurseUpward - let node = self - while node != {} && node.getLineNum() ==# -1 - let node = node.parent - call node.open() - endwhile - call s:renderView() - call node.putCursorHere(a:isJump, 0) - endif - endif -endfunction - -"FUNCTION: TreeFileNode.refresh() {{{3 -function! s:TreeFileNode.refresh() - call self.path.refresh() -endfunction -"FUNCTION: TreeFileNode.rename() {{{3 -"Calls the rename method for this nodes path obj -function! s:TreeFileNode.rename(newName) - let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') - call self.path.rename(newName) - call self.parent.removeChild(self) - - let parentPath = self.path.getParent() - let newParent = b:NERDTreeRoot.findNode(parentPath) - - if newParent != {} - call newParent.createChild(self.path, 1) - call newParent.refresh() - endif -endfunction -"FUNCTION: TreeFileNode.renderToString {{{3 -"returns a string representation for this tree to be rendered in the view -function! s:TreeFileNode.renderToString() - return self._renderToString(0, 0, [], self.getChildCount() ==# 1) -endfunction - - -"Args: -"depth: the current depth in the tree for this call -"drawText: 1 if we should actually draw the line for this node (if 0 then the -"child nodes are rendered only) -"vertMap: a binary array that indicates whether a vertical bar should be draw -"for each depth in the tree -"isLastChild:true if this curNode is the last child of its parent -function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) - let output = "" - if a:drawText ==# 1 - - let treeParts = '' - - "get all the leading spaces and vertical tree parts for this line - if a:depth > 1 - for j in a:vertMap[0:-2] - if g:NERDTreeDirArrows - let treeParts = treeParts . ' ' - else - if j ==# 1 - let treeParts = treeParts . '| ' - else - let treeParts = treeParts . ' ' - endif - endif - endfor - endif - - "get the last vertical tree part for this line which will be different - "if this node is the last child of its parent - if !g:NERDTreeDirArrows - if a:isLastChild - let treeParts = treeParts . '`' - else - let treeParts = treeParts . '|' - endif - endif - - "smack the appropriate dir/file symbol on the line before the file/dir - "name itself - if self.path.isDirectory - if self.isOpen - if g:NERDTreeDirArrows - let treeParts = treeParts . '▾ ' - else - let treeParts = treeParts . '~' - endif - else - if g:NERDTreeDirArrows - let treeParts = treeParts . '▸ ' - else - let treeParts = treeParts . '+' - endif - endif - else - if g:NERDTreeDirArrows - let treeParts = treeParts . ' ' - else - let treeParts = treeParts . '-' - endif - endif - let line = treeParts . self.displayString() - - let output = output . line . "\n" - endif - - "if the node is an open dir, draw its children - if self.path.isDirectory ==# 1 && self.isOpen ==# 1 - - let childNodesToDraw = self.getVisibleChildren() - if len(childNodesToDraw) > 0 - - "draw all the nodes children except the last - let lastIndx = len(childNodesToDraw)-1 - if lastIndx > 0 - for i in childNodesToDraw[0:lastIndx-1] - let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0) - endfor - endif - - "draw the last child, indicating that it IS the last - let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1) - endif - endif - - return output -endfunction -"CLASS: TreeDirNode {{{2 -"This class is a child of the TreeFileNode class and constitutes the -"'Composite' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:TreeDirNode = copy(s:TreeFileNode) -"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3 -"class method that returns the highest cached ancestor of the current root -function! s:TreeDirNode.AbsoluteTreeRoot() - let currentNode = b:NERDTreeRoot - while currentNode.parent != {} - let currentNode = currentNode.parent - endwhile - return currentNode -endfunction -"FUNCTION: TreeDirNode.activate([options]) {{{3 -unlet s:TreeDirNode.activate -function! s:TreeDirNode.activate(...) - let opts = a:0 ? a:1 : {} - call self.toggleOpen(opts) - call s:renderView() - call self.putCursorHere(0, 0) -endfunction -"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3 -"Adds the given treenode to the list of children for this node -" -"Args: -"-treenode: the node to add -"-inOrder: 1 if the new node should be inserted in sorted order -function! s:TreeDirNode.addChild(treenode, inOrder) - call add(self.children, a:treenode) - let a:treenode.parent = self - - if a:inOrder - call self.sortChildren() - endif -endfunction - -"FUNCTION: TreeDirNode.close() {{{3 -"Closes this directory -function! s:TreeDirNode.close() - let self.isOpen = 0 -endfunction - -"FUNCTION: TreeDirNode.closeChildren() {{{3 -"Closes all the child dir nodes of this node -function! s:TreeDirNode.closeChildren() - for i in self.children - if i.path.isDirectory - call i.close() - call i.closeChildren() - endif - endfor -endfunction - -"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3 -"Instantiates a new child node for this node with the given path. The new -"nodes parent is set to this node. -" -"Args: -"path: a Path object that this node will represent/contain -"inOrder: 1 if the new node should be inserted in sorted order -" -"Returns: -"the newly created node -function! s:TreeDirNode.createChild(path, inOrder) - let newTreeNode = s:TreeFileNode.New(a:path) - call self.addChild(newTreeNode, a:inOrder) - return newTreeNode -endfunction - -"FUNCTION: TreeDirNode.findNode(path) {{{3 -"Will find one of the children (recursively) that has the given path -" -"Args: -"path: a path object -unlet s:TreeDirNode.findNode -function! s:TreeDirNode.findNode(path) - if a:path.equals(self.path) - return self - endif - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return {} - endif - - if self.path.isDirectory - for i in self.children - let retVal = i.findNode(a:path) - if retVal != {} - return retVal - endif - endfor - endif - return {} -endfunction -"FUNCTION: TreeDirNode.getChildCount() {{{3 -"Returns the number of children this node has -function! s:TreeDirNode.getChildCount() - return len(self.children) -endfunction - -"FUNCTION: TreeDirNode.getChild(path) {{{3 -"Returns child node of this node that has the given path or {} if no such node -"exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:TreeDirNode.getChild(path) - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return {} - endif - - let index = self.getChildIndex(a:path) - if index ==# -1 - return {} - else - return self.children[index] - endif - -endfunction - -"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3 -"returns the child at the given index -"Args: -"indx: the index to get the child from -"visible: 1 if only the visible children array should be used, 0 if all the -"children should be searched. -function! s:TreeDirNode.getChildByIndex(indx, visible) - let array_to_search = a:visible? self.getVisibleChildren() : self.children - if a:indx > len(array_to_search) - throw "NERDTree.InvalidArgumentsError: Index is out of bounds." - endif - return array_to_search[a:indx] -endfunction - -"FUNCTION: TreeDirNode.getChildIndex(path) {{{3 -"Returns the index of the child node of this node that has the given path or -"-1 if no such node exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:TreeDirNode.getChildIndex(path) - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return -1 - endif - - "do a binary search for the child - let a = 0 - let z = self.getChildCount() - while a < z - let mid = (a+z)/2 - let diff = a:path.compareTo(self.children[mid].path) - - if diff ==# -1 - let z = mid - elseif diff ==# 1 - let a = mid+1 - else - return mid - endif - endwhile - return -1 -endfunction - -"FUNCTION: TreeDirNode.GetSelected() {{{3 -"Returns the current node if it is a dir node, or else returns the current -"nodes parent -unlet s:TreeDirNode.GetSelected -function! s:TreeDirNode.GetSelected() - let currentDir = s:TreeFileNode.GetSelected() - if currentDir != {} && !currentDir.isRoot() - if currentDir.path.isDirectory ==# 0 - let currentDir = currentDir.parent - endif - endif - return currentDir -endfunction -"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3 -"Returns the number of visible children this node has -function! s:TreeDirNode.getVisibleChildCount() - return len(self.getVisibleChildren()) -endfunction - -"FUNCTION: TreeDirNode.getVisibleChildren() {{{3 -"Returns a list of children to display for this node, in the correct order -" -"Return: -"an array of treenodes -function! s:TreeDirNode.getVisibleChildren() - let toReturn = [] - for i in self.children - if i.path.ignore() ==# 0 - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3 -"returns 1 if this node has any childre, 0 otherwise.. -function! s:TreeDirNode.hasVisibleChildren() - return self.getVisibleChildCount() != 0 -endfunction - -"FUNCTION: TreeDirNode._initChildren() {{{3 -"Removes all childen from this node and re-reads them -" -"Args: -"silent: 1 if the function should not echo any "please wait" messages for -"large directories -" -"Return: the number of child nodes read -function! s:TreeDirNode._initChildren(silent) - "remove all the current child nodes - let self.children = [] - - "get an array of all the files in the nodes dir - let dir = self.path - let globDir = dir.str({'format': 'Glob'}) - - if version >= 703 - let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1) - else - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - endif - - let files = split(filesStr, "\n") - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:echo("Please wait, caching a large dir ...") - endif - - let invalidFilesFound = 0 - for i in files - - "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns - "../ for path with strange chars (eg $) - if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' - - "put the next file in a new node and attach it - try - let path = s:Path.New(i) - call self.createChild(path, 0) - catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound += 1 - endtry - endif - endfor - - call self.sortChildren() - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).") - endif - - if invalidFilesFound - call s:echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") - endif - return self.getChildCount() -endfunction -"FUNCTION: TreeDirNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -unlet s:TreeDirNode.New -function! s:TreeDirNode.New(path) - if a:path.isDirectory != 1 - throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." - endif - - let newTreeNode = copy(self) - let newTreeNode.path = a:path - - let newTreeNode.isOpen = 0 - let newTreeNode.children = [] - - let newTreeNode.parent = {} - - return newTreeNode -endfunction -"FUNCTION: TreeDirNode.open([opts]) {{{3 -"Open the dir in the current tree or in a new tree elsewhere. -" -"If opening in the current tree, return the number of cached nodes. -unlet s:TreeDirNode.open -function! s:TreeDirNode.open(...) - let opts = a:0 ? a:1 : {} - - if has_key(opts, 'where') && !empty(opts['where']) - let opener = s:Opener.New(self.path, opts) - call opener.open(self) - else - let self.isOpen = 1 - if self.children ==# [] - return self._initChildren(0) - else - return 0 - endif - endif -endfunction -"FUNCTION: TreeDirNode.openAlong([opts]) {{{3 -"recursive open the dir if it has only one directory child. -" -"return the level of opened directories. -function! s:TreeDirNode.openAlong(...) - let opts = a:0 ? a:1 : {} - let level = 0 - - let node = self - while node.path.isDirectory - call node.open(opts) - let level += 1 - if node.getVisibleChildCount() == 1 - let node = node.getChildByIndex(0, 1) - else - break - endif - endwhile - return level -endfunction -" FUNCTION: TreeDirNode.openExplorer() {{{3 -" opens an explorer window for this node in the previous window (could be a -" nerd tree or a netrw) -function! s:TreeDirNode.openExplorer() - call self.open({'where': 'p'}) -endfunction -"FUNCTION: TreeDirNode.openInNewTab(options) {{{3 -unlet s:TreeDirNode.openInNewTab -function! s:TreeDirNode.openInNewTab(options) - call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') - call self.open({'where': 't'}) -endfunction -"FUNCTION: TreeDirNode._openInNewTab() {{{3 -function! s:TreeDirNode._openInNewTab() - tabnew - call s:initNerdTree(self.path.str()) -endfunction -"FUNCTION: TreeDirNode.openRecursively() {{{3 -"Opens this treenode and all of its children whose paths arent 'ignored' -"because of the file filters. -" -"This method is actually a wrapper for the OpenRecursively2 method which does -"the work. -function! s:TreeDirNode.openRecursively() - call self._openRecursively2(1) -endfunction - -"FUNCTION: TreeDirNode._openRecursively2() {{{3 -"Opens this all children of this treenode recursively if either: -" *they arent filtered by file filters -" *a:forceOpen is 1 -" -"Args: -"forceOpen: 1 if this node should be opened regardless of file filters -function! s:TreeDirNode._openRecursively2(forceOpen) - if self.path.ignore() ==# 0 || a:forceOpen - let self.isOpen = 1 - if self.children ==# [] - call self._initChildren(1) - endif - - for i in self.children - if i.path.isDirectory ==# 1 - call i._openRecursively2(0) - endif - endfor - endif -endfunction - -"FUNCTION: TreeDirNode.refresh() {{{3 -unlet s:TreeDirNode.refresh -function! s:TreeDirNode.refresh() - call self.path.refresh() - - "if this node was ever opened, refresh its children - if self.isOpen || !empty(self.children) - "go thru all the files/dirs under this node - let newChildNodes = [] - let invalidFilesFound = 0 - let dir = self.path - let globDir = dir.str({'format': 'Glob'}) - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - let files = split(filesStr, "\n") - for i in files - "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns - "../ for path with strange chars (eg $) - if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' - - try - "create a new path and see if it exists in this nodes children - let path = s:Path.New(i) - let newNode = self.getChild(path) - if newNode != {} - call newNode.refresh() - call add(newChildNodes, newNode) - - "the node doesnt exist so create it - else - let newNode = s:TreeFileNode.New(path) - let newNode.parent = self - call add(newChildNodes, newNode) - endif - - - catch /^NERDTree.InvalidArgumentsError/ - let invalidFilesFound = 1 - endtry - endif - endfor - - "swap this nodes children out for the children we just read/refreshed - let self.children = newChildNodes - call self.sortChildren() - - if invalidFilesFound - call s:echoWarning("some files could not be loaded into the NERD tree") - endif - endif -endfunction - -"FUNCTION: TreeDirNode.reveal(path) {{{3 -"reveal the given path, i.e. cache and open all treenodes needed to display it -"in the UI -function! s:TreeDirNode.reveal(path) - if !a:path.isUnder(self.path) - throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() - endif - - call self.open() - - if self.path.equals(a:path.getParent()) - let n = self.findNode(a:path) - call s:renderView() - call n.putCursorHere(1,0) - return - endif - - let p = a:path - while !p.getParent().equals(self.path) - let p = p.getParent() - endwhile - - let n = self.findNode(p) - call n.reveal(a:path) -endfunction -"FUNCTION: TreeDirNode.removeChild(treenode) {{{3 -" -"Removes the given treenode from this nodes set of children -" -"Args: -"treenode: the node to remove -" -"Throws a NERDTree.ChildNotFoundError if the given treenode is not found -function! s:TreeDirNode.removeChild(treenode) - for i in range(0, self.getChildCount()-1) - if self.children[i].equals(a:treenode) - call remove(self.children, i) - return - endif - endfor - - throw "NERDTree.ChildNotFoundError: child node was not found" -endfunction - -"FUNCTION: TreeDirNode.sortChildren() {{{3 -" -"Sorts the children of this node according to alphabetical order and the -"directory priority. -" -function! s:TreeDirNode.sortChildren() - let CompareFunc = function("s:compareNodes") - call sort(self.children, CompareFunc) -endfunction - -"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3 -"Opens this directory if it is closed and vice versa -function! s:TreeDirNode.toggleOpen(...) - let opts = a:0 ? a:1 : {} - if self.isOpen ==# 1 - call self.close() - else - if g:NERDTreeCasadeOpenSingleChildDir == 0 - call self.open(opts) - else - call self.openAlong(opts) - endif - endif -endfunction -"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3 -"Replaces the child of this with the given node (where the child node's full -"path matches a:newNode's fullpath). The search for the matching node is -"non-recursive -" -"Arg: -"newNode: the node to graft into the tree -function! s:TreeDirNode.transplantChild(newNode) - for i in range(0, self.getChildCount()-1) - if self.children[i].equals(a:newNode) - let self.children[i] = a:newNode - let a:newNode.parent = self - break - endif - endfor -endfunction -"============================================================ -"CLASS: Opener {{{2 -"============================================================ -let s:Opener = {} - -"FUNCTION: Opener._checkToCloseTree(newtab) {{{3 -"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see -"if the tree should be closed now. -" -"Args: -"a:newtab - boolean. If set, only close the tree now if we are opening the -"target in a new tab. This is needed because we have to close tree before we -"leave the tab -function! s:Opener._checkToCloseTree(newtab) - if self._keepopen - return - endif - - if (a:newtab && self._where == 't') || !a:newtab - call s:closeTreeIfQuitOnOpen() - endif -endfunction - -"FUNCTION: Opener._gotoTargetWin() {{{3 -function! s:Opener._gotoTargetWin() - if b:NERDTreeType ==# "secondary" - if self._where == 'v' - vsplit - elseif self._where == 'h' - split - elseif self._where == 't' - tabnew - endif - else - call self._checkToCloseTree(1) - - if self._where == 'v' - call self._newVSplit() - elseif self._where == 'h' - call self._newSplit() - elseif self._where == 't' - tabnew - elseif self._where == 'p' - call self._previousWindow() - endif - - call self._checkToCloseTree(0) - endif -endfunction - -"FUNCTION: Opener.New(path, opts) {{{3 -"Args: -" -"a:path: The path object that is to be opened. -" -"a:opts: -" -"A dictionary containing the following keys (all optional): -" 'where': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' or 'h' or 't' (for open in -" new tab) -" 'reuse': if a window is displaying the file then jump the cursor there -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win -function! s:Opener.New(path, opts) - let newObj = copy(self) - - let newObj._path = a:path - let newObj._stay = s:has_opt(a:opts, 'stay') - let newObj._reuse = s:has_opt(a:opts, 'reuse') - let newObj._keepopen = s:has_opt(a:opts, 'keepopen') - let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' - let newObj._treetype = b:NERDTreeType - call newObj._saveCursorPos() - - return newObj -endfunction - -"FUNCTION: Opener._newSplit() {{{3 -function! s:Opener._newSplit() - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call s:exec(back) - - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately - if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below - endif - - let splitMode = onlyOneWin ? "vertical" : "" - - " Open the new window - try - exec(splitMode." sp ") - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - "do nothing - endtry - - "resize the tree window if no other window was open before - if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call s:exec(there) - exec("silent ". splitMode ." resize ". size) - call s:exec('wincmd p') - endif - - " Restore splitmode settings - let &splitbelow=savesplitbelow - let &splitright=savesplitright -endfunction - -"FUNCTION: Opener._newVSplit() {{{3 -function! s:Opener._newVSplit() - let winwidth = winwidth(".") - if winnr("$")==#1 - let winwidth = g:NERDTreeWinSize - endif - - call s:exec("wincmd p") - vnew - - "resize the nerd tree back to the original size - call s:putCursorInTreeWin() - exec("silent vertical resize ". winwidth) - call s:exec('wincmd p') -endfunction - -"FUNCTION: Opener.open(target) {{{3 -function! s:Opener.open(target) - if self._path.isDirectory - call self._openDirectory(a:target) - else - call self._openFile() - endif -endfunction - -"FUNCTION: Opener._openFile() {{{3 -function! s:Opener._openFile() - if self._reuse && self._reuseWindow() - return - endif - - call self._gotoTargetWin() - - if self._treetype ==# "secondary" - call self._path.edit() - else - call self._path.edit() - - - if self._stay - call self._restoreCursorPos() - endif - endif -endfunction - -"FUNCTION: Opener._openDirectory(node) {{{3 -function! s:Opener._openDirectory(node) - if self._treetype ==# "secondary" - call self._gotoTargetWin() - call s:initNerdTreeInPlace(a:node.path.str()) - else - call self._gotoTargetWin() - if empty(self._where) - call a:node.makeRoot() - call s:renderView() - call a:node.putCursorHere(0, 0) - elseif self._where == 't' - call s:initNerdTree(a:node.path.str()) - else - call s:initNerdTreeInPlace(a:node.path.str()) - endif - endif - - if self._stay - call self._restoreCursorPos() - endif -endfunction - -"FUNCTION: Opener._previousWindow() {{{3 -function! s:Opener._previousWindow() - if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 - call self._newSplit() - else - try - if !s:isWindowUsable(winnr("#")) - call s:exec(s:firstUsableWindow() . "wincmd w") - else - call s:exec('wincmd p') - endif - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - echo v:exception - endtry - endif -endfunction - -"FUNCTION: Opener._restoreCursorPos(){{{3 -function! s:Opener._restoreCursorPos() - call s:exec('normal ' . self._tabnr . 'gt') - call s:exec(bufwinnr(self._bufnr) . 'wincmd w') -endfunction - -"FUNCTION: Opener._reuseWindow(){{{3 -"put the cursor in the first window we find for this file -" -"return 1 if we were successful -function! s:Opener._reuseWindow() - "check the current tab for the window - let winnr = bufwinnr('^' . self._path.str() . '$') - if winnr != -1 - call s:exec(winnr . "wincmd w") - call self._checkToCloseTree(0) - return 1 - else - "check other tabs - let tabnr = self._path.tabnr() - if tabnr - call self._checkToCloseTree(1) - call s:exec('normal! ' . tabnr . 'gt') - let winnr = bufwinnr('^' . self._path.str() . '$') - call s:exec(winnr . "wincmd w") - return 1 - endif - endif - return 0 -endfunction - -"FUNCTION: Opener._saveCursorPos(){{{3 -function! s:Opener._saveCursorPos() - let self._bufnr = bufnr("") - let self._tabnr = tabpagenr() -endfunction - -"CLASS: Path {{{2 -"============================================================ -let s:Path = {} -"FUNCTION: Path.AbsolutePathFor(str) {{{3 -function! s:Path.AbsolutePathFor(str) - let prependCWD = 0 - if s:running_windows - let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)' - else - let prependCWD = a:str !~# '^/' - endif - - let toReturn = a:str - if prependCWD - let toReturn = getcwd() . s:Path.Slash() . a:str - endif - - return toReturn -endfunction -"FUNCTION: Path.bookmarkNames() {{{3 -function! s:Path.bookmarkNames() - if !exists("self._bookmarkNames") - call self.cacheDisplayString() - endif - return self._bookmarkNames -endfunction -"FUNCTION: Path.cacheDisplayString() {{{3 -function! s:Path.cacheDisplayString() - let self.cachedDisplayString = self.getLastPathComponent(1) - - if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . '*' - endif - - let self._bookmarkNames = [] - for i in s:Bookmark.Bookmarks() - if i.path.equals(self) - call add(self._bookmarkNames, i.name) - endif - endfor - if !empty(self._bookmarkNames) - let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' - endif - - if self.isSymLink - let self.cachedDisplayString .= ' -> ' . self.symLinkDest - endif - - if self.isReadOnly - let self.cachedDisplayString .= ' [RO]' - endif -endfunction -"FUNCTION: Path.changeToDir() {{{3 -function! s:Path.changeToDir() - let dir = self.str({'format': 'Cd'}) - if self.isDirectory ==# 0 - let dir = self.getParent().str({'format': 'Cd'}) - endif - - try - execute "cd " . dir - call s:echo("CWD is now: " . getcwd()) - catch - throw "NERDTree.PathChangeError: cannot change CWD to " . dir - endtry -endfunction - -"FUNCTION: Path.compareTo() {{{3 -" -"Compares this Path to the given path and returns 0 if they are equal, -1 if -"this Path is "less than" the given path, or 1 if it is "greater". -" -"Args: -"path: the path object to compare this to -" -"Return: -"1, -1 or 0 -function! s:Path.compareTo(path) - let thisPath = self.getLastPathComponent(1) - let thatPath = a:path.getLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath ==# thatPath - return 0 - endif - - let thisSS = self.getSortOrderIndex() - let thatSS = a:path.getSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath limit - let toReturn = "<" . strpart(toReturn, len(toReturn) - limit + 1) - endif - endif - - return toReturn -endfunction - -"FUNCTION: Path._strForUI() {{{3 -function! s:Path._strForUI() - let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' - let toReturn = toReturn . '/' - endif - return toReturn -endfunction - -"FUNCTION: Path._strForCd() {{{3 -" -" returns a string that can be used with :cd -function! s:Path._strForCd() - return escape(self.str(), s:escape_chars) -endfunction -"FUNCTION: Path._strForEdit() {{{3 -" -"Return: the string for this path that is suitable to be used with the :edit -"command -function! s:Path._strForEdit() - let p = escape(self.str({'format': 'UI'}), s:escape_chars) - let cwd = getcwd() . s:Path.Slash() - - "return a relative path if we can - let isRelative = 0 - if s:running_windows - let isRelative = stridx(tolower(p), tolower(cwd)) == 0 - else - let isRelative = stridx(p, cwd) == 0 - endif - - if isRelative - let p = strpart(p, strlen(cwd)) - - "handle the edge case where the file begins with a + (vim interprets - "the +foo in `:e +foo` as an option to :edit) - if p[0] == "+" - let p = '\' . p - endif - endif - - if p ==# '' - let p = '.' - endif - - return p -endfunction -"FUNCTION: Path._strForGlob() {{{3 -function! s:Path._strForGlob() - let lead = s:Path.Slash() - - "if we are running windows then slap a drive letter on the front - if s:running_windows - let lead = self.drive . '\' - endif - - let toReturn = lead . join(self.pathSegments, s:Path.Slash()) - - if !s:running_windows - let toReturn = escape(toReturn, s:escape_chars) - endif - return toReturn -endfunction -"FUNCTION: Path._str() {{{3 -" -"Gets the string path for this path object that is appropriate for the OS. -"EG, in windows c:\foo\bar -" in *nix /foo/bar -function! s:Path._str() - let lead = s:Path.Slash() - - "if we are running windows then slap a drive letter on the front - if s:running_windows - let lead = self.drive . '\' - endif - - return lead . join(self.pathSegments, s:Path.Slash()) -endfunction - -"FUNCTION: Path.strTrunk() {{{3 -"Gets the path without the last segment on the end. -function! s:Path.strTrunk() - return self.drive . '/' . join(self.pathSegments[0:-2], '/') -endfunction - -" FUNCTION: Path.tabnr() {{{3 -" return the number of the first tab that is displaying this file -" -" return 0 if no tab was found -function! s:Path.tabnr() - let str = self.str() - for t in range(tabpagenr('$')) - for b in tabpagebuflist(t+1) - if str == expand('#' . b . ':p') - return t+1 - endif - endfor - endfor - return 0 -endfunction -"FUNCTION: Path.WinToUnixPath(pathstr){{{3 -"Takes in a windows path and returns the unix equiv -" -"A class level method -" -"Args: -"pathstr: the windows path to convert -function! s:Path.WinToUnixPath(pathstr) - if !s:running_windows - return a:pathstr - endif - - let toReturn = a:pathstr - - "remove the x:\ of the front - let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") - - "remove the \\ network share from the front - let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "") - - "convert all \ chars to / - let toReturn = substitute(toReturn, '\', '/', "g") - - return toReturn -endfunction - -" SECTION: General Functions {{{1 -"============================================================ -"FUNCTION: s:bufInWindows(bnum){{{2 -"[[STOLEN FROM VTREEEXPLORER.VIM]] -"Determine the number of windows open to this buffer number. -"Care of Yegappan Lakshman. Thanks! -" -"Args: -"bnum: the subject buffers buffer number -function! s:bufInWindows(bnum) - let cnt = 0 - let winnum = 1 - while 1 - let bufnum = winbufnr(winnum) - if bufnum < 0 - break - endif - if bufnum ==# a:bnum - let cnt = cnt + 1 - endif - let winnum = winnum + 1 - endwhile - - return cnt -endfunction " >>> -"FUNCTION: s:checkForBrowse(dir) {{{2 -"inits a secondary nerd tree in the current buffer if appropriate -function! s:checkForBrowse(dir) - if a:dir != '' && isdirectory(a:dir) - call s:initNerdTreeInPlace(a:dir) - endif -endfunction -"FUNCTION: s:compareBookmarks(first, second) {{{2 -"Compares two bookmarks -function! s:compareBookmarks(first, second) - return a:first.compareTo(a:second) -endfunction - -" FUNCTION: s:completeBookmarks(A,L,P) {{{2 -" completion function for the bookmark commands -function! s:completeBookmarks(A,L,P) - return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') -endfunction -" FUNCTION: s:createDefaultBindings() {{{2 -function! s:createDefaultBindings() - let s = '' . s:SID() . '_' - - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) - - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': s."chRootCwd" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) - -endfunction -" FUNCTION: s:deprecated(func, [msg]) {{{2 -" Issue a deprecation warning for a:func. If a second arg is given, use this -" as the deprecation message -function! s:deprecated(func, ...) - let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' - - if !exists('s:deprecationWarnings') - let s:deprecationWarnings = {} - endif - if !has_key(s:deprecationWarnings, a:func) - let s:deprecationWarnings[a:func] = 1 - echomsg msg - endif -endfunction -" FUNCTION: s:exec(cmd) {{{2 -" same as :exec cmd but eventignore=all is set for the duration -function! s:exec(cmd) - let old_ei = &ei - set ei=all - exec a:cmd - let &ei = old_ei -endfunction -" FUNCTION: s:findAndRevealPath() {{{2 -function! s:findAndRevealPath() - try - let p = s:Path.New(expand("%:p")) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("no file for the current buffer") - return - endtry - - if p.isUnixHiddenFile() - let showhidden=g:NERDTreeShowHidden - let g:NERDTreeShowHidden = 1 - endif - - if !s:treeExistsForTab() - try - let cwd = s:Path.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("current directory does not exist.") - let cwd = p.getParent() - endtry - - if p.isUnder(cwd) - call s:initNerdTree(cwd.str()) - else - call s:initNerdTree(p.getParent().str()) - endif - else - if !p.isUnder(s:TreeFileNode.GetRootForTab().path) - if !s:isTreeOpen() - call s:createTreeWin() - else - call s:putCursorInTreeWin() - endif - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - call s:chRoot(s:TreeDirNode.New(p.getParent())) - else - if !s:isTreeOpen() - call s:toggle("") - endif - endif - endif - call s:putCursorInTreeWin() - call b:NERDTreeRoot.reveal(p) - - if p.isUnixHiddenFile() - let g:NERDTreeShowHidden = showhidden - endif -endfunction - -" FUNCTION: s:has_opt(options, name) {{{2 -function! s:has_opt(options, name) - return has_key(a:options, a:name) && a:options[a:name] == 1 -endfunction - -"FUNCTION: s:initNerdTree(name) {{{2 -"Initialise the nerd tree for this tab. The tree will start in either the -"given directory, or the directory associated with the given bookmark -" -"Args: -"name: the name of a bookmark or a directory -function! s:initNerdTree(name) - let path = {} - if s:Bookmark.BookmarkExistsFor(a:name) - let path = s:Bookmark.BookmarkFor(a:name).path - else - let dir = a:name ==# '' ? getcwd() : a:name - - "hack to get an absolute path if a relative path is given - if dir =~# '^\.' - let dir = getcwd() . s:Path.Slash() . dir - endif - let dir = s:Path.Resolve(dir) - - try - let path = s:Path.New(dir) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("No bookmark or directory found for: " . a:name) - return - endtry - endif - if !path.isDirectory - let path = path.getParent() - endif - - "if instructed to, then change the vim CWD to the dir the NERDTree is - "inited in - if g:NERDTreeChDirMode != 0 - call path.changeToDir() - endif - - if s:treeExistsForTab() - if s:isTreeOpen() - call s:closeTree() - endif - unlet t:NERDTreeBufName - endif - - let newRoot = s:TreeDirNode.New(path) - call newRoot.open() - - call s:createTreeWin() - let b:treeShowHelp = 0 - let b:NERDTreeIgnoreEnabled = 1 - let b:NERDTreeShowFiles = g:NERDTreeShowFiles - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - let b:NERDTreeRoot = newRoot - let b:NERDTreeType = "primary" - - call s:renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) - - silent doautocmd User NERDTreeInit -endfunction - -"FUNCTION: s:initNerdTreeInPlace(dir) {{{2 -function! s:initNerdTreeInPlace(dir) - try - let path = s:Path.New(a:dir) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("Invalid directory name:" . a:name) - return - endtry - - "we want the directory buffer to disappear when we do the :edit below - setlocal bufhidden=wipe - - let previousBuf = expand("#") - - "we need a unique name for each secondary tree buffer to ensure they are - "all independent - exec "silent edit " . s:nextBufferName() - - let b:NERDTreePreviousBuf = bufnr(previousBuf) - - let b:NERDTreeRoot = s:TreeDirNode.New(path) - call b:NERDTreeRoot.open() - - call s:setCommonBufOptions() - let b:NERDTreeType = "secondary" - - call s:renderView() - - silent doautocmd User NERDTreeInit -endfunction -" FUNCTION: s:initNerdTreeMirror() {{{2 -function! s:initNerdTreeMirror() - - "get the names off all the nerd tree buffers - let treeBufNames = [] - for i in range(1, tabpagenr("$")) - let nextName = s:tabpagevar(i, 'NERDTreeBufName') - if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) - call add(treeBufNames, nextName) - endif - endfor - let treeBufNames = s:unique(treeBufNames) - - "map the option names (that the user will be prompted with) to the nerd - "tree buffer names - let options = {} - let i = 0 - while i < len(treeBufNames) - let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTreeRoot") - let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName - let i = i + 1 - endwhile - - "work out which tree to mirror, if there is more than 1 then ask the user - let bufferName = '' - if len(keys(options)) > 1 - let choices = ["Choose a tree to mirror"] - let choices = extend(choices, sort(keys(options))) - let choice = inputlist(choices) - if choice < 1 || choice > len(options) || choice ==# '' - return - endif - - let bufferName = options[sort(keys(options))[choice-1]] - elseif len(keys(options)) ==# 1 - let bufferName = values(options)[0] - else - call s:echo("No trees to mirror") - return - endif - - if s:treeExistsForTab() && s:isTreeOpen() - call s:closeTree() - endif - - let t:NERDTreeBufName = bufferName - call s:createTreeWin() - exec 'buffer ' . bufferName - if !&hidden - call s:renderView() - endif -endfunction -" FUNCTION: s:nextBufferName() {{{2 -" returns the buffer name for the next nerd tree -function! s:nextBufferName() - let name = s:NERDTreeBufName . s:next_buffer_number - let s:next_buffer_number += 1 - return name -endfunction -" FUNCTION: s:postSourceActions() {{{2 -function! s:postSourceActions() - call s:Bookmark.CacheBookmarks(0) - call s:createDefaultBindings() - - "load all nerdtree plugins - runtime! nerdtree_plugin/**/*.vim -endfunction -" FUNCTION: s:tabpagevar(tabnr, var) {{{2 -function! s:tabpagevar(tabnr, var) - let currentTab = tabpagenr() - let old_ei = &ei - set ei=all - - exec "tabnext " . a:tabnr - let v = -1 - if exists('t:' . a:var) - exec 'let v = t:' . a:var - endif - exec "tabnext " . currentTab - - let &ei = old_ei - - return v -endfunction -" Function: s:treeExistsForBuffer() {{{2 -" Returns 1 if a nerd tree root exists in the current buffer -function! s:treeExistsForBuf() - return exists("b:NERDTreeRoot") -endfunction -" Function: s:treeExistsForTab() {{{2 -" Returns 1 if a nerd tree root exists in the current tab -function! s:treeExistsForTab() - return exists("t:NERDTreeBufName") -endfunction -" Function: s:SID() {{{2 -function s:SID() - if !exists("s:sid") - let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') - endif - return s:sid -endfun -"FUNCTION: s:upDir(keepState) {{{2 -"moves the tree up a level -" -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! s:upDir(keepState) - let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) - if cwd ==# "/" || cwd =~# '^[^/]..$' - call s:echo("already at top dir") - else - if !a:keepState - call b:NERDTreeRoot.close() - endif - - let oldRoot = b:NERDTreeRoot - - if empty(b:NERDTreeRoot.parent) - let path = b:NERDTreeRoot.path.getParent() - let newRoot = s:TreeDirNode.New(path) - call newRoot.open() - call newRoot.transplantChild(b:NERDTreeRoot) - let b:NERDTreeRoot = newRoot - else - let b:NERDTreeRoot = b:NERDTreeRoot.parent - endif - - if g:NERDTreeChDirMode ==# 2 - call b:NERDTreeRoot.path.changeToDir() - endif - - call s:renderView() - call oldRoot.putCursorHere(0, 0) - endif -endfunction -" Function: s:unique(list) {{{2 -" returns a:list without duplicates -function! s:unique(list) - let uniqlist = [] - for elem in a:list - if index(uniqlist, elem) ==# -1 - let uniqlist += [elem] - endif - endfor - return uniqlist -endfunction -" SECTION: Public API {{{1 -"============================================================ -let g:NERDTreePath = s:Path -let g:NERDTreeDirNode = s:TreeDirNode -let g:NERDTreeFileNode = s:TreeFileNode -let g:NERDTreeBookmark = s:Bookmark - -function! NERDTreeAddMenuItem(options) - call s:MenuItem.Create(a:options) -endfunction - -function! NERDTreeAddMenuSeparator(...) - let opts = a:0 ? a:1 : {} - call s:MenuItem.CreateSeparator(opts) -endfunction - -function! NERDTreeAddSubmenu(options) - return s:MenuItem.Create(a:options) -endfunction - -function! NERDTreeAddKeyMap(options) - call s:KeyMap.Create(a:options) -endfunction - -function! NERDTreeRender() - call s:renderView() -endfunction - -function! NERDTreeFocus() - if s:isTreeOpen() - call s:putCursorInTreeWin() - else - call s:toggle("") - endif -endfunction - -function! NERDTreeCWD() - call NERDTreeFocus() - call s:chRootCwd() -endfunction - -" SECTION: View Functions {{{1 -"============================================================ -"FUNCTION: s:centerView() {{{2 -"centers the nerd tree window around the cursor (provided the nerd tree -"options permit) -function! s:centerView() - if g:NERDTreeAutoCenter - let current_line = winline() - let lines_to_top = current_line - let lines_to_bottom = winheight(s:getTreeWinNum()) - current_line - if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold - normal! zz - endif - endif -endfunction -"FUNCTION: s:closeTree() {{{2 -"Closes the primary NERD tree window for this tab -function! s:closeTree() - if !s:isTreeOpen() - throw "NERDTree.NoTreeFoundError: no NERDTree is open" - endif - - if winnr("$") != 1 - if winnr() == s:getTreeWinNum() - call s:exec("wincmd p") - let bufnr = bufnr("") - call s:exec("wincmd p") - else - let bufnr = bufnr("") - endif - - call s:exec(s:getTreeWinNum() . " wincmd w") - close - call s:exec(bufwinnr(bufnr) . " wincmd w") - else - close - 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:closeTreeIfQuitOnOpen() {{{2 -"Closes the NERD tree window if the close on open option is set -function! s:closeTreeIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && s:isTreeOpen() - call s:closeTree() - endif -endfunction -"FUNCTION: s:createTreeWin() {{{2 -"Inits the NERD tree window. ie. opens it, sizes it, sets all the local -"options etc -function! s:createTreeWin() - "create the nerd tree window - let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " - let splitSize = g:NERDTreeWinSize - - if !exists('t:NERDTreeBufName') - let t:NERDTreeBufName = s:nextBufferName() - silent! exec splitLocation . 'vertical ' . splitSize . ' new' - silent! exec "edit " . t:NERDTreeBufName - else - silent! exec splitLocation . 'vertical ' . splitSize . ' split' - silent! exec "buffer " . t:NERDTreeBufName - endif - - setlocal winfixwidth - call s:setCommonBufOptions() -endfunction - -"FUNCTION: s:dumpHelp {{{2 -"prints out the quick help -function! s:dumpHelp() - let old_h = @h - if b:treeShowHelp ==# 1 - let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n" - let @h=@h."\" ============================\n" - let @h=@h."\" File node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" - let @h=@h."\" ,\n" - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" - else - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" - endif - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" - endif - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" - let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Directory node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" - let @h=@h."\" current node recursively\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Bookmark table mappings~\n" - let @h=@h."\" double-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree navigation mappings~\n" - let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Filesystem mappings~\n" - let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" - let @h=@h."\" but leave old root open\n" - let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" - let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" - - "add quickhelp entries for each custom key map - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Custom mappings~\n" - for i in s:KeyMap.All() - if !empty(i.quickhelpText) - let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" - endif - endfor - - 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" - let @h=@h."\" :Bookmark \n" - let @h=@h."\" :BookmarkToRoot \n" - let @h=@h."\" :RevealBookmark \n" - let @h=@h."\" :OpenBookmark \n" - let @h=@h."\" :ClearBookmarks []\n" - let @h=@h."\" :ClearAllBookmarks\n" - silent! put h - elseif g:NERDTreeMinimalUI == 0 - let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" - silent! put h - endif - - let @h = old_h -endfunction -"FUNCTION: s:echo {{{2 -"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages -" -"Args: -"msg: the message to echo -function! s:echo(msg) - redraw - echomsg "NERDTree: " . a:msg -endfunction -"FUNCTION: s:echoWarning {{{2 -"Wrapper for s:echo, sets the message type to warningmsg for this message -"Args: -"msg: the message to echo -function! s:echoWarning(msg) - echohl warningmsg - call s:echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:echoError {{{2 -"Wrapper for s:echo, sets the message type to errormsg for this message -"Args: -"msg: the message to echo -function! s:echoError(msg) - echohl errormsg - call s:echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:firstUsableWindow(){{{2 -"find the window number of the first normal window -function! s:firstUsableWindow() - let i = 1 - while i <= winnr("$") - let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' - \ && !getwinvar(i, '&previewwindow') - \ && (!getbufvar(bnum, '&modified') || &hidden) - return i - endif - - let i += 1 - endwhile - return -1 -endfunction -"FUNCTION: s:getPath(ln) {{{2 -"Gets the full path to the node that is rendered on the given line number -" -"Args: -"ln: the line number to get the path for -" -"Return: -"A path if a node was selected, {} if nothing is selected. -"If the 'up a dir' line was selected then the path to the parent of the -"current root is returned -function! s:getPath(ln) - let line = getline(a:ln) - - let rootLine = s:TreeFileNode.GetRootLineNum() - - "check to see if we have the root node - if a:ln == rootLine - return b:NERDTreeRoot.path - endif - - if !g:NERDTreeDirArrows - " in case called from outside the tree - if line !~# '^ *[|`▸▾ ]' || line =~# '^$' - return {} - endif - endif - - if line ==# s:tree_up_dir_line - return b:NERDTreeRoot.path.getParent() - endif - - let indent = s:indentLevelFor(line) - - "remove the tree parts and the leading space - let curFile = s:stripMarkupFromLine(line, 0) - - let wasdir = 0 - if curFile =~# '/$' - let wasdir = 1 - let curFile = substitute(curFile, '/\?$', '/', "") - endif - - let dir = "" - let lnum = a:ln - while lnum > 0 - let lnum = lnum - 1 - let curLine = getline(lnum) - let curLineStripped = s:stripMarkupFromLine(curLine, 1) - - "have we reached the top of the tree? - if lnum == rootLine - let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir - break - endif - if curLineStripped =~# '/$' - let lpindent = s:indentLevelFor(curLine) - if lpindent < indent - let indent = indent - 1 - - let dir = substitute (curLineStripped,'^\\', "", "") . dir - continue - endif - endif - endwhile - let curFile = b:NERDTreeRoot.path.drive . dir . curFile - let toReturn = s:Path.New(curFile) - return toReturn -endfunction - -"FUNCTION: s:getTreeWinNum() {{{2 -"gets the nerd tree window number for this tab -function! s:getTreeWinNum() - if exists("t:NERDTreeBufName") - return bufwinnr(t:NERDTreeBufName) - else - return -1 - endif -endfunction -"FUNCTION: s:indentLevelFor(line) {{{2 -function! s:indentLevelFor(line) - let level = match(a:line, '[^ \-+~▸▾`|]') / s:tree_wid - " check if line includes arrows - if match(a:line, '[▸▾]') > -1 - " decrement level as arrow uses 3 ascii chars - let level = level - 1 - endif - return level -endfunction -"FUNCTION: s:isTreeOpen() {{{2 -function! s:isTreeOpen() - return s:getTreeWinNum() != -1 -endfunction -"FUNCTION: s:isWindowUsable(winnumber) {{{2 -"Returns 0 if opening a file from the tree in the given window requires it to -"be split, 1 otherwise -" -"Args: -"winnumber: the number of the window in question -function! s:isWindowUsable(winnumber) - "gotta split if theres only one window (i.e. the NERD tree) - if winnr("$") ==# 1 - return 0 - endif - - let oldwinnr = winnr() - call s:exec(a:winnumber . "wincmd p") - let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') - let modified = &modified - call s:exec(oldwinnr . "wincmd p") - - "if its a special window e.g. quickfix or another explorer plugin then we - "have to split - if specialWindow - return 0 - endif - - if &hidden - return 1 - endif - - return !modified || s:bufInWindows(winbufnr(a:winnumber)) >= 2 -endfunction - -" FUNCTION: s:jumpToChild(direction) {{{2 -" Args: -" direction: 0 if going to first child, 1 if going to last -function! s:jumpToChild(currentNode, direction) - if a:currentNode.isRoot() - return s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - end - let dirNode = a:currentNode.parent - let childNodes = dirNode.getVisibleChildren() - - let targetNode = childNodes[0] - if a:direction - let targetNode = childNodes[len(childNodes) - 1] - endif - - if targetNode.equals(a:currentNode) - let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) - if siblingDir != {} - let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 - let targetNode = siblingDir.getChildByIndex(indx, 1) - endif - endif - - call targetNode.putCursorHere(1, 0) - - call s:centerView() -endfunction - - -" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2 -" moves the cursor to the sibling of the current node in the given direction -" -" Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! s:jumpToSibling(currentNode, forward) - let sibling = a:currentNode.findSibling(a:forward) - - if !empty(sibling) - call sibling.putCursorHere(1, 0) - call s:centerView() - endif -endfunction - -"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:promptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - -"FUNCTION: s:putCursorOnBookmarkTable(){{{2 -"Places the cursor at the top of the bookmarks table -function! s:putCursorOnBookmarkTable() - if !b:NERDTreeShowBookmarks - throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" - endif - - if g:NERDTreeMinimalUI - return cursor(1, 2) - endif - - let rootNodeLine = s:TreeFileNode.GetRootLineNum() - - let line = 1 - while getline(line) !~# '^>-\+Bookmarks-\+$' - let line = line + 1 - if line >= rootNodeLine - throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" - endif - endwhile - call cursor(line, 2) -endfunction - -"FUNCTION: s:putCursorInTreeWin(){{{2 -"Places the cursor in the nerd tree window -function! s:putCursorInTreeWin() - if !s:isTreeOpen() - throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" - endif - - call s:exec(s:getTreeWinNum() . "wincmd w") -endfunction - -"FUNCTION: s:renderBookmarks {{{2 -function! s:renderBookmarks() - - if g:NERDTreeMinimalUI == 0 - call setline(line(".")+1, ">----------Bookmarks----------") - call cursor(line(".")+1, col(".")) - endif - - for i in s:Bookmark.Bookmarks() - call setline(line(".")+1, i.str()) - call cursor(line(".")+1, col(".")) - endfor - - call setline(line(".")+1, '') - call cursor(line(".")+1, col(".")) -endfunction -"FUNCTION: s:renderView {{{2 -"The entry function for rendering the tree -function! s:renderView() - setlocal modifiable - - "remember the top line of the buffer and the current line so we can - "restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") - - "delete all lines in the buffer (being careful not to clobber a register) - silent 1,$delete _ - - call s:dumpHelp() - - "delete the blank line before the help and add one after it - if g:NERDTreeMinimalUI == 0 - call setline(line(".")+1, "") - call cursor(line(".")+1, col(".")) - endif - - if b:NERDTreeShowBookmarks - call s:renderBookmarks() - endif - - "add the 'up a dir' line - if !g:NERDTreeMinimalUI - call setline(line(".")+1, s:tree_up_dir_line) - call cursor(line(".")+1, col(".")) - endif - - "draw the header line - let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) - call setline(line(".")+1, header) - call cursor(line(".")+1, col(".")) - - "draw the tree - let old_o = @o - let @o = b:NERDTreeRoot.renderToString() - silent put o - let @o = old_o - - "delete the blank line at the top of the buffer - silent 1,1delete _ - - "restore the view - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(topLine, 1) - normal! zt - call cursor(curLine, curCol) - let &scrolloff = old_scrolloff - - setlocal nomodifiable -endfunction - -"FUNCTION: s:renderViewSavingPosition {{{2 -"Renders the tree and ensures the cursor stays on the current node or the -"current nodes parent if it is no longer available upon re-rendering -function! s:renderViewSavingPosition() - let currentNode = s:TreeFileNode.GetSelected() - - "go up the tree till we find a node that will be visible or till we run - "out of nodes - while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() - let currentNode = currentNode.parent - endwhile - - call s:renderView() - - if currentNode != {} - call currentNode.putCursorHere(0, 0) - endif -endfunction -"FUNCTION: s:restoreScreenState() {{{2 -" -"Sets the screen state back to what it was when s:saveScreenState was last -"called. -" -"Assumes the cursor is in the NERDTree window -function! s:restoreScreenState() - if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize") - return - endif - exec("silent vertical resize ".b:NERDTreeOldWindowSize) - - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(b:NERDTreeOldTopLine, 0) - normal! zt - call setpos(".", b:NERDTreeOldPos) - let &scrolloff=old_scrolloff -endfunction - -"FUNCTION: s:saveScreenState() {{{2 -"Saves the current cursor position in the current buffer and the window -"scroll position -function! s:saveScreenState() - let win = winnr() - try - call s:putCursorInTreeWin() - let b:NERDTreeOldPos = getpos(".") - let b:NERDTreeOldTopLine = line("w0") - let b:NERDTreeOldWindowSize = winwidth("") - call s:exec(win . "wincmd w") - catch /^NERDTree.InvalidOperationError/ - 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 foldmethod=manual - setlocal nofoldenable - setlocal nobuflisted - setlocal nospell - if g:NERDTreeShowLineNumbers - setlocal nu - else - setlocal nonu - if v:version >= 703 - setlocal nornu - endif - endif - - iabc - - 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 - let &l:statusline = g:NERDTreeStatusline - endif -endfunction -"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2 -"returns the given line with all the tree parts stripped off -" -"Args: -"line: the subject line -"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = -"any spaces before the actual text of the node) -function! s:stripMarkupFromLine(line, removeLeadingSpaces) - let line = a:line - "remove the tree parts and the leading space - let line = substitute (line, s:tree_markup_reg,"","") - - "strip off any read only flag - let line = substitute (line, ' \[RO\]', "","") - - "strip off any bookmark flags - let line = substitute (line, ' {[^}]*}', "","") - - "strip off any executable flags - let line = substitute (line, '*\ze\($\| \)', "","") - - let wasdir = 0 - if line =~# '/$' - let wasdir = 1 - endif - let line = substitute (line,' -> .*',"","") " remove link to - if wasdir ==# 1 - let line = substitute (line, '/\?$', '/', "") - endif - - if a:removeLeadingSpaces - let line = substitute (line, '^ *', '', '') - endif - - return line -endfunction - -"FUNCTION: s:toggle(dir) {{{2 -"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -"closed it is restored or initialized (if it doesnt exist) -" -"Args: -"dir: the full path for the root node (is only used if the NERD tree is being -"initialized. -function! s:toggle(dir) - if s:treeExistsForTab() - if !s:isTreeOpen() - call s:createTreeWin() - if !&hidden - call s:renderView() - endif - call s:restoreScreenState() - else - call s:closeTree() - endif - else - call s:initNerdTree(a:dir) - endif -endfunction -"SECTION: Interface bindings {{{1 -"============================================================ - -"FUNCTION: s:activateAll() {{{2 -"handle the user activating the updir line -function! s:activateAll() - if getline(".") ==# s:tree_up_dir_line - return s:upDir(0) - endif -endfunction - -"FUNCTION: s:activateDirNode() {{{2 -"handle the user activating a tree node -function! s:activateDirNode(node) - call a:node.activate({'reuse': 1}) -endfunction - -"FUNCTION: s:activateFileNode() {{{2 -"handle the user activating a tree node -function! s:activateFileNode(node) - call a:node.activate({'reuse': 1, 'where': 'p'}) -endfunction - -"FUNCTION: s:activateBookmark() {{{2 -"handle the user activating a bookmark -function! s:activateBookmark(bm) - call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) -endfunction - -"FUNCTION: s:bindMappings() {{{2 -function! s:bindMappings() - "make do the same as the default 'o' mapping - exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" - - call s:KeyMap.BindAll() - - command! -buffer -nargs=? Bookmark :call bookmarkNode('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=+ BookmarkToRoot call s:Bookmark.ToRoot('') - command! -buffer -nargs=0 ClearAllBookmarks call s:Bookmark.ClearAll() call renderView() - command! -buffer -nargs=0 ReadBookmarks call s:Bookmark.CacheBookmarks(0) call renderView() - command! -buffer -nargs=0 WriteBookmarks call s:Bookmark.Write() -endfunction - -" FUNCTION: s:bookmarkNode(name) {{{2 -" Associate the current node with the given name -function! s:bookmarkNode(...) - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - let name = a:1 - if empty(name) - let name = currentNode.path.getLastPathComponent(0) - endif - try - call currentNode.bookmark(name) - call s:renderView() - catch /^NERDTree.IllegalBookmarkNameError/ - call s:echo("bookmark names must not contain spaces") - endtry - else - call s:echo("select a node first") - endif -endfunction - -" FUNCTION: s:chCwd(node) {{{2 -function! s:chCwd(node) - try - call a:node.path.changeToDir() - catch /^NERDTree.PathChangeError/ - call s:echoWarning("could not change cwd") - endtry -endfunction - -" FUNCTION: s:chRoot(node) {{{2 -" changes the current root to the selected one -function! s:chRoot(node) - call a:node.makeRoot() - call s:renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) -endfunction - -" FUNCTION: s:chRootCwd() {{{2 -" changes the current root to CWD -function! s:chRootCwd() - try - let cwd = s:Path.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("current directory does not exist.") - return - endtry - if cwd.str() == s:TreeFileNode.GetRootForTab().path.str() - return - endif - call s:chRoot(s:TreeDirNode.New(cwd)) -endfunction - -" FUNCTION: s:clearBookmarks(bookmarks) {{{2 -function! s:clearBookmarks(bookmarks) - if a:bookmarks ==# '' - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - call currentNode.clearBookmarks() - endif - else - for name in split(a:bookmarks, ' ') - let bookmark = s:Bookmark.BookmarkFor(name) - call bookmark.delete() - endfor - endif - call s:renderView() -endfunction -" FUNCTION: s:closeChildren(node) {{{2 -" closes all childnodes of the current node -function! s:closeChildren(node) - call a:node.closeChildren() - call s:renderView() - call a:node.putCursorHere(0, 0) -endfunction -" FUNCTION: s:closeCurrentDir(node) {{{2 -" closes the parent dir of the current node -function! s:closeCurrentDir(node) - let parent = a:node.parent - if parent ==# {} || parent.isRoot() - call s:echo("cannot close tree root") - else - call a:node.parent.close() - call s:renderView() - call a:node.parent.putCursorHere(0, 0) - endif -endfunction -" FUNCTION: s:closeTreeWindow() {{{2 -" close the tree window -function! s:closeTreeWindow() - if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 - exec "buffer " . b:NERDTreePreviousBuf - else - if winnr("$") > 1 - call s:closeTree() - else - call s:echo("Cannot close last window") - endif - endif -endfunction -" FUNCTION: s:deleteBookmark(bm) {{{2 -" if the cursor is on a bookmark, prompt to delete -function! s:deleteBookmark(bm) - echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" - - if nr2char(getchar()) ==# 'y' - try - call a:bm.delete() - call s:renderView() - redraw - catch /^NERDTree/ - call s:echoWarning("Could not remove bookmark") - endtry - else - call s:echo("delete aborted" ) - endif - -endfunction - -" FUNCTION: s:displayHelp() {{{2 -" toggles the help display -function! s:displayHelp() - let b:treeShowHelp = b:treeShowHelp ? 0 : 1 - call s:renderView() - call s:centerView() -endfunction - -"FUNCTION: s:handleLeftClick() {{{2 -"Checks if the click should open the current node -function! s:handleLeftClick() - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - - "the dir arrows are multibyte chars, and vim's string functions only - "deal with single bytes - so split the line up with the hack below and - "take the line substring manually - let line = split(getline(line(".")), '\zs') - let startToCur = "" - for i in range(0,len(line)-1) - let startToCur .= line[i] - endfor - - if currentNode.path.isDirectory - if startToCur =~# s:tree_markup_reg && startToCur =~# '[+~▾▸] \?$' - call currentNode.activate() - return - endif - endif - - if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 - let char = strpart(startToCur, strlen(startToCur)-1, 1) - if char !~# s:tree_markup_reg - if currentNode.path.isDirectory - call currentNode.activate() - else - call currentNode.activate({'reuse': 1, 'where': 'p'}) - endif - return - endif - endif - endif -endfunction - -" FUNCTION: s:handleMiddleMouse() {{{2 -function! s:handleMiddleMouse() - let curNode = s:TreeFileNode.GetSelected() - if curNode ==# {} - call s:echo("Put the cursor on a node first" ) - return - endif - - if curNode.path.isDirectory - call s:openExplorer(curNode) - else - call curNode.open({'where': 'h'}) - endif -endfunction - -" FUNCTION: s:jumpToFirstChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToFirstChild(node) - call s:jumpToChild(a:node, 0) -endfunction - -" FUNCTION: s:jumpToLastChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToLastChild(node) - call s:jumpToChild(a:node, 1) -endfunction - -" FUNCTION: s:jumpToParent(node) {{{2 -" moves the cursor to the parent of the current node -function! s:jumpToParent(node) - if !empty(a:node.parent) - call a:node.parent.putCursorHere(1, 0) - call s:centerView() - else - call s:echo("cannot jump to parent") - endif -endfunction - -" FUNCTION: s:jumpToRoot() {{{2 -" moves the cursor to the root node -function! s:jumpToRoot() - call b:NERDTreeRoot.putCursorHere(1, 0) - call s:centerView() -endfunction - -" FUNCTION: s:jumpToNextSibling(node) {{{2 -function! s:jumpToNextSibling(node) - call s:jumpToSibling(a:node, 1) -endfunction - -" FUNCTION: s:jumpToPrevSibling(node) {{{2 -function! s:jumpToPrevSibling(node) - call s:jumpToSibling(a:node, 0) -endfunction - -" FUNCTION: s:openBookmark(name) {{{2 -" put the cursor on the given bookmark and, if its a file, open it -function! s:openBookmark(name) - try - let targetNode = s:Bookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - redraw! - catch /^NERDTree.BookmarkedNodeNotFoundError/ - call s:echo("note - target node is not cached") - let bookmark = s:Bookmark.BookmarkFor(a:name) - let targetNode = s:TreeFileNode.New(bookmark.path) - endtry - if targetNode.path.isDirectory - call targetNode.openExplorer() - else - call targetNode.open({'where': 'p'}) - endif -endfunction - -" FUNCTION: s:openHSplit(target) {{{2 -function! s:openHSplit(target) - call a:target.activate({'where': 'h'}) -endfunction - -" FUNCTION: s:openVSplit(target) {{{2 -function! s:openVSplit(target) - call a:target.activate({'where': 'v'}) -endfunction - -" FUNCTION: s:openExplorer(node) {{{2 -function! s:openExplorer(node) - call a:node.openExplorer() -endfunction - -" FUNCTION: s:openInNewTab(target) {{{2 -function! s:openInNewTab(target) - call a:target.activate({'where': 't'}) -endfunction - -" FUNCTION: s:openInNewTabSilent(target) {{{2 -function! s:openInNewTabSilent(target) - call a:target.activate({'where': 't', 'stay': 1}) -endfunction - -" FUNCTION: s:openNodeRecursively(node) {{{2 -function! s:openNodeRecursively(node) - call s:echo("Recursively opening node. Please wait...") - call a:node.openRecursively() - call s:renderView() - redraw - call s:echo("Recursively opening node. Please wait... DONE") -endfunction - -"FUNCTION: s:previewNodeCurrent(node) {{{2 -function! s:previewNodeCurrent(node) - call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) -endfunction - -"FUNCTION: s:previewNodeHSplit(node) {{{2 -function! s:previewNodeHSplit(node) - call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) -endfunction - -"FUNCTION: s:previewNodeVSplit(node) {{{2 -function! s:previewNodeVSplit(node) - call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) -endfunction - -" FUNCTION: s:revealBookmark(name) {{{2 -" put the cursor on the node associate with the given name -function! s:revealBookmark(name) - try - let targetNode = s:Bookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - catch /^NERDTree.BookmarkNotFoundError/ - call s:echo("Bookmark isnt cached under the current root") - endtry -endfunction -" FUNCTION: s:refreshRoot() {{{2 -" Reloads the current root. All nodes below this will be lost and the root dir -" will be reloaded. -function! s:refreshRoot() - call s:echo("Refreshing the root node. This could take a while...") - call b:NERDTreeRoot.refresh() - call s:renderView() - redraw - call s:echo("Refreshing the root node. This could take a while... DONE") -endfunction - -" FUNCTION: s:refreshCurrent(node) {{{2 -" refreshes the root for the current node -function! s:refreshCurrent(node) - let node = a:node - if !node.path.isDirectory - let node = node.parent - endif - - call s:echo("Refreshing node. This could take a while...") - call node.refresh() - call s:renderView() - redraw - call s:echo("Refreshing node. This could take a while... DONE") -endfunction -" FUNCTION: s:showMenu(node) {{{2 -function! s:showMenu(node) - let mc = s:MenuController.New(s:MenuItem.AllEnabled()) - call mc.showMenu() -endfunction - -" FUNCTION: s:toggleIgnoreFilter() {{{2 -" toggles the use of the NERDTreeIgnore option -function! s:toggleIgnoreFilter() - let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled - call s:renderViewSavingPosition() - call s:centerView() -endfunction - -" FUNCTION: s:toggleShowBookmarks() {{{2 -" toggles the display of bookmarks -function! s:toggleShowBookmarks() - let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks - if b:NERDTreeShowBookmarks - call s:renderView() - call s:putCursorOnBookmarkTable() - else - call s:renderViewSavingPosition() - endif - call s:centerView() -endfunction -" FUNCTION: s:toggleShowFiles() {{{2 -" toggles the display of hidden files -function! s:toggleShowFiles() - let b:NERDTreeShowFiles = !b:NERDTreeShowFiles - call s:renderViewSavingPosition() - call s:centerView() -endfunction - -" FUNCTION: s:toggleShowHidden() {{{2 -" toggles the display of hidden files -function! s:toggleShowHidden() - let b:NERDTreeShowHidden = !b:NERDTreeShowHidden - call s:renderViewSavingPosition() - 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:upDirCurrentRootOpen() {{{2 -function! s:upDirCurrentRootOpen() - call s:upDir(1) -endfunction - -" FUNCTION: s:upDirCurrentRootClosed() {{{2 -function! s:upDirCurrentRootClosed() - call s:upDir(0) -endfunction - " SECTION: Post Source Actions {{{1 -call s:postSourceActions() +call nerdtree#postSourceActions() "reset &cpo back to users setting let &cpo = s:old_cpo diff --git a/plugin/nerdtree/bookmark.vim b/plugin/nerdtree/bookmark.vim new file mode 100644 index 00000000..77a50235 --- /dev/null +++ b/plugin/nerdtree/bookmark.vim @@ -0,0 +1,293 @@ +"CLASS: Bookmark {{{2 +"============================================================ +let s:Bookmark = {} +let g:NERDTreeBookmark = s:Bookmark +" FUNCTION: Bookmark.activate() {{{3 +function! s:Bookmark.activate(...) + call self.open(a:0 ? a:1 : {}) +endfunction +" FUNCTION: Bookmark.AddBookmark(name, path) {{{3 +" Class method to add a new bookmark to the list, if a previous bookmark exists +" with the same name, just update the path for that bookmark +function! s:Bookmark.AddBookmark(name, path) + for i in s:Bookmark.Bookmarks() + if i.name ==# a:name + let i.path = a:path + return + endif + endfor + call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) + call s:Bookmark.Sort() +endfunction +" Function: Bookmark.Bookmarks() {{{3 +" Class method to get all bookmarks. Lazily initializes the bookmarks global +" variable +function! s:Bookmark.Bookmarks() + if !exists("g:NERDTreeBookmarks") + let g:NERDTreeBookmarks = [] + endif + return g:NERDTreeBookmarks +endfunction +" Function: Bookmark.BookmarkExistsFor(name) {{{3 +" class method that returns 1 if a bookmark with the given name is found, 0 +" otherwise +function! s:Bookmark.BookmarkExistsFor(name) + try + call s:Bookmark.BookmarkFor(a:name) + return 1 + catch /^NERDTree.BookmarkNotFoundError/ + return 0 + endtry +endfunction +" Function: Bookmark.BookmarkFor(name) {{{3 +" Class method to get the bookmark that has the given name. {} is return if no +" bookmark is found +function! s:Bookmark.BookmarkFor(name) + for i in s:Bookmark.Bookmarks() + if i.name ==# a:name + return i + endif + endfor + throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' +endfunction +" Function: Bookmark.BookmarkNames() {{{3 +" Class method to return an array of all bookmark names +function! s:Bookmark.BookmarkNames() + let names = [] + for i in s:Bookmark.Bookmarks() + call add(names, i.name) + endfor + return names +endfunction +" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3 +" Class method to read all bookmarks from the bookmarks file intialize +" bookmark objects for each one. +" +" Args: +" silent - dont echo an error msg if invalid bookmarks are found +function! s:Bookmark.CacheBookmarks(silent) + if filereadable(g:NERDTreeBookmarksFile) + let g:NERDTreeBookmarks = [] + let g:NERDTreeInvalidBookmarks = [] + let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) + let invalidBookmarksFound = 0 + for i in bookmarkStrings + + "ignore blank lines + if i != '' + + let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') + let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') + + try + let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path)) + call add(g:NERDTreeBookmarks, bookmark) + catch /^NERDTree.InvalidArgumentsError/ + call add(g:NERDTreeInvalidBookmarks, i) + let invalidBookmarksFound += 1 + endtry + endif + endfor + if invalidBookmarksFound + call s:Bookmark.Write() + if !a:silent + call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") + endif + endif + call s:Bookmark.Sort() + endif +endfunction +" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3 +" Compare these two bookmarks for sorting purposes +function! s:Bookmark.compareTo(otherbookmark) + return a:otherbookmark.name < self.name +endfunction +" FUNCTION: Bookmark.ClearAll() {{{3 +" Class method to delete all bookmarks. +function! s:Bookmark.ClearAll() + for i in s:Bookmark.Bookmarks() + call i.delete() + endfor + call s:Bookmark.Write() +endfunction +" FUNCTION: Bookmark.delete() {{{3 +" Delete this bookmark. If the node for this bookmark is under the current +" root, then recache bookmarks for its Path object +function! s:Bookmark.delete() + let node = {} + try + let node = self.getNode(1) + catch /^NERDTree.BookmarkedNodeNotFoundError/ + endtry + call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) + if !empty(node) + call node.path.cacheDisplayString() + endif + call s:Bookmark.Write() +endfunction +" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3 +" Gets the treenode for this bookmark +" +" Args: +" searchFromAbsoluteRoot: specifies whether we should search from the current +" tree root, or the highest cached node +function! s:Bookmark.getNode(searchFromAbsoluteRoot) + let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot + let targetNode = searchRoot.findNode(self.path) + if empty(targetNode) + throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name + endif + return targetNode +endfunction +" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3 +" Class method that finds the bookmark with the given name and returns the +" treenode for it. +function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) + let bookmark = s:Bookmark.BookmarkFor(a:name) + return bookmark.getNode(a:searchFromAbsoluteRoot) +endfunction +" FUNCTION: Bookmark.GetSelected() {{{3 +" returns the Bookmark the cursor is over, or {} +function! s:Bookmark.GetSelected() + let line = getline(".") + let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') + if name != line + try + return s:Bookmark.BookmarkFor(name) + catch /^NERDTree.BookmarkNotFoundError/ + return {} + endtry + endif + return {} +endfunction + +" Function: Bookmark.InvalidBookmarks() {{{3 +" Class method to get all invalid bookmark strings read from the bookmarks +" file +function! s:Bookmark.InvalidBookmarks() + if !exists("g:NERDTreeInvalidBookmarks") + let g:NERDTreeInvalidBookmarks = [] + endif + return g:NERDTreeInvalidBookmarks +endfunction +" FUNCTION: Bookmark.mustExist() {{{3 +function! s:Bookmark.mustExist() + if !self.path.exists() + call s:Bookmark.CacheBookmarks(1) + throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". + \ self.name ."\" points to a non existing location: \"". self.path.str() + endif +endfunction +" FUNCTION: Bookmark.New(name, path) {{{3 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.New(name, path) + if a:name =~# ' ' + throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name + endif + + let newBookmark = copy(self) + let newBookmark.name = a:name + let newBookmark.path = a:path + return newBookmark +endfunction +" FUNCTION: Bookmark.open([options]) {{{3 +"Args: +"A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' (vertical split), 'h' +" (horizontal split), 't' (new tab) or 'p' (previous window). +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +" +function! s:Bookmark.open(...) + let opts = a:0 ? a:1 : {} + + if self.path.isDirectory && !has_key(opts, 'where') + call self.toRoot() + else + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) + endif +endfunction +" FUNCTION: Bookmark.openInNewTab(options) {{{3 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.openInNewTab(options) + call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') + call self.open(a:options) +endfunction +" Function: Bookmark.setPath(path) {{{3 +" makes this bookmark point to the given path +function! s:Bookmark.setPath(path) + let self.path = a:path +endfunction +" Function: Bookmark.Sort() {{{3 +" Class method that sorts all bookmarks +function! s:Bookmark.Sort() + let CompareFunc = function("nerdtree#compareBookmarks") + call sort(s:Bookmark.Bookmarks(), CompareFunc) +endfunction +" Function: Bookmark.str() {{{3 +" Get the string that should be rendered in the view for this bookmark +function! s:Bookmark.str() + let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name) + if &nu + let pathStrMaxLen = pathStrMaxLen - &numberwidth + endif + + let pathStr = self.path.str({'format': 'UI'}) + if len(pathStr) > pathStrMaxLen + let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) + endif + return '>' . self.name . ' ' . pathStr +endfunction +" FUNCTION: Bookmark.toRoot() {{{3 +" Make the node for this bookmark the new tree root +function! s:Bookmark.toRoot() + if self.validate() + try + let targetNode = self.getNode(1) + catch /^NERDTree.BookmarkedNodeNotFoundError/ + let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) + endtry + call targetNode.makeRoot() + call nerdtree#renderView() + call targetNode.putCursorHere(0, 0) + endif +endfunction +" FUNCTION: Bookmark.ToRoot(name) {{{3 +" Make the node for this bookmark the new tree root +function! s:Bookmark.ToRoot(name) + let bookmark = s:Bookmark.BookmarkFor(a:name) + call bookmark.toRoot() +endfunction + + +"FUNCTION: Bookmark.validate() {{{3 +function! s:Bookmark.validate() + if self.path.exists() + return 1 + else + call s:Bookmark.CacheBookmarks(1) + call nerdtree#renderView() + call s:echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") + return 0 + endif +endfunction + +" Function: Bookmark.Write() {{{3 +" Class method to write all bookmarks to the bookmarks file +function! s:Bookmark.Write() + let bookmarkStrings = [] + for i in s:Bookmark.Bookmarks() + call add(bookmarkStrings, i.name . ' ' . i.path.str()) + endfor + + "add a blank line before the invalid ones + call add(bookmarkStrings, "") + + for j in s:Bookmark.InvalidBookmarks() + call add(bookmarkStrings, j) + endfor + call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) +endfunction diff --git a/plugin/nerdtree/key_map.vim b/plugin/nerdtree/key_map.vim new file mode 100644 index 00000000..d010c5a1 --- /dev/null +++ b/plugin/nerdtree/key_map.vim @@ -0,0 +1,147 @@ +"CLASS: KeyMap {{{2 +"============================================================ +let s:KeyMap = {} +let g:NERDTreeKeyMap = s:KeyMap +"FUNCTION: KeyMap.All() {{{3 +function! s:KeyMap.All() + if !exists("s:keyMaps") + let s:keyMaps = [] + endif + return s:keyMaps +endfunction + +"FUNCTION: KeyMap.FindFor(key, scope) {{{3 +function! s:KeyMap.FindFor(key, scope) + for i in s:KeyMap.All() + if i.key ==# a:key && i.scope ==# a:scope + return i + endif + endfor + return {} +endfunction + +"FUNCTION: KeyMap.BindAll() {{{3 +function! s:KeyMap.BindAll() + for i in s:KeyMap.All() + call i.bind() + endfor +endfunction + +"FUNCTION: KeyMap.bind() {{{3 +function! s:KeyMap.bind() + " If the key sequence we're trying to map contains any '<>' notation, we + " must replace each of the '<' characters with '' to ensure the string + " is not translated into its corresponding keycode during the later part + " of the map command below + " :he <> + let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)' + if self.key =~# specialNotationRegex + let keymapInvokeString = substitute(self.key, specialNotationRegex, '\1', 'g') + else + let keymapInvokeString = self.key + endif + + let premap = self.key == "" ? " " : " " + + exec 'nnoremap '. self.key . premap . ':call KeyMap_Invoke("'. keymapInvokeString .'")' +endfunction + +"FUNCTION: KeyMap.Remove(key, scope) {{{3 +function! s:KeyMap.Remove(key, scope) + let maps = s:KeyMap.All() + for i in range(len(maps)) + if maps[i].key ==# a:key && maps[i].scope ==# a:scope + return remove(maps, i) + endif + endfor +endfunction +"FUNCTION: KeyMap.invoke() {{{3 +"Call the KeyMaps callback function +function! s:KeyMap.invoke(...) + let Callback = function(self.callback) + if a:0 + call Callback(a:1) + else + call Callback() + endif +endfunction + + +"FUNCTION: KeyMap.Invoke() {{{3 +"Find a keymapping for a:key and the current scope invoke it. +" +"Scope is determined as follows: +" * if the cursor is on a dir node then "DirNode" +" * if the cursor is on a file node then "FileNode" +" * if the cursor is on a bookmark then "Bookmark" +" +"If a keymap has the scope of "all" then it will be called if no other keymap +"is found for a:key and the scope. +function! s:KeyMap.Invoke(key) + let node = g:NERDTreeFileNode.GetSelected() + if !empty(node) + + "try file node + if !node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "FileNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try dir node + if node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, "DirNode") + if !empty(km) + return km.invoke(node) + endif + endif + + "try generic node + let km = s:KeyMap.FindFor(a:key, "Node") + if !empty(km) + return km.invoke(node) + endif + + endif + + "try bookmark + let bm = g:NERDTreeBookmark.GetSelected() + if !empty(bm) + let km = s:KeyMap.FindFor(a:key, "Bookmark") + if !empty(km) + return km.invoke(bm) + endif + endif + + "try all + let km = s:KeyMap.FindFor(a:key, "all") + if !empty(km) + return km.invoke() + endif +endfunction + +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! s:KeyMap_Invoke(key) + call s:KeyMap.Invoke(a:key) +endfunction + +"FUNCTION: KeyMap.Create(options) {{{3 +function! s:KeyMap.Create(options) + let newKeyMap = copy(self) + let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) + let newKeyMap.key = opts['key'] + let newKeyMap.quickhelpText = opts['quickhelpText'] + let newKeyMap.callback = opts['callback'] + let newKeyMap.scope = opts['scope'] + + call s:KeyMap.Add(newKeyMap) +endfunction + +"FUNCTION: KeyMap.Add(keymap) {{{3 +function! s:KeyMap.Add(keymap) + call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) + call add(s:KeyMap.All(), a:keymap) +endfunction + diff --git a/plugin/nerdtree/menu_controller.vim b/plugin/nerdtree/menu_controller.vim new file mode 100644 index 00000000..a7bfb959 --- /dev/null +++ b/plugin/nerdtree/menu_controller.vim @@ -0,0 +1,178 @@ +"CLASS: MenuController {{{2 +"============================================================ +let s:MenuController = {} +let g:NERDTreeMenuController = s:MenuController +"FUNCTION: MenuController.New(menuItems) {{{3 +"create a new menu controller that operates on the given menu items +function! s:MenuController.New(menuItems) + let newMenuController = copy(self) + if a:menuItems[0].isSeparator() + let newMenuController.menuItems = a:menuItems[1:-1] + else + let newMenuController.menuItems = a:menuItems + endif + return newMenuController +endfunction + +"FUNCTION: MenuController.showMenu() {{{3 +"start the main loop of the menu and get the user to choose/execute a menu +"item +function! s:MenuController.showMenu() + call self._saveOptions() + + try + let self.selection = 0 + + let done = 0 + while !done + redraw! + call self._echoPrompt() + let key = nr2char(getchar()) + let done = self._handleKeypress(key) + endwhile + finally + call self._restoreOptions() + endtry + + if self.selection != -1 + let m = self._current() + call m.execute() + endif +endfunction + +"FUNCTION: MenuController._echoPrompt() {{{3 +function! s:MenuController._echoPrompt() + echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" + echo "==========================================================" + + for i in range(0, len(self.menuItems)-1) + if self.selection == i + echo "> " . self.menuItems[i].text + else + echo " " . self.menuItems[i].text + endif + endfor +endfunction + +"FUNCTION: MenuController._current(key) {{{3 +"get the MenuItem that is currently selected +function! s:MenuController._current() + return self.menuItems[self.selection] +endfunction + +"FUNCTION: MenuController._handleKeypress(key) {{{3 +"change the selection (if appropriate) and return 1 if the user has made +"their choice, 0 otherwise +function! s:MenuController._handleKeypress(key) + if a:key == 'j' + call self._cursorDown() + elseif a:key == 'k' + call self._cursorUp() + elseif a:key == nr2char(27) "escape + let self.selection = -1 + return 1 + elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j + return 1 + else + let index = self._nextIndexFor(a:key) + if index != -1 + let self.selection = index + if len(self._allIndexesFor(a:key)) == 1 + return 1 + endif + endif + endif + + return 0 +endfunction + +"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3 +"get indexes to all menu items with the given shortcut +function! s:MenuController._allIndexesFor(shortcut) + let toReturn = [] + + for i in range(0, len(self.menuItems)-1) + if self.menuItems[i].shortcut == a:shortcut + call add(toReturn, i) + endif + endfor + + return toReturn +endfunction + +"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3 +"get the index to the next menu item with the given shortcut, starts from the +"current cursor location and wraps around to the top again if need be +function! s:MenuController._nextIndexFor(shortcut) + for i in range(self.selection+1, len(self.menuItems)-1) + if self.menuItems[i].shortcut == a:shortcut + return i + endif + endfor + + for i in range(0, self.selection) + if self.menuItems[i].shortcut == a:shortcut + return i + endif + endfor + + return -1 +endfunction + +"FUNCTION: MenuController._setCmdheight() {{{3 +"sets &cmdheight to whatever is needed to display the menu +function! s:MenuController._setCmdheight() + let &cmdheight = len(self.menuItems) + 3 +endfunction + +"FUNCTION: MenuController._saveOptions() {{{3 +"set any vim options that are required to make the menu work (saving their old +"values) +function! s:MenuController._saveOptions() + let self._oldLazyredraw = &lazyredraw + let self._oldCmdheight = &cmdheight + set nolazyredraw + call self._setCmdheight() +endfunction + +"FUNCTION: MenuController._restoreOptions() {{{3 +"restore the options we saved in _saveOptions() +function! s:MenuController._restoreOptions() + let &cmdheight = self._oldCmdheight + let &lazyredraw = self._oldLazyredraw +endfunction + +"FUNCTION: MenuController._cursorDown() {{{3 +"move the cursor to the next menu item, skipping separators +function! s:MenuController._cursorDown() + let done = 0 + while !done + if self.selection < len(self.menuItems)-1 + let self.selection += 1 + else + let self.selection = 0 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + +"FUNCTION: MenuController._cursorUp() {{{3 +"move the cursor to the previous menu item, skipping separators +function! s:MenuController._cursorUp() + let done = 0 + while !done + if self.selection > 0 + let self.selection -= 1 + else + let self.selection = len(self.menuItems)-1 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + diff --git a/plugin/nerdtree/menu_item.vim b/plugin/nerdtree/menu_item.vim new file mode 100644 index 00000000..234bdede --- /dev/null +++ b/plugin/nerdtree/menu_item.vim @@ -0,0 +1,112 @@ +"CLASS: MenuItem {{{2 +"============================================================ +let s:MenuItem = {} +let g:NERDTreeMenuItem = s:MenuItem +"FUNCTION: MenuItem.All() {{{3 +"get all top level menu items +function! s:MenuItem.All() + if !exists("s:menuItems") + let s:menuItems = [] + endif + return s:menuItems +endfunction + +"FUNCTION: MenuItem.AllEnabled() {{{3 +"get all top level menu items that are currently enabled +function! s:MenuItem.AllEnabled() + let toReturn = [] + for i in s:MenuItem.All() + if i.enabled() + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +"FUNCTION: MenuItem.Create(options) {{{3 +"make a new menu item and add it to the global list +function! s:MenuItem.Create(options) + let newMenuItem = copy(self) + + let newMenuItem.text = a:options['text'] + let newMenuItem.shortcut = a:options['shortcut'] + let newMenuItem.children = [] + + let newMenuItem.isActiveCallback = -1 + if has_key(a:options, 'isActiveCallback') + let newMenuItem.isActiveCallback = a:options['isActiveCallback'] + endif + + let newMenuItem.callback = -1 + if has_key(a:options, 'callback') + let newMenuItem.callback = a:options['callback'] + endif + + if has_key(a:options, 'parent') + call add(a:options['parent'].children, newMenuItem) + else + call add(s:MenuItem.All(), newMenuItem) + endif + + return newMenuItem +endfunction + +"FUNCTION: MenuItem.CreateSeparator(options) {{{3 +"make a new separator menu item and add it to the global list +function! s:MenuItem.CreateSeparator(options) + let standard_options = { 'text': '--------------------', + \ 'shortcut': -1, + \ 'callback': -1 } + let options = extend(a:options, standard_options, "force") + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.CreateSubmenu(options) {{{3 +"make a new submenu and add it to global list +function! s:MenuItem.CreateSubmenu(options) + let standard_options = { 'callback': -1 } + let options = extend(a:options, standard_options, "force") + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.enabled() {{{3 +"return 1 if this menu item should be displayed +" +"delegates off to the isActiveCallback, and defaults to 1 if no callback was +"specified +function! s:MenuItem.enabled() + if self.isActiveCallback != -1 + return {self.isActiveCallback}() + endif + return 1 +endfunction + +"FUNCTION: MenuItem.execute() {{{3 +"perform the action behind this menu item, if this menuitem has children then +"display a new menu for them, otherwise deletegate off to the menuitem's +"callback +function! s:MenuItem.execute() + if len(self.children) + let mc = s:MenuController.New(self.children) + call mc.showMenu() + else + if self.callback != -1 + call {self.callback}() + endif + endif +endfunction + +"FUNCTION: MenuItem.isSeparator() {{{3 +"return 1 if this menuitem is a separator +function! s:MenuItem.isSeparator() + return self.callback == -1 && self.children == [] +endfunction + +"FUNCTION: MenuItem.isSubmenu() {{{3 +"return 1 if this menuitem is a submenu +function! s:MenuItem.isSubmenu() + return self.callback == -1 && !empty(self.children) +endfunction + diff --git a/plugin/nerdtree/opener.vim b/plugin/nerdtree/opener.vim new file mode 100644 index 00000000..df8978f2 --- /dev/null +++ b/plugin/nerdtree/opener.vim @@ -0,0 +1,263 @@ +"CLASS: Opener {{{2 +"============================================================ +let s:Opener = {} +let g:NERDTreeOpener = s:Opener + +"FUNCTION: Opener._checkToCloseTree(newtab) {{{3 +"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see +"if the tree should be closed now. +" +"Args: +"a:newtab - boolean. If set, only close the tree now if we are opening the +"target in a new tab. This is needed because we have to close tree before we +"leave the tab +function! s:Opener._checkToCloseTree(newtab) + if self._keepopen + return + endif + + if (a:newtab && self._where == 't') || !a:newtab + call nerdtree#closeTreeIfQuitOnOpen() + endif +endfunction + +"FUNCTION: Opener._gotoTargetWin() {{{3 +function! s:Opener._gotoTargetWin() + if b:NERDTreeType ==# "secondary" + if self._where == 'v' + vsplit + elseif self._where == 'h' + split + elseif self._where == 't' + tabnew + endif + else + call self._checkToCloseTree(1) + + if self._where == 'v' + call self._newVSplit() + elseif self._where == 'h' + call self._newSplit() + elseif self._where == 't' + tabnew + elseif self._where == 'p' + call self._previousWindow() + endif + + call self._checkToCloseTree(0) + endif +endfunction + +"FUNCTION: Opener.New(path, opts) {{{3 +"Args: +" +"a:path: The path object that is to be opened. +" +"a:opts: +" +"A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +function! s:Opener.New(path, opts) + let newObj = copy(self) + + let newObj._path = a:path + let newObj._stay = nerdtree#has_opt(a:opts, 'stay') + let newObj._reuse = nerdtree#has_opt(a:opts, 'reuse') + let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen') + let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' + let newObj._treetype = b:NERDTreeType + call newObj._saveCursorPos() + + return newObj +endfunction + +"FUNCTION: Opener._newSplit() {{{3 +function! s:Opener._newSplit() + " Save the user's settings for splitbelow and splitright + let savesplitbelow=&splitbelow + let savesplitright=&splitright + + " 'there' will be set to a command to move from the split window + " back to the explorer window + " + " 'back' will be set to a command to move from the explorer window + " back to the newly split window + " + " 'right' and 'below' will be set to the settings needed for + " splitbelow and splitright IF the explorer is the only window. + " + let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" + let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" + let right= g:NERDTreeWinPos ==# "left" + let below=0 + + " Attempt to go to adjacent window + call nerdtree#exec(back) + + let onlyOneWin = (winnr("$") ==# 1) + + " If no adjacent window, set splitright and splitbelow appropriately + if onlyOneWin + let &splitright=right + let &splitbelow=below + else + " found adjacent window - invert split direction + let &splitright=!right + let &splitbelow=!below + endif + + let splitMode = onlyOneWin ? "vertical" : "" + + " Open the new window + try + exec(splitMode." sp ") + catch /^Vim\%((\a\+)\)\=:E37/ + call nerdtree#putCursorInTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + "do nothing + endtry + + "resize the tree window if no other window was open before + if onlyOneWin + let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call nerdtree#exec(there) + exec("silent ". splitMode ." resize ". size) + call nerdtree#exec('wincmd p') + endif + + " Restore splitmode settings + let &splitbelow=savesplitbelow + let &splitright=savesplitright +endfunction + +"FUNCTION: Opener._newVSplit() {{{3 +function! s:Opener._newVSplit() + let winwidth = winwidth(".") + if winnr("$")==#1 + let winwidth = g:NERDTreeWinSize + endif + + call nerdtree#exec("wincmd p") + vnew + + "resize the nerd tree back to the original size + call nerdtree#putCursorInTreeWin() + exec("silent vertical resize ". winwidth) + call nerdtree#exec('wincmd p') +endfunction + +"FUNCTION: Opener.open(target) {{{3 +function! s:Opener.open(target) + if self._path.isDirectory + call self._openDirectory(a:target) + else + call self._openFile() + endif +endfunction + +"FUNCTION: Opener._openFile() {{{3 +function! s:Opener._openFile() + if self._reuse && self._reuseWindow() + return + endif + + call self._gotoTargetWin() + + if self._treetype ==# "secondary" + call self._path.edit() + else + call self._path.edit() + + + if self._stay + call self._restoreCursorPos() + endif + endif +endfunction + +"FUNCTION: Opener._openDirectory(node) {{{3 +function! s:Opener._openDirectory(node) + if self._treetype ==# "secondary" + call self._gotoTargetWin() + call nerdtree#initNerdTreeInPlace(a:node.path.str()) + else + call self._gotoTargetWin() + if empty(self._where) + call a:node.makeRoot() + call nerdtree#renderView() + call a:node.putCursorHere(0, 0) + elseif self._where == 't' + call nerdtree#initNerdTree(a:node.path.str()) + else + call nerdtree#initNerdTreeInPlace(a:node.path.str()) + endif + endif + + if self._stay + call self._restoreCursorPos() + endif +endfunction + +"FUNCTION: Opener._previousWindow() {{{3 +function! s:Opener._previousWindow() + if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1 + call self._newSplit() + else + try + if !nerdtree#isWindowUsable(winnr("#")) + call nerdtree#exec(nerdtree#firstUsableWindow() . "wincmd w") + else + call nerdtree#exec('wincmd p') + endif + catch /^Vim\%((\a\+)\)\=:E37/ + call nerdtree#putCursorInTreeWin() + throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + catch /^Vim\%((\a\+)\)\=:/ + echo v:exception + endtry + endif +endfunction + +"FUNCTION: Opener._restoreCursorPos(){{{3 +function! s:Opener._restoreCursorPos() + call nerdtree#exec('normal ' . self._tabnr . 'gt') + call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') +endfunction + +"FUNCTION: Opener._reuseWindow(){{{3 +"put the cursor in the first window we find for this file +" +"return 1 if we were successful +function! s:Opener._reuseWindow() + "check the current tab for the window + let winnr = bufwinnr('^' . self._path.str() . '$') + if winnr != -1 + call nerdtree#exec(winnr . "wincmd w") + call self._checkToCloseTree(0) + return 1 + else + "check other tabs + let tabnr = self._path.tabnr() + if tabnr + call self._checkToCloseTree(1) + call nerdtree#exec('normal! ' . tabnr . 'gt') + let winnr = bufwinnr('^' . self._path.str() . '$') + call nerdtree#exec(winnr . "wincmd w") + return 1 + endif + endif + return 0 +endfunction + +"FUNCTION: Opener._saveCursorPos(){{{3 +function! s:Opener._saveCursorPos() + let self._bufnr = bufnr("") + let self._tabnr = tabpagenr() +endfunction + diff --git a/plugin/nerdtree/path.vim b/plugin/nerdtree/path.vim new file mode 100644 index 00000000..9ef0b28d --- /dev/null +++ b/plugin/nerdtree/path.vim @@ -0,0 +1,695 @@ +"we need to use this number many times for sorting... so we calculate it only +"once here +let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') + +"CLASS: Path {{{2 +"============================================================ +let s:Path = {} +let g:NERDTreePath = s:Path +"FUNCTION: Path.AbsolutePathFor(str) {{{3 +function! s:Path.AbsolutePathFor(str) + let prependCWD = 0 + if nerdtree#runningWindows() + let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)' + else + let prependCWD = a:str !~# '^/' + endif + + let toReturn = a:str + if prependCWD + let toReturn = getcwd() . s:Path.Slash() . a:str + endif + + return toReturn +endfunction +"FUNCTION: Path.bookmarkNames() {{{3 +function! s:Path.bookmarkNames() + if !exists("self._bookmarkNames") + call self.cacheDisplayString() + endif + return self._bookmarkNames +endfunction +"FUNCTION: Path.cacheDisplayString() {{{3 +function! s:Path.cacheDisplayString() + let self.cachedDisplayString = self.getLastPathComponent(1) + + if self.isExecutable + let self.cachedDisplayString = self.cachedDisplayString . '*' + endif + + let self._bookmarkNames = [] + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self) + call add(self._bookmarkNames, i.name) + endif + endfor + if !empty(self._bookmarkNames) + let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' + endif + + if self.isSymLink + let self.cachedDisplayString .= ' -> ' . self.symLinkDest + endif + + if self.isReadOnly + let self.cachedDisplayString .= ' [RO]' + endif +endfunction +"FUNCTION: Path.changeToDir() {{{3 +function! s:Path.changeToDir() + let dir = self.str({'format': 'Cd'}) + if self.isDirectory ==# 0 + let dir = self.getParent().str({'format': 'Cd'}) + endif + + try + execute "cd " . dir + call s:echo("CWD is now: " . getcwd()) + catch + throw "NERDTree.PathChangeError: cannot change CWD to " . dir + endtry +endfunction + +"FUNCTION: Path.compareTo() {{{3 +" +"Compares this Path to the given path and returns 0 if they are equal, -1 if +"this Path is "less than" the given path, or 1 if it is "greater". +" +"Args: +"path: the path object to compare this to +" +"Return: +"1, -1 or 0 +function! s:Path.compareTo(path) + let thisPath = self.getLastPathComponent(1) + let thatPath = a:path.getLastPathComponent(1) + + "if the paths are the same then clearly we return 0 + if thisPath ==# thatPath + return 0 + endif + + let thisSS = self.getSortOrderIndex() + let thatSS = a:path.getSortOrderIndex() + + "compare the sort sequences, if they are different then the return + "value is easy + if thisSS < thatSS + return -1 + elseif thisSS > thatSS + return 1 + else + "if the sort sequences are the same then compare the paths + "alphabetically + let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath limit + let toReturn = "<" . strpart(toReturn, len(toReturn) - limit + 1) + endif + endif + + return toReturn +endfunction + +"FUNCTION: Path._strForUI() {{{3 +function! s:Path._strForUI() + let toReturn = '/' . join(self.pathSegments, '/') + if self.isDirectory && toReturn != '/' + let toReturn = toReturn . '/' + endif + return toReturn +endfunction + +"FUNCTION: Path._strForCd() {{{3 +" +" returns a string that can be used with :cd +function! s:Path._strForCd() + return escape(self.str(), nerdtree#escChars()) +endfunction +"FUNCTION: Path._strForEdit() {{{3 +" +"Return: the string for this path that is suitable to be used with the :edit +"command +function! s:Path._strForEdit() + let p = escape(self.str({'format': 'UI'}), nerdtree#escChars()) + let cwd = getcwd() . s:Path.Slash() + + "return a relative path if we can + let isRelative = 0 + if nerdtree#runningWindows() + let isRelative = stridx(tolower(p), tolower(cwd)) == 0 + else + let isRelative = stridx(p, cwd) == 0 + endif + + if isRelative + let p = strpart(p, strlen(cwd)) + + "handle the edge case where the file begins with a + (vim interprets + "the +foo in `:e +foo` as an option to :edit) + if p[0] == "+" + let p = '\' . p + endif + endif + + if p ==# '' + let p = '.' + endif + + return p +endfunction +"FUNCTION: Path._strForGlob() {{{3 +function! s:Path._strForGlob() + let lead = s:Path.Slash() + + "if we are running windows then slap a drive letter on the front + if nerdtree#runningWindows() + let lead = self.drive . '\' + endif + + let toReturn = lead . join(self.pathSegments, s:Path.Slash()) + + if !nerdtree#runningWindows() + let toReturn = escape(toReturn, nerdtree#escChars()) + endif + return toReturn +endfunction +"FUNCTION: Path._str() {{{3 +" +"Gets the string path for this path object that is appropriate for the OS. +"EG, in windows c:\foo\bar +" in *nix /foo/bar +function! s:Path._str() + let lead = s:Path.Slash() + + "if we are running windows then slap a drive letter on the front + if nerdtree#runningWindows() + let lead = self.drive . '\' + endif + + return lead . join(self.pathSegments, s:Path.Slash()) +endfunction + +"FUNCTION: Path.strTrunk() {{{3 +"Gets the path without the last segment on the end. +function! s:Path.strTrunk() + return self.drive . '/' . join(self.pathSegments[0:-2], '/') +endfunction + +" FUNCTION: Path.tabnr() {{{3 +" return the number of the first tab that is displaying this file +" +" return 0 if no tab was found +function! s:Path.tabnr() + let str = self.str() + for t in range(tabpagenr('$')) + for b in tabpagebuflist(t+1) + if str == expand('#' . b . ':p') + return t+1 + endif + endfor + endfor + return 0 +endfunction +"FUNCTION: Path.WinToUnixPath(pathstr){{{3 +"Takes in a windows path and returns the unix equiv +" +"A class level method +" +"Args: +"pathstr: the windows path to convert +function! s:Path.WinToUnixPath(pathstr) + if !nerdtree#runningWindows() + return a:pathstr + endif + + let toReturn = a:pathstr + + "remove the x:\ of the front + let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") + + "remove the \\ network share from the front + let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "") + + "convert all \ chars to / + let toReturn = substitute(toReturn, '\', '/', "g") + + return toReturn +endfunction + diff --git a/plugin/nerdtree/tree_dir_node.vim b/plugin/nerdtree/tree_dir_node.vim new file mode 100644 index 00000000..85688bec --- /dev/null +++ b/plugin/nerdtree/tree_dir_node.vim @@ -0,0 +1,513 @@ +"CLASS: TreeDirNode {{{2 +"This class is a child of the TreeFileNode class and constitutes the +"'Composite' part of the composite design pattern between the treenode +"classes. +"============================================================ +let s:TreeDirNode = copy(g:NERDTreeFileNode) +let g:NERDTreeDirNode = s:TreeDirNode +"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3 +"class method that returns the highest cached ancestor of the current root +function! s:TreeDirNode.AbsoluteTreeRoot() + let currentNode = b:NERDTreeRoot + while currentNode.parent != {} + let currentNode = currentNode.parent + endwhile + return currentNode +endfunction +"FUNCTION: TreeDirNode.activate([options]) {{{3 +unlet s:TreeDirNode.activate +function! s:TreeDirNode.activate(...) + let opts = a:0 ? a:1 : {} + call self.toggleOpen(opts) + call nerdtree#renderView() + call self.putCursorHere(0, 0) +endfunction +"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3 +"Adds the given treenode to the list of children for this node +" +"Args: +"-treenode: the node to add +"-inOrder: 1 if the new node should be inserted in sorted order +function! s:TreeDirNode.addChild(treenode, inOrder) + call add(self.children, a:treenode) + let a:treenode.parent = self + + if a:inOrder + call self.sortChildren() + endif +endfunction + +"FUNCTION: TreeDirNode.close() {{{3 +"Closes this directory +function! s:TreeDirNode.close() + let self.isOpen = 0 +endfunction + +"FUNCTION: TreeDirNode.closeChildren() {{{3 +"Closes all the child dir nodes of this node +function! s:TreeDirNode.closeChildren() + for i in self.children + if i.path.isDirectory + call i.close() + call i.closeChildren() + endif + endfor +endfunction + +"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3 +"Instantiates a new child node for this node with the given path. The new +"nodes parent is set to this node. +" +"Args: +"path: a Path object that this node will represent/contain +"inOrder: 1 if the new node should be inserted in sorted order +" +"Returns: +"the newly created node +function! s:TreeDirNode.createChild(path, inOrder) + let newTreeNode = g:NERDTreeFileNode.New(a:path) + call self.addChild(newTreeNode, a:inOrder) + return newTreeNode +endfunction + +"FUNCTION: TreeDirNode.findNode(path) {{{3 +"Will find one of the children (recursively) that has the given path +" +"Args: +"path: a path object +unlet s:TreeDirNode.findNode +function! s:TreeDirNode.findNode(path) + if a:path.equals(self.path) + return self + endif + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return {} + endif + + if self.path.isDirectory + for i in self.children + let retVal = i.findNode(a:path) + if retVal != {} + return retVal + endif + endfor + endif + return {} +endfunction +"FUNCTION: TreeDirNode.getChildCount() {{{3 +"Returns the number of children this node has +function! s:TreeDirNode.getChildCount() + return len(self.children) +endfunction + +"FUNCTION: TreeDirNode.getChild(path) {{{3 +"Returns child node of this node that has the given path or {} if no such node +"exists. +" +"This function doesnt not recurse into child dir nodes +" +"Args: +"path: a path object +function! s:TreeDirNode.getChild(path) + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return {} + endif + + let index = self.getChildIndex(a:path) + if index ==# -1 + return {} + else + return self.children[index] + endif + +endfunction + +"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3 +"returns the child at the given index +"Args: +"indx: the index to get the child from +"visible: 1 if only the visible children array should be used, 0 if all the +"children should be searched. +function! s:TreeDirNode.getChildByIndex(indx, visible) + let array_to_search = a:visible? self.getVisibleChildren() : self.children + if a:indx > len(array_to_search) + throw "NERDTree.InvalidArgumentsError: Index is out of bounds." + endif + return array_to_search[a:indx] +endfunction + +"FUNCTION: TreeDirNode.getChildIndex(path) {{{3 +"Returns the index of the child node of this node that has the given path or +"-1 if no such node exists. +" +"This function doesnt not recurse into child dir nodes +" +"Args: +"path: a path object +function! s:TreeDirNode.getChildIndex(path) + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return -1 + endif + + "do a binary search for the child + let a = 0 + let z = self.getChildCount() + while a < z + let mid = (a+z)/2 + let diff = a:path.compareTo(self.children[mid].path) + + if diff ==# -1 + let z = mid + elseif diff ==# 1 + let a = mid+1 + else + return mid + endif + endwhile + return -1 +endfunction + +"FUNCTION: TreeDirNode.GetSelected() {{{3 +"Returns the current node if it is a dir node, or else returns the current +"nodes parent +unlet s:TreeDirNode.GetSelected +function! s:TreeDirNode.GetSelected() + let currentDir = g:NERDTreeFileNode.GetSelected() + if currentDir != {} && !currentDir.isRoot() + if currentDir.path.isDirectory ==# 0 + let currentDir = currentDir.parent + endif + endif + return currentDir +endfunction +"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3 +"Returns the number of visible children this node has +function! s:TreeDirNode.getVisibleChildCount() + return len(self.getVisibleChildren()) +endfunction + +"FUNCTION: TreeDirNode.getVisibleChildren() {{{3 +"Returns a list of children to display for this node, in the correct order +" +"Return: +"an array of treenodes +function! s:TreeDirNode.getVisibleChildren() + let toReturn = [] + for i in self.children + if i.path.ignore() ==# 0 + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3 +"returns 1 if this node has any childre, 0 otherwise.. +function! s:TreeDirNode.hasVisibleChildren() + return self.getVisibleChildCount() != 0 +endfunction + +"FUNCTION: TreeDirNode._initChildren() {{{3 +"Removes all childen from this node and re-reads them +" +"Args: +"silent: 1 if the function should not echo any "please wait" messages for +"large directories +" +"Return: the number of child nodes read +function! s:TreeDirNode._initChildren(silent) + "remove all the current child nodes + let self.children = [] + + "get an array of all the files in the nodes dir + let dir = self.path + let globDir = dir.str({'format': 'Glob'}) + + if version >= 703 + let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1) + else + let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + endif + + let files = split(filesStr, "\n") + + if !a:silent && len(files) > g:NERDTreeNotificationThreshold + call nerdtree#echo("Please wait, caching a large dir ...") + endif + + let invalidFilesFound = 0 + for i in files + + "filter out the .. and . directories + "Note: we must match .. AND ../ cos sometimes the globpath returns + "../ for path with strange chars (eg $) + if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' + + "put the next file in a new node and attach it + try + let path = g:NERDTreePath.New(i) + call self.createChild(path, 0) + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound += 1 + endtry + endif + endfor + + call self.sortChildren() + + if !a:silent && len(files) > g:NERDTreeNotificationThreshold + call nerdtree#echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).") + endif + + if invalidFilesFound + call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") + endif + return self.getChildCount() +endfunction +"FUNCTION: TreeDirNode.New(path) {{{3 +"Returns a new TreeNode object with the given path and parent +" +"Args: +"path: a path object representing the full filesystem path to the file/dir that the node represents +unlet s:TreeDirNode.New +function! s:TreeDirNode.New(path) + if a:path.isDirectory != 1 + throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." + endif + + let newTreeNode = copy(self) + let newTreeNode.path = a:path + + let newTreeNode.isOpen = 0 + let newTreeNode.children = [] + + let newTreeNode.parent = {} + + return newTreeNode +endfunction +"FUNCTION: TreeDirNode.open([opts]) {{{3 +"Open the dir in the current tree or in a new tree elsewhere. +" +"If opening in the current tree, return the number of cached nodes. +unlet s:TreeDirNode.open +function! s:TreeDirNode.open(...) + let opts = a:0 ? a:1 : {} + + if has_key(opts, 'where') && !empty(opts['where']) + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) + else + let self.isOpen = 1 + if self.children ==# [] + return self._initChildren(0) + else + return 0 + endif + endif +endfunction +"FUNCTION: TreeDirNode.openAlong([opts]) {{{3 +"recursive open the dir if it has only one directory child. +" +"return the level of opened directories. +function! s:TreeDirNode.openAlong(...) + let opts = a:0 ? a:1 : {} + let level = 0 + + let node = self + while node.path.isDirectory + call node.open(opts) + let level += 1 + if node.getVisibleChildCount() == 1 + let node = node.getChildByIndex(0, 1) + else + break + endif + endwhile + return level +endfunction +" FUNCTION: TreeDirNode.openExplorer() {{{3 +" opens an explorer window for this node in the previous window (could be a +" nerd tree or a netrw) +function! s:TreeDirNode.openExplorer() + call self.open({'where': 'p'}) +endfunction +"FUNCTION: TreeDirNode.openInNewTab(options) {{{3 +unlet s:TreeDirNode.openInNewTab +function! s:TreeDirNode.openInNewTab(options) + call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') + call self.open({'where': 't'}) +endfunction +"FUNCTION: TreeDirNode._openInNewTab() {{{3 +function! s:TreeDirNode._openInNewTab() + tabnew + call nerdtree#initNerdTree(self.path.str()) +endfunction +"FUNCTION: TreeDirNode.openRecursively() {{{3 +"Opens this treenode and all of its children whose paths arent 'ignored' +"because of the file filters. +" +"This method is actually a wrapper for the OpenRecursively2 method which does +"the work. +function! s:TreeDirNode.openRecursively() + call self._openRecursively2(1) +endfunction + +"FUNCTION: TreeDirNode._openRecursively2() {{{3 +"Opens this all children of this treenode recursively if either: +" *they arent filtered by file filters +" *a:forceOpen is 1 +" +"Args: +"forceOpen: 1 if this node should be opened regardless of file filters +function! s:TreeDirNode._openRecursively2(forceOpen) + if self.path.ignore() ==# 0 || a:forceOpen + let self.isOpen = 1 + if self.children ==# [] + call self._initChildren(1) + endif + + for i in self.children + if i.path.isDirectory ==# 1 + call i._openRecursively2(0) + endif + endfor + endif +endfunction + +"FUNCTION: TreeDirNode.refresh() {{{3 +unlet s:TreeDirNode.refresh +function! s:TreeDirNode.refresh() + call self.path.refresh() + + "if this node was ever opened, refresh its children + if self.isOpen || !empty(self.children) + "go thru all the files/dirs under this node + let newChildNodes = [] + let invalidFilesFound = 0 + let dir = self.path + let globDir = dir.str({'format': 'Glob'}) + let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') + let files = split(filesStr, "\n") + for i in files + "filter out the .. and . directories + "Note: we must match .. AND ../ cos sometimes the globpath returns + "../ for path with strange chars (eg $) + if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' + + try + "create a new path and see if it exists in this nodes children + let path = g:NERDTreePath.New(i) + let newNode = self.getChild(path) + if newNode != {} + call newNode.refresh() + call add(newChildNodes, newNode) + + "the node doesnt exist so create it + else + let newNode = g:NERDTreeFileNode.New(path) + let newNode.parent = self + call add(newChildNodes, newNode) + endif + + + catch /^NERDTree.InvalidArgumentsError/ + let invalidFilesFound = 1 + endtry + endif + endfor + + "swap this nodes children out for the children we just read/refreshed + let self.children = newChildNodes + call self.sortChildren() + + if invalidFilesFound + call nerdtree#echoWarning("some files could not be loaded into the NERD tree") + endif + endif +endfunction + +"FUNCTION: TreeDirNode.reveal(path) {{{3 +"reveal the given path, i.e. cache and open all treenodes needed to display it +"in the UI +function! s:TreeDirNode.reveal(path) + if !a:path.isUnder(self.path) + throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() + endif + + call self.open() + + if self.path.equals(a:path.getParent()) + let n = self.findNode(a:path) + call nerdtree#renderView() + call n.putCursorHere(1,0) + return + endif + + let p = a:path + while !p.getParent().equals(self.path) + let p = p.getParent() + endwhile + + let n = self.findNode(p) + call n.reveal(a:path) +endfunction +"FUNCTION: TreeDirNode.removeChild(treenode) {{{3 +" +"Removes the given treenode from this nodes set of children +" +"Args: +"treenode: the node to remove +" +"Throws a NERDTree.ChildNotFoundError if the given treenode is not found +function! s:TreeDirNode.removeChild(treenode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:treenode) + call remove(self.children, i) + return + endif + endfor + + throw "NERDTree.ChildNotFoundError: child node was not found" +endfunction + +"FUNCTION: TreeDirNode.sortChildren() {{{3 +" +"Sorts the children of this node according to alphabetical order and the +"directory priority. +" +function! s:TreeDirNode.sortChildren() + let CompareFunc = function("nerdtree#compareNodes") + call sort(self.children, CompareFunc) +endfunction + +"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3 +"Opens this directory if it is closed and vice versa +function! s:TreeDirNode.toggleOpen(...) + let opts = a:0 ? a:1 : {} + if self.isOpen ==# 1 + call self.close() + else + if g:NERDTreeCasadeOpenSingleChildDir == 0 + call self.open(opts) + else + call self.openAlong(opts) + endif + endif +endfunction +"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3 +"Replaces the child of this with the given node (where the child node's full +"path matches a:newNode's fullpath). The search for the matching node is +"non-recursive +" +"Arg: +"newNode: the node to graft into the tree +function! s:TreeDirNode.transplantChild(newNode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:newNode) + let self.children[i] = a:newNode + let a:newNode.parent = self + break + endif + endfor +endfunction +"============================================================ diff --git a/plugin/nerdtree/tree_file_node.vim b/plugin/nerdtree/tree_file_node.vim new file mode 100644 index 00000000..2cecedfa --- /dev/null +++ b/plugin/nerdtree/tree_file_node.vim @@ -0,0 +1,469 @@ +"CLASS: TreeFileNode {{{2 +"This class is the parent of the TreeDirNode class and constitures the +"'Component' part of the composite design pattern between the treenode +"classes. +"============================================================ +let s:TreeFileNode = {} +let g:NERDTreeFileNode = s:TreeFileNode +"FUNCTION: TreeFileNode.activate(...) {{{3 +function! s:TreeFileNode.activate(...) + call self.open(a:0 ? a:1 : {}) +endfunction +"FUNCTION: TreeFileNode.bookmark(name) {{{3 +"bookmark this node with a:name +function! s:TreeFileNode.bookmark(name) + + "if a bookmark exists with the same name and the node is cached then save + "it so we can update its display string + let oldMarkedNode = {} + try + let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1) + catch /^NERDTree.BookmarkNotFoundError/ + catch /^NERDTree.BookmarkedNodeNotFoundError/ + endtry + + call g:NERDTreeBookmark.AddBookmark(a:name, self.path) + call self.path.cacheDisplayString() + call g:NERDTreeBookmark.Write() + + if !empty(oldMarkedNode) + call oldMarkedNode.path.cacheDisplayString() + endif +endfunction +"FUNCTION: TreeFileNode.cacheParent() {{{3 +"initializes self.parent if it isnt already +function! s:TreeFileNode.cacheParent() + if empty(self.parent) + let parentPath = self.path.getParent() + if parentPath.equals(self.path) + throw "NERDTree.CannotCacheParentError: already at root" + endif + let self.parent = s:TreeFileNode.New(parentPath) + endif +endfunction + +"FUNCTION: TreeFileNode.clearBookmarks() {{{3 +function! s:TreeFileNode.clearBookmarks() + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self.path) + call i.delete() + end + endfor + call self.path.cacheDisplayString() +endfunction +"FUNCTION: TreeFileNode.copy(dest) {{{3 +function! s:TreeFileNode.copy(dest) + call self.path.copy(a:dest) + let newPath = s:NERDTreePath.New(a:dest) + let parent = b:NERDTreeRoot.findNode(newPath.getParent()) + if !empty(parent) + call parent.refresh() + return parent.findNode(newPath) + else + return {} + endif +endfunction + +"FUNCTION: TreeFileNode.delete {{{3 +"Removes this node from the tree and calls the Delete method for its path obj +function! s:TreeFileNode.delete() + call self.path.delete() + call self.parent.removeChild(self) +endfunction + +"FUNCTION: TreeFileNode.displayString() {{{3 +" +"Returns a string that specifies how the node should be represented as a +"string +" +"Return: +"a string that can be used in the view to represent this node +function! s:TreeFileNode.displayString() + return self.path.displayString() +endfunction + +"FUNCTION: TreeFileNode.equals(treenode) {{{3 +" +"Compares this treenode to the input treenode and returns 1 if they are the +"same node. +" +"Use this method instead of == because sometimes when the treenodes contain +"many children, vim seg faults when doing == +" +"Args: +"treenode: the other treenode to compare to +function! s:TreeFileNode.equals(treenode) + return self.path.str() ==# a:treenode.path.str() +endfunction + +"FUNCTION: TreeFileNode.findNode(path) {{{3 +"Returns self if this node.path.Equals the given path. +"Returns {} if not equal. +" +"Args: +"path: the path object to compare against +function! s:TreeFileNode.findNode(path) + if a:path.equals(self.path) + return self + endif + return {} +endfunction +"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3 +" +"Finds the next sibling for this node in the indicated direction. This sibling +"must be a directory and may/may not have children as specified. +" +"Args: +"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" +"Return: +"a treenode object or {} if no appropriate sibling could be found +function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) + "if we have no parent then we can have no siblings + if self.parent != {} + let nextSibling = self.findSibling(a:direction) + + while nextSibling != {} + if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen + return nextSibling + endif + let nextSibling = nextSibling.findSibling(a:direction) + endwhile + endif + + return {} +endfunction +"FUNCTION: TreeFileNode.findSibling(direction) {{{3 +" +"Finds the next sibling for this node in the indicated direction +" +"Args: +"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" +"Return: +"a treenode object or {} if no sibling could be found +function! s:TreeFileNode.findSibling(direction) + "if we have no parent then we can have no siblings + if self.parent != {} + + "get the index of this node in its parents children + let siblingIndx = self.parent.getChildIndex(self.path) + + if siblingIndx != -1 + "move a long to the next potential sibling node + let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 + + "keep moving along to the next sibling till we find one that is valid + let numSiblings = self.parent.getChildCount() + while siblingIndx >= 0 && siblingIndx < numSiblings + + "if the next node is not an ignored node (i.e. wont show up in the + "view) then return it + if self.parent.children[siblingIndx].path.ignore() ==# 0 + return self.parent.children[siblingIndx] + endif + + "go to next node + let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 + endwhile + endif + endif + + return {} +endfunction + +"FUNCTION: TreeFileNode.getLineNum(){{{3 +"returns the line number this node is rendered on, or -1 if it isnt rendered +function! s:TreeFileNode.getLineNum() + "if the node is the root then return the root line no. + if self.isRoot() + return s:TreeFileNode.GetRootLineNum() + endif + + let totalLines = line("$") + + "the path components we have matched so far + let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] + "the index of the component we are searching for + let curPathComponent = 1 + + let fullpath = self.path.str({'format': 'UI'}) + + + let lnum = s:TreeFileNode.GetRootLineNum() + while lnum > 0 + let lnum = lnum + 1 + "have we reached the bottom of the tree? + if lnum ==# totalLines+1 + return -1 + endif + + let curLine = getline(lnum) + + let indent = nerdtree#indentLevelFor(curLine) + if indent ==# curPathComponent + let curLine = nerdtree#stripMarkupFromLine(curLine, 1) + + let curPath = join(pathcomponents, '/') . '/' . curLine + if stridx(fullpath, curPath, 0) ==# 0 + if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' + let curLine = substitute(curLine, '/ *$', '', '') + call add(pathcomponents, curLine) + let curPathComponent = curPathComponent + 1 + + if fullpath ==# curPath + return lnum + endif + endif + endif + endif + endwhile + return -1 +endfunction + +"FUNCTION: TreeFileNode.GetRootForTab(){{{3 +"get the root node for this tab +function! s:TreeFileNode.GetRootForTab() + if nerdtree#treeExistsForTab() + return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot') + end + return {} +endfunction +"FUNCTION: TreeFileNode.GetRootLineNum(){{{3 +"gets the line number of the root node +function! s:TreeFileNode.GetRootLineNum() + let rootLine = 1 + while getline(rootLine) !~# '^\(/\|<\)' + let rootLine = rootLine + 1 + endwhile + return rootLine +endfunction + +"FUNCTION: TreeFileNode.GetSelected() {{{3 +"gets the treenode that the cursor is currently over +function! s:TreeFileNode.GetSelected() + try + let path = nerdtree#getPath(line(".")) + if path ==# {} + return {} + endif + return b:NERDTreeRoot.findNode(path) + catch /^NERDTree/ + return {} + endtry +endfunction +"FUNCTION: TreeFileNode.isVisible() {{{3 +"returns 1 if this node should be visible according to the tree filters and +"hidden file filters (and their on/off status) +function! s:TreeFileNode.isVisible() + return !self.path.ignore() +endfunction +"FUNCTION: TreeFileNode.isRoot() {{{3 +"returns 1 if this node is b:NERDTreeRoot +function! s:TreeFileNode.isRoot() + if !nerdtree#treeExistsForBuf() + throw "NERDTree.NoTreeError: No tree exists for the current buffer" + endif + + return self.equals(b:NERDTreeRoot) +endfunction + +"FUNCTION: TreeFileNode.makeRoot() {{{3 +"Make this node the root of the tree +function! s:TreeFileNode.makeRoot() + if self.path.isDirectory + let b:NERDTreeRoot = self + else + call self.cacheParent() + let b:NERDTreeRoot = self.parent + endif + + call b:NERDTreeRoot.open() + + "change dir to the dir of the new root if instructed to + if g:NERDTreeChDirMode ==# 2 + exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'}) + endif + + silent doautocmd User NERDTreeNewRoot +endfunction +"FUNCTION: TreeFileNode.New(path) {{{3 +"Returns a new TreeNode object with the given path and parent +" +"Args: +"path: a path object representing the full filesystem path to the file/dir that the node represents +function! s:TreeFileNode.New(path) + if a:path.isDirectory + return g:NERDTreeDirNode.New(a:path) + else + let newTreeNode = copy(self) + let newTreeNode.path = a:path + let newTreeNode.parent = {} + return newTreeNode + endif +endfunction + +"FUNCTION: TreeFileNode.open() {{{3 +function! s:TreeFileNode.open(...) + let opts = a:0 ? a:1 : {} + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) +endfunction + +"FUNCTION: TreeFileNode.openSplit() {{{3 +"Open this node in a new window +function! s:TreeFileNode.openSplit() + call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'h'}) +endfunction +"FUNCTION: TreeFileNode.openVSplit() {{{3 +"Open this node in a new vertical window +function! s:TreeFileNode.openVSplit() + call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'v'}) +endfunction +"FUNCTION: TreeFileNode.openInNewTab(options) {{{3 +function! s:TreeFileNode.openInNewTab(options) + echomsg 'TreeFileNode.openInNewTab is deprecated' + call self.open(extend({'where': 't'}, a:options)) +endfunction +"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 +"Places the cursor on the line number this node is rendered on +" +"Args: +"isJump: 1 if this cursor movement should be counted as a jump by vim +"recurseUpward: try to put the cursor on the parent if the this node isnt +"visible +function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) + let ln = self.getLineNum() + if ln != -1 + if a:isJump + mark ' + endif + call cursor(ln, col(".")) + else + if a:recurseUpward + let node = self + while node != {} && node.getLineNum() ==# -1 + let node = node.parent + call node.open() + endwhile + call nerdtree#renderView() + call node.putCursorHere(a:isJump, 0) + endif + endif +endfunction + +"FUNCTION: TreeFileNode.refresh() {{{3 +function! s:TreeFileNode.refresh() + call self.path.refresh() +endfunction +"FUNCTION: TreeFileNode.rename() {{{3 +"Calls the rename method for this nodes path obj +function! s:TreeFileNode.rename(newName) + let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') + call self.path.rename(newName) + call self.parent.removeChild(self) + + let parentPath = self.path.getParent() + let newParent = b:NERDTreeRoot.findNode(parentPath) + + if newParent != {} + call newParent.createChild(self.path, 1) + call newParent.refresh() + endif +endfunction +"FUNCTION: TreeFileNode.renderToString {{{3 +"returns a string representation for this tree to be rendered in the view +function! s:TreeFileNode.renderToString() + return self._renderToString(0, 0, [], self.getChildCount() ==# 1) +endfunction + + +"Args: +"depth: the current depth in the tree for this call +"drawText: 1 if we should actually draw the line for this node (if 0 then the +"child nodes are rendered only) +"vertMap: a binary array that indicates whether a vertical bar should be draw +"for each depth in the tree +"isLastChild:true if this curNode is the last child of its parent +function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) + let output = "" + if a:drawText ==# 1 + + let treeParts = '' + + "get all the leading spaces and vertical tree parts for this line + if a:depth > 1 + for j in a:vertMap[0:-2] + if g:NERDTreeDirArrows + let treeParts = treeParts . ' ' + else + if j ==# 1 + let treeParts = treeParts . '| ' + else + let treeParts = treeParts . ' ' + endif + endif + endfor + endif + + "get the last vertical tree part for this line which will be different + "if this node is the last child of its parent + if !g:NERDTreeDirArrows + if a:isLastChild + let treeParts = treeParts . '`' + else + let treeParts = treeParts . '|' + endif + endif + + "smack the appropriate dir/file symbol on the line before the file/dir + "name itself + if self.path.isDirectory + if self.isOpen + if g:NERDTreeDirArrows + let treeParts = treeParts . '▾ ' + else + let treeParts = treeParts . '~' + endif + else + if g:NERDTreeDirArrows + let treeParts = treeParts . '▸ ' + else + let treeParts = treeParts . '+' + endif + endif + else + if g:NERDTreeDirArrows + let treeParts = treeParts . ' ' + else + let treeParts = treeParts . '-' + endif + endif + let line = treeParts . self.displayString() + + let output = output . line . "\n" + endif + + "if the node is an open dir, draw its children + if self.path.isDirectory ==# 1 && self.isOpen ==# 1 + + let childNodesToDraw = self.getVisibleChildren() + if len(childNodesToDraw) > 0 + + "draw all the nodes children except the last + let lastIndx = len(childNodesToDraw)-1 + if lastIndx > 0 + for i in childNodesToDraw[0:lastIndx-1] + let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0) + endfor + endif + + "draw the last child, indicating that it IS the last + let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1) + endif + endif + + return output +endfunction From 370f180ca0d24da5861b4b5c017567a9914ef8df Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 01:47:20 +0000 Subject: [PATCH 092/680] replace a script level var with a query --- autoload/nerdtree.vim | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b32edb27..9f4beb3c 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -7,9 +7,6 @@ function! nerdtree#version() return '4.2.0' endfunction -"the number to add to the nerd tree buffer name to make the buf name unique -let s:next_buffer_number = 1 - " SECTION: General Functions {{{1 "============================================================ "FUNCTION: nerdtree#bufInWindows(bnum){{{2 @@ -377,11 +374,22 @@ endfunction " FUNCTION: nerdtree#nextBufferName() {{{2 " returns the buffer name for the next nerd tree function! nerdtree#nextBufferName() - let name = nerdtree#bufNamePrefix() . s:next_buffer_number - let s:next_buffer_number += 1 + let name = nerdtree#bufNamePrefix() . nerdtree#nextBufferNumber() return name endfunction +" FUNCTION: nerdtree#nextBufferNumber() {{{2 +" the number to add to the nerd tree buffer name to make the buf name unique +function! nerdtree#nextBufferNumber() + if !exists("s:nextBufNum") + let s:nextBufNum = 1 + else + let s:nextBufNum += 1 + endif + + return s:nextBufNum +endfunction + " FUNCTION: nerdtree#postSourceActions() {{{2 function! nerdtree#postSourceActions() call g:NERDTreeBookmark.CacheBookmarks(0) From 8a984260e75f85869fcf897575f3950380410f92 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 01:48:13 +0000 Subject: [PATCH 093/680] manually apply #220 to fix NERDTreeFind for hidden dirs --- autoload/nerdtree.vim | 2 +- plugin/nerdtree/path.vim | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 9f4beb3c..fdc816d0 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -179,7 +179,7 @@ function! nerdtree#findAndRevealPath() return endtry - if p.isUnixHiddenFile() + if p.isUnixHiddenPath() let showhidden=g:NERDTreeShowHidden let g:NERDTreeShowHidden = 1 endif diff --git a/plugin/nerdtree/path.vim b/plugin/nerdtree/path.vim index 9ef0b28d..8c01339c 100644 --- a/plugin/nerdtree/path.vim +++ b/plugin/nerdtree/path.vim @@ -327,6 +327,21 @@ function! s:Path.isUnixHiddenFile() return self.getLastPathComponent(0) =~# '^\.' endfunction +"FUNCTION: Path.isUnixHiddenPath() {{{3 +"check for unix path with hidden components +function! s:Path.isUnixHiddenPath() + if self.getLastPathComponent(0) =~# '^\.' + return 1 + else + for segment in self.pathSegments + if segment =~# '^\.' + return 1 + endif + endfor + return 0 + endif +endfunction + "FUNCTION: Path.ignore() {{{3 "returns true if this path should be ignored function! s:Path.ignore() @@ -693,3 +708,4 @@ function! s:Path.WinToUnixPath(pathstr) return toReturn endfunction +" vim: set sw=4 sts=4 et fdm=marker: From cc0777b7921e2aaca670e9bed28e06c669dcef92 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 11:44:48 +0000 Subject: [PATCH 094/680] move KeyMap_Invoke into the autoload file This will keep the class file cleaner, and may also fix #223 --- autoload/nerdtree.vim | 7 +++++++ plugin/nerdtree/key_map.vim | 9 ++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index fdc816d0..f1d94a72 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -371,6 +371,13 @@ function! nerdtree#initNerdTreeMirror() endif endfunction +" FUNCTION: nerdtree#invokeKeyMap(key) {{{2 +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! nerdtree#invokeKeyMap(key) + call g:NERDTreeKeyMap.Invoke(a:key) +endfunction + " FUNCTION: nerdtree#nextBufferName() {{{2 " returns the buffer name for the next nerd tree function! nerdtree#nextBufferName() diff --git a/plugin/nerdtree/key_map.vim b/plugin/nerdtree/key_map.vim index d010c5a1..deecea81 100644 --- a/plugin/nerdtree/key_map.vim +++ b/plugin/nerdtree/key_map.vim @@ -43,7 +43,7 @@ function! s:KeyMap.bind() let premap = self.key == "" ? " " : " " - exec 'nnoremap '. self.key . premap . ':call KeyMap_Invoke("'. keymapInvokeString .'")' + exec 'nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{3 @@ -121,12 +121,6 @@ function! s:KeyMap.Invoke(key) endif endfunction -"this is needed since I cant figure out how to invoke dict functions from a -"key map -function! s:KeyMap_Invoke(key) - call s:KeyMap.Invoke(a:key) -endfunction - "FUNCTION: KeyMap.Create(options) {{{3 function! s:KeyMap.Create(options) let newKeyMap = copy(self) @@ -145,3 +139,4 @@ function! s:KeyMap.Add(keymap) call add(s:KeyMap.All(), a:keymap) endfunction +" vim: set sw=4 sts=4 et fdm=marker: From a7d5b3dbc137cf42f723622a5b726e5d5f9376f6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 11:57:48 +0000 Subject: [PATCH 095/680] fix the mapping It now acts the same as the ActivateNode mapping ('o' by default) again. This was broken in the big refactor. Fixes #222 --- autoload/nerdtree.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index f1d94a72..7622302e 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -1228,11 +1228,11 @@ endfunction "FUNCTION: nerdtree#bindMappings() {{{2 function! nerdtree#bindMappings() - "make do the same as the default 'o' mapping - exec "nnoremap :call KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')" - call g:NERDTreeKeyMap.BindAll() + "make do the same as the default 'o' mapping + exec "nnoremap :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')" + command! -buffer -nargs=? Bookmark :call bookmarkNode('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') From 2eff928e7ca9aab73ef3a8ec8f2ece1a8628d1d3 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jan 2013 12:30:07 +0000 Subject: [PATCH 096/680] some cosmetic updates to the class files * fix the fold markers (they were unnecessarily deep) * always have one line under each method * update some of the fold comments -> always use FUNCTION in all caps * add a modeline to each class file --- plugin/nerdtree/bookmark.vim | 76 ++++++++++++++-------- plugin/nerdtree/key_map.vim | 23 +++---- plugin/nerdtree/menu_controller.vim | 28 ++++---- plugin/nerdtree/menu_item.vim | 22 ++++--- plugin/nerdtree/opener.vim | 27 ++++---- plugin/nerdtree/path.vim | 99 ++++++++++++++++------------- plugin/nerdtree/tree_dir_node.vim | 85 +++++++++++++++---------- plugin/nerdtree/tree_file_node.vim | 76 +++++++++++++--------- 8 files changed, 254 insertions(+), 182 deletions(-) diff --git a/plugin/nerdtree/bookmark.vim b/plugin/nerdtree/bookmark.vim index 77a50235..603da53f 100644 --- a/plugin/nerdtree/bookmark.vim +++ b/plugin/nerdtree/bookmark.vim @@ -1,12 +1,14 @@ -"CLASS: Bookmark {{{2 +"CLASS: Bookmark "============================================================ let s:Bookmark = {} let g:NERDTreeBookmark = s:Bookmark -" FUNCTION: Bookmark.activate() {{{3 + +" FUNCTION: Bookmark.activate() {{{1 function! s:Bookmark.activate(...) call self.open(a:0 ? a:1 : {}) endfunction -" FUNCTION: Bookmark.AddBookmark(name, path) {{{3 + +" FUNCTION: Bookmark.AddBookmark(name, path) {{{1 " Class method to add a new bookmark to the list, if a previous bookmark exists " with the same name, just update the path for that bookmark function! s:Bookmark.AddBookmark(name, path) @@ -19,7 +21,8 @@ function! s:Bookmark.AddBookmark(name, path) call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) call s:Bookmark.Sort() endfunction -" Function: Bookmark.Bookmarks() {{{3 + +" FUNCTION: Bookmark.Bookmarks() {{{1 " Class method to get all bookmarks. Lazily initializes the bookmarks global " variable function! s:Bookmark.Bookmarks() @@ -28,7 +31,8 @@ function! s:Bookmark.Bookmarks() endif return g:NERDTreeBookmarks endfunction -" Function: Bookmark.BookmarkExistsFor(name) {{{3 + +" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1 " class method that returns 1 if a bookmark with the given name is found, 0 " otherwise function! s:Bookmark.BookmarkExistsFor(name) @@ -39,7 +43,8 @@ function! s:Bookmark.BookmarkExistsFor(name) return 0 endtry endfunction -" Function: Bookmark.BookmarkFor(name) {{{3 + +" FUNCTION: Bookmark.BookmarkFor(name) {{{1 " Class method to get the bookmark that has the given name. {} is return if no " bookmark is found function! s:Bookmark.BookmarkFor(name) @@ -50,7 +55,8 @@ function! s:Bookmark.BookmarkFor(name) endfor throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' endfunction -" Function: Bookmark.BookmarkNames() {{{3 + +" FUNCTION: Bookmark.BookmarkNames() {{{1 " Class method to return an array of all bookmark names function! s:Bookmark.BookmarkNames() let names = [] @@ -59,7 +65,8 @@ function! s:Bookmark.BookmarkNames() endfor return names endfunction -" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3 + +" FUNCTION: Bookmark.CacheBookmarks(silent) {{{1 " Class method to read all bookmarks from the bookmarks file intialize " bookmark objects for each one. " @@ -97,12 +104,13 @@ function! s:Bookmark.CacheBookmarks(silent) call s:Bookmark.Sort() endif endfunction -" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3 + +" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1 " Compare these two bookmarks for sorting purposes function! s:Bookmark.compareTo(otherbookmark) return a:otherbookmark.name < self.name endfunction -" FUNCTION: Bookmark.ClearAll() {{{3 +" FUNCTION: Bookmark.ClearAll() {{{1 " Class method to delete all bookmarks. function! s:Bookmark.ClearAll() for i in s:Bookmark.Bookmarks() @@ -110,7 +118,8 @@ function! s:Bookmark.ClearAll() endfor call s:Bookmark.Write() endfunction -" FUNCTION: Bookmark.delete() {{{3 + +" FUNCTION: Bookmark.delete() {{{1 " Delete this bookmark. If the node for this bookmark is under the current " root, then recache bookmarks for its Path object function! s:Bookmark.delete() @@ -125,7 +134,8 @@ function! s:Bookmark.delete() endif call s:Bookmark.Write() endfunction -" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3 + +" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1 " Gets the treenode for this bookmark " " Args: @@ -139,14 +149,16 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot) endif return targetNode endfunction -" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3 + +" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1 " Class method that finds the bookmark with the given name and returns the " treenode for it. function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) let bookmark = s:Bookmark.BookmarkFor(a:name) return bookmark.getNode(a:searchFromAbsoluteRoot) endfunction -" FUNCTION: Bookmark.GetSelected() {{{3 + +" FUNCTION: Bookmark.GetSelected() {{{1 " returns the Bookmark the cursor is over, or {} function! s:Bookmark.GetSelected() let line = getline(".") @@ -161,7 +173,7 @@ function! s:Bookmark.GetSelected() return {} endfunction -" Function: Bookmark.InvalidBookmarks() {{{3 +" FUNCTION: Bookmark.InvalidBookmarks() {{{1 " Class method to get all invalid bookmark strings read from the bookmarks " file function! s:Bookmark.InvalidBookmarks() @@ -170,7 +182,8 @@ function! s:Bookmark.InvalidBookmarks() endif return g:NERDTreeInvalidBookmarks endfunction -" FUNCTION: Bookmark.mustExist() {{{3 + +" FUNCTION: Bookmark.mustExist() {{{1 function! s:Bookmark.mustExist() if !self.path.exists() call s:Bookmark.CacheBookmarks(1) @@ -178,7 +191,8 @@ function! s:Bookmark.mustExist() \ self.name ."\" points to a non existing location: \"". self.path.str() endif endfunction -" FUNCTION: Bookmark.New(name, path) {{{3 + +" FUNCTION: Bookmark.New(name, path) {{{1 " Create a new bookmark object with the given name and path object function! s:Bookmark.New(name, path) if a:name =~# ' ' @@ -190,7 +204,8 @@ function! s:Bookmark.New(name, path) let newBookmark.path = a:path return newBookmark endfunction -" FUNCTION: Bookmark.open([options]) {{{3 + +" FUNCTION: Bookmark.open([options]) {{{1 "Args: "A dictionary containing the following keys (all optional): " 'where': Specifies whether the node should be opened in new split/tab or in @@ -210,24 +225,28 @@ function! s:Bookmark.open(...) call opener.open(self) endif endfunction -" FUNCTION: Bookmark.openInNewTab(options) {{{3 + +" FUNCTION: Bookmark.openInNewTab(options) {{{1 " Create a new bookmark object with the given name and path object function! s:Bookmark.openInNewTab(options) call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') call self.open(a:options) endfunction -" Function: Bookmark.setPath(path) {{{3 + +" FUNCTION: Bookmark.setPath(path) {{{1 " makes this bookmark point to the given path function! s:Bookmark.setPath(path) let self.path = a:path endfunction -" Function: Bookmark.Sort() {{{3 + +" FUNCTION: Bookmark.Sort() {{{1 " Class method that sorts all bookmarks function! s:Bookmark.Sort() let CompareFunc = function("nerdtree#compareBookmarks") call sort(s:Bookmark.Bookmarks(), CompareFunc) endfunction -" Function: Bookmark.str() {{{3 + +" FUNCTION: Bookmark.str() {{{1 " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name) @@ -241,7 +260,8 @@ function! s:Bookmark.str() endif return '>' . self.name . ' ' . pathStr endfunction -" FUNCTION: Bookmark.toRoot() {{{3 + +" FUNCTION: Bookmark.toRoot() {{{1 " Make the node for this bookmark the new tree root function! s:Bookmark.toRoot() if self.validate() @@ -255,15 +275,15 @@ function! s:Bookmark.toRoot() call targetNode.putCursorHere(0, 0) endif endfunction -" FUNCTION: Bookmark.ToRoot(name) {{{3 + +" FUNCTION: Bookmark.ToRoot(name) {{{1 " Make the node for this bookmark the new tree root function! s:Bookmark.ToRoot(name) let bookmark = s:Bookmark.BookmarkFor(a:name) call bookmark.toRoot() endfunction - -"FUNCTION: Bookmark.validate() {{{3 +" FUNCTION: Bookmark.validate() {{{1 function! s:Bookmark.validate() if self.path.exists() return 1 @@ -275,7 +295,7 @@ function! s:Bookmark.validate() endif endfunction -" Function: Bookmark.Write() {{{3 +" FUNCTION: Bookmark.Write() {{{1 " Class method to write all bookmarks to the bookmarks file function! s:Bookmark.Write() let bookmarkStrings = [] @@ -291,3 +311,5 @@ function! s:Bookmark.Write() endfor call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/key_map.vim b/plugin/nerdtree/key_map.vim index deecea81..86457652 100644 --- a/plugin/nerdtree/key_map.vim +++ b/plugin/nerdtree/key_map.vim @@ -1,8 +1,9 @@ -"CLASS: KeyMap {{{2 +"CLASS: KeyMap "============================================================ let s:KeyMap = {} let g:NERDTreeKeyMap = s:KeyMap -"FUNCTION: KeyMap.All() {{{3 + +"FUNCTION: KeyMap.All() {{{1 function! s:KeyMap.All() if !exists("s:keyMaps") let s:keyMaps = [] @@ -10,7 +11,7 @@ function! s:KeyMap.All() return s:keyMaps endfunction -"FUNCTION: KeyMap.FindFor(key, scope) {{{3 +"FUNCTION: KeyMap.FindFor(key, scope) {{{1 function! s:KeyMap.FindFor(key, scope) for i in s:KeyMap.All() if i.key ==# a:key && i.scope ==# a:scope @@ -20,14 +21,14 @@ function! s:KeyMap.FindFor(key, scope) return {} endfunction -"FUNCTION: KeyMap.BindAll() {{{3 +"FUNCTION: KeyMap.BindAll() {{{1 function! s:KeyMap.BindAll() for i in s:KeyMap.All() call i.bind() endfor endfunction -"FUNCTION: KeyMap.bind() {{{3 +"FUNCTION: KeyMap.bind() {{{1 function! s:KeyMap.bind() " If the key sequence we're trying to map contains any '<>' notation, we " must replace each of the '<' characters with '' to ensure the string @@ -46,7 +47,7 @@ function! s:KeyMap.bind() exec 'nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' endfunction -"FUNCTION: KeyMap.Remove(key, scope) {{{3 +"FUNCTION: KeyMap.Remove(key, scope) {{{1 function! s:KeyMap.Remove(key, scope) let maps = s:KeyMap.All() for i in range(len(maps)) @@ -55,7 +56,8 @@ function! s:KeyMap.Remove(key, scope) endif endfor endfunction -"FUNCTION: KeyMap.invoke() {{{3 + +"FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) let Callback = function(self.callback) @@ -66,8 +68,7 @@ function! s:KeyMap.invoke(...) endif endfunction - -"FUNCTION: KeyMap.Invoke() {{{3 +"FUNCTION: KeyMap.Invoke() {{{1 "Find a keymapping for a:key and the current scope invoke it. " "Scope is determined as follows: @@ -121,7 +122,7 @@ function! s:KeyMap.Invoke(key) endif endfunction -"FUNCTION: KeyMap.Create(options) {{{3 +"FUNCTION: KeyMap.Create(options) {{{1 function! s:KeyMap.Create(options) let newKeyMap = copy(self) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) @@ -133,7 +134,7 @@ function! s:KeyMap.Create(options) call s:KeyMap.Add(newKeyMap) endfunction -"FUNCTION: KeyMap.Add(keymap) {{{3 +"FUNCTION: KeyMap.Add(keymap) {{{1 function! s:KeyMap.Add(keymap) call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) call add(s:KeyMap.All(), a:keymap) diff --git a/plugin/nerdtree/menu_controller.vim b/plugin/nerdtree/menu_controller.vim index a7bfb959..ae0ee848 100644 --- a/plugin/nerdtree/menu_controller.vim +++ b/plugin/nerdtree/menu_controller.vim @@ -1,8 +1,9 @@ -"CLASS: MenuController {{{2 +"CLASS: MenuController "============================================================ let s:MenuController = {} let g:NERDTreeMenuController = s:MenuController -"FUNCTION: MenuController.New(menuItems) {{{3 + +"FUNCTION: MenuController.New(menuItems) {{{1 "create a new menu controller that operates on the given menu items function! s:MenuController.New(menuItems) let newMenuController = copy(self) @@ -14,7 +15,7 @@ function! s:MenuController.New(menuItems) return newMenuController endfunction -"FUNCTION: MenuController.showMenu() {{{3 +"FUNCTION: MenuController.showMenu() {{{1 "start the main loop of the menu and get the user to choose/execute a menu "item function! s:MenuController.showMenu() @@ -40,7 +41,7 @@ function! s:MenuController.showMenu() endif endfunction -"FUNCTION: MenuController._echoPrompt() {{{3 +"FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" echo "==========================================================" @@ -54,13 +55,13 @@ function! s:MenuController._echoPrompt() endfor endfunction -"FUNCTION: MenuController._current(key) {{{3 +"FUNCTION: MenuController._current(key) {{{1 "get the MenuItem that is currently selected function! s:MenuController._current() return self.menuItems[self.selection] endfunction -"FUNCTION: MenuController._handleKeypress(key) {{{3 +"FUNCTION: MenuController._handleKeypress(key) {{{1 "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) @@ -86,7 +87,7 @@ function! s:MenuController._handleKeypress(key) return 0 endfunction -"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3 +"FUNCTION: MenuController._allIndexesFor(shortcut) {{{1 "get indexes to all menu items with the given shortcut function! s:MenuController._allIndexesFor(shortcut) let toReturn = [] @@ -100,7 +101,7 @@ function! s:MenuController._allIndexesFor(shortcut) return toReturn endfunction -"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3 +"FUNCTION: MenuController._nextIndexFor(shortcut) {{{1 "get the index to the next menu item with the given shortcut, starts from the "current cursor location and wraps around to the top again if need be function! s:MenuController._nextIndexFor(shortcut) @@ -119,13 +120,13 @@ function! s:MenuController._nextIndexFor(shortcut) return -1 endfunction -"FUNCTION: MenuController._setCmdheight() {{{3 +"FUNCTION: MenuController._setCmdheight() {{{1 "sets &cmdheight to whatever is needed to display the menu function! s:MenuController._setCmdheight() let &cmdheight = len(self.menuItems) + 3 endfunction -"FUNCTION: MenuController._saveOptions() {{{3 +"FUNCTION: MenuController._saveOptions() {{{1 "set any vim options that are required to make the menu work (saving their old "values) function! s:MenuController._saveOptions() @@ -135,14 +136,14 @@ function! s:MenuController._saveOptions() call self._setCmdheight() endfunction -"FUNCTION: MenuController._restoreOptions() {{{3 +"FUNCTION: MenuController._restoreOptions() {{{1 "restore the options we saved in _saveOptions() function! s:MenuController._restoreOptions() let &cmdheight = self._oldCmdheight let &lazyredraw = self._oldLazyredraw endfunction -"FUNCTION: MenuController._cursorDown() {{{3 +"FUNCTION: MenuController._cursorDown() {{{1 "move the cursor to the next menu item, skipping separators function! s:MenuController._cursorDown() let done = 0 @@ -159,7 +160,7 @@ function! s:MenuController._cursorDown() endwhile endfunction -"FUNCTION: MenuController._cursorUp() {{{3 +"FUNCTION: MenuController._cursorUp() {{{1 "move the cursor to the previous menu item, skipping separators function! s:MenuController._cursorUp() let done = 0 @@ -176,3 +177,4 @@ function! s:MenuController._cursorUp() endwhile endfunction +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/menu_item.vim b/plugin/nerdtree/menu_item.vim index 234bdede..6fb9d9e3 100644 --- a/plugin/nerdtree/menu_item.vim +++ b/plugin/nerdtree/menu_item.vim @@ -1,8 +1,9 @@ -"CLASS: MenuItem {{{2 +"CLASS: MenuItem "============================================================ let s:MenuItem = {} let g:NERDTreeMenuItem = s:MenuItem -"FUNCTION: MenuItem.All() {{{3 + +"FUNCTION: MenuItem.All() {{{1 "get all top level menu items function! s:MenuItem.All() if !exists("s:menuItems") @@ -11,7 +12,7 @@ function! s:MenuItem.All() return s:menuItems endfunction -"FUNCTION: MenuItem.AllEnabled() {{{3 +"FUNCTION: MenuItem.AllEnabled() {{{1 "get all top level menu items that are currently enabled function! s:MenuItem.AllEnabled() let toReturn = [] @@ -23,7 +24,7 @@ function! s:MenuItem.AllEnabled() return toReturn endfunction -"FUNCTION: MenuItem.Create(options) {{{3 +"FUNCTION: MenuItem.Create(options) {{{1 "make a new menu item and add it to the global list function! s:MenuItem.Create(options) let newMenuItem = copy(self) @@ -51,7 +52,7 @@ function! s:MenuItem.Create(options) return newMenuItem endfunction -"FUNCTION: MenuItem.CreateSeparator(options) {{{3 +"FUNCTION: MenuItem.CreateSeparator(options) {{{1 "make a new separator menu item and add it to the global list function! s:MenuItem.CreateSeparator(options) let standard_options = { 'text': '--------------------', @@ -62,7 +63,7 @@ function! s:MenuItem.CreateSeparator(options) return s:MenuItem.Create(options) endfunction -"FUNCTION: MenuItem.CreateSubmenu(options) {{{3 +"FUNCTION: MenuItem.CreateSubmenu(options) {{{1 "make a new submenu and add it to global list function! s:MenuItem.CreateSubmenu(options) let standard_options = { 'callback': -1 } @@ -71,7 +72,7 @@ function! s:MenuItem.CreateSubmenu(options) return s:MenuItem.Create(options) endfunction -"FUNCTION: MenuItem.enabled() {{{3 +"FUNCTION: MenuItem.enabled() {{{1 "return 1 if this menu item should be displayed " "delegates off to the isActiveCallback, and defaults to 1 if no callback was @@ -83,7 +84,7 @@ function! s:MenuItem.enabled() return 1 endfunction -"FUNCTION: MenuItem.execute() {{{3 +"FUNCTION: MenuItem.execute() {{{1 "perform the action behind this menu item, if this menuitem has children then "display a new menu for them, otherwise deletegate off to the menuitem's "callback @@ -98,15 +99,16 @@ function! s:MenuItem.execute() endif endfunction -"FUNCTION: MenuItem.isSeparator() {{{3 +"FUNCTION: MenuItem.isSeparator() {{{1 "return 1 if this menuitem is a separator function! s:MenuItem.isSeparator() return self.callback == -1 && self.children == [] endfunction -"FUNCTION: MenuItem.isSubmenu() {{{3 +"FUNCTION: MenuItem.isSubmenu() {{{1 "return 1 if this menuitem is a submenu function! s:MenuItem.isSubmenu() return self.callback == -1 && !empty(self.children) endfunction +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/opener.vim b/plugin/nerdtree/opener.vim index df8978f2..947d5e16 100644 --- a/plugin/nerdtree/opener.vim +++ b/plugin/nerdtree/opener.vim @@ -1,9 +1,9 @@ -"CLASS: Opener {{{2 +"CLASS: Opener "============================================================ let s:Opener = {} let g:NERDTreeOpener = s:Opener -"FUNCTION: Opener._checkToCloseTree(newtab) {{{3 +"FUNCTION: Opener._checkToCloseTree(newtab) {{{1 "Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see "if the tree should be closed now. " @@ -21,7 +21,7 @@ function! s:Opener._checkToCloseTree(newtab) endif endfunction -"FUNCTION: Opener._gotoTargetWin() {{{3 +"FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTreeType ==# "secondary" if self._where == 'v' @@ -48,7 +48,7 @@ function! s:Opener._gotoTargetWin() endif endfunction -"FUNCTION: Opener.New(path, opts) {{{3 +"FUNCTION: Opener.New(path, opts) {{{1 "Args: " "a:path: The path object that is to be opened. @@ -76,7 +76,7 @@ function! s:Opener.New(path, opts) return newObj endfunction -"FUNCTION: Opener._newSplit() {{{3 +"FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() " Save the user's settings for splitbelow and splitright let savesplitbelow=&splitbelow @@ -136,7 +136,7 @@ function! s:Opener._newSplit() let &splitright=savesplitright endfunction -"FUNCTION: Opener._newVSplit() {{{3 +"FUNCTION: Opener._newVSplit() {{{1 function! s:Opener._newVSplit() let winwidth = winwidth(".") if winnr("$")==#1 @@ -152,7 +152,7 @@ function! s:Opener._newVSplit() call nerdtree#exec('wincmd p') endfunction -"FUNCTION: Opener.open(target) {{{3 +"FUNCTION: Opener.open(target) {{{1 function! s:Opener.open(target) if self._path.isDirectory call self._openDirectory(a:target) @@ -161,7 +161,7 @@ function! s:Opener.open(target) endif endfunction -"FUNCTION: Opener._openFile() {{{3 +"FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() if self._reuse && self._reuseWindow() return @@ -181,7 +181,7 @@ function! s:Opener._openFile() endif endfunction -"FUNCTION: Opener._openDirectory(node) {{{3 +"FUNCTION: Opener._openDirectory(node) {{{1 function! s:Opener._openDirectory(node) if self._treetype ==# "secondary" call self._gotoTargetWin() @@ -204,7 +204,7 @@ function! s:Opener._openDirectory(node) endif endfunction -"FUNCTION: Opener._previousWindow() {{{3 +"FUNCTION: Opener._previousWindow() {{{1 function! s:Opener._previousWindow() if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1 call self._newSplit() @@ -224,13 +224,13 @@ function! s:Opener._previousWindow() endif endfunction -"FUNCTION: Opener._restoreCursorPos(){{{3 +"FUNCTION: Opener._restoreCursorPos(){{{1 function! s:Opener._restoreCursorPos() call nerdtree#exec('normal ' . self._tabnr . 'gt') call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') endfunction -"FUNCTION: Opener._reuseWindow(){{{3 +"FUNCTION: Opener._reuseWindow(){{{1 "put the cursor in the first window we find for this file " "return 1 if we were successful @@ -255,9 +255,10 @@ function! s:Opener._reuseWindow() return 0 endfunction -"FUNCTION: Opener._saveCursorPos(){{{3 +"FUNCTION: Opener._saveCursorPos(){{{1 function! s:Opener._saveCursorPos() let self._bufnr = bufnr("") let self._tabnr = tabpagenr() endfunction +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/path.vim b/plugin/nerdtree/path.vim index 8c01339c..68d50215 100644 --- a/plugin/nerdtree/path.vim +++ b/plugin/nerdtree/path.vim @@ -2,11 +2,12 @@ "once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') -"CLASS: Path {{{2 +"CLASS: Path "============================================================ let s:Path = {} let g:NERDTreePath = s:Path -"FUNCTION: Path.AbsolutePathFor(str) {{{3 + +"FUNCTION: Path.AbsolutePathFor(str) {{{1 function! s:Path.AbsolutePathFor(str) let prependCWD = 0 if nerdtree#runningWindows() @@ -22,14 +23,16 @@ function! s:Path.AbsolutePathFor(str) return toReturn endfunction -"FUNCTION: Path.bookmarkNames() {{{3 + +"FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() if !exists("self._bookmarkNames") call self.cacheDisplayString() endif return self._bookmarkNames endfunction -"FUNCTION: Path.cacheDisplayString() {{{3 + +"FUNCTION: Path.cacheDisplayString() {{{1 function! s:Path.cacheDisplayString() let self.cachedDisplayString = self.getLastPathComponent(1) @@ -55,7 +58,8 @@ function! s:Path.cacheDisplayString() let self.cachedDisplayString .= ' [RO]' endif endfunction -"FUNCTION: Path.changeToDir() {{{3 + +"FUNCTION: Path.changeToDir() {{{1 function! s:Path.changeToDir() let dir = self.str({'format': 'Cd'}) if self.isDirectory ==# 0 @@ -70,7 +74,7 @@ function! s:Path.changeToDir() endtry endfunction -"FUNCTION: Path.compareTo() {{{3 +"FUNCTION: Path.compareTo() {{{1 " "Compares this Path to the given path and returns 0 if they are equal, -1 if "this Path is "less than" the given path, or 1 if it is "greater". @@ -110,7 +114,7 @@ function! s:Path.compareTo(path) endif endfunction -"FUNCTION: Path.Create(fullpath) {{{3 +"FUNCTION: Path.Create(fullpath) {{{1 " "Factory method. " @@ -146,7 +150,7 @@ function! s:Path.Create(fullpath) return s:Path.New(a:fullpath) endfunction -"FUNCTION: Path.copy(dest) {{{3 +"FUNCTION: Path.copy(dest) {{{1 " "Copies the file/dir represented by this Path to the given location " @@ -166,15 +170,14 @@ function! s:Path.copy(dest) endif endfunction -"FUNCTION: Path.CopyingSupported() {{{3 +"FUNCTION: Path.CopyingSupported() {{{1 " "returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() return exists('g:NERDTreeCopyCmd') endfunction - -"FUNCTION: Path.copyingWillOverwrite(dest) {{{3 +"FUNCTION: Path.copyingWillOverwrite(dest) {{{1 " "returns 1 if copy this path to the given location will cause files to "overwritten @@ -194,7 +197,7 @@ function! s:Path.copyingWillOverwrite(dest) endif endfunction -"FUNCTION: Path.delete() {{{3 +"FUNCTION: Path.delete() {{{1 " "Deletes the file represented by this path. "Deletion of directories is not supported @@ -223,7 +226,7 @@ function! s:Path.delete() endfor endfunction -"FUNCTION: Path.displayString() {{{3 +"FUNCTION: Path.displayString() {{{1 " "Returns a string that specifies how the path should be represented as a "string @@ -234,11 +237,13 @@ function! s:Path.displayString() return self.cachedDisplayString endfunction -"FUNCTION: Path.edit() {{{3 + +"FUNCTION: Path.edit() {{{1 function! s:Path.edit() exec "edit " . self.str({'format': 'Edit'}) endfunction -"FUNCTION: Path.extractDriveLetter(fullpath) {{{3 + +"FUNCTION: Path.extractDriveLetter(fullpath) {{{1 " "If running windows, cache the drive letter for this path function! s:Path.extractDriveLetter(fullpath) @@ -255,13 +260,15 @@ function! s:Path.extractDriveLetter(fullpath) endif endfunction -"FUNCTION: Path.exists() {{{3 + +"FUNCTION: Path.exists() {{{1 "return 1 if this path points to a location that is readable or is a directory function! s:Path.exists() let p = self.str() return filereadable(p) || isdirectory(p) endfunction -"FUNCTION: Path.getDir() {{{3 + +"FUNCTION: Path.getDir() {{{1 " "Returns this path if it is a directory, else this paths parent. " @@ -274,7 +281,8 @@ function! s:Path.getDir() return self.getParent() endif endfunction -"FUNCTION: Path.getParent() {{{3 + +"FUNCTION: Path.getParent() {{{1 " "Returns a new path object for this paths parent " @@ -289,7 +297,8 @@ function! s:Path.getParent() return s:Path.New(path) endfunction -"FUNCTION: Path.getLastPathComponent(dirSlash) {{{3 + +"FUNCTION: Path.getLastPathComponent(dirSlash) {{{1 " "Gets the last part of this path. " @@ -307,7 +316,7 @@ function! s:Path.getLastPathComponent(dirSlash) return toReturn endfunction -"FUNCTION: Path.getSortOrderIndex() {{{3 +"FUNCTION: Path.getSortOrderIndex() {{{1 "returns the index of the pattern in g:NERDTreeSortOrder that this path matches function! s:Path.getSortOrderIndex() let i = 0 @@ -320,14 +329,13 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction - -"FUNCTION: Path.isUnixHiddenFile() {{{3 +"FUNCTION: Path.isUnixHiddenFile() {{{1 "check for unix hidden files function! s:Path.isUnixHiddenFile() return self.getLastPathComponent(0) =~# '^\.' endfunction -"FUNCTION: Path.isUnixHiddenPath() {{{3 +"FUNCTION: Path.isUnixHiddenPath() {{{1 "check for unix path with hidden components function! s:Path.isUnixHiddenPath() if self.getLastPathComponent(0) =~# '^\.' @@ -342,7 +350,7 @@ function! s:Path.isUnixHiddenPath() endif endfunction -"FUNCTION: Path.ignore() {{{3 +"FUNCTION: Path.ignore() {{{1 "returns true if this path should be ignored function! s:Path.ignore() "filter out the user specified paths to ignore @@ -370,7 +378,7 @@ function! s:Path.ignore() return 0 endfunction -"FUNCTION: Path._ignorePatternMatches(pattern) {{{3 +"FUNCTION: Path._ignorePatternMatches(pattern) {{{1 "returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern @@ -388,7 +396,8 @@ function! s:Path._ignorePatternMatches(pattern) return self.getLastPathComponent(0) =~# pat endfunction -"FUNCTION: Path.isUnder(path) {{{3 + +"FUNCTION: Path.isUnder(path) {{{1 "return 1 if this path is somewhere under the given path in the filesystem. " "a:path should be a dir @@ -402,7 +411,7 @@ function! s:Path.isUnder(path) return stridx(this, that . s:Path.Slash()) == 0 endfunction -"FUNCTION: Path.JoinPathStrings(...) {{{3 +"FUNCTION: Path.JoinPathStrings(...) {{{1 function! s:Path.JoinPathStrings(...) let components = [] for i in a:000 @@ -411,7 +420,7 @@ function! s:Path.JoinPathStrings(...) return '/' . join(components, '/') endfunction -"FUNCTION: Path.equals() {{{3 +"FUNCTION: Path.equals() {{{1 " "Determines whether 2 path objects are "equal". "They are equal if the paths they represent are the same @@ -422,7 +431,7 @@ function! s:Path.equals(path) return self.str() ==# a:path.str() endfunction -"FUNCTION: Path.New() {{{3 +"FUNCTION: Path.New() {{{1 "The Constructor for the Path object function! s:Path.New(path) let newPath = copy(self) @@ -434,13 +443,13 @@ function! s:Path.New(path) return newPath endfunction -"FUNCTION: Path.Slash() {{{3 +"FUNCTION: Path.Slash() {{{1 "return the slash to use for the current OS function! s:Path.Slash() return nerdtree#runningWindows() ? '\' : '/' endfunction -"FUNCTION: Path.Resolve() {{{3 +"FUNCTION: Path.Resolve() {{{1 "Invoke the vim resolve() function and return the result "This is necessary because in some versions of vim resolve() removes trailing "slashes while in other versions it doesn't. This always removes the trailing @@ -450,7 +459,7 @@ function! s:Path.Resolve(path) return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp endfunction -"FUNCTION: Path.readInfoFromDisk(fullpath) {{{3 +"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 " " "Throws NERDTree.Path.InvalidArguments exception. @@ -504,13 +513,13 @@ function! s:Path.readInfoFromDisk(fullpath) endif endfunction -"FUNCTION: Path.refresh() {{{3 +"FUNCTION: Path.refresh() {{{1 function! s:Path.refresh() call self.readInfoFromDisk(self.str()) call self.cacheDisplayString() endfunction -"FUNCTION: Path.rename() {{{3 +"FUNCTION: Path.rename() {{{1 " "Renames this node on the filesystem function! s:Path.rename(newPath) @@ -531,7 +540,7 @@ function! s:Path.rename(newPath) call g:NERDTreeBookmark.Write() endfunction -"FUNCTION: Path.str() {{{3 +"FUNCTION: Path.str() {{{1 " "Returns a string representation of this Path " @@ -582,7 +591,7 @@ function! s:Path.str(...) return toReturn endfunction -"FUNCTION: Path._strForUI() {{{3 +"FUNCTION: Path._strForUI() {{{1 function! s:Path._strForUI() let toReturn = '/' . join(self.pathSegments, '/') if self.isDirectory && toReturn != '/' @@ -591,13 +600,14 @@ function! s:Path._strForUI() return toReturn endfunction -"FUNCTION: Path._strForCd() {{{3 +"FUNCTION: Path._strForCd() {{{1 " " returns a string that can be used with :cd function! s:Path._strForCd() return escape(self.str(), nerdtree#escChars()) endfunction -"FUNCTION: Path._strForEdit() {{{3 + +"FUNCTION: Path._strForEdit() {{{1 " "Return: the string for this path that is suitable to be used with the :edit "command @@ -629,7 +639,8 @@ function! s:Path._strForEdit() return p endfunction -"FUNCTION: Path._strForGlob() {{{3 + +"FUNCTION: Path._strForGlob() {{{1 function! s:Path._strForGlob() let lead = s:Path.Slash() @@ -645,7 +656,8 @@ function! s:Path._strForGlob() endif return toReturn endfunction -"FUNCTION: Path._str() {{{3 + +"FUNCTION: Path._str() {{{1 " "Gets the string path for this path object that is appropriate for the OS. "EG, in windows c:\foo\bar @@ -661,13 +673,13 @@ function! s:Path._str() return lead . join(self.pathSegments, s:Path.Slash()) endfunction -"FUNCTION: Path.strTrunk() {{{3 +"FUNCTION: Path.strTrunk() {{{1 "Gets the path without the last segment on the end. function! s:Path.strTrunk() return self.drive . '/' . join(self.pathSegments[0:-2], '/') endfunction -" FUNCTION: Path.tabnr() {{{3 +" FUNCTION: Path.tabnr() {{{1 " return the number of the first tab that is displaying this file " " return 0 if no tab was found @@ -682,7 +694,8 @@ function! s:Path.tabnr() endfor return 0 endfunction -"FUNCTION: Path.WinToUnixPath(pathstr){{{3 + +"FUNCTION: Path.WinToUnixPath(pathstr){{{1 "Takes in a windows path and returns the unix equiv " "A class level method diff --git a/plugin/nerdtree/tree_dir_node.vim b/plugin/nerdtree/tree_dir_node.vim index 85688bec..25f10349 100644 --- a/plugin/nerdtree/tree_dir_node.vim +++ b/plugin/nerdtree/tree_dir_node.vim @@ -1,11 +1,12 @@ -"CLASS: TreeDirNode {{{2 -"This class is a child of the TreeFileNode class and constitutes the -"'Composite' part of the composite design pattern between the treenode -"classes. +"CLASS: TreeDirNode +"A subclass of NERDTreeFileNode. +" +"The 'composite' part of the file/dir composite. "============================================================ let s:TreeDirNode = copy(g:NERDTreeFileNode) let g:NERDTreeDirNode = s:TreeDirNode -"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3 + +"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1 "class method that returns the highest cached ancestor of the current root function! s:TreeDirNode.AbsoluteTreeRoot() let currentNode = b:NERDTreeRoot @@ -14,7 +15,8 @@ function! s:TreeDirNode.AbsoluteTreeRoot() endwhile return currentNode endfunction -"FUNCTION: TreeDirNode.activate([options]) {{{3 + +"FUNCTION: TreeDirNode.activate([options]) {{{1 unlet s:TreeDirNode.activate function! s:TreeDirNode.activate(...) let opts = a:0 ? a:1 : {} @@ -22,7 +24,8 @@ function! s:TreeDirNode.activate(...) call nerdtree#renderView() call self.putCursorHere(0, 0) endfunction -"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3 + +"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1 "Adds the given treenode to the list of children for this node " "Args: @@ -37,13 +40,13 @@ function! s:TreeDirNode.addChild(treenode, inOrder) endif endfunction -"FUNCTION: TreeDirNode.close() {{{3 +"FUNCTION: TreeDirNode.close() {{{1 "Closes this directory function! s:TreeDirNode.close() let self.isOpen = 0 endfunction -"FUNCTION: TreeDirNode.closeChildren() {{{3 +"FUNCTION: TreeDirNode.closeChildren() {{{1 "Closes all the child dir nodes of this node function! s:TreeDirNode.closeChildren() for i in self.children @@ -54,7 +57,7 @@ function! s:TreeDirNode.closeChildren() endfor endfunction -"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3 +"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1 "Instantiates a new child node for this node with the given path. The new "nodes parent is set to this node. " @@ -70,7 +73,7 @@ function! s:TreeDirNode.createChild(path, inOrder) return newTreeNode endfunction -"FUNCTION: TreeDirNode.findNode(path) {{{3 +"FUNCTION: TreeDirNode.findNode(path) {{{1 "Will find one of the children (recursively) that has the given path " "Args: @@ -94,13 +97,14 @@ function! s:TreeDirNode.findNode(path) endif return {} endfunction -"FUNCTION: TreeDirNode.getChildCount() {{{3 + +"FUNCTION: TreeDirNode.getChildCount() {{{1 "Returns the number of children this node has function! s:TreeDirNode.getChildCount() return len(self.children) endfunction -"FUNCTION: TreeDirNode.getChild(path) {{{3 +"FUNCTION: TreeDirNode.getChild(path) {{{1 "Returns child node of this node that has the given path or {} if no such node "exists. " @@ -122,7 +126,7 @@ function! s:TreeDirNode.getChild(path) endfunction -"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3 +"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1 "returns the child at the given index "Args: "indx: the index to get the child from @@ -136,7 +140,7 @@ function! s:TreeDirNode.getChildByIndex(indx, visible) return array_to_search[a:indx] endfunction -"FUNCTION: TreeDirNode.getChildIndex(path) {{{3 +"FUNCTION: TreeDirNode.getChildIndex(path) {{{1 "Returns the index of the child node of this node that has the given path or "-1 if no such node exists. " @@ -167,7 +171,7 @@ function! s:TreeDirNode.getChildIndex(path) return -1 endfunction -"FUNCTION: TreeDirNode.GetSelected() {{{3 +"FUNCTION: TreeDirNode.GetSelected() {{{1 "Returns the current node if it is a dir node, or else returns the current "nodes parent unlet s:TreeDirNode.GetSelected @@ -180,13 +184,14 @@ function! s:TreeDirNode.GetSelected() endif return currentDir endfunction -"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3 + +"FUNCTION: TreeDirNode.getVisibleChildCount() {{{1 "Returns the number of visible children this node has function! s:TreeDirNode.getVisibleChildCount() return len(self.getVisibleChildren()) endfunction -"FUNCTION: TreeDirNode.getVisibleChildren() {{{3 +"FUNCTION: TreeDirNode.getVisibleChildren() {{{1 "Returns a list of children to display for this node, in the correct order " "Return: @@ -201,13 +206,13 @@ function! s:TreeDirNode.getVisibleChildren() return toReturn endfunction -"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3 +"FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 "returns 1 if this node has any childre, 0 otherwise.. function! s:TreeDirNode.hasVisibleChildren() return self.getVisibleChildCount() != 0 endfunction -"FUNCTION: TreeDirNode._initChildren() {{{3 +"FUNCTION: TreeDirNode._initChildren() {{{1 "Removes all childen from this node and re-reads them " "Args: @@ -264,7 +269,8 @@ function! s:TreeDirNode._initChildren(silent) endif return self.getChildCount() endfunction -"FUNCTION: TreeDirNode.New(path) {{{3 + +"FUNCTION: TreeDirNode.New(path) {{{1 "Returns a new TreeNode object with the given path and parent " "Args: @@ -285,7 +291,8 @@ function! s:TreeDirNode.New(path) return newTreeNode endfunction -"FUNCTION: TreeDirNode.open([opts]) {{{3 + +"FUNCTION: TreeDirNode.open([opts]) {{{1 "Open the dir in the current tree or in a new tree elsewhere. " "If opening in the current tree, return the number of cached nodes. @@ -305,7 +312,8 @@ function! s:TreeDirNode.open(...) endif endif endfunction -"FUNCTION: TreeDirNode.openAlong([opts]) {{{3 + +"FUNCTION: TreeDirNode.openAlong([opts]) {{{1 "recursive open the dir if it has only one directory child. " "return the level of opened directories. @@ -325,24 +333,28 @@ function! s:TreeDirNode.openAlong(...) endwhile return level endfunction -" FUNCTION: TreeDirNode.openExplorer() {{{3 + +" FUNCTION: TreeDirNode.openExplorer() {{{1 " opens an explorer window for this node in the previous window (could be a " nerd tree or a netrw) function! s:TreeDirNode.openExplorer() call self.open({'where': 'p'}) endfunction -"FUNCTION: TreeDirNode.openInNewTab(options) {{{3 + +"FUNCTION: TreeDirNode.openInNewTab(options) {{{1 unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') call self.open({'where': 't'}) endfunction -"FUNCTION: TreeDirNode._openInNewTab() {{{3 + +"FUNCTION: TreeDirNode._openInNewTab() {{{1 function! s:TreeDirNode._openInNewTab() tabnew call nerdtree#initNerdTree(self.path.str()) endfunction -"FUNCTION: TreeDirNode.openRecursively() {{{3 + +"FUNCTION: TreeDirNode.openRecursively() {{{1 "Opens this treenode and all of its children whose paths arent 'ignored' "because of the file filters. " @@ -352,7 +364,7 @@ function! s:TreeDirNode.openRecursively() call self._openRecursively2(1) endfunction -"FUNCTION: TreeDirNode._openRecursively2() {{{3 +"FUNCTION: TreeDirNode._openRecursively2() {{{1 "Opens this all children of this treenode recursively if either: " *they arent filtered by file filters " *a:forceOpen is 1 @@ -374,7 +386,7 @@ function! s:TreeDirNode._openRecursively2(forceOpen) endif endfunction -"FUNCTION: TreeDirNode.refresh() {{{3 +"FUNCTION: TreeDirNode.refresh() {{{1 unlet s:TreeDirNode.refresh function! s:TreeDirNode.refresh() call self.path.refresh() @@ -426,7 +438,7 @@ function! s:TreeDirNode.refresh() endif endfunction -"FUNCTION: TreeDirNode.reveal(path) {{{3 +"FUNCTION: TreeDirNode.reveal(path) {{{1 "reveal the given path, i.e. cache and open all treenodes needed to display it "in the UI function! s:TreeDirNode.reveal(path) @@ -451,7 +463,8 @@ function! s:TreeDirNode.reveal(path) let n = self.findNode(p) call n.reveal(a:path) endfunction -"FUNCTION: TreeDirNode.removeChild(treenode) {{{3 + +"FUNCTION: TreeDirNode.removeChild(treenode) {{{1 " "Removes the given treenode from this nodes set of children " @@ -470,7 +483,7 @@ function! s:TreeDirNode.removeChild(treenode) throw "NERDTree.ChildNotFoundError: child node was not found" endfunction -"FUNCTION: TreeDirNode.sortChildren() {{{3 +"FUNCTION: TreeDirNode.sortChildren() {{{1 " "Sorts the children of this node according to alphabetical order and the "directory priority. @@ -480,7 +493,7 @@ function! s:TreeDirNode.sortChildren() call sort(self.children, CompareFunc) endfunction -"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3 +"FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 "Opens this directory if it is closed and vice versa function! s:TreeDirNode.toggleOpen(...) let opts = a:0 ? a:1 : {} @@ -494,7 +507,8 @@ function! s:TreeDirNode.toggleOpen(...) endif endif endfunction -"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3 + +"FUNCTION: TreeDirNode.transplantChild(newNode) {{{1 "Replaces the child of this with the given node (where the child node's full "path matches a:newNode's fullpath). The search for the matching node is "non-recursive @@ -510,4 +524,5 @@ function! s:TreeDirNode.transplantChild(newNode) endif endfor endfunction -"============================================================ + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/tree_file_node.vim b/plugin/nerdtree/tree_file_node.vim index 2cecedfa..6b5246f9 100644 --- a/plugin/nerdtree/tree_file_node.vim +++ b/plugin/nerdtree/tree_file_node.vim @@ -1,15 +1,17 @@ -"CLASS: TreeFileNode {{{2 -"This class is the parent of the TreeDirNode class and constitures the +"CLASS: TreeFileNode +"This class is the parent of the TreeDirNode class and is the "'Component' part of the composite design pattern between the treenode "classes. "============================================================ let s:TreeFileNode = {} let g:NERDTreeFileNode = s:TreeFileNode -"FUNCTION: TreeFileNode.activate(...) {{{3 + +"FUNCTION: TreeFileNode.activate(...) {{{1 function! s:TreeFileNode.activate(...) call self.open(a:0 ? a:1 : {}) endfunction -"FUNCTION: TreeFileNode.bookmark(name) {{{3 + +"FUNCTION: TreeFileNode.bookmark(name) {{{1 "bookmark this node with a:name function! s:TreeFileNode.bookmark(name) @@ -30,7 +32,8 @@ function! s:TreeFileNode.bookmark(name) call oldMarkedNode.path.cacheDisplayString() endif endfunction -"FUNCTION: TreeFileNode.cacheParent() {{{3 + +"FUNCTION: TreeFileNode.cacheParent() {{{1 "initializes self.parent if it isnt already function! s:TreeFileNode.cacheParent() if empty(self.parent) @@ -42,7 +45,7 @@ function! s:TreeFileNode.cacheParent() endif endfunction -"FUNCTION: TreeFileNode.clearBookmarks() {{{3 +"FUNCTION: TreeFileNode.clearBookmarks() {{{1 function! s:TreeFileNode.clearBookmarks() for i in g:NERDTreeBookmark.Bookmarks() if i.path.equals(self.path) @@ -51,7 +54,8 @@ function! s:TreeFileNode.clearBookmarks() endfor call self.path.cacheDisplayString() endfunction -"FUNCTION: TreeFileNode.copy(dest) {{{3 + +"FUNCTION: TreeFileNode.copy(dest) {{{1 function! s:TreeFileNode.copy(dest) call self.path.copy(a:dest) let newPath = s:NERDTreePath.New(a:dest) @@ -64,14 +68,14 @@ function! s:TreeFileNode.copy(dest) endif endfunction -"FUNCTION: TreeFileNode.delete {{{3 +"FUNCTION: TreeFileNode.delete {{{1 "Removes this node from the tree and calls the Delete method for its path obj function! s:TreeFileNode.delete() call self.path.delete() call self.parent.removeChild(self) endfunction -"FUNCTION: TreeFileNode.displayString() {{{3 +"FUNCTION: TreeFileNode.displayString() {{{1 " "Returns a string that specifies how the node should be represented as a "string @@ -82,7 +86,7 @@ function! s:TreeFileNode.displayString() return self.path.displayString() endfunction -"FUNCTION: TreeFileNode.equals(treenode) {{{3 +"FUNCTION: TreeFileNode.equals(treenode) {{{1 " "Compares this treenode to the input treenode and returns 1 if they are the "same node. @@ -96,7 +100,7 @@ function! s:TreeFileNode.equals(treenode) return self.path.str() ==# a:treenode.path.str() endfunction -"FUNCTION: TreeFileNode.findNode(path) {{{3 +"FUNCTION: TreeFileNode.findNode(path) {{{1 "Returns self if this node.path.Equals the given path. "Returns {} if not equal. " @@ -108,7 +112,8 @@ function! s:TreeFileNode.findNode(path) endif return {} endfunction -"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3 + +"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1 " "Finds the next sibling for this node in the indicated direction. This sibling "must be a directory and may/may not have children as specified. @@ -133,7 +138,8 @@ function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) return {} endfunction -"FUNCTION: TreeFileNode.findSibling(direction) {{{3 + +"FUNCTION: TreeFileNode.findSibling(direction) {{{1 " "Finds the next sibling for this node in the indicated direction " @@ -172,7 +178,7 @@ function! s:TreeFileNode.findSibling(direction) return {} endfunction -"FUNCTION: TreeFileNode.getLineNum(){{{3 +"FUNCTION: TreeFileNode.getLineNum(){{{1 "returns the line number this node is rendered on, or -1 if it isnt rendered function! s:TreeFileNode.getLineNum() "if the node is the root then return the root line no. @@ -221,7 +227,7 @@ function! s:TreeFileNode.getLineNum() return -1 endfunction -"FUNCTION: TreeFileNode.GetRootForTab(){{{3 +"FUNCTION: TreeFileNode.GetRootForTab(){{{1 "get the root node for this tab function! s:TreeFileNode.GetRootForTab() if nerdtree#treeExistsForTab() @@ -229,7 +235,8 @@ function! s:TreeFileNode.GetRootForTab() end return {} endfunction -"FUNCTION: TreeFileNode.GetRootLineNum(){{{3 + +"FUNCTION: TreeFileNode.GetRootLineNum(){{{1 "gets the line number of the root node function! s:TreeFileNode.GetRootLineNum() let rootLine = 1 @@ -239,7 +246,7 @@ function! s:TreeFileNode.GetRootLineNum() return rootLine endfunction -"FUNCTION: TreeFileNode.GetSelected() {{{3 +"FUNCTION: TreeFileNode.GetSelected() {{{1 "gets the treenode that the cursor is currently over function! s:TreeFileNode.GetSelected() try @@ -252,13 +259,15 @@ function! s:TreeFileNode.GetSelected() return {} endtry endfunction -"FUNCTION: TreeFileNode.isVisible() {{{3 + +"FUNCTION: TreeFileNode.isVisible() {{{1 "returns 1 if this node should be visible according to the tree filters and "hidden file filters (and their on/off status) function! s:TreeFileNode.isVisible() return !self.path.ignore() endfunction -"FUNCTION: TreeFileNode.isRoot() {{{3 + +"FUNCTION: TreeFileNode.isRoot() {{{1 "returns 1 if this node is b:NERDTreeRoot function! s:TreeFileNode.isRoot() if !nerdtree#treeExistsForBuf() @@ -268,7 +277,7 @@ function! s:TreeFileNode.isRoot() return self.equals(b:NERDTreeRoot) endfunction -"FUNCTION: TreeFileNode.makeRoot() {{{3 +"FUNCTION: TreeFileNode.makeRoot() {{{1 "Make this node the root of the tree function! s:TreeFileNode.makeRoot() if self.path.isDirectory @@ -287,7 +296,8 @@ function! s:TreeFileNode.makeRoot() silent doautocmd User NERDTreeNewRoot endfunction -"FUNCTION: TreeFileNode.New(path) {{{3 + +"FUNCTION: TreeFileNode.New(path) {{{1 "Returns a new TreeNode object with the given path and parent " "Args: @@ -303,31 +313,34 @@ function! s:TreeFileNode.New(path) endif endfunction -"FUNCTION: TreeFileNode.open() {{{3 +"FUNCTION: TreeFileNode.open() {{{1 function! s:TreeFileNode.open(...) let opts = a:0 ? a:1 : {} let opener = g:NERDTreeOpener.New(self.path, opts) call opener.open(self) endfunction -"FUNCTION: TreeFileNode.openSplit() {{{3 +"FUNCTION: TreeFileNode.openSplit() {{{1 "Open this node in a new window function! s:TreeFileNode.openSplit() call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') call self.open({'where': 'h'}) endfunction -"FUNCTION: TreeFileNode.openVSplit() {{{3 + +"FUNCTION: TreeFileNode.openVSplit() {{{1 "Open this node in a new vertical window function! s:TreeFileNode.openVSplit() call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') call self.open({'where': 'v'}) endfunction -"FUNCTION: TreeFileNode.openInNewTab(options) {{{3 + +"FUNCTION: TreeFileNode.openInNewTab(options) {{{1 function! s:TreeFileNode.openInNewTab(options) echomsg 'TreeFileNode.openInNewTab is deprecated' call self.open(extend({'where': 't'}, a:options)) endfunction -"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 + +"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 "Places the cursor on the line number this node is rendered on " "Args: @@ -354,11 +367,12 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) endif endfunction -"FUNCTION: TreeFileNode.refresh() {{{3 +"FUNCTION: TreeFileNode.refresh() {{{1 function! s:TreeFileNode.refresh() call self.path.refresh() endfunction -"FUNCTION: TreeFileNode.rename() {{{3 + +"FUNCTION: TreeFileNode.rename() {{{1 "Calls the rename method for this nodes path obj function! s:TreeFileNode.rename(newName) let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') @@ -373,13 +387,13 @@ function! s:TreeFileNode.rename(newName) call newParent.refresh() endif endfunction -"FUNCTION: TreeFileNode.renderToString {{{3 + +"FUNCTION: TreeFileNode.renderToString {{{1 "returns a string representation for this tree to be rendered in the view function! s:TreeFileNode.renderToString() return self._renderToString(0, 0, [], self.getChildCount() ==# 1) endfunction - "Args: "depth: the current depth in the tree for this call "drawText: 1 if we should actually draw the line for this node (if 0 then the @@ -467,3 +481,5 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) return output endfunction + +" vim: set sw=4 sts=4 et fdm=marker: From 29d3db8ffe795e1b2d29c3333fe52f71acd4c9be Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 6 Jan 2013 00:56:22 +0000 Subject: [PATCH 097/680] fix a couple of function calls that should have been renamed Call nerdtree#echo, not s:echo. This was changed in the big refactor. Fixes #224. --- plugin/nerdtree/bookmark.vim | 2 +- plugin/nerdtree/path.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/nerdtree/bookmark.vim b/plugin/nerdtree/bookmark.vim index 603da53f..0d37b478 100644 --- a/plugin/nerdtree/bookmark.vim +++ b/plugin/nerdtree/bookmark.vim @@ -290,7 +290,7 @@ function! s:Bookmark.validate() else call s:Bookmark.CacheBookmarks(1) call nerdtree#renderView() - call s:echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") + call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") return 0 endif endfunction diff --git a/plugin/nerdtree/path.vim b/plugin/nerdtree/path.vim index 68d50215..58bb0138 100644 --- a/plugin/nerdtree/path.vim +++ b/plugin/nerdtree/path.vim @@ -68,7 +68,7 @@ function! s:Path.changeToDir() try execute "cd " . dir - call s:echo("CWD is now: " . getcwd()) + call nerdtree#echo("CWD is now: " . getcwd()) catch throw "NERDTree.PathChangeError: cannot change CWD to " . dir endtry From 25b80b8a16bcea662117b2a5dcfc1169dd740c77 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 8 Jan 2013 00:01:14 +0000 Subject: [PATCH 098/680] extract the tree creation functions out into their own class Add the NERDTreeCreator class. Stick all functions related to creating a primary/secondary/mirror nerdtree in there. We may break this down further in the future, but this is a good starting point. Make some of the interface binding functions in autoload/nerdtree public. This is needed since we are accessing some of them from NERDTreeCreator. Should be temporary until we get some kind of proper interface binding system set up. --- autoload/nerdtree.vim | 283 ++---------------------------- plugin/NERD_tree.vim | 11 +- plugin/nerdtree/creator.vim | 274 +++++++++++++++++++++++++++++ plugin/nerdtree/opener.vim | 6 +- plugin/nerdtree/tree_dir_node.vim | 2 +- 5 files changed, 302 insertions(+), 274 deletions(-) create mode 100644 plugin/nerdtree/creator.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 7622302e..d0f984f3 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -42,7 +42,7 @@ endfunction "inits a secondary nerd tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) if a:dir != '' && isdirectory(a:dir) - call nerdtree#initNerdTreeInPlace(a:dir) + call g:NERDTreeCreator.New().createSecondary(a:dir) endif endfunction @@ -193,14 +193,14 @@ function! nerdtree#findAndRevealPath() endtry if p.isUnder(cwd) - call nerdtree#initNerdTree(cwd.str()) + call g:NERDTreeCreator.New().createPrimary(cwd.str()) else - call nerdtree#initNerdTree(p.getParent().str()) + call g:NERDTreeCreator.New().createPrimary(p.getParent().str()) endif else if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) if !nerdtree#isTreeOpen() - call nerdtree#createTreeWin() + call g:NERDTreeCreator.New().togglePrimary('') else call nerdtree#putCursorInTreeWin() endif @@ -208,7 +208,7 @@ function! nerdtree#findAndRevealPath() call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) else if !nerdtree#isTreeOpen() - call nerdtree#toggle("") + call g:NERDTreeCreator.New().togglePrimary("") endif endif endif @@ -225,152 +225,6 @@ function! nerdtree#has_opt(options, name) return has_key(a:options, a:name) && a:options[a:name] == 1 endfunction -"FUNCTION: nerdtree#initNerdTree(name) {{{2 -"Initialise the nerd tree for this tab. The tree will start in either the -"given directory, or the directory associated with the given bookmark -" -"Args: -"name: the name of a bookmark or a directory -function! nerdtree#initNerdTree(name) - let path = {} - if g:NERDTreeBookmark.BookmarkExistsFor(a:name) - let path = g:NERDTreeBookmark.BookmarkFor(a:name).path - else - let dir = a:name ==# '' ? getcwd() : a:name - - "hack to get an absolute path if a relative path is given - if dir =~# '^\.' - let dir = getcwd() . g:NERDTreePath.Slash() . dir - endif - let dir = g:NERDTreePath.Resolve(dir) - - try - let path = g:NERDTreePath.New(dir) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("No bookmark or directory found for: " . a:name) - return - endtry - endif - if !path.isDirectory - let path = path.getParent() - endif - - "if instructed to, then change the vim CWD to the dir the NERDTree is - "inited in - if g:NERDTreeChDirMode != 0 - call path.changeToDir() - endif - - if nerdtree#treeExistsForTab() - if nerdtree#isTreeOpen() - call nerdtree#closeTree() - endif - unlet t:NERDTreeBufName - endif - - let newRoot = g:NERDTreeDirNode.New(path) - call newRoot.open() - - call nerdtree#createTreeWin() - let b:treeShowHelp = 0 - let b:NERDTreeIgnoreEnabled = 1 - let b:NERDTreeShowFiles = g:NERDTreeShowFiles - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - let b:NERDTreeRoot = newRoot - let b:NERDTreeType = "primary" - - call nerdtree#renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) - - silent doautocmd User NERDTreeInit -endfunction - -"FUNCTION: nerdtree#initNerdTreeInPlace(dir) {{{2 -function! nerdtree#initNerdTreeInPlace(dir) - try - let path = g:NERDTreePath.New(a:dir) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("Invalid directory name:" . a:name) - return - endtry - - "we want the directory buffer to disappear when we do the :edit below - setlocal bufhidden=wipe - - let previousBuf = expand("#") - - "we need a unique name for each secondary tree buffer to ensure they are - "all independent - exec "silent edit " . nerdtree#nextBufferName() - - let b:NERDTreePreviousBuf = bufnr(previousBuf) - - let b:NERDTreeRoot = g:NERDTreeDirNode.New(path) - call b:NERDTreeRoot.open() - - call nerdtree#setCommonBufOptions() - let b:NERDTreeType = "secondary" - - call nerdtree#renderView() - - silent doautocmd User NERDTreeInit -endfunction - -" FUNCTION: nerdtree#initNerdTreeMirror() {{{2 -function! nerdtree#initNerdTreeMirror() - - "get the names off all the nerd tree buffers - let treeBufNames = [] - for i in range(1, tabpagenr("$")) - let nextName = nerdtree#tabpagevar(i, 'NERDTreeBufName') - if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) - call add(treeBufNames, nextName) - endif - endfor - let treeBufNames = nerdtree#unique(treeBufNames) - - "map the option names (that the user will be prompted with) to the nerd - "tree buffer names - let options = {} - let i = 0 - while i < len(treeBufNames) - let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTreeRoot") - let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName - let i = i + 1 - endwhile - - "work out which tree to mirror, if there is more than 1 then ask the user - let bufferName = '' - if len(keys(options)) > 1 - let choices = ["Choose a tree to mirror"] - let choices = extend(choices, sort(keys(options))) - let choice = inputlist(choices) - if choice < 1 || choice > len(options) || choice ==# '' - return - endif - - let bufferName = options[sort(keys(options))[choice-1]] - elseif len(keys(options)) ==# 1 - let bufferName = values(options)[0] - else - call nerdtree#echo("No trees to mirror") - return - endif - - if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen() - call nerdtree#closeTree() - endif - - let t:NERDTreeBufName = bufferName - call nerdtree#createTreeWin() - exec 'buffer ' . bufferName - if !&hidden - call nerdtree#renderView() - endif -endfunction - " FUNCTION: nerdtree#invokeKeyMap(key) {{{2 "this is needed since I cant figure out how to invoke dict functions from a "key map @@ -533,6 +387,11 @@ function! nerdtree#centerView() endif endfunction +" FUNCTION: nerdtree#chRoot(node) {{{2 +" changes the current root to the selected one +function! nerdtree#chRoot(node) + call s:chRoot(a:node) +endfunction "FUNCTION: nerdtree#closeTree() {{{2 "Closes the primary NERD tree window for this tab function! nerdtree#closeTree() @@ -573,27 +432,6 @@ function! nerdtree#closeTreeIfQuitOnOpen() endif endfunction -"FUNCTION: nerdtree#createTreeWin() {{{2 -"Inits the NERD tree window. ie. opens it, sizes it, sets all the local -"options etc -function! nerdtree#createTreeWin() - "create the nerd tree window - let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " - let splitSize = g:NERDTreeWinSize - - if !exists('t:NERDTreeBufName') - let t:NERDTreeBufName = nerdtree#nextBufferName() - silent! exec splitLocation . 'vertical ' . splitSize . ' new' - silent! exec "edit " . t:NERDTreeBufName - else - silent! exec splitLocation . 'vertical ' . splitSize . ' split' - silent! exec "buffer " . t:NERDTreeBufName - endif - - setlocal winfixwidth - call nerdtree#setCommonBufOptions() -endfunction - "FUNCTION: nerdtree#dumpHelp {{{2 "prints out the quick help function! nerdtree#dumpHelp() @@ -1093,51 +931,6 @@ function! nerdtree#saveScreenState() endtry endfunction -"FUNCTION: nerdtree#setCommonBufOptions() {{{2 -function! nerdtree#setCommonBufOptions() - "throwaway buffer options - setlocal noswapfile - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal nowrap - setlocal foldcolumn=0 - setlocal foldmethod=manual - setlocal nofoldenable - setlocal nobuflisted - setlocal nospell - if g:NERDTreeShowLineNumbers - setlocal nu - else - setlocal nonu - if v:version >= 703 - setlocal nornu - endif - endif - - iabc - - if g:NERDTreeHighlightCursorline - setlocal cursorline - endif - - call nerdtree#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 nerdtree#bindMappings() -endfunction - -"FUNCTION: nerdtree#setupStatusline() {{{2 -function! nerdtree#setupStatusline() - if g:NERDTreeStatusline != -1 - let &l:statusline = g:NERDTreeStatusline - endif -endfunction - "FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2 "returns the given line with all the tree parts stripped off " @@ -1175,29 +968,6 @@ function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) return line endfunction -"FUNCTION: nerdtree#toggle(dir) {{{2 -"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -"closed it is restored or initialized (if it doesnt exist) -" -"Args: -"dir: the full path for the root node (is only used if the NERD tree is being -"initialized. -function! nerdtree#toggle(dir) - if nerdtree#treeExistsForTab() - if !nerdtree#isTreeOpen() - call nerdtree#createTreeWin() - if !&hidden - call nerdtree#renderView() - endif - call nerdtree#restoreScreenState() - else - call nerdtree#closeTree() - endif - else - call nerdtree#initNerdTree(a:dir) - endif -endfunction - "SECTION: Interface bindings {{{1 "============================================================ @@ -1226,26 +996,9 @@ function! s:activateBookmark(bm) call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) endfunction -"FUNCTION: nerdtree#bindMappings() {{{2 -function! nerdtree#bindMappings() - call g:NERDTreeKeyMap.BindAll() - - "make do the same as the default 'o' mapping - exec "nnoremap :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')" - - command! -buffer -nargs=? Bookmark :call bookmarkNode('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') - command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call nerdtree#renderView() - command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call nerdtree#renderView() - command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() -endfunction - -" FUNCTION: s:bookmarkNode(name) {{{2 +" FUNCTION: nerdtree#bookmarkNode(name) {{{2 " Associate the current node with the given name -function! s:bookmarkNode(...) +function! nerdtree#bookmarkNode(...) let currentNode = g:NERDTreeFileNode.GetSelected() if currentNode != {} let name = a:1 @@ -1295,8 +1048,8 @@ function! s:chRootCwd() call nerdtree#chRoot(g:NERDTreeDirNode.New(cwd)) endfunction -" FUNCTION: s:clearBookmarks(bookmarks) {{{2 -function! s:clearBookmarks(bookmarks) +" FUNCTION: nerdtree#clearBookmarks(bookmarks) {{{2 +function! nerdtree#clearBookmarks(bookmarks) if a:bookmarks ==# '' let currentNode = g:NERDTreeFileNode.GetSelected() if currentNode != {} @@ -1464,9 +1217,9 @@ function! s:jumpToPrevSibling(node) call nerdtree#jumpToSibling(a:node, 0) endfunction -" FUNCTION: s:openBookmark(name) {{{2 +" FUNCTION: nerdtree#openBookmark(name) {{{2 " put the cursor on the given bookmark and, if its a file, open it -function! s:openBookmark(name) +function! nerdtree#openBookmark(name) try let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) call targetNode.putCursorHere(0, 1) @@ -1532,9 +1285,9 @@ function! s:previewNodeVSplit(node) call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) endfunction -" FUNCTION: s:revealBookmark(name) {{{2 +" FUNCTION: nerdtree#revealBookmark(name) {{{2 " put the cursor on the node associate with the given name -function! s:revealBookmark(name) +function! nerdtree#revealBookmark(name) try let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) call targetNode.putCursorHere(0, 1) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 08ae9975..667c20b4 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -144,15 +144,16 @@ runtime plugin/nerdtree/bookmark.vim runtime plugin/nerdtree/tree_file_node.vim runtime plugin/nerdtree/tree_dir_node.vim runtime plugin/nerdtree/opener.vim +runtime plugin/nerdtree/creator.vim " SECTION: Commands {{{1 "============================================================ "init the command that users start the nerd tree with -command! -n=? -complete=dir -bar NERDTree :call nerdtree#initNerdTree('') -command! -n=? -complete=dir -bar NERDTreeToggle :call nerdtree#toggle('') +command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.New().createPrimary('') +command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.New().togglePrimary('') command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() -command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call nerdtree#initNerdTree('') -command! -n=0 -bar NERDTreeMirror call nerdtree#initNerdTreeMirror() +command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.New().createPrimary('') +command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.New().createMirror() command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() @@ -200,7 +201,7 @@ function! NERDTreeFocus() if nerdtree#isTreeOpen() call nerdtree#putCursorInTreeWin() else - call nerdtree#toggle("") + call g:NERDTreeCreator.New().togglePrimary("") endif endfunction diff --git a/plugin/nerdtree/creator.vim b/plugin/nerdtree/creator.vim new file mode 100644 index 00000000..b1672862 --- /dev/null +++ b/plugin/nerdtree/creator.vim @@ -0,0 +1,274 @@ +"CLASS: Creator +"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and +"buffer options and key mappings etc. +"============================================================ +let s:Creator = {} +let g:NERDTreeCreator = s:Creator + +"FUNCTION: s:Creator._bindMappings() {{{1 +function! s:Creator._bindMappings() + call g:NERDTreeKeyMap.BindAll() + + "make do the same as the default 'o' mapping + exec "nnoremap :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')" + + command! -buffer -nargs=? Bookmark :call nerdtree#bookmarkNode('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#revealBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#clearBookmarks('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') + command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call nerdtree#renderView() + command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call nerdtree#renderView() + command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() +endfunction + +"FUNCTION: s:Creator._broadcastInitEvent() {{{1 +function! s:Creator._broadcastInitEvent() + silent doautocmd User NERDTreeInit +endfunction + +"FUNCTION: s:Creator.createPrimary(a:name) {{{1 +"name: the name of a bookmark or a directory +function! s:Creator.createPrimary(name) + let path = self._pathForString(a:name) + + "if instructed to, then change the vim CWD to the dir the NERDTree is + "inited in + if g:NERDTreeChDirMode != 0 + call path.changeToDir() + endif + + if nerdtree#treeExistsForTab() + if nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif + unlet t:NERDTreeBufName + endif + + let newRoot = g:NERDTreeDirNode.New(path) + call newRoot.open() + + call self._createTreeWin() + let b:treeShowHelp = 0 + let b:NERDTreeIgnoreEnabled = 1 + let b:NERDTreeShowFiles = g:NERDTreeShowFiles + let b:NERDTreeShowHidden = g:NERDTreeShowHidden + let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks + let b:NERDTreeRoot = newRoot + let b:NERDTreeType = "primary" + + call nerdtree#renderView() + call b:NERDTreeRoot.putCursorHere(0, 0) + + call self._broadcastInitEvent() +endfunction + +"FUNCTION: s:Creator.createSecondary(dir) {{{1 +function! s:Creator.createSecondary(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("Invalid directory name:" . a:name) + return + endtry + + "we want the directory buffer to disappear when we do the :edit below + setlocal bufhidden=wipe + + let previousBuf = expand("#") + + "we need a unique name for each secondary tree buffer to ensure they are + "all independent + exec "silent edit " . nerdtree#nextBufferName() + + let b:NERDTreePreviousBuf = bufnr(previousBuf) + + let b:NERDTreeRoot = g:NERDTreeDirNode.New(path) + call b:NERDTreeRoot.open() + + call self._setCommonBufOptions() + let b:NERDTreeType = "secondary" + + call nerdtree#renderView() + + call self._broadcastInitEvent() +endfunction + +" FUNCTION: s:Creator.createMirror() {{{1 +function! s:Creator.createMirror() + "get the names off all the nerd tree buffers + let treeBufNames = [] + for i in range(1, tabpagenr("$")) + let nextName = nerdtree#tabpagevar(i, 'NERDTreeBufName') + if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) + call add(treeBufNames, nextName) + endif + endfor + let treeBufNames = nerdtree#unique(treeBufNames) + + "map the option names (that the user will be prompted with) to the nerd + "tree buffer names + let options = {} + let i = 0 + while i < len(treeBufNames) + let bufName = treeBufNames[i] + let treeRoot = getbufvar(bufName, "NERDTreeRoot") + let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName + let i = i + 1 + endwhile + + "work out which tree to mirror, if there is more than 1 then ask the user + let bufferName = '' + if len(keys(options)) > 1 + let choices = ["Choose a tree to mirror"] + let choices = extend(choices, sort(keys(options))) + let choice = inputlist(choices) + if choice < 1 || choice > len(options) || choice ==# '' + return + endif + + let bufferName = options[sort(keys(options))[choice-1]] + elseif len(keys(options)) ==# 1 + let bufferName = values(options)[0] + else + call nerdtree#echo("No trees to mirror") + return + endif + + if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen() + call nerdtree#closeTree() + endif + + let t:NERDTreeBufName = bufferName + call self._createTreeWin() + exec 'buffer ' . bufferName + if !&hidden + call nerdtree#renderView() + endif +endfunction + +"FUNCTION: s:Creator._createTreeWin() {{{1 +"Inits the NERD tree window. ie. opens it, sizes it, sets all the local +"options etc +function! s:Creator._createTreeWin() + "create the nerd tree window + let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " + let splitSize = g:NERDTreeWinSize + + if !exists('t:NERDTreeBufName') + let t:NERDTreeBufName = nerdtree#nextBufferName() + silent! exec splitLocation . 'vertical ' . splitSize . ' new' + silent! exec "edit " . t:NERDTreeBufName + else + silent! exec splitLocation . 'vertical ' . splitSize . ' split' + silent! exec "buffer " . t:NERDTreeBufName + endif + + setlocal winfixwidth + call self._setCommonBufOptions() +endfunction + +"FUNCTION: s:Creator.New() {{{1 +function! s:Creator.New() + let newCreator = copy(self) + return newCreator +endfunction + +"FUNCTION: s:Creator._pathForString(str) {{{1 +"find a bookmark or adirectory for the given string +function! s:Creator._pathForString(str) + let path = {} + if g:NERDTreeBookmark.BookmarkExistsFor(a:str) + let path = g:NERDTreeBookmark.BookmarkFor(a:str).path + else + let dir = a:str ==# '' ? getcwd() : a:str + + "hack to get an absolute path if a relative path is given + if dir =~# '^\.' + let dir = getcwd() . g:NERDTreePath.Slash() . dir + endif + let dir = g:NERDTreePath.Resolve(dir) + + try + let path = g:NERDTreePath.New(dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("No bookmark or directory found for: " . a:str) + return + endtry + endif + if !path.isDirectory + let path = path.getParent() + endif + + return path +endfunction + +"FUNCTION: s:Creator._setCommonBufOptions() {{{1 +function! s:Creator._setCommonBufOptions() + "throwaway buffer options + setlocal noswapfile + setlocal buftype=nofile + setlocal bufhidden=hide + setlocal nowrap + setlocal foldcolumn=0 + setlocal foldmethod=manual + setlocal nofoldenable + setlocal nobuflisted + setlocal nospell + if g:NERDTreeShowLineNumbers + setlocal nu + else + setlocal nonu + if v:version >= 703 + setlocal nornu + endif + endif + + iabc + + if g:NERDTreeHighlightCursorline + setlocal cursorline + endif + + call self._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 self._bindMappings() +endfunction + +"FUNCTION: s:Creator._setupStatusline() {{{1 +function! s:Creator._setupStatusline() + if g:NERDTreeStatusline != -1 + let &l:statusline = g:NERDTreeStatusline + endif +endfunction + +"FUNCTION: s:Creator.togglePrimary(dir) {{{1 +"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is +"closed it is restored or initialized (if it doesnt exist) +" +"Args: +"dir: the full path for the root node (is only used if the NERD tree is being +"initialized. +function! s:Creator.togglePrimary(dir) + if nerdtree#treeExistsForTab() + if !nerdtree#isTreeOpen() + call self._createTreeWin() + if !&hidden + call nerdtree#renderView() + endif + call nerdtree#restoreScreenState() + else + call nerdtree#closeTree() + endif + else + call self.createPrimary(a:dir) + endif +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/plugin/nerdtree/opener.vim b/plugin/nerdtree/opener.vim index 947d5e16..df250991 100644 --- a/plugin/nerdtree/opener.vim +++ b/plugin/nerdtree/opener.vim @@ -185,7 +185,7 @@ endfunction function! s:Opener._openDirectory(node) if self._treetype ==# "secondary" call self._gotoTargetWin() - call nerdtree#initNerdTreeInPlace(a:node.path.str()) + call g:NERDTreeCreator.New().createSecondary(a:node.path.str()) else call self._gotoTargetWin() if empty(self._where) @@ -193,9 +193,9 @@ function! s:Opener._openDirectory(node) call nerdtree#renderView() call a:node.putCursorHere(0, 0) elseif self._where == 't' - call nerdtree#initNerdTree(a:node.path.str()) + call g:NERDTreeCreator.New().createPrimary(a:node.path.str()) else - call nerdtree#initNerdTreeInPlace(a:node.path.str()) + call g:NERDTreeCreator.New().createSecondary(a:node.path.str()) endif endif diff --git a/plugin/nerdtree/tree_dir_node.vim b/plugin/nerdtree/tree_dir_node.vim index 25f10349..63becf5a 100644 --- a/plugin/nerdtree/tree_dir_node.vim +++ b/plugin/nerdtree/tree_dir_node.vim @@ -351,7 +351,7 @@ endfunction "FUNCTION: TreeDirNode._openInNewTab() {{{1 function! s:TreeDirNode._openInNewTab() tabnew - call nerdtree#initNerdTree(self.path.str()) + call g:NERDTreeCreator.New().createPrimary(self.path.str()) endfunction "FUNCTION: TreeDirNode.openRecursively() {{{1 From f5956dbbcfedff22c2c6d31ec3c980de6883bd5b Mon Sep 17 00:00:00 2001 From: Dmitry Kasimtsev Date: Tue, 8 Jan 2013 17:17:04 +0200 Subject: [PATCH 099/680] fixed error messages on copy node in NERDTree buffer --- plugin/nerdtree/tree_file_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/nerdtree/tree_file_node.vim b/plugin/nerdtree/tree_file_node.vim index 6b5246f9..ab8d3719 100644 --- a/plugin/nerdtree/tree_file_node.vim +++ b/plugin/nerdtree/tree_file_node.vim @@ -58,7 +58,7 @@ endfunction "FUNCTION: TreeFileNode.copy(dest) {{{1 function! s:TreeFileNode.copy(dest) call self.path.copy(a:dest) - let newPath = s:NERDTreePath.New(a:dest) + let newPath = g:NERDTreePath.New(a:dest) let parent = b:NERDTreeRoot.findNode(newPath.getParent()) if !empty(parent) call parent.refresh() From c3b63d2fd9c929359231363bcabc880ba29eb96e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 9 Jan 2013 00:41:34 +0000 Subject: [PATCH 100/680] add some class methods to wrap the NERDTreeCreator public methods This is needed because some versions of vim dont let you chain method calls together. So do the work in NERDTreeCreator instead of forcing all callers to break the New().createXXX() calls out onto 2 lines with an intermediate variable. Fixes #226. --- autoload/nerdtree.vim | 10 +++++----- plugin/NERD_tree.vim | 10 +++++----- plugin/nerdtree/creator.vim | 24 ++++++++++++++++++++++++ plugin/nerdtree/opener.vim | 6 +++--- plugin/nerdtree/tree_dir_node.vim | 2 +- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d0f984f3..e6054e03 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -42,7 +42,7 @@ endfunction "inits a secondary nerd tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) if a:dir != '' && isdirectory(a:dir) - call g:NERDTreeCreator.New().createSecondary(a:dir) + call g:NERDTreeCreator.CreateSecondary(a:dir) endif endfunction @@ -193,14 +193,14 @@ function! nerdtree#findAndRevealPath() endtry if p.isUnder(cwd) - call g:NERDTreeCreator.New().createPrimary(cwd.str()) + call g:NERDTreeCreator.CreatePrimary(cwd.str()) else - call g:NERDTreeCreator.New().createPrimary(p.getParent().str()) + call g:NERDTreeCreator.CreatePrimary(p.getParent().str()) endif else if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) if !nerdtree#isTreeOpen() - call g:NERDTreeCreator.New().togglePrimary('') + call g:NERDTreeCreator.TogglePrimary('') else call nerdtree#putCursorInTreeWin() endif @@ -208,7 +208,7 @@ function! nerdtree#findAndRevealPath() call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) else if !nerdtree#isTreeOpen() - call g:NERDTreeCreator.New().togglePrimary("") + call g:NERDTreeCreator.TogglePrimary("") endif endif endif diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 667c20b4..8b853d41 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -149,11 +149,11 @@ runtime plugin/nerdtree/creator.vim " SECTION: Commands {{{1 "============================================================ "init the command that users start the nerd tree with -command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.New().createPrimary('') -command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.New().togglePrimary('') +command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('') +command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() -command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.New().createPrimary('') -command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.New().createMirror() +command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') +command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() @@ -201,7 +201,7 @@ function! NERDTreeFocus() if nerdtree#isTreeOpen() call nerdtree#putCursorInTreeWin() else - call g:NERDTreeCreator.New().togglePrimary("") + call g:NERDTreeCreator.TogglePrimary("") endif endfunction diff --git a/plugin/nerdtree/creator.vim b/plugin/nerdtree/creator.vim index b1672862..5adc9601 100644 --- a/plugin/nerdtree/creator.vim +++ b/plugin/nerdtree/creator.vim @@ -27,6 +27,12 @@ function! s:Creator._broadcastInitEvent() silent doautocmd User NERDTreeInit endfunction +"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1 +function! s:Creator.CreatePrimary(name) + let creator = s:Creator.New() + call creator.createPrimary(a:name) +endfunction + "FUNCTION: s:Creator.createPrimary(a:name) {{{1 "name: the name of a bookmark or a directory function! s:Creator.createPrimary(name) @@ -63,6 +69,12 @@ function! s:Creator.createPrimary(name) call self._broadcastInitEvent() endfunction +"FUNCTION: s:Creator.CreateSecondary(dir) {{{1 +function! s:Creator.CreateSecondary(dir) + let creator = s:Creator.New() + call creator.createSecondary(a:dir) +endfunction + "FUNCTION: s:Creator.createSecondary(dir) {{{1 function! s:Creator.createSecondary(dir) try @@ -94,6 +106,12 @@ function! s:Creator.createSecondary(dir) call self._broadcastInitEvent() endfunction +" FUNCTION: s:Creator.CreateMirror() {{{1 +function! s:Creator.CreateMirror() + let creator = s:Creator.New() + call creator.createMirror() +endfunction + " FUNCTION: s:Creator.createMirror() {{{1 function! s:Creator.createMirror() "get the names off all the nerd tree buffers @@ -248,6 +266,12 @@ function! s:Creator._setupStatusline() endif endfunction +"FUNCTION: s:Creator.TogglePrimary(dir) {{{1 +function! s:Creator.TogglePrimary(dir) + let creator = s:Creator.New() + call creator.togglePrimary(a:dir) +endfunction + "FUNCTION: s:Creator.togglePrimary(dir) {{{1 "Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is "closed it is restored or initialized (if it doesnt exist) diff --git a/plugin/nerdtree/opener.vim b/plugin/nerdtree/opener.vim index df250991..bcc0d4fc 100644 --- a/plugin/nerdtree/opener.vim +++ b/plugin/nerdtree/opener.vim @@ -185,7 +185,7 @@ endfunction function! s:Opener._openDirectory(node) if self._treetype ==# "secondary" call self._gotoTargetWin() - call g:NERDTreeCreator.New().createSecondary(a:node.path.str()) + call g:NERDTreeCreator.CreateSecondary(a:node.path.str()) else call self._gotoTargetWin() if empty(self._where) @@ -193,9 +193,9 @@ function! s:Opener._openDirectory(node) call nerdtree#renderView() call a:node.putCursorHere(0, 0) elseif self._where == 't' - call g:NERDTreeCreator.New().createPrimary(a:node.path.str()) + call g:NERDTreeCreator.CreatePrimary(a:node.path.str()) else - call g:NERDTreeCreator.New().createSecondary(a:node.path.str()) + call g:NERDTreeCreator.CreateSecondary(a:node.path.str()) endif endif diff --git a/plugin/nerdtree/tree_dir_node.vim b/plugin/nerdtree/tree_dir_node.vim index 63becf5a..1b1a231d 100644 --- a/plugin/nerdtree/tree_dir_node.vim +++ b/plugin/nerdtree/tree_dir_node.vim @@ -351,7 +351,7 @@ endfunction "FUNCTION: TreeDirNode._openInNewTab() {{{1 function! s:TreeDirNode._openInNewTab() tabnew - call g:NERDTreeCreator.New().createPrimary(self.path.str()) + call g:NERDTreeCreator.CreatePrimary(self.path.str()) endfunction "FUNCTION: TreeDirNode.openRecursively() {{{1 From 64cb6204ccfeaa0ea73c946e0082b4da138f4a72 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 9 Jan 2013 09:48:16 +0000 Subject: [PATCH 101/680] move a couple of functions into NERDTreeCreator The "next buffer name" functions are only used in NERDTreeCreator so put them there. --- autoload/nerdtree.vim | 24 ------------------------ plugin/NERD_tree.vim | 4 ++-- plugin/nerdtree/creator.vim | 28 ++++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index e6054e03..b8f69dca 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -33,11 +33,6 @@ function! nerdtree#bufInWindows(bnum) return cnt endfunction -" FUNCTION: nerdtree#bufNamePrefix() {{{2 -function! nerdtree#bufNamePrefix() - return 'NERD_tree_' -endfunction - "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a secondary nerd tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) @@ -232,25 +227,6 @@ function! nerdtree#invokeKeyMap(key) call g:NERDTreeKeyMap.Invoke(a:key) endfunction -" FUNCTION: nerdtree#nextBufferName() {{{2 -" returns the buffer name for the next nerd tree -function! nerdtree#nextBufferName() - let name = nerdtree#bufNamePrefix() . nerdtree#nextBufferNumber() - return name -endfunction - -" FUNCTION: nerdtree#nextBufferNumber() {{{2 -" the number to add to the nerd tree buffer name to make the buf name unique -function! nerdtree#nextBufferNumber() - if !exists("s:nextBufNum") - let s:nextBufNum = 1 - else - let s:nextBufNum += 1 - endif - - return s:nextBufNum -endfunction - " FUNCTION: nerdtree#postSourceActions() {{{2 function! nerdtree#postSourceActions() call g:NERDTreeBookmark.CacheBookmarks(0) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8b853d41..6c19a3fa 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -161,10 +161,10 @@ command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufWinLeave ". nerdtree#bufNamePrefix() ."* call nerdtree#saveScreenState()" + exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call nerdtree#saveScreenState()" "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". nerdtree#bufNamePrefix() ."* stopinsert" + exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" augroup END if g:NERDTreeHijackNetrw diff --git a/plugin/nerdtree/creator.vim b/plugin/nerdtree/creator.vim index 5adc9601..ee5f7407 100644 --- a/plugin/nerdtree/creator.vim +++ b/plugin/nerdtree/creator.vim @@ -27,6 +27,11 @@ function! s:Creator._broadcastInitEvent() silent doautocmd User NERDTreeInit endfunction +" FUNCTION: s:Creator.BufNamePrefix() {{{2 +function! s:Creator.BufNamePrefix() + return 'NERD_tree_' +endfunction + "FUNCTION: s:Creator.CreatePrimary(a:name) {{{1 function! s:Creator.CreatePrimary(name) let creator = s:Creator.New() @@ -91,7 +96,7 @@ function! s:Creator.createSecondary(dir) "we need a unique name for each secondary tree buffer to ensure they are "all independent - exec "silent edit " . nerdtree#nextBufferName() + exec "silent edit " . self._nextBufferName() let b:NERDTreePreviousBuf = bufnr(previousBuf) @@ -174,7 +179,7 @@ function! s:Creator._createTreeWin() let splitSize = g:NERDTreeWinSize if !exists('t:NERDTreeBufName') - let t:NERDTreeBufName = nerdtree#nextBufferName() + let t:NERDTreeBufName = self._nextBufferName() silent! exec splitLocation . 'vertical ' . splitSize . ' new' silent! exec "edit " . t:NERDTreeBufName else @@ -192,6 +197,25 @@ function! s:Creator.New() return newCreator endfunction +" FUNCTION: s:Creator._nextBufferName() {{{2 +" returns the buffer name for the next nerd tree +function! s:Creator._nextBufferName() + let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() + return name +endfunction + +" FUNCTION: s:Creator._nextBufferNumber() {{{2 +" the number to add to the nerd tree buffer name to make the buf name unique +function! s:Creator._nextBufferNumber() + if !exists("s:Creator._NextBufNum") + let s:Creator._NextBufNum = 1 + else + let s:Creator._NextBufNum += 1 + endif + + return s:Creator._NextBufNum +endfunction + "FUNCTION: s:Creator._pathForString(str) {{{1 "find a bookmark or adirectory for the given string function! s:Creator._pathForString(str) From 40d05ace57fb51cc2c2b2e9eb81c4832ed291630 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 30 Jan 2013 13:54:30 +0000 Subject: [PATCH 102/680] catch an error thrown when refreshing a dir with a FIFO or socket --- plugin/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/nerdtree/tree_dir_node.vim b/plugin/nerdtree/tree_dir_node.vim index 1b1a231d..e3a068ed 100644 --- a/plugin/nerdtree/tree_dir_node.vim +++ b/plugin/nerdtree/tree_dir_node.vim @@ -422,7 +422,7 @@ function! s:TreeDirNode.refresh() endif - catch /^NERDTree.InvalidArgumentsError/ + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound = 1 endtry endif From b8cab9bae22756f32bd229c59aa6e71698d39e87 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Thu, 31 Jan 2013 15:53:44 +0100 Subject: [PATCH 103/680] Set filetype unconditionally and after defining mappings. Because NERD_Tree sets the filetype in its buffer, it's tempting to hook into the FileType event in order to customize it. Unfortunately, the buffer-local mappings are only defined _after_ setting the filetype, so one cannot un-/redefine them via this mechanism. (I know there are config variables and an API for that, but one may have other unforeseen uses.) Therefore, swap the order and set the filetype last. Also, use :setlocal filetype= instead of :setfiletype. In the (remote) chance that a custom filetype detection mistakenly sets a filetype for the NERD_Tree buffer, the :setfiletype would be without effect, but we want to force the filetype (for the special syntax) here. --- plugin/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/nerdtree/creator.vim b/plugin/nerdtree/creator.vim index ee5f7407..c35f6946 100644 --- a/plugin/nerdtree/creator.vim +++ b/plugin/nerdtree/creator.vim @@ -279,8 +279,8 @@ function! s:Creator._setCommonBufOptions() let b:NERDTreeShowFiles = g:NERDTreeShowFiles let b:NERDTreeShowHidden = g:NERDTreeShowHidden let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - setfiletype nerdtree call self._bindMappings() + setlocal filetype=nerdtree endfunction "FUNCTION: s:Creator._setupStatusline() {{{1 From f93d2c79e5b99f8c7326bfc6bb940fed1212c6a1 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 3 Apr 2013 13:35:31 +0100 Subject: [PATCH 104/680] fix NERDTreeCWD Closes #233 --- autoload/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b8f69dca..3da55662 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -98,7 +98,7 @@ function! nerdtree#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': s."chRootCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#chRootCwd" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) @@ -1011,7 +1011,7 @@ endfunction " FUNCTION: s:chRootCwd() {{{2 " changes the current root to CWD -function! s:chRootCwd() +function! nerdtree#chRootCwd() try let cwd = g:NERDTreePath.New(getcwd()) catch /^NERDTree.InvalidArgumentsError/ From 9a341ec18f631e58398350cc9665b8ec4d50954d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 9 Apr 2013 10:10:14 +0100 Subject: [PATCH 105/680] fix a bug where the user couldnt override the mapping for --- plugin/nerdtree/creator.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/nerdtree/creator.vim b/plugin/nerdtree/creator.vim index ee5f7407..7f0721f0 100644 --- a/plugin/nerdtree/creator.vim +++ b/plugin/nerdtree/creator.vim @@ -7,11 +7,11 @@ let g:NERDTreeCreator = s:Creator "FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() - call g:NERDTreeKeyMap.BindAll() - "make do the same as the default 'o' mapping exec "nnoremap :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')" + call g:NERDTreeKeyMap.BindAll() + command! -buffer -nargs=? Bookmark :call nerdtree#bookmarkNode('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#revealBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#openBookmark('') From eaf19734e73dbaa5b30f10591079043b0eba0aab Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 13 Apr 2013 20:32:25 +0100 Subject: [PATCH 106/680] move the class files out of the plugin dir On some new versions of vim these files were being loaded before the main NERD_tree.vim which was causing errors as dependencies werent loaded in time. Move the classes into lib - so vim wont try to load them until we tell it --- autoload/nerdtree.vim | 13 +++++++++++++ {plugin => lib}/nerdtree/bookmark.vim | 0 {plugin => lib}/nerdtree/creator.vim | 0 {plugin => lib}/nerdtree/key_map.vim | 0 {plugin => lib}/nerdtree/menu_controller.vim | 0 {plugin => lib}/nerdtree/menu_item.vim | 0 {plugin => lib}/nerdtree/opener.vim | 0 {plugin => lib}/nerdtree/path.vim | 0 {plugin => lib}/nerdtree/tree_dir_node.vim | 0 {plugin => lib}/nerdtree/tree_file_node.vim | 0 plugin/NERD_tree.vim | 10 +--------- 11 files changed, 14 insertions(+), 9 deletions(-) rename {plugin => lib}/nerdtree/bookmark.vim (100%) rename {plugin => lib}/nerdtree/creator.vim (100%) rename {plugin => lib}/nerdtree/key_map.vim (100%) rename {plugin => lib}/nerdtree/menu_controller.vim (100%) rename {plugin => lib}/nerdtree/menu_item.vim (100%) rename {plugin => lib}/nerdtree/opener.vim (100%) rename {plugin => lib}/nerdtree/path.vim (100%) rename {plugin => lib}/nerdtree/tree_dir_node.vim (100%) rename {plugin => lib}/nerdtree/tree_file_node.vim (100%) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3da55662..3a2d71a6 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -227,6 +227,19 @@ function! nerdtree#invokeKeyMap(key) call g:NERDTreeKeyMap.Invoke(a:key) endfunction +" FUNCTION: nerdtree#loadClassFiles() {{{2 +function! nerdtree#loadClassFiles() + runtime lib/nerdtree/path.vim + runtime lib/nerdtree/menu_controller.vim + runtime lib/nerdtree/menu_item.vim + runtime lib/nerdtree/key_map.vim + runtime lib/nerdtree/bookmark.vim + runtime lib/nerdtree/tree_file_node.vim + runtime lib/nerdtree/tree_dir_node.vim + runtime lib/nerdtree/opener.vim + runtime lib/nerdtree/creator.vim +endfunction + " FUNCTION: nerdtree#postSourceActions() {{{2 function! nerdtree#postSourceActions() call g:NERDTreeBookmark.CacheBookmarks(0) diff --git a/plugin/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim similarity index 100% rename from plugin/nerdtree/bookmark.vim rename to lib/nerdtree/bookmark.vim diff --git a/plugin/nerdtree/creator.vim b/lib/nerdtree/creator.vim similarity index 100% rename from plugin/nerdtree/creator.vim rename to lib/nerdtree/creator.vim diff --git a/plugin/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim similarity index 100% rename from plugin/nerdtree/key_map.vim rename to lib/nerdtree/key_map.vim diff --git a/plugin/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim similarity index 100% rename from plugin/nerdtree/menu_controller.vim rename to lib/nerdtree/menu_controller.vim diff --git a/plugin/nerdtree/menu_item.vim b/lib/nerdtree/menu_item.vim similarity index 100% rename from plugin/nerdtree/menu_item.vim rename to lib/nerdtree/menu_item.vim diff --git a/plugin/nerdtree/opener.vim b/lib/nerdtree/opener.vim similarity index 100% rename from plugin/nerdtree/opener.vim rename to lib/nerdtree/opener.vim diff --git a/plugin/nerdtree/path.vim b/lib/nerdtree/path.vim similarity index 100% rename from plugin/nerdtree/path.vim rename to lib/nerdtree/path.vim diff --git a/plugin/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim similarity index 100% rename from plugin/nerdtree/tree_dir_node.vim rename to lib/nerdtree/tree_dir_node.vim diff --git a/plugin/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim similarity index 100% rename from plugin/nerdtree/tree_file_node.vim rename to lib/nerdtree/tree_file_node.vim diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 6c19a3fa..5bee03ad 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -136,15 +136,7 @@ call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") call s:initVariable("g:NERDTreeMapCWD", "CD") "SECTION: Load class files{{{2 -runtime plugin/nerdtree/path.vim -runtime plugin/nerdtree/menu_controller.vim -runtime plugin/nerdtree/menu_item.vim -runtime plugin/nerdtree/key_map.vim -runtime plugin/nerdtree/bookmark.vim -runtime plugin/nerdtree/tree_file_node.vim -runtime plugin/nerdtree/tree_dir_node.vim -runtime plugin/nerdtree/opener.vim -runtime plugin/nerdtree/creator.vim +call nerdtree#loadClassFiles() " SECTION: Commands {{{1 "============================================================ From 60683f1ccef35b18124bae50d89817b81ef30d8d Mon Sep 17 00:00:00 2001 From: pendulm Date: Mon, 22 Apr 2013 23:35:15 +0800 Subject: [PATCH 107/680] Fix typo Casade to Cascade --- doc/NERD_tree.txt | 10 +++++----- lib/nerdtree/tree_dir_node.vim | 2 +- plugin/NERD_tree.vim | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 47f34726..dda2b75b 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -667,8 +667,8 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of + ~ chars when displaying directories. -|'NERDTreeCasadeOpenSingleChildDir'| - Casade open while selected directory has only +|'NERDTreeCascadeOpenSingleChildDir'| + Cascade open while selected directory has only one child that also is a directory. |'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove @@ -987,7 +987,7 @@ option: > < ------------------------------------------------------------------------------ - *'NERDTreeCasadeOpenSingleChildDir'* + *'NERDTreeCascadeOpenSingleChildDir'* Values: 0 or 1 Default: 1. @@ -995,8 +995,8 @@ When opening dir nodes, this option tells NERDTree to recursively open dirs that have only one child which is also a dir. NERDTree will stop when it finds a dir that contains anything but another single dir. This option may be useful for Java projects. Use one of the follow lines to set this option: > - let NERDTreeCasadeOpenSingleChildDir=0 - let NERDTreeCasadeOpenSingleChildDir=1 + let NERDTreeCascadeOpenSingleChildDir=0 + let NERDTreeCascadeOpenSingleChildDir=1 < ------------------------------------------------------------------------------ diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index e3a068ed..b9a905a8 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -500,7 +500,7 @@ function! s:TreeDirNode.toggleOpen(...) if self.isOpen ==# 1 call self.close() else - if g:NERDTreeCasadeOpenSingleChildDir == 0 + if g:NERDTreeCascadeOpenSingleChildDir == 0 call self.open(opts) else call self.openAlong(opts) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 5bee03ad..e42533a5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -66,7 +66,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) -call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1) +call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] From 6ef67a2d8eb0322bda10e767519242f403b6c597 Mon Sep 17 00:00:00 2001 From: pendulm Date: Mon, 22 Apr 2013 23:39:26 +0800 Subject: [PATCH 108/680] Add correspoding close action to cascade open single child dir --- autoload/nerdtree.vim | 12 ++++++++++-- doc/NERD_tree.txt | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3a2d71a6..c440bf87 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -1068,9 +1068,17 @@ function! s:closeCurrentDir(node) if parent ==# {} || parent.isRoot() call nerdtree#echo("cannot close tree root") else - call a:node.parent.close() + while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot() + if parent.parent.getVisibleChildCount() == 1 + call parent.close() + let parent = parent.parent + else + break + endif + endwhile + call parent.close() call nerdtree#renderView() - call a:node.parent.putCursorHere(0, 0) + call parent.putCursorHere(0, 0) endif endfunction diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index dda2b75b..b2621317 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -993,8 +993,9 @@ Default: 1. When opening dir nodes, this option tells NERDTree to recursively open dirs that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. This option may be useful -for Java projects. Use one of the follow lines to set this option: > +a dir that contains anything but another single dir. Set this option on also +cause NERDTree close parent dir intelligent. This option may be useful for Java +projects. Use one of the follow lines to set this option: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < From 2fa35fb4949f670f1c137dc26a779f6e0515b330 Mon Sep 17 00:00:00 2001 From: Josh Hoff Date: Thu, 25 Apr 2013 21:34:36 -0500 Subject: [PATCH 109/680] don't redefine user-defined mappings As a user it's a little jarring when a plugin maps over something I've already defined. This patch fixes that problem, by using `` to ensure unique mappings. For more info see `:help ` Note: This has no effect if the mapping isn't already defined (that is, NERDTree is defining a unique mapping), so this won't break for normal users of the plugin. Note: `:silent!` is needed to ignore the error that occurs when a mapping is already defined. Fixes #252 --- lib/nerdtree/key_map.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 86457652..6066275a 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -44,7 +44,7 @@ function! s:KeyMap.bind() let premap = self.key == "" ? " " : " " - exec 'nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' + exec 'silent! nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{1 From 6697bb7bede42dd180dbb2b62c04cf86aeab1e2e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 13 May 2013 10:00:40 +0100 Subject: [PATCH 110/680] Revert "don't redefine user-defined mappings" This reverts commit 2fa35fb4949f670f1c137dc26a779f6e0515b330. --- lib/nerdtree/key_map.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 6066275a..86457652 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -44,7 +44,7 @@ function! s:KeyMap.bind() let premap = self.key == "" ? " " : " " - exec 'silent! nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' + exec 'nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{1 From 21af5e0abd3bde9eebf5ab758fb2e6defe0b80c1 Mon Sep 17 00:00:00 2001 From: Volodymyr Medvid Date: Tue, 14 May 2013 16:39:46 +0300 Subject: [PATCH 111/680] fix spelling in documentation --- README.markdown | 6 +++--- doc/NERD_tree.txt | 10 +++++----- lib/nerdtree/bookmark.vim | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.markdown b/README.markdown index 60869dea..e6178091 100644 --- a/README.markdown +++ b/README.markdown @@ -44,11 +44,11 @@ The following features and functionality are provided by the NERD tree: as you left it * You can have a separate NERD tree for each tab, share trees across tabs, or a mix of both. - * By default the script overrides the default file browser (netw), so if - you :edit a directory a (slighly modified) NERD tree will appear in the + * By default the script overrides the default file browser (netrw), so if + you :edit a directory a (slightly modified) NERD tree will appear in the current window * A programmable menu system is provided (simulates right clicking on a node) - * one default menu plugin is provided to perform basic filesytem + * one default menu plugin is provided to perform basic filesystem operations (create/delete/move/copy files/directories) * There's an API for adding your own keymappings diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 47f34726..bf038962 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -83,12 +83,12 @@ The following features and functionality are provided by the NERD tree: as you left it * You can have a separate NERD tree for each tab, share trees across tabs, or a mix of both. - * By default the script overrides the default file browser (netw), so if - you :edit a directory a (slighly modified) NERD tree will appear in the + * By default the script overrides the default file browser (netrw), so if + you :edit a directory a (slightly modified) NERD tree will appear in the current window * A programmable menu system is provided (simulates right clicking on a node) - * one default menu plugin is provided to perform basic filesytem + * one default menu plugin is provided to perform basic filesystem operations (create/delete/move/copy files/directories) * There's an API for adding your own keymappings @@ -228,7 +228,7 @@ gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs| O.......Recursively open the selected directory..................|NERDTree-O| x.......Close the current nodes parent...........................|NERDTree-x| X.......Recursively close all children of the current node.......|NERDTree-X| -e.......Edit the current dif.....................................|NERDTree-e| +e.......Edit the current dir.....................................|NERDTree-e| ...............same as |NERDTree-o|. double-click.......same as the |NERDTree-o| map. @@ -780,7 +780,7 @@ If set to 1, doing a > < will open up a "secondary" NERD tree instead of a netrw in the target window. -Secondary NERD trees behaves slighly different from a regular trees in the +Secondary NERD trees behaves slightly different from a regular trees in the following respects: 1. 'o' will open the selected file in the same window as the tree, replacing it. diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 0d37b478..5b845d81 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -67,7 +67,7 @@ function! s:Bookmark.BookmarkNames() endfunction " FUNCTION: Bookmark.CacheBookmarks(silent) {{{1 -" Class method to read all bookmarks from the bookmarks file intialize +" Class method to read all bookmarks from the bookmarks file initialize " bookmark objects for each one. " " Args: From 2ebe28468b8c4fcc7270d5710edbaf7b66dfcf85 Mon Sep 17 00:00:00 2001 From: Stephan Klinger Date: Tue, 28 May 2013 00:20:15 +0300 Subject: [PATCH 112/680] Fixed typo in NERD_tree.txt --- doc/NERD_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..50d99089 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -358,7 +358,7 @@ Default key: O Map option: NERDTreeMapOpenRecursively Applies to: directories. -Recursively opens the selelected directory. +Recursively opens the selected directory. All files and directories are cached, but if a directory would not be displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the From 5b51f9d1ba095dfca1e614a26b0bb2d86a0336f3 Mon Sep 17 00:00:00 2001 From: Anton Nizhegorodov Date: Mon, 22 Jul 2013 00:29:03 +0300 Subject: [PATCH 113/680] Fix help mistake --- doc/NERD_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..a91a5326 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -109,7 +109,7 @@ The following features and functionality are provided by the NERD tree: < :NERDTreeFromBookmark *:NERDTreeFromBookmark* Opens a fresh NERD tree with the root initialized to the dir for - . This only reason to use this command over :NERDTree is for + . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). :NERDTreeToggle [ | ] *:NERDTreeToggle* From eacd5d72ecde909c2214427733c8750a5c38c891 Mon Sep 17 00:00:00 2001 From: Danielle Sucher Date: Tue, 8 Oct 2013 00:25:27 -0400 Subject: [PATCH 114/680] Create nested parent directories as needed Allows the user to create or copy a nested node in a single step with ma or mc, recursively creating nested parent directories if needed, and without throwing any errors if they already exist. [Finishes #163, #34] --- lib/nerdtree/path.vim | 17 +++++++++++++++++ nerdtree_plugin/fs_menu.vim | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 58bb0138..6cd8c809 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -141,6 +141,7 @@ function! s:Path.Create(fullpath) "assume its a file and create else + call s:Path.createParentDirectories(a:fullpath) call writefile([], a:fullpath) endif catch @@ -161,6 +162,8 @@ function! s:Path.copy(dest) throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS" endif + call s:Path.createParentDirectories(a:dest) + let dest = s:Path.WinToUnixPath(a:dest) let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), nerdtree#escChars()) . " " . escape(dest, nerdtree#escChars()) @@ -197,6 +200,20 @@ function! s:Path.copyingWillOverwrite(dest) endif endfunction +"FUNCTION: Path.createParentDirectories(path) {{{1 +" +"create parent directories for this path if needed +"without throwing any errors is those directories already exist +" +"Args: +"path: full path of the node whose parent directories may need to be created +function! s:Path.createParentDirectories(path) + let dir_path = fnamemodify(a:path, ':h') + if !isdirectory(dir_path) + call mkdir(dir_path, 'p') + endif +endfunction + "FUNCTION: Path.delete() {{{1 " "Deletes the file represented by this path. diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9b81ed37..f36b31b4 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -114,7 +114,10 @@ function! NERDTreeAddNode() let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) let newTreeNode = g:NERDTreeFileNode.New(newPath) - if parentNode.isOpen || !empty(parentNode.children) + if empty(parentNode) + call b:NERDTreeRoot.refresh() + call nerdtree#renderView() + elseif parentNode.isOpen || !empty(parentNode.children) call parentNode.addChild(newTreeNode, 1) call NERDTreeRender() call newTreeNode.putCursorHere(1, 0) @@ -224,7 +227,10 @@ function! NERDTreeCopyNode() if confirmed try let newNode = currentNode.copy(newNodePath) - if !empty(newNode) + if empty(newNode) + call b:NERDTreeRoot.refresh() + call nerdtree#renderView() + else call NERDTreeRender() call newNode.putCursorHere(0, 0) endif From 24561ad59c092f245264135cb24895b3dab1da26 Mon Sep 17 00:00:00 2001 From: Rickard Karlsson Date: Tue, 5 Nov 2013 12:17:28 +0100 Subject: [PATCH 115/680] Ugly hack to fix Error 121 when NERDTree is the active window and clicking on the command line below another window. --- lib/nerdtree/key_map.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 86457652..e2370762 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -79,6 +79,9 @@ endfunction "If a keymap has the scope of "all" then it will be called if no other keymap "is found for a:key and the scope. function! s:KeyMap.Invoke(key) + if !exists('b:NERDTreeRoot') + return {} + endif let node = g:NERDTreeFileNode.GetSelected() if !empty(node) From 4f48af0cb49b4dd24de1b95eabbb51cd3f3f81fe Mon Sep 17 00:00:00 2001 From: Christophe Sicard Date: Wed, 6 Nov 2013 15:41:25 +0100 Subject: [PATCH 116/680] Fix typo --- doc/NERD_tree.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..f78982d4 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1062,8 +1062,8 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* call NERDTreeAddKeyMap({ \ 'key': 'foo', \ 'callback': 'NERDTreeCDHandler', - \ 'quickhelpText': 'echo full path of current node' }) - \ 'scope': 'DirNode' + \ 'quickhelpText': 'echo full path of current node', + \ 'scope': 'DirNode' }) function! NERDTreeCDHandler(dirnode) call a:dirnode.changeToDir() From a50c571929a085c3a91dd2e2d1972c3d6d2b843e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Dec 2013 00:10:46 -0500 Subject: [PATCH 117/680] Add option to respect wildignore --- doc/NERD_tree.txt | 9 +++++++++ lib/nerdtree/tree_dir_node.vim | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..5dd295fc 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -631,6 +631,8 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeIgnore'| Tells the NERD tree which files to ignore. +|'NERDTreeWildIgnore'| Tells the NERD tree to respect |'wildignore'|. + |'NERDTreeBookmarksFile'| Where the bookmarks are stored. |'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse @@ -817,6 +819,13 @@ line: > The file filters can be turned on and off dynamically with the |NERDTree-f| mapping. +------------------------------------------------------------------------------ + *'NERDTreeWildIgnore'* +Values: 0 or 1. +Default: 0. + +If set to 1, the |'wildignore'| setting is respected. + ------------------------------------------------------------------------------ *'NERDTreeBookmarksFile'* Values: a path diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index e3a068ed..d6a7c5f1 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -228,7 +228,7 @@ function! s:TreeDirNode._initChildren(silent) let dir = self.path let globDir = dir.str({'format': 'Glob'}) - if version >= 703 + if version >= 703 && g:NERDTreeWildIgnore let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1) else let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') From ad4ebaac93e3004a8a2f888c9f173e2f500d80e5 Mon Sep 17 00:00:00 2001 From: Yamamoto Yuji Date: Sat, 1 Feb 2014 20:56:40 +0900 Subject: [PATCH 118/680] correct invalid reference to MenuController I found an error when I tried to use [git_menu.vim](g:NERDTreeMenuController): ``` Error detected while processing function nerdtree#invokeKeyMap..91..90..52_showMenu..65..82: line 2: E121: Undefined variable: s:MenuController E15: Invalid expression: s:MenuController.New(self.children) line 3: E121: Undefined variable: mc ``` I searched the line at which it happened then, I found that `s:MenuController` is not defined in `menu_item.vim` but in menu_controller.vim . So I corrected the name to refer to MenuController. --- lib/nerdtree/menu_item.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/menu_item.vim b/lib/nerdtree/menu_item.vim index 6fb9d9e3..92c1bbbf 100644 --- a/lib/nerdtree/menu_item.vim +++ b/lib/nerdtree/menu_item.vim @@ -90,7 +90,7 @@ endfunction "callback function! s:MenuItem.execute() if len(self.children) - let mc = s:MenuController.New(self.children) + let mc = g:NERDTreeMenuController.New(self.children) call mc.showMenu() else if self.callback != -1 From 13b4058f2f9a352857b566d1872cb503954abb22 Mon Sep 17 00:00:00 2001 From: aramasamy Date: Fri, 21 Feb 2014 00:46:15 +0000 Subject: [PATCH 119/680] Issue 315 - Incorrect buffer deleted on file delete --- nerdtree_plugin/fs_menu.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9b81ed37..242b386b 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -138,7 +138,7 @@ function! NERDTreeMoveNode() endif try - let bufnum = bufnr(curNode.path.str()) + let bufnum = bufnr("^".curNode.path.str()."$") call curNode.rename(newNodePath) call NERDTreeRender() @@ -186,7 +186,7 @@ function! NERDTreeDeleteNode() "if the node is open in a buffer, ask the user if they want to "close that buffer - let bufnum = bufnr(currentNode.path.str()) + let bufnum = bufnr("^".currentNode.path.str()."$") if buflisted(bufnum) let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" call s:promptToDelBuffer(bufnum, prompt) From 603e6c74f2b5a2a842c5b005c7c1d7030fc54d30 Mon Sep 17 00:00:00 2001 From: Miguel de Val-Borro Date: Tue, 8 Apr 2014 13:03:50 -0400 Subject: [PATCH 120/680] Use pathogen.vim Helptags command in README file --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index e6178091..e9bb313c 100644 --- a/README.markdown +++ b/README.markdown @@ -60,7 +60,7 @@ Installation cd ~/.vim/bundle git clone https://github.com/scrooloose/nerdtree.git -Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`. +Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. Faq From e38d8a8340242cb33a5add2b1ff4270b04ed78de Mon Sep 17 00:00:00 2001 From: Jinn Koriech Date: Thu, 24 Apr 2014 15:51:55 +0100 Subject: [PATCH 121/680] Add flag to disable/enable bookmark sorting The bookmarks are normally sorted, however with a newly introduced flag this can be disabled. --- doc/NERD_tree.txt | 11 +++++++++++ lib/nerdtree/bookmark.vim | 8 ++++++-- plugin/NERD_tree.vim | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..532dc433 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -633,6 +633,9 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeBookmarksFile'| Where the bookmarks are stored. +|'NERDTreeBookmarksSort'| Whether the bookmarks list is sorted on + display. + |'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse clicks. @@ -824,6 +827,14 @@ Default: $HOME/.NERDTreeBookmarks This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. +------------------------------------------------------------------------------ + *'NERDTreeBookmarksSort'* +Values: 0 or 1 +Default: 1 + +If set to 0 then the bookmarks list is not sorted. +If set to 1 the bookmarks list is sorted. + ------------------------------------------------------------------------------ *'NERDTreeMouseMode'* Values: 1, 2 or 3. diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 5b845d81..84a6099f 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -19,7 +19,9 @@ function! s:Bookmark.AddBookmark(name, path) endif endfor call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) - call s:Bookmark.Sort() + if g:NERDTreeBookmarksSort ==# 1 + call s:Bookmark.Sort() + endif endfunction " FUNCTION: Bookmark.Bookmarks() {{{1 @@ -101,7 +103,9 @@ function! s:Bookmark.CacheBookmarks(silent) call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") endif endif - call s:Bookmark.Sort() + if g:NERDTreeBookmarksSort ==# 1 + call s:Bookmark.Sort() + endif endif endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 5bee03ad..fa257972 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -55,6 +55,7 @@ if !exists("g:NERDTreeIgnore") let g:NERDTreeIgnore = ['\~$'] endif call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') +call s:initVariable("g:NERDTreeBookmarksSort", 1) call s:initVariable("g:NERDTreeHighlightCursorline", 1) call s:initVariable("g:NERDTreeHijackNetrw", 1) call s:initVariable("g:NERDTreeMouseMode", 1) From fbab099fa9ed17c3709931c00fd742d12566872b Mon Sep 17 00:00:00 2001 From: Tristan Koch Date: Fri, 30 May 2014 13:05:37 +0200 Subject: [PATCH 122/680] Support space in path when renaming --- nerdtree_plugin/fs_menu.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9b81ed37..c3ecd5df 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -82,13 +82,14 @@ endfunction function! s:promptToRenameBuffer(bufnum, msg, newFileName) echo a:msg if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + let quotedFileName = "'" . a:newFileName . "'" " 1. ensure that a new buffer is loaded - exec "badd " . a:newFileName + exec "badd " . quotedFileName " 2. ensure that all windows which display the just deleted filename " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . a:newFileName . "' | endif" + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec \":e! " . quotedFileName . "\" | endif" exec "tabnext " . s:originalTabNumber exec s:originalWindowNumber . "wincmd w" " 3. We don't need a previous buffer anymore From 43842e0de5edb6764dfb3e2aa5df61e450ed3b31 Mon Sep 17 00:00:00 2001 From: Jaeho Shin Date: Mon, 9 Jun 2014 03:06:59 -0700 Subject: [PATCH 123/680] Option for mixing dot files when sorting NERDTree can now optionally ignore the dot at the beginning of hidden filenames for sorting to show them next to normal files if `g:NERDTreeSortHiddenFirst` is set to 0. (By default it's set to 1 to preserve the current behavior.) This is just like what GNU ls does when `LC_COLLATE` environment variable is set to `en_US`. --- doc/NERD_tree.txt | 4 ++++ lib/nerdtree/path.vim | 4 ++++ plugin/NERD_tree.vim | 1 + 3 files changed, 9 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf038962..f1abb885 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -620,6 +620,10 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case sensitive or not when sorting nodes. +|'NERDTreeSortHiddenFirst'| Tells the NERD tree whether to take the dot + at the beginning of the hidden file names + into account when sorting nodes. + |'NERDTreeChDirMode'| Tells the NERD tree if/when it should change vim's current working directory. diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 58bb0138..72a230b6 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -103,6 +103,10 @@ function! s:Path.compareTo(path) elseif thisSS > thatSS return 1 else + if !g:NERDTreeSortHiddenFirst + let thisPath = substitute(thisPath, '^[._]', '', '') + let thatPath = substitute(thatPath, '^[._]', '', '') + endif "if the sort sequences are the same then compare the paths "alphabetically let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath Date: Thu, 26 Jun 2014 10:01:15 +0100 Subject: [PATCH 124/680] rename NERDTreeWildIgnore option and refactor the usage of it Rename it to the more intention revealing NERDTreeRespectWildIgnore. Use it directly in the `globpath()` call rather than surrounding if statement. Its subjective, but I find this clearer. Add an initializer for the option. --- doc/NERD_tree.txt | 4 ++-- lib/nerdtree/tree_dir_node.vim | 4 ++-- plugin/NERD_tree.vim | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 99814ba8..459f3916 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -635,7 +635,7 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeIgnore'| Tells the NERD tree which files to ignore. -|'NERDTreeWildIgnore'| Tells the NERD tree to respect |'wildignore'|. +|'NERDTreeRespectWildIgnore'| Tells the NERD tree to respect |'wildignore'|. |'NERDTreeBookmarksFile'| Where the bookmarks are stored. @@ -827,7 +827,7 @@ The file filters can be turned on and off dynamically with the |NERDTree-f| mapping. ------------------------------------------------------------------------------ - *'NERDTreeWildIgnore'* + *'NERDTreeRespectWildIgnore'* Values: 0 or 1. Default: 0. diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index d6a7c5f1..3d23ccaf 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -228,8 +228,8 @@ function! s:TreeDirNode._initChildren(silent) let dir = self.path let globDir = dir.str({'format': 'Glob'}) - if version >= 703 && g:NERDTreeWildIgnore - let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1) + if version >= 703 + let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore) else let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') endif diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c3b9dfd6..3b7db11b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -62,6 +62,7 @@ call s:initVariable("g:NERDTreeHijackNetrw", 1) call s:initVariable("g:NERDTreeMouseMode", 1) call s:initVariable("g:NERDTreeNotificationThreshold", 100) call s:initVariable("g:NERDTreeQuitOnOpen", 0) +call s:initVariable("g:NERDTreeRespectWildIgnore", 0) call s:initVariable("g:NERDTreeShowBookmarks", 0) call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) From 1168f5898723d9857671c9d9e2bbceb602b7c323 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 27 Jun 2014 19:29:38 +0100 Subject: [PATCH 125/680] update the NERDTreeCascadeOpenSingleChildDir doc --- doc/NERD_tree.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 3930d8ff..2458d11a 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1017,9 +1017,9 @@ Default: 1. When opening dir nodes, this option tells NERDTree to recursively open dirs that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. Set this option on also -cause NERDTree close parent dir intelligent. This option may be useful for Java -projects. Use one of the follow lines to set this option: > +a dir that contains anything but another single dir. This option also causes +the |NERDTree-x| mapping to close dirs in the same manner. This option may be +useful for Java projects. Use one of the follow lines to set this option: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < From 0b1166ff7878ec510f4ce6cbdd336de549141f6a Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2014 12:29:49 +0100 Subject: [PATCH 126/680] update code in readme to auto-open a tree on startup Closes #242 --- README.markdown | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index e9bb313c..bfae5c68 100644 --- a/README.markdown +++ b/README.markdown @@ -80,7 +80,10 @@ A. Stick this in your vimrc: `autocmd vimenter * NERDTree` __Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__ -A. Stick this in your vimrc `autocmd vimenter * if !argc() | NERDTree | endif` +A. Stick this in your vimrc + + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if !argc() == 0 && !exists("s:std_in") | NERDTree | endif __Q. How can I map a specific key or shortcut to open NERDTree?__ From 55a8954c48d94c207facb1a0ba109a427b15bcbf Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2014 12:37:29 +0100 Subject: [PATCH 127/680] update the doc/quickhelp for :Bookmark Make it clearer that the argument is optional. Closes #229 --- autoload/nerdtree.vim | 2 +- doc/NERD_tree.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index c440bf87..35919320 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -513,7 +513,7 @@ function! nerdtree#dumpHelp() let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n" let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Bookmark commands~\n" - let @h=@h."\" :Bookmark \n" + let @h=@h."\" :Bookmark []\n" let @h=@h."\" :BookmarkToRoot \n" let @h=@h."\" :RevealBookmark \n" let @h=@h."\" :OpenBookmark \n" diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 2458d11a..6e83423c 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -160,7 +160,7 @@ click bookmarks or use the |NERDTree-o| mapping to activate them. See also, Note that the following commands are only available in the NERD tree buffer. -:Bookmark +:Bookmark [] Bookmark the current node as . If there is already a bookmark, it is overwritten. must not contain spaces. If is not provided, it defaults to the file or directory name. From 9704a38a14854aa282748d18cb3042c7f3ebd01a Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2014 16:14:51 +0100 Subject: [PATCH 128/680] update symlink highlighting Previously we highlighted symlinks as one item (NERDTreeLink): symlinked_file -> /path/to/target Split this out into 3 highlight groups: * NERDTreeLinkFile * NERDTreeLinkDir * NERDTreeLinkTarget So we have: symlinked_dir/ -> /foo/bar -------------- *********** ^ ^ | | NERDTreeLinkDir NERDTreeLinkTarget Similarly for file links - with NERDTreeLinkFile instead of NERDTreeLinkDir. This allows users to modify how symlinks are highlighted. E.g. to make them appear as normal files/dirs they could add this to their vimrc: hi link NERDTreeLinkFile NERDTreeFile hi link NERDTreeLinkDir NERDTreeDir hi link NERDTreeLinkTarget ignore --- syntax/nerdtree.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 636d2af7..87fdfb83 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -31,14 +31,16 @@ syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTr syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile "highlighting for sym links -syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash +syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile +syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile +syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# -syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable -syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark -syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile -syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile +syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable +syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark +syn match NERDTreeFile #|-.*# contains=NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile +syn match NERDTreeFile #`-.*# contains=NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile syn match NERDTreeCWD #^[ Date: Sun, 29 Jun 2014 18:17:19 +0100 Subject: [PATCH 129/680] separate out syntax matching for Dir Arrows vs old style --- syntax/nerdtree.vim | 58 +++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 636d2af7..cc961f56 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -7,17 +7,6 @@ syn match NERDTreeFlag #\[RO\]# "highlighting for the .. (up dir) line at the top of the tree execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" -"highlighting for the ~/+ symbols for the directory nodes -syn match NERDTreeClosable #\~\<# -syn match NERDTreeClosable #\~\.# -syn match NERDTreeOpenable #+\<# -syn match NERDTreeOpenable #+\.#he=e-1 - -"highlighting for the tree structural parts -syn match NERDTreePart #|# -syn match NERDTreePart #`# -syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart - "quickhelp syntax elements syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 @@ -30,15 +19,40 @@ syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTr "highlighting for readonly files syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile -"highlighting for sym links -syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash - "highlighing for directory nodes and file nodes -syn match NERDTreeDirSlash #/# -syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable -syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark -syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile -syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +if g:NERDTreeDirArrows + syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile + syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile + + syn match NERDTreeDir #[^▾▸ ].*/# contains=NERDTreeLink + syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeLink,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark + syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + + "highlighting for sym links + syn match NERDTreeLink #^ *[^▾▸]* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash +else + "highlighting for the ~/+ symbols for the directory nodes + syn match NERDTreeClosable #\~\<# + syn match NERDTreeClosable #\~\.# + syn match NERDTreeOpenable #+\<# + syn match NERDTreeOpenable #+\.#he=e-1 + + "highlighting for the tree structural parts + syn match NERDTreePart #|# + syn match NERDTreePart #`# + syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + + syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable + syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark + syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + + "highlighting for sym links + syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash +endif + syn match NERDTreeCWD #^[.*$# contains=NERDTreeBookmarksLeader,NERDTreeBook if exists("g:NERDChristmasTree") && g:NERDChristmasTree hi def link NERDTreePart Special hi def link NERDTreePartFile Type - hi def link NERDTreeFile Normal hi def link NERDTreeExecFile Title hi def link NERDTreeDirSlash Identifier - hi def link NERDTreeClosable Type else hi def link NERDTreePart Normal hi def link NERDTreePartFile Normal - hi def link NERDTreeFile Normal - hi def link NERDTreeClosable Title endif hi def link NERDTreeBookmarksHeader statement @@ -78,9 +88,11 @@ hi def link NERDTreeToggleOff WarningMsg hi def link NERDTreeDir Directory hi def link NERDTreeUp Directory +hi def link NERDTreeFile Normal hi def link NERDTreeCWD Statement hi def link NERDTreeLink Macro hi def link NERDTreeOpenable Title +hi def link NERDTreeClosable Title hi def link NERDTreeFlag ignore hi def link NERDTreeRO WarningMsg hi def link NERDTreeBookmark Statement From abb93879bb758d609b3dc1126e10ce50f1f3a0d4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2014 18:40:11 +0100 Subject: [PATCH 130/680] simplify the syntax matching code slightly --- syntax/nerdtree.vim | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7b2e9204..c7f925d0 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -8,16 +8,16 @@ syn match NERDTreeFlag #\[RO\]# execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" "quickhelp syntax elements -syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 -syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 -syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag -syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey -syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 +syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1 +syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 +syn match NERDTreeToggleOff #(off)#hs=e-3,he=e-1 syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand "highlighting for readonly files -syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile +syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart "highlighting for sym links syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile @@ -31,12 +31,9 @@ if g:NERDTreeDirArrows syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeDir #[^▾▸ ].*/# contains=NERDTreeLink - syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeLink,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - - "highlighting for sym links - syn match NERDTreeLink #^ *[^▾▸]* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash + syn match NERDTreeDir #[^▾▸ ].*/# + syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark + syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile else "highlighting for the ~/+ symbols for the directory nodes syn match NERDTreeClosable #\~\<# @@ -47,15 +44,12 @@ else "highlighting for the tree structural parts syn match NERDTreePart #|# syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart containedin=NERDTreeRO syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - - "highlighting for sym links - syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash endif syn match NERDTreeCWD #^[ Date: Sun, 29 Jun 2014 19:53:57 +0100 Subject: [PATCH 131/680] remove the NERDChristmasTree option If users want to customise the tree colours, this can be done trivially in their vimrc. e.g. hi link NERDTreeFile error --- doc/NERD_tree.txt | 13 +------------ plugin/NERD_tree.vim | 1 - syntax/nerdtree.vim | 13 ++++--------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 6e83423c..4ddc2507 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -609,12 +609,10 @@ NERD tree. These options should be set in your vimrc. |'loaded_nerd_tree'| Turns off the script. -|'NERDChristmasTree'| Tells the NERD tree to make itself colourful - and pretty. - |'NERDTreeAutoCenter'| Controls whether the NERD tree window centers when the cursor moves within a specified distance to the top/bottom of the window. + |'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering. |'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case @@ -695,15 +693,6 @@ If this plugin is making you feel homicidal, it may be a good idea to turn it off with this line in your vimrc: > let loaded_nerd_tree=1 < ------------------------------------------------------------------------------- - *'NERDChristmasTree'* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then some extra syntax highlighting elements are -added to the nerd tree to make it more colourful. - -Set it to 0 for a more vanilla looking tree. ------------------------------------------------------------------------------ *'NERDTreeAutoCenter'* diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b2c7c699..cbfa884e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -45,7 +45,6 @@ function! s:initVariable(var, value) endfunction "SECTION: Init variable calls and other random constants {{{2 -call s:initVariable("g:NERDChristmasTree", 1) call s:initVariable("g:NERDTreeAutoCenter", 1) call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index c7f925d0..8b82f32a 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -63,15 +63,10 @@ syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmark syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader -if exists("g:NERDChristmasTree") && g:NERDChristmasTree - hi def link NERDTreePart Special - hi def link NERDTreePartFile Type - hi def link NERDTreeExecFile Title - hi def link NERDTreeDirSlash Identifier -else - hi def link NERDTreePart Normal - hi def link NERDTreePartFile Normal -endif +hi def link NERDTreePart Special +hi def link NERDTreePartFile Type +hi def link NERDTreeExecFile Title +hi def link NERDTreeDirSlash Identifier hi def link NERDTreeBookmarksHeader statement hi def link NERDTreeBookmarksLeader ignore From e68e12a33b2dd05be4459a794e511a02ac6038bd Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2014 21:44:19 +0100 Subject: [PATCH 132/680] fix highlighting for readonly files --- syntax/nerdtree.vim | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 8b82f32a..5ab1f8c6 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -16,9 +16,6 @@ syn match NERDTreeToggleOff #(off)#hs=e-3,he=e-1 syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand -"highlighting for readonly files -syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart - "highlighting for sym links syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile @@ -31,9 +28,12 @@ if g:NERDTreeDirArrows syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeDir #[^▾▸ ].*/# - syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + "syn match NERDTreeDir #[^▾▸ ].*/# + "syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark + "syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + + "highlighting for readonly files + syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeFlag,NERDTreeBookmark,NERDTreeFile else "highlighting for the ~/+ symbols for the directory nodes syn match NERDTreeClosable #\~\<# @@ -44,12 +44,15 @@ else "highlighting for the tree structural parts syn match NERDTreePart #|# syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart containedin=NERDTreeRO + syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable - syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark + syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + + "highlighting for readonly files + syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile endif syn match NERDTreeCWD #^[ Date: Sun, 29 Jun 2014 21:44:40 +0100 Subject: [PATCH 133/680] trivial highlighting update for consistency --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 5ab1f8c6..8765ee1a 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -12,7 +12,7 @@ syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1 syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 -syn match NERDTreeToggleOff #(off)#hs=e-3,he=e-1 +syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1 syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand From b64942a500a2a08def1293567af48267f3abc53c Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 30 Jun 2014 09:40:51 +0100 Subject: [PATCH 134/680] uncomment out some needed syntax matching code... fail --- syntax/nerdtree.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 8765ee1a..7cbba6ee 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -28,9 +28,9 @@ if g:NERDTreeDirArrows syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile - "syn match NERDTreeDir #[^▾▸ ].*/# - "syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - "syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeDir #[^▾▸ ].*/# + syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark + syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile "highlighting for readonly files syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeFlag,NERDTreeBookmark,NERDTreeFile From 82cd4f5a9f93bb0a7b5fd901d99bf3302389b9a2 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Jul 2014 20:29:52 -0400 Subject: [PATCH 135/680] Fix not working if active node map is special char such as --- lib/nerdtree/creator.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 19c51ffb..d76452c8 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -7,8 +7,8 @@ let g:NERDTreeCreator = s:Creator "FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() - "make do the same as the default 'o' mapping - exec "nnoremap :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')" + "make do the same as the activate node mapping + exec "nnoremap :call nerdtree#invokeKeyMap(g:NERDTreeMapActivateNode)" call g:NERDTreeKeyMap.BindAll() From 0ee888ee17cbc8a452bd69f34e8ca6c0788b3124 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 2 Jul 2014 20:25:17 +0100 Subject: [PATCH 136/680] simplify the mapping definition --- lib/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index d76452c8..b1a617fe 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -8,7 +8,7 @@ let g:NERDTreeCreator = s:Creator "FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() "make do the same as the activate node mapping - exec "nnoremap :call nerdtree#invokeKeyMap(g:NERDTreeMapActivateNode)" + nnoremap :call nerdtree#invokeKeyMap(g:NERDTreeMapActivateNode) call g:NERDTreeKeyMap.BindAll() From d162c08fd7fa618d0f576a02134a54799adbc772 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 2 Jul 2014 20:54:14 +0100 Subject: [PATCH 137/680] comment and tweak the fix in 24561ad --- lib/nerdtree/key_map.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index e2370762..ee099fa9 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -79,9 +79,16 @@ endfunction "If a keymap has the scope of "all" then it will be called if no other keymap "is found for a:key and the scope. function! s:KeyMap.Invoke(key) - if !exists('b:NERDTreeRoot') + + "required because clicking the command window below another window still + "invokes the mapping - but changes the window cursor + "is in first + " + "TODO: remove this check when the vim bug is fixed + if !nerdtree#treeExistsForBuf() return {} endif + let node = g:NERDTreeFileNode.GetSelected() if !empty(node) From 04ac39b4b92262935cdd76299dc6476f74915245 Mon Sep 17 00:00:00 2001 From: Keith Laban Date: Wed, 2 Jul 2014 19:46:03 -0400 Subject: [PATCH 138/680] Fixes README for opening vim with no files --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index bfae5c68..9dacf682 100644 --- a/README.markdown +++ b/README.markdown @@ -83,7 +83,7 @@ __Q. How can I open a NERDTree automatically when vim starts up if no files were A. Stick this in your vimrc autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if !argc() == 0 && !exists("s:std_in") | NERDTree | endif + autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif __Q. How can I map a specific key or shortcut to open NERDTree?__ From a7428eba38fcd23a50f1cf5c26938c68ffd62673 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jul 2014 00:29:45 +0100 Subject: [PATCH 139/680] add proof of concept for path flags API and add git modified flags --- autoload/nerdtree.vim | 4 ++ lib/nerdtree/creator.vim | 6 +-- lib/nerdtree/path.vim | 32 ++++++++++++++- lib/nerdtree/refresh_notifier.vim | 21 ++++++++++ lib/nerdtree/tree_dir_node.vim | 1 + nerdtree_plugin/git.vim | 65 +++++++++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 lib/nerdtree/refresh_notifier.vim create mode 100644 nerdtree_plugin/git.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 35919320..4139787b 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -238,6 +238,7 @@ function! nerdtree#loadClassFiles() runtime lib/nerdtree/tree_dir_node.vim runtime lib/nerdtree/opener.vim runtime lib/nerdtree/creator.vim + runtime lib/nerdtree/refresh_notifier.vim endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 @@ -941,6 +942,9 @@ function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) "strip off any executable flags let line = substitute (line, '*\ze\($\| \)', "","") + "strip off any generic flags + let line = substitute (line, '\[[^]]*\]', "","") + let wasdir = 0 if line =~# '/$' let wasdir = 1 diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index b1a617fe..cf1c402d 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -56,17 +56,17 @@ function! s:Creator.createPrimary(name) unlet t:NERDTreeBufName endif + call self._createTreeWin() let newRoot = g:NERDTreeDirNode.New(path) + let b:NERDTreeRoot = newRoot + let b:NERDTreeType = "primary" call newRoot.open() - call self._createTreeWin() let b:treeShowHelp = 0 let b:NERDTreeIgnoreEnabled = 1 let b:NERDTreeShowFiles = g:NERDTreeShowFiles let b:NERDTreeShowHidden = g:NERDTreeShowHidden let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - let b:NERDTreeRoot = newRoot - let b:NERDTreeType = "primary" call nerdtree#renderView() call b:NERDTreeRoot.putCursorHere(0, 0) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 047a72a6..e034c861 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -24,6 +24,13 @@ function! s:Path.AbsolutePathFor(str) return toReturn endfunction +"FUNCTION: Path.addFlag(flag) {{{1 +function! s:Path.addFlag(flag) + if index(self._flags, a:flag) == -1 + call add(self._flags, a:flag) + endif +endfunction + "FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() if !exists("self._bookmarkNames") @@ -33,8 +40,10 @@ function! s:Path.bookmarkNames() endfunction "FUNCTION: Path.cacheDisplayString() {{{1 -function! s:Path.cacheDisplayString() - let self.cachedDisplayString = self.getLastPathComponent(1) +function! s:Path.cacheDisplayString() abort + let self.cachedDisplayString = self._flagString() + + let self.cachedDisplayString .= self.getLastPathComponent(1) if self.isExecutable let self.cachedDisplayString = self.cachedDisplayString . '*' @@ -350,6 +359,15 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction +"FUNCTION: Path._flagString() {{{1 +function! s:Path._flagString() + if empty(self._flags) + return "" + endif + + return '[' . join(self._flags, ',') . ']' +endfunction + "FUNCTION: Path.isUnixHiddenFile() {{{1 "check for unix hidden files function! s:Path.isUnixHiddenFile() @@ -460,6 +478,7 @@ function! s:Path.New(path) call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path)) let newPath.cachedDisplayString = "" + let newPath._flags = [] return newPath endfunction @@ -480,6 +499,14 @@ function! s:Path.Resolve(path) return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp endfunction +"FUNCTION: Path.removeFlag(flag) {{{1 +function! s:Path.removeFlag(flag) + let i = index(self._flags, a:flag) + if i >= 0 + call remove(self._flags, i) + endif +endfunction + "FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 " " @@ -537,6 +564,7 @@ endfunction "FUNCTION: Path.refresh() {{{1 function! s:Path.refresh() call self.readInfoFromDisk(self.str()) + call g:NERDTreeRefreshNotifier.NotifyListeners(self) call self.cacheDisplayString() endfunction diff --git a/lib/nerdtree/refresh_notifier.vim b/lib/nerdtree/refresh_notifier.vim new file mode 100644 index 00000000..0cc62b05 --- /dev/null +++ b/lib/nerdtree/refresh_notifier.vim @@ -0,0 +1,21 @@ +"CLASS: RefreshNotifier +"============================================================ +let s:RefreshNotifier = {} +let g:NERDTreeRefreshNotifier = s:RefreshNotifier + +function! s:RefreshNotifier.AddListener(funcname) + call add(s:RefreshNotifier.GetListeners(), a:funcname) +endfunction + +function! s:RefreshNotifier.NotifyListeners(refreshedPath) + for listener in s:RefreshNotifier.GetListeners() + call {listener}(a:refreshedPath) + endfor +endfunction + +function! s:RefreshNotifier.GetListeners() + if !exists("s:refreshListeners") + let s:refreshListeners = [] + endif + return s:refreshListeners +endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 520fca6a..bf93c1d7 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -252,6 +252,7 @@ function! s:TreeDirNode._initChildren(silent) try let path = g:NERDTreePath.New(i) call self.createChild(path, 0) + call g:NERDTreeRefreshNotifier.NotifyListeners(path) catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound += 1 endtry diff --git a/nerdtree_plugin/git.vim b/nerdtree_plugin/git.vim new file mode 100644 index 00000000..615ebc0e --- /dev/null +++ b/nerdtree_plugin/git.vim @@ -0,0 +1,65 @@ +" ============================================================================ +" File: git.vim +" Description: Expt. plugin to add git flags to the UI +" Maintainer: +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ +if exists("g:loaded_nerdtree_git") + finish +endif +let g:loaded_nerdtree_git = 1 + +call g:NERDTreeRefreshNotifier.AddListener("g:NERDTreeGitRefreshListener") + +function! g:NERDTreeGitRefreshListener(path) + if !isdirectory(b:NERDTreeRoot.path.str() . '/.git') + return + end + + let modifiedFiles = s:GetModifiedFiles() + if index(modifiedFiles, a:path.str()) >= 0 + call a:path.addFlag("+") + else + call a:path.removeFlag("+") + endif +endfunction + +"Cache the list of modified files for a few seconds - otherwise we must shell +"out to get it for every path that is refreshed which takes ages +function! s:GetModifiedFiles() + if !exists('s:modifiedFiles') || (localtime() - s:modifiedFilesTime > 2) + let s:modifiedFiles = split(system('git -C ' . b:NERDTreeRoot.path.str() . ' ls-files -m')) + let s:modifiedFilesTime = localtime() + call map(s:modifiedFiles, 'b:NERDTreeRoot.path.str() . "/" . v:val') + endif + + return s:modifiedFiles +endfunction + +autocmd filetype nerdtree call s:AddHighlighting() +function! s:AddHighlighting() + syn match NERDTreeGitflag #^ *\zs\[+\]# containedin=NERDTreeFile + hi link NERDTreeGitFlag error +endfunction + +"when a buffer is saved, refresh it in nerdtree +autocmd bufwritepost * call s:FileUpdated(expand("%")) +function! s:FileUpdated(fname) + if !nerdtree#isTreeOpen() + return + endif + + call nerdtree#putCursorInTreeWin() + let node = b:NERDTreeRoot.findNode(g:NERDTreePath.New(a:fname)) + if !empty(node) + call node.refresh() + endif + + call NERDTreeRender() +endfunction + From 32cf3ee62d6ce722238525e3a0ea98a93f9297e2 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 5 Jul 2014 20:51:21 +0100 Subject: [PATCH 140/680] allow flags to be scoped to a plugin Add new FlagSet class and init each Path with one. Call Path.flagSet.addFlag(scope, flag) instead of Path.addFlag(flag) --- autoload/nerdtree.vim | 1 + lib/nerdtree/flag_set.vim | 56 +++++++++++++++++++++++++++++++++++++++ lib/nerdtree/path.vim | 28 ++------------------ nerdtree_plugin/git.vim | 4 +-- 4 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 lib/nerdtree/flag_set.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 4139787b..72e820cd 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -239,6 +239,7 @@ function! nerdtree#loadClassFiles() runtime lib/nerdtree/opener.vim runtime lib/nerdtree/creator.vim runtime lib/nerdtree/refresh_notifier.vim + runtime lib/nerdtree/flag_set.vim endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 diff --git a/lib/nerdtree/flag_set.vim b/lib/nerdtree/flag_set.vim new file mode 100644 index 00000000..f9d36add --- /dev/null +++ b/lib/nerdtree/flag_set.vim @@ -0,0 +1,56 @@ +"CLASS: FlagSet +"============================================================ +let s:FlagSet = {} +let g:NERDTreeFlagSet = s:FlagSet + +"FUNCTION: FlagSet.addFlag(scope, flag) {{{1 +function! s:FlagSet.addFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + if index(flags, a:flag) == -1 + call add(flags, a:flag) + end +endfunction + +"FUNCTION: FlagSet.clearFlags(scope) {{{1 +function! s:FlagSet.clearFlags(scope, flag) + let self._flags[a:scope] = [] +endfunction + +"FUNCTION: FlagSet._flagsForScope(scope) {{{1 +function! s:FlagSet._flagsForScope(scope) + if !has_key(self._flags, a:scope) + let self._flags[a:scope] = [] + endif + return self._flags[a:scope] +endfunction + +"FUNCTION: FlagSet.New() {{{1 +function! s:FlagSet.New() + let newObj = copy(self) + let newObj._flags = {} + return newObj +endfunction + +"FUNCTION: FlagSet.removeFlag(scope, flag) {{{1 +function! s:FlagSet.removeFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + + let i = index(flags, a:flag) + if i >= 0 + call remove(flags, i) + endif +endfunction + +"FUNCTION: FlagSet.renderToString() {{{1 +function! s:FlagSet.renderToString() + let flagstring = "" + for i in values(self._flags) + let flagstring .= join(i) + endfor + + if len(flagstring) == 0 + return "" + endif + + return '[' . flagstring . ']' +endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index e034c861..bfc72f1c 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -24,13 +24,6 @@ function! s:Path.AbsolutePathFor(str) return toReturn endfunction -"FUNCTION: Path.addFlag(flag) {{{1 -function! s:Path.addFlag(flag) - if index(self._flags, a:flag) == -1 - call add(self._flags, a:flag) - endif -endfunction - "FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() if !exists("self._bookmarkNames") @@ -41,7 +34,7 @@ endfunction "FUNCTION: Path.cacheDisplayString() {{{1 function! s:Path.cacheDisplayString() abort - let self.cachedDisplayString = self._flagString() + let self.cachedDisplayString = self.flagSet.renderToString() let self.cachedDisplayString .= self.getLastPathComponent(1) @@ -359,15 +352,6 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction -"FUNCTION: Path._flagString() {{{1 -function! s:Path._flagString() - if empty(self._flags) - return "" - endif - - return '[' . join(self._flags, ',') . ']' -endfunction - "FUNCTION: Path.isUnixHiddenFile() {{{1 "check for unix hidden files function! s:Path.isUnixHiddenFile() @@ -478,7 +462,7 @@ function! s:Path.New(path) call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path)) let newPath.cachedDisplayString = "" - let newPath._flags = [] + let newPath.flagSet = g:NERDTreeFlagSet.New() return newPath endfunction @@ -499,14 +483,6 @@ function! s:Path.Resolve(path) return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp endfunction -"FUNCTION: Path.removeFlag(flag) {{{1 -function! s:Path.removeFlag(flag) - let i = index(self._flags, a:flag) - if i >= 0 - call remove(self._flags, i) - endif -endfunction - "FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 " " diff --git a/nerdtree_plugin/git.vim b/nerdtree_plugin/git.vim index 615ebc0e..67dff596 100644 --- a/nerdtree_plugin/git.vim +++ b/nerdtree_plugin/git.vim @@ -23,9 +23,9 @@ function! g:NERDTreeGitRefreshListener(path) let modifiedFiles = s:GetModifiedFiles() if index(modifiedFiles, a:path.str()) >= 0 - call a:path.addFlag("+") + call a:path.flagSet.addFlag("git", "+") else - call a:path.removeFlag("+") + call a:path.flagSet.removeFlag("git", "+") endif endfunction From 3941389f13a36b8b01a81352b07db0e1ce0edb11 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 6 Jul 2014 23:36:45 +0100 Subject: [PATCH 141/680] fix a retarded bug with FlagSet.clearFlags --- lib/nerdtree/flag_set.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/flag_set.vim b/lib/nerdtree/flag_set.vim index f9d36add..9d8d3359 100644 --- a/lib/nerdtree/flag_set.vim +++ b/lib/nerdtree/flag_set.vim @@ -12,7 +12,7 @@ function! s:FlagSet.addFlag(scope, flag) endfunction "FUNCTION: FlagSet.clearFlags(scope) {{{1 -function! s:FlagSet.clearFlags(scope, flag) +function! s:FlagSet.clearFlags(scope) let self._flags[a:scope] = [] endfunction From 04d9b275413680c7d7b1cd52edc48e097a9c65e4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 7 Jul 2014 18:24:37 +0100 Subject: [PATCH 142/680] add `.refreshFlags()` to path/dir/file objects This will trigger the path refresh callbacks without refreshing the path's from disk (which takes ages) --- lib/nerdtree/path.vim | 6 ++++++ lib/nerdtree/tree_dir_node.vim | 9 +++++++++ lib/nerdtree/tree_file_node.vim | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index bfc72f1c..cb94e4f3 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -544,6 +544,12 @@ function! s:Path.refresh() call self.cacheDisplayString() endfunction +"FUNCTION: Path.refreshFlags() {{{1 +function! s:Path.refreshFlags() + call g:NERDTreeRefreshNotifier.NotifyListeners(self) + call self.cacheDisplayString() +endfunction + "FUNCTION: Path.rename() {{{1 " "Renames this node on the filesystem diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index bf93c1d7..5459307f 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -439,6 +439,15 @@ function! s:TreeDirNode.refresh() endif endfunction +"FUNCTION: TreeDirNode.refreshFlags() {{{1 +unlet s:TreeDirNode.refreshFlags +function! s:TreeDirNode.refreshFlags() + call self.path.refreshFlags() + for i in self.children + call i.refreshFlags() + endfor +endfunction + "FUNCTION: TreeDirNode.reveal(path) {{{1 "reveal the given path, i.e. cache and open all treenodes needed to display it "in the UI diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index ab8d3719..5106932e 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -372,6 +372,11 @@ function! s:TreeFileNode.refresh() call self.path.refresh() endfunction +"FUNCTION: TreeFileNode.refreshFlags() {{{1 +function! s:TreeFileNode.refreshFlags() + call self.path.refreshFlags() +endfunction + "FUNCTION: TreeFileNode.rename() {{{1 "Calls the rename method for this nodes path obj function! s:TreeFileNode.rename(newName) From 86488b1aa027f66465e1f740f7d425a30ca98c50 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 7 Jul 2014 19:36:34 +0100 Subject: [PATCH 143/680] move ui functions out into their own autoload All of the autoload shit needs to be cleaned up... break it out first --- autoload/nerdtree.vim | 512 +-------------------------------- autoload/nerdtree/ui_glue.vim | 518 ++++++++++++++++++++++++++++++++++ lib/nerdtree/creator.vim | 8 +- 3 files changed, 523 insertions(+), 515 deletions(-) create mode 100644 autoload/nerdtree/ui_glue.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 35919320..cc0e30ce 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -57,80 +57,6 @@ function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction -" FUNCTION: nerdtree#createDefaultBindings() {{{2 -function! nerdtree#createDefaultBindings() - let s = '' . s:SID() . '_' - - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) - - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#chRootCwd" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) - - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) -endfunction " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this @@ -243,7 +169,7 @@ endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 function! nerdtree#postSourceActions() call g:NERDTreeBookmark.CacheBookmarks(0) - call nerdtree#createDefaultBindings() + call nerdtree#ui_glue#createDefaultBindings() "load all nerdtree plugins runtime! nerdtree_plugin/**/*.vim @@ -254,14 +180,6 @@ function! nerdtree#runningWindows() return has("win16") || has("win32") || has("win64") endfunction -" Function: s:SID() {{{2 -function s:SID() - if !exists("s:sid") - let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') - endif - return s:sid -endfun - " FUNCTION: nerdtree#tabpagevar(tabnr, var) {{{2 function! nerdtree#tabpagevar(tabnr, var) let currentTab = tabpagenr() @@ -957,432 +875,4 @@ function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) return line endfunction -"SECTION: Interface bindings {{{1 -"============================================================ - -"FUNCTION: s:activateAll() {{{2 -"handle the user activating the updir line -function! s:activateAll() - if getline(".") ==# nerdtree#treeUpDirLine() - return nerdtree#upDir(0) - endif -endfunction -"FUNCTION: s:activateDirNode() {{{2 -"handle the user activating a tree node -function! s:activateDirNode(node) - call a:node.activate({'reuse': 1}) -endfunction - -"FUNCTION: s:activateFileNode() {{{2 -"handle the user activating a tree node -function! s:activateFileNode(node) - call a:node.activate({'reuse': 1, 'where': 'p'}) -endfunction - -"FUNCTION: s:activateBookmark() {{{2 -"handle the user activating a bookmark -function! s:activateBookmark(bm) - call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) -endfunction - -" FUNCTION: nerdtree#bookmarkNode(name) {{{2 -" Associate the current node with the given name -function! nerdtree#bookmarkNode(...) - let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} - let name = a:1 - if empty(name) - let name = currentNode.path.getLastPathComponent(0) - endif - try - call currentNode.bookmark(name) - call nerdtree#renderView() - catch /^NERDTree.IllegalBookmarkNameError/ - call nerdtree#echo("bookmark names must not contain spaces") - endtry - else - call nerdtree#echo("select a node first") - endif -endfunction - -" FUNCTION: s:chCwd(node) {{{2 -function! s:chCwd(node) - try - call a:node.path.changeToDir() - catch /^NERDTree.PathChangeError/ - call nerdtree#echoWarning("could not change cwd") - endtry -endfunction - -" FUNCTION: s:chRoot(node) {{{2 -" changes the current root to the selected one -function! s:chRoot(node) - call a:node.makeRoot() - call nerdtree#renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) -endfunction - -" FUNCTION: s:chRootCwd() {{{2 -" changes the current root to CWD -function! nerdtree#chRootCwd() - try - let cwd = g:NERDTreePath.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("current directory does not exist.") - return - endtry - if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() - return - endif - call nerdtree#chRoot(g:NERDTreeDirNode.New(cwd)) -endfunction - -" FUNCTION: nerdtree#clearBookmarks(bookmarks) {{{2 -function! nerdtree#clearBookmarks(bookmarks) - if a:bookmarks ==# '' - let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} - call currentNode.clearBookmarks() - endif - else - for name in split(a:bookmarks, ' ') - let bookmark = g:NERDTreeBookmark.BookmarkFor(name) - call bookmark.delete() - endfor - endif - call nerdtree#renderView() -endfunction - -" FUNCTION: s:closeChildren(node) {{{2 -" closes all childnodes of the current node -function! s:closeChildren(node) - call a:node.closeChildren() - call nerdtree#renderView() - call a:node.putCursorHere(0, 0) -endfunction - -" FUNCTION: s:closeCurrentDir(node) {{{2 -" closes the parent dir of the current node -function! s:closeCurrentDir(node) - let parent = a:node.parent - if parent ==# {} || parent.isRoot() - call nerdtree#echo("cannot close tree root") - else - while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot() - if parent.parent.getVisibleChildCount() == 1 - call parent.close() - let parent = parent.parent - else - break - endif - endwhile - call parent.close() - call nerdtree#renderView() - call parent.putCursorHere(0, 0) - endif -endfunction - -" FUNCTION: s:closeTreeWindow() {{{2 -" close the tree window -function! s:closeTreeWindow() - if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 - exec "buffer " . b:NERDTreePreviousBuf - else - if winnr("$") > 1 - call nerdtree#closeTree() - else - call nerdtree#echo("Cannot close last window") - endif - endif -endfunction - -" FUNCTION: s:deleteBookmark(bm) {{{2 -" if the cursor is on a bookmark, prompt to delete -function! s:deleteBookmark(bm) - echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" - - if nr2char(getchar()) ==# 'y' - try - call a:bm.delete() - call nerdtree#renderView() - redraw - catch /^NERDTree/ - call nerdtree#echoWarning("Could not remove bookmark") - endtry - else - call nerdtree#echo("delete aborted" ) - endif - -endfunction - -" FUNCTION: s:displayHelp() {{{2 -" toggles the help display -function! s:displayHelp() - let b:treeShowHelp = b:treeShowHelp ? 0 : 1 - call nerdtree#renderView() - call nerdtree#centerView() -endfunction - -"FUNCTION: s:handleLeftClick() {{{2 -"Checks if the click should open the current node -function! s:handleLeftClick() - let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} - - "the dir arrows are multibyte chars, and vim's string functions only - "deal with single bytes - so split the line up with the hack below and - "take the line substring manually - let line = split(getline(line(".")), '\zs') - let startToCur = "" - for i in range(0,len(line)-1) - let startToCur .= line[i] - endfor - - if currentNode.path.isDirectory - if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' - call currentNode.activate() - return - endif - endif - - if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 - let char = strpart(startToCur, strlen(startToCur)-1, 1) - if char !~# nerdtree#treeMarkupReg() - if currentNode.path.isDirectory - call currentNode.activate() - else - call currentNode.activate({'reuse': 1, 'where': 'p'}) - endif - return - endif - endif - endif -endfunction - -" FUNCTION: s:handleMiddleMouse() {{{2 -function! s:handleMiddleMouse() - let curNode = g:NERDTreeFileNode.GetSelected() - if curNode ==# {} - call nerdtree#echo("Put the cursor on a node first" ) - return - endif - - if curNode.path.isDirectory - call nerdtree#openExplorer(curNode) - else - call curNode.open({'where': 'h'}) - endif -endfunction - -" FUNCTION: s:jumpToFirstChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToFirstChild(node) - call nerdtree#jumpToChild(a:node, 0) -endfunction - -" FUNCTION: s:jumpToLastChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToLastChild(node) - call nerdtree#jumpToChild(a:node, 1) -endfunction - -" FUNCTION: s:jumpToParent(node) {{{2 -" moves the cursor to the parent of the current node -function! s:jumpToParent(node) - if !empty(a:node.parent) - call a:node.parent.putCursorHere(1, 0) - call nerdtree#centerView() - else - call nerdtree#echo("cannot jump to parent") - endif -endfunction - -" FUNCTION: s:jumpToRoot() {{{2 -" moves the cursor to the root node -function! s:jumpToRoot() - call b:NERDTreeRoot.putCursorHere(1, 0) - call nerdtree#centerView() -endfunction - -" FUNCTION: s:jumpToNextSibling(node) {{{2 -function! s:jumpToNextSibling(node) - call nerdtree#jumpToSibling(a:node, 1) -endfunction - -" FUNCTION: s:jumpToPrevSibling(node) {{{2 -function! s:jumpToPrevSibling(node) - call nerdtree#jumpToSibling(a:node, 0) -endfunction - -" FUNCTION: nerdtree#openBookmark(name) {{{2 -" put the cursor on the given bookmark and, if its a file, open it -function! nerdtree#openBookmark(name) - try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - redraw! - catch /^NERDTree.BookmarkedNodeNotFoundError/ - call nerdtree#echo("note - target node is not cached") - let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) - let targetNode = g:NERDTreeFileNode.New(bookmark.path) - endtry - if targetNode.path.isDirectory - call targetNode.openExplorer() - else - call targetNode.open({'where': 'p'}) - endif -endfunction - -" FUNCTION: s:openHSplit(target) {{{2 -function! s:openHSplit(target) - call a:target.activate({'where': 'h'}) -endfunction - -" FUNCTION: s:openVSplit(target) {{{2 -function! s:openVSplit(target) - call a:target.activate({'where': 'v'}) -endfunction - -" FUNCTION: s:openExplorer(node) {{{2 -function! s:openExplorer(node) - call a:node.openExplorer() -endfunction - -" FUNCTION: s:openInNewTab(target) {{{2 -function! s:openInNewTab(target) - call a:target.activate({'where': 't'}) -endfunction - -" FUNCTION: s:openInNewTabSilent(target) {{{2 -function! s:openInNewTabSilent(target) - call a:target.activate({'where': 't', 'stay': 1}) -endfunction - -" FUNCTION: s:openNodeRecursively(node) {{{2 -function! s:openNodeRecursively(node) - call nerdtree#echo("Recursively opening node. Please wait...") - call a:node.openRecursively() - call nerdtree#renderView() - redraw - call nerdtree#echo("Recursively opening node. Please wait... DONE") -endfunction - -"FUNCTION: s:previewNodeCurrent(node) {{{2 -function! s:previewNodeCurrent(node) - call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) -endfunction - -"FUNCTION: s:previewNodeHSplit(node) {{{2 -function! s:previewNodeHSplit(node) - call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) -endfunction - -"FUNCTION: s:previewNodeVSplit(node) {{{2 -function! s:previewNodeVSplit(node) - call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) -endfunction - -" FUNCTION: nerdtree#revealBookmark(name) {{{2 -" put the cursor on the node associate with the given name -function! nerdtree#revealBookmark(name) - try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - catch /^NERDTree.BookmarkNotFoundError/ - call nerdtree#echo("Bookmark isnt cached under the current root") - endtry -endfunction - -" FUNCTION: s:refreshRoot() {{{2 -" Reloads the current root. All nodes below this will be lost and the root dir -" will be reloaded. -function! s:refreshRoot() - call nerdtree#echo("Refreshing the root node. This could take a while...") - call b:NERDTreeRoot.refresh() - call nerdtree#renderView() - redraw - call nerdtree#echo("Refreshing the root node. This could take a while... DONE") -endfunction - -" FUNCTION: s:refreshCurrent(node) {{{2 -" refreshes the root for the current node -function! s:refreshCurrent(node) - let node = a:node - if !node.path.isDirectory - let node = node.parent - endif - - call nerdtree#echo("Refreshing node. This could take a while...") - call node.refresh() - call nerdtree#renderView() - redraw - call nerdtree#echo("Refreshing node. This could take a while... DONE") -endfunction - -" FUNCTION: s:showMenu(node) {{{2 -function! s:showMenu(node) - let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) - call mc.showMenu() -endfunction - -" FUNCTION: s:toggleIgnoreFilter() {{{2 -" toggles the use of the NERDTreeIgnore option -function! s:toggleIgnoreFilter() - let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled - call nerdtree#renderViewSavingPosition() - call nerdtree#centerView() -endfunction - -" FUNCTION: s:toggleShowBookmarks() {{{2 -" toggles the display of bookmarks -function! s:toggleShowBookmarks() - let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks - if b:NERDTreeShowBookmarks - call nerdtree#renderView() - call nerdtree#putCursorOnBookmarkTable() - else - call nerdtree#renderViewSavingPosition() - endif - call nerdtree#centerView() -endfunction - -" FUNCTION: s:toggleShowFiles() {{{2 -" toggles the display of hidden files -function! s:toggleShowFiles() - let b:NERDTreeShowFiles = !b:NERDTreeShowFiles - call nerdtree#renderViewSavingPosition() - call nerdtree#centerView() -endfunction - -" FUNCTION: s:toggleShowHidden() {{{2 -" toggles the display of hidden files -function! s:toggleShowHidden() - let b:NERDTreeShowHidden = !b:NERDTreeShowHidden - call nerdtree#renderViewSavingPosition() - call nerdtree#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:upDirCurrentRootOpen() {{{2 -function! s:upDirCurrentRootOpen() - call nerdtree#upDir(1) -endfunction - -" FUNCTION: s:upDirCurrentRootClosed() {{{2 -function! s:upDirCurrentRootClosed() - call nerdtree#upDir(0) -endfunction - " vim: set sw=4 sts=4 et fdm=marker: diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim new file mode 100644 index 00000000..036ead9f --- /dev/null +++ b/autoload/nerdtree/ui_glue.vim @@ -0,0 +1,518 @@ +if exists("g:loaded_nerdtree_ui_glue_autoload") + finish +endif +let g:loaded_nerdtree_ui_glue_autoload = 1 + +" FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1 +function! nerdtree#ui_glue#createDefaultBindings() + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) +endfunction + + +"SECTION: Interface bindings {{{1 +"============================================================ + +"FUNCTION: s:activateAll() {{{1 +"handle the user activating the updir line +function! s:activateAll() + if getline(".") ==# nerdtree#treeUpDirLine() + return nerdtree#upDir(0) + endif +endfunction +"FUNCTION: s:activateDirNode() {{{1 +"handle the user activating a tree node +function! s:activateDirNode(node) + call a:node.activate({'reuse': 1}) +endfunction + +"FUNCTION: s:activateFileNode() {{{1 +"handle the user activating a tree node +function! s:activateFileNode(node) + call a:node.activate({'reuse': 1, 'where': 'p'}) +endfunction + +"FUNCTION: s:activateBookmark() {{{1 +"handle the user activating a bookmark +function! s:activateBookmark(bm) + call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) +endfunction + +" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 +" Associate the current node with the given name +function! nerdtree#ui_glue#bookmarkNode(...) + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(0) + endif + try + call currentNode.bookmark(name) + call nerdtree#renderView() + catch /^NERDTree.IllegalBookmarkNameError/ + call nerdtree#echo("bookmark names must not contain spaces") + endtry + else + call nerdtree#echo("select a node first") + endif +endfunction + +" FUNCTION: s:chCwd(node) {{{1 +function! s:chCwd(node) + try + call a:node.path.changeToDir() + catch /^NERDTree.PathChangeError/ + call nerdtree#echoWarning("could not change cwd") + endtry +endfunction + +" FUNCTION: s:chRoot(node) {{{1 +" changes the current root to the selected one +function! s:chRoot(node) + call a:node.makeRoot() + call nerdtree#renderView() + call b:NERDTreeRoot.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 +" changes the current root to CWD +function! nerdtree#ui_glue#chRootCwd() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + return + endtry + if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() + return + endif + call nerdtree#chRoot(g:NERDTreeDirNode.New(cwd)) +endfunction + +" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 +function! nerdtree#ui_glue#clearBookmarks(bookmarks) + if a:bookmarks ==# '' + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + call currentNode.clearBookmarks() + endif + else + for name in split(a:bookmarks, ' ') + let bookmark = g:NERDTreeBookmark.BookmarkFor(name) + call bookmark.delete() + endfor + endif + call nerdtree#renderView() +endfunction + +" FUNCTION: s:closeChildren(node) {{{1 +" closes all childnodes of the current node +function! s:closeChildren(node) + call a:node.closeChildren() + call nerdtree#renderView() + call a:node.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:closeCurrentDir(node) {{{1 +" closes the parent dir of the current node +function! s:closeCurrentDir(node) + let parent = a:node.parent + if parent ==# {} || parent.isRoot() + call nerdtree#echo("cannot close tree root") + else + while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot() + if parent.parent.getVisibleChildCount() == 1 + call parent.close() + let parent = parent.parent + else + break + endif + endwhile + call parent.close() + call nerdtree#renderView() + call parent.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: s:closeTreeWindow() {{{1 +" close the tree window +function! s:closeTreeWindow() + if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 + exec "buffer " . b:NERDTreePreviousBuf + else + if winnr("$") > 1 + call nerdtree#closeTree() + else + call nerdtree#echo("Cannot close last window") + endif + endif +endfunction + +" FUNCTION: s:deleteBookmark(bm) {{{1 +" if the cursor is on a bookmark, prompt to delete +function! s:deleteBookmark(bm) + echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" + + if nr2char(getchar()) ==# 'y' + try + call a:bm.delete() + call nerdtree#renderView() + redraw + catch /^NERDTree/ + call nerdtree#echoWarning("Could not remove bookmark") + endtry + else + call nerdtree#echo("delete aborted" ) + endif + +endfunction + +" FUNCTION: s:displayHelp() {{{1 +" toggles the help display +function! s:displayHelp() + let b:treeShowHelp = b:treeShowHelp ? 0 : 1 + call nerdtree#renderView() + call nerdtree#centerView() +endfunction + +"FUNCTION: s:handleLeftClick() {{{1 +"Checks if the click should open the current node +function! s:handleLeftClick() + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode != {} + + "the dir arrows are multibyte chars, and vim's string functions only + "deal with single bytes - so split the line up with the hack below and + "take the line substring manually + let line = split(getline(line(".")), '\zs') + let startToCur = "" + for i in range(0,len(line)-1) + let startToCur .= line[i] + endfor + + if currentNode.path.isDirectory + if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' + call currentNode.activate() + return + endif + endif + + if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 + let char = strpart(startToCur, strlen(startToCur)-1, 1) + if char !~# nerdtree#treeMarkupReg() + if currentNode.path.isDirectory + call currentNode.activate() + else + call currentNode.activate({'reuse': 1, 'where': 'p'}) + endif + return + endif + endif + endif +endfunction + +" FUNCTION: s:handleMiddleMouse() {{{1 +function! s:handleMiddleMouse() + let curNode = g:NERDTreeFileNode.GetSelected() + if curNode ==# {} + call nerdtree#echo("Put the cursor on a node first" ) + return + endif + + if curNode.path.isDirectory + call nerdtree#openExplorer(curNode) + else + call curNode.open({'where': 'h'}) + endif +endfunction + +" FUNCTION: s:jumpToFirstChild() {{{1 +" wrapper for the jump to child method +function! s:jumpToFirstChild(node) + call nerdtree#jumpToChild(a:node, 0) +endfunction + +" FUNCTION: s:jumpToLastChild() {{{1 +" wrapper for the jump to child method +function! s:jumpToLastChild(node) + call nerdtree#jumpToChild(a:node, 1) +endfunction + +" FUNCTION: s:jumpToParent(node) {{{1 +" moves the cursor to the parent of the current node +function! s:jumpToParent(node) + if !empty(a:node.parent) + call a:node.parent.putCursorHere(1, 0) + call nerdtree#centerView() + else + call nerdtree#echo("cannot jump to parent") + endif +endfunction + +" FUNCTION: s:jumpToRoot() {{{1 +" moves the cursor to the root node +function! s:jumpToRoot() + call b:NERDTreeRoot.putCursorHere(1, 0) + call nerdtree#centerView() +endfunction + +" FUNCTION: s:jumpToNextSibling(node) {{{1 +function! s:jumpToNextSibling(node) + call nerdtree#jumpToSibling(a:node, 1) +endfunction + +" FUNCTION: s:jumpToPrevSibling(node) {{{1 +function! s:jumpToPrevSibling(node) + call nerdtree#jumpToSibling(a:node, 0) +endfunction + +" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 +" put the cursor on the given bookmark and, if its a file, open it +function! nerdtree#ui_glue#openBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + call targetNode.putCursorHere(0, 1) + redraw! + catch /^NERDTree.BookmarkedNodeNotFoundError/ + call nerdtree#echo("note - target node is not cached") + let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + let targetNode = g:NERDTreeFileNode.New(bookmark.path) + endtry + if targetNode.path.isDirectory + call targetNode.openExplorer() + else + call targetNode.open({'where': 'p'}) + endif +endfunction + +" FUNCTION: s:openHSplit(target) {{{1 +function! s:openHSplit(target) + call a:target.activate({'where': 'h'}) +endfunction + +" FUNCTION: s:openVSplit(target) {{{1 +function! s:openVSplit(target) + call a:target.activate({'where': 'v'}) +endfunction + +" FUNCTION: s:openExplorer(node) {{{1 +function! s:openExplorer(node) + call a:node.openExplorer() +endfunction + +" FUNCTION: s:openInNewTab(target) {{{1 +function! s:openInNewTab(target) + call a:target.activate({'where': 't'}) +endfunction + +" FUNCTION: s:openInNewTabSilent(target) {{{1 +function! s:openInNewTabSilent(target) + call a:target.activate({'where': 't', 'stay': 1}) +endfunction + +" FUNCTION: s:openNodeRecursively(node) {{{1 +function! s:openNodeRecursively(node) + call nerdtree#echo("Recursively opening node. Please wait...") + call a:node.openRecursively() + call nerdtree#renderView() + redraw + call nerdtree#echo("Recursively opening node. Please wait... DONE") +endfunction + +"FUNCTION: s:previewNodeCurrent(node) {{{1 +function! s:previewNodeCurrent(node) + call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeHSplit(node) {{{1 +function! s:previewNodeHSplit(node) + call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeVSplit(node) {{{1 +function! s:previewNodeVSplit(node) + call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) +endfunction + +" FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1 +" put the cursor on the node associate with the given name +function! nerdtree#ui_glue#revealBookmark(name) + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + call targetNode.putCursorHere(0, 1) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echo("Bookmark isnt cached under the current root") + endtry +endfunction + +" FUNCTION: s:refreshRoot() {{{1 +" Reloads the current root. All nodes below this will be lost and the root dir +" will be reloaded. +function! s:refreshRoot() + call nerdtree#echo("Refreshing the root node. This could take a while...") + call b:NERDTreeRoot.refresh() + call nerdtree#renderView() + redraw + call nerdtree#echo("Refreshing the root node. This could take a while... DONE") +endfunction + +" FUNCTION: s:refreshCurrent(node) {{{1 +" refreshes the root for the current node +function! s:refreshCurrent(node) + let node = a:node + if !node.path.isDirectory + let node = node.parent + endif + + call nerdtree#echo("Refreshing node. This could take a while...") + call node.refresh() + call nerdtree#renderView() + redraw + call nerdtree#echo("Refreshing node. This could take a while... DONE") +endfunction + +" Function: s:SID() {{{1 +function s:SID() + if !exists("s:sid") + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun + +" FUNCTION: s:showMenu(node) {{{1 +function! s:showMenu(node) + let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) + call mc.showMenu() +endfunction + +" FUNCTION: s:toggleIgnoreFilter() {{{1 +" toggles the use of the NERDTreeIgnore option +function! s:toggleIgnoreFilter() + let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled + call nerdtree#renderViewSavingPosition() + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowBookmarks() {{{1 +" toggles the display of bookmarks +function! s:toggleShowBookmarks() + let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks + if b:NERDTreeShowBookmarks + call nerdtree#renderView() + call nerdtree#putCursorOnBookmarkTable() + else + call nerdtree#renderViewSavingPosition() + endif + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowFiles() {{{1 +" toggles the display of hidden files +function! s:toggleShowFiles() + let b:NERDTreeShowFiles = !b:NERDTreeShowFiles + call nerdtree#renderViewSavingPosition() + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:toggleShowHidden() + let b:NERDTreeShowHidden = !b:NERDTreeShowHidden + call nerdtree#renderViewSavingPosition() + call nerdtree#centerView() +endfunction + +" FUNCTION: s:toggleZoom() {{{1 +" 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:upDirCurrentRootOpen() {{{1 +function! s:upDirCurrentRootOpen() + call nerdtree#upDir(1) +endfunction + +" FUNCTION: s:upDirCurrentRootClosed() {{{1 +function! s:upDirCurrentRootClosed() + call nerdtree#upDir(0) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index b1a617fe..a45b4cd9 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -12,10 +12,10 @@ function! s:Creator._bindMappings() call g:NERDTreeKeyMap.BindAll() - command! -buffer -nargs=? Bookmark :call nerdtree#bookmarkNode('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#revealBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#openBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#clearBookmarks('') + command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call nerdtree#renderView() command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call nerdtree#renderView() From f982f61e8a1dfdd66e6741f79bb71eb8408875fb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 7 Jul 2014 20:12:05 +0100 Subject: [PATCH 144/680] continue breaking up the autoload/nerdtree god module --- autoload/nerdtree.vim | 263 +--------------------------------- autoload/nerdtree/ui_glue.vim | 164 ++++++++++++++++++++- lib/nerdtree/creator.vim | 34 ++++- lib/nerdtree/key_map.vim | 2 +- lib/nerdtree/opener.vim | 78 +++++++++- lib/nerdtree/path.vim | 17 ++- plugin/NERD_tree.vim | 11 +- 7 files changed, 281 insertions(+), 288 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index cc0e30ce..61470896 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -9,29 +9,6 @@ endfunction " SECTION: General Functions {{{1 "============================================================ -"FUNCTION: nerdtree#bufInWindows(bnum){{{2 -"[[STOLEN FROM VTREEEXPLORER.VIM]] -"Determine the number of windows open to this buffer number. -"Care of Yegappan Lakshman. Thanks! -" -"Args: -"bnum: the subject buffers buffer number -function! nerdtree#bufInWindows(bnum) - let cnt = 0 - let winnum = 1 - while 1 - let bufnum = winbufnr(winnum) - if bufnum < 0 - break - endif - if bufnum ==# a:bnum - let cnt = cnt + 1 - endif - let winnum = winnum + 1 - endwhile - - return cnt -endfunction "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a secondary nerd tree in the current buffer if appropriate @@ -57,7 +34,6 @@ function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction - " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message @@ -73,15 +49,6 @@ function! nerdtree#deprecated(func, ...) endif endfunction -"FUNCTION: nerdtree#escChars(dir) {{{2 -function! nerdtree#escChars() - if nerdtree#runningWindows() - return " `\|\"#%&,?()\*^<>" - endif - - return " \\`\|\"#%&,?()\*^<>[]" -endfunction - " FUNCTION: nerdtree#exec(cmd) {{{2 " same as :exec cmd but eventignore=all is set for the duration function! nerdtree#exec(cmd) @@ -91,68 +58,11 @@ function! nerdtree#exec(cmd) let &ei = old_ei endfunction -" FUNCTION: nerdtree#findAndRevealPath() {{{2 -function! nerdtree#findAndRevealPath() - try - let p = g:NERDTreePath.New(expand("%:p")) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("no file for the current buffer") - return - endtry - - if p.isUnixHiddenPath() - let showhidden=g:NERDTreeShowHidden - let g:NERDTreeShowHidden = 1 - endif - - if !nerdtree#treeExistsForTab() - try - let cwd = g:NERDTreePath.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("current directory does not exist.") - let cwd = p.getParent() - endtry - - if p.isUnder(cwd) - call g:NERDTreeCreator.CreatePrimary(cwd.str()) - else - call g:NERDTreeCreator.CreatePrimary(p.getParent().str()) - endif - else - if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) - if !nerdtree#isTreeOpen() - call g:NERDTreeCreator.TogglePrimary('') - else - call nerdtree#putCursorInTreeWin() - endif - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) - else - if !nerdtree#isTreeOpen() - call g:NERDTreeCreator.TogglePrimary("") - endif - endif - endif - call nerdtree#putCursorInTreeWin() - call b:NERDTreeRoot.reveal(p) - - if p.isUnixHiddenFile() - let g:NERDTreeShowHidden = showhidden - endif -endfunction - " FUNCTION: nerdtree#has_opt(options, name) {{{2 function! nerdtree#has_opt(options, name) return has_key(a:options, a:name) && a:options[a:name] == 1 endfunction -" FUNCTION: nerdtree#invokeKeyMap(key) {{{2 -"this is needed since I cant figure out how to invoke dict functions from a -"key map -function! nerdtree#invokeKeyMap(key) - call g:NERDTreeKeyMap.Invoke(a:key) -endfunction - " FUNCTION: nerdtree#loadClassFiles() {{{2 function! nerdtree#loadClassFiles() runtime lib/nerdtree/path.vim @@ -180,24 +90,6 @@ function! nerdtree#runningWindows() return has("win16") || has("win32") || has("win64") endfunction -" FUNCTION: nerdtree#tabpagevar(tabnr, var) {{{2 -function! nerdtree#tabpagevar(tabnr, var) - let currentTab = tabpagenr() - let old_ei = &ei - set ei=all - - exec "tabnext " . a:tabnr - let v = -1 - if exists('t:' . a:var) - exec 'let v = t:' . a:var - endif - exec "tabnext " . currentTab - - let &ei = old_ei - - return v -endfunction - " Function: nerdtree#treeExistsForBuffer() {{{2 " Returns 1 if a nerd tree root exists in the current buffer function! nerdtree#treeExistsForBuf() @@ -229,54 +121,6 @@ function! nerdtree#treeWid() return 2 endfunction -"FUNCTION: nerdtree#upDir(keepState) {{{2 -"moves the tree up a level -" -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! nerdtree#upDir(keepState) - let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) - if cwd ==# "/" || cwd =~# '^[^/]..$' - call nerdtree#echo("already at top dir") - else - if !a:keepState - call b:NERDTreeRoot.close() - endif - - let oldRoot = b:NERDTreeRoot - - if empty(b:NERDTreeRoot.parent) - let path = b:NERDTreeRoot.path.getParent() - let newRoot = g:NERDTreeDirNode.New(path) - call newRoot.open() - call newRoot.transplantChild(b:NERDTreeRoot) - let b:NERDTreeRoot = newRoot - else - let b:NERDTreeRoot = b:NERDTreeRoot.parent - endif - - if g:NERDTreeChDirMode ==# 2 - call b:NERDTreeRoot.path.changeToDir() - endif - - call nerdtree#renderView() - call oldRoot.putCursorHere(0, 0) - endif -endfunction - -" Function: nerdtree#unique(list) {{{2 -" returns a:list without duplicates -function! nerdtree#unique(list) - let uniqlist = [] - for elem in a:list - if index(uniqlist, elem) ==# -1 - let uniqlist += [elem] - endif - endfor - return uniqlist -endfunction - " SECTION: View Functions {{{1 "============================================================ " @@ -299,6 +143,7 @@ endfunction function! nerdtree#chRoot(node) call s:chRoot(a:node) endfunction + "FUNCTION: nerdtree#closeTree() {{{2 "Closes the primary NERD tree window for this tab function! nerdtree#closeTree() @@ -476,23 +321,6 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#firstUsableWindow(){{{2 -"find the window number of the first normal window -function! nerdtree#firstUsableWindow() - let i = 1 - while i <= winnr("$") - let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' - \ && !getwinvar(i, '&previewwindow') - \ && (!getbufvar(bnum, '&modified') || &hidden) - return i - endif - - let i += 1 - endwhile - return -1 -endfunction - "FUNCTION: nerdtree#getPath(ln) {{{2 "Gets the full path to the node that is rendered on the given line number " @@ -588,95 +416,6 @@ function! nerdtree#isTreeOpen() return nerdtree#getTreeWinNum() != -1 endfunction -"FUNCTION: nerdtree#isWindowUsable(winnumber) {{{2 -"Returns 0 if opening a file from the tree in the given window requires it to -"be split, 1 otherwise -" -"Args: -"winnumber: the number of the window in question -function! nerdtree#isWindowUsable(winnumber) - "gotta split if theres only one window (i.e. the NERD tree) - if winnr("$") ==# 1 - return 0 - endif - - let oldwinnr = winnr() - call nerdtree#exec(a:winnumber . "wincmd p") - let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') - let modified = &modified - call nerdtree#exec(oldwinnr . "wincmd p") - - "if its a special window e.g. quickfix or another explorer plugin then we - "have to split - if specialWindow - return 0 - endif - - if &hidden - return 1 - endif - - return !modified || nerdtree#bufInWindows(winbufnr(a:winnumber)) >= 2 -endfunction - -" FUNCTION: nerdtree#jumpToChild(direction) {{{2 -" Args: -" direction: 0 if going to first child, 1 if going to last -function! nerdtree#jumpToChild(currentNode, direction) - if a:currentNode.isRoot() - return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - end - let dirNode = a:currentNode.parent - let childNodes = dirNode.getVisibleChildren() - - let targetNode = childNodes[0] - if a:direction - let targetNode = childNodes[len(childNodes) - 1] - endif - - if targetNode.equals(a:currentNode) - let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) - if siblingDir != {} - let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 - let targetNode = siblingDir.getChildByIndex(indx, 1) - endif - endif - - call targetNode.putCursorHere(1, 0) - - call nerdtree#centerView() -endfunction - -" FUNCTION: nerdtree#jumpToSibling(currentNode, forward) {{{2 -" moves the cursor to the sibling of the current node in the given direction -" -" Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! nerdtree#jumpToSibling(currentNode, forward) - let sibling = a:currentNode.findSibling(a:forward) - - if !empty(sibling) - call sibling.putCursorHere(1, 0) - call nerdtree#centerView() - endif -endfunction - -"FUNCTION: nerdtree#promptToDelBuffer(bufnum, msg){{{2 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! nerdtree#promptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - "FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 "Places the cursor at the top of the bookmarks table function! nerdtree#putCursorOnBookmarkTable() diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 036ead9f..60c905d3 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -86,9 +86,10 @@ endfunction "handle the user activating the updir line function! s:activateAll() if getline(".") ==# nerdtree#treeUpDirLine() - return nerdtree#upDir(0) + return nerdtree#ui_glue#upDir(0) endif endfunction + "FUNCTION: s:activateDirNode() {{{1 "handle the user activating a tree node function! s:activateDirNode(node) @@ -245,6 +246,56 @@ function! s:displayHelp() call nerdtree#centerView() endfunction +" FUNCTION: s:findAndRevealPath() {{{1 +function! s:findAndRevealPath() + try + let p = g:NERDTreePath.New(expand("%:p")) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("no file for the current buffer") + return + endtry + + if p.isUnixHiddenPath() + let showhidden=g:NERDTreeShowHidden + let g:NERDTreeShowHidden = 1 + endif + + if !nerdtree#treeExistsForTab() + try + let cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo("current directory does not exist.") + let cwd = p.getParent() + endtry + + if p.isUnder(cwd) + call g:NERDTreeCreator.CreatePrimary(cwd.str()) + else + call g:NERDTreeCreator.CreatePrimary(p.getParent().str()) + endif + else + if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) + if !nerdtree#isTreeOpen() + call g:NERDTreeCreator.TogglePrimary('') + else + call nerdtree#putCursorInTreeWin() + endif + let b:NERDTreeShowHidden = g:NERDTreeShowHidden + call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) + else + if !nerdtree#isTreeOpen() + call g:NERDTreeCreator.TogglePrimary("") + endif + endif + endif + call nerdtree#putCursorInTreeWin() + call b:NERDTreeRoot.reveal(p) + + if p.isUnixHiddenFile() + let g:NERDTreeShowHidden = showhidden + endif +endfunction + "FUNCTION: s:handleLeftClick() {{{1 "Checks if the click should open the current node function! s:handleLeftClick() @@ -296,16 +347,52 @@ function! s:handleMiddleMouse() endif endfunction +" FUNCTION: s:jumpToChild(direction) {{{2 +" Args: +" direction: 0 if going to first child, 1 if going to last +function! s:jumpToChild(currentNode, direction) + if a:currentNode.isRoot() + return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child") + end + let dirNode = a:currentNode.parent + let childNodes = dirNode.getVisibleChildren() + + let targetNode = childNodes[0] + if a:direction + let targetNode = childNodes[len(childNodes) - 1] + endif + + if targetNode.equals(a:currentNode) + let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) + if siblingDir != {} + let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 + let targetNode = siblingDir.getChildByIndex(indx, 1) + endif + endif + + call targetNode.putCursorHere(1, 0) + + call nerdtree#centerView() +endfunction + + +" FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! nerdtree#ui_glue#invokeKeyMap(key) + call g:NERDTreeKeyMap.Invoke(a:key) +endfunction + " FUNCTION: s:jumpToFirstChild() {{{1 " wrapper for the jump to child method function! s:jumpToFirstChild(node) - call nerdtree#jumpToChild(a:node, 0) + call s:jumpToChild(a:node, 0) endfunction " FUNCTION: s:jumpToLastChild() {{{1 " wrapper for the jump to child method function! s:jumpToLastChild(node) - call nerdtree#jumpToChild(a:node, 1) + call s:jumpToChild(a:node, 1) endfunction " FUNCTION: s:jumpToParent(node) {{{1 @@ -328,12 +415,27 @@ endfunction " FUNCTION: s:jumpToNextSibling(node) {{{1 function! s:jumpToNextSibling(node) - call nerdtree#jumpToSibling(a:node, 1) + call s:jumpToSibling(a:node, 1) endfunction " FUNCTION: s:jumpToPrevSibling(node) {{{1 function! s:jumpToPrevSibling(node) - call nerdtree#jumpToSibling(a:node, 0) + call s:jumpToSibling(a:node, 0) +endfunction + +" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2 +" moves the cursor to the sibling of the current node in the given direction +" +" Args: +" forward: 1 if the cursor should move to the next sibling, 0 if it should +" move back to the previous sibling +function! s:jumpToSibling(currentNode, forward) + let sibling = a:currentNode.findSibling(a:forward) + + if !empty(sibling) + call sibling.putCursorHere(1, 0) + call nerdtree#centerView() + endif endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 @@ -441,6 +543,18 @@ function! s:refreshCurrent(node) call nerdtree#echo("Refreshing node. This could take a while... DONE") endfunction +" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 +function! nerdtree#ui_glue#setupCommands() + command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('') + command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') + command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() + command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') + command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() + command! -n=0 -bar NERDTreeFind call nerdtree#ui_glue#findAndRevealPath() + command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() + command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() +endfunction + " Function: s:SID() {{{1 function s:SID() if !exists("s:sid") @@ -505,14 +619,50 @@ function! s:toggleZoom() endif endfunction +"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1 +"moves the tree up a level +" +"Args: +"keepState: 1 if the current root should be left open when the tree is +"re-rendered +function! nerdtree#ui_glue#upDir(keepState) + let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) + if cwd ==# "/" || cwd =~# '^[^/]..$' + call nerdtree#echo("already at top dir") + else + if !a:keepState + call b:NERDTreeRoot.close() + endif + + let oldRoot = b:NERDTreeRoot + + if empty(b:NERDTreeRoot.parent) + let path = b:NERDTreeRoot.path.getParent() + let newRoot = g:NERDTreeDirNode.New(path) + call newRoot.open() + call newRoot.transplantChild(b:NERDTreeRoot) + let b:NERDTreeRoot = newRoot + else + let b:NERDTreeRoot = b:NERDTreeRoot.parent + endif + + if g:NERDTreeChDirMode ==# 2 + call b:NERDTreeRoot.path.changeToDir() + endif + + call nerdtree#renderView() + call oldRoot.putCursorHere(0, 0) + endif +endfunction + " FUNCTION: s:upDirCurrentRootOpen() {{{1 function! s:upDirCurrentRootOpen() - call nerdtree#upDir(1) + call nerdtree#ui_glue#upDir(1) endfunction " FUNCTION: s:upDirCurrentRootClosed() {{{1 function! s:upDirCurrentRootClosed() - call nerdtree#upDir(0) + call nerdtree#ui_glue#upDir(0) endfunction " vim: set sw=4 sts=4 et fdm=marker: diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index a45b4cd9..0ddc1f1f 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -122,12 +122,12 @@ function! s:Creator.createMirror() "get the names off all the nerd tree buffers let treeBufNames = [] for i in range(1, tabpagenr("$")) - let nextName = nerdtree#tabpagevar(i, 'NERDTreeBufName') + let nextName = self._tabpagevar(i, 'NERDTreeBufName') if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) call add(treeBufNames, nextName) endif endfor - let treeBufNames = nerdtree#unique(treeBufNames) + let treeBufNames = self._uniq(treeBufNames) "map the option names (that the user will be prompted with) to the nerd "tree buffer names @@ -290,6 +290,24 @@ function! s:Creator._setupStatusline() endif endfunction +" FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1 +function! s:Creator._tabpagevar(tabnr, var) + let currentTab = tabpagenr() + let old_ei = &ei + set ei=all + + exec "tabnext " . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec "tabnext " . currentTab + + let &ei = old_ei + + return v +endfunction + "FUNCTION: s:Creator.TogglePrimary(dir) {{{1 function! s:Creator.TogglePrimary(dir) let creator = s:Creator.New() @@ -319,4 +337,16 @@ function! s:Creator.togglePrimary(dir) endif endfunction +" Function: s:Creator._uniq(list) {{{1 +" returns a:list without duplicates +function! s:Creator._uniq(list) + let uniqlist = [] + for elem in a:list + if index(uniqlist, elem) ==# -1 + let uniqlist += [elem] + endif + endfor + return uniqlist +endfunction + " vim: set sw=4 sts=4 et fdm=marker: diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index ee099fa9..27dab556 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -44,7 +44,7 @@ function! s:KeyMap.bind() let premap = self.key == "" ? " " : " " - exec 'nnoremap '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")' + exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{1 diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index bcc0d4fc..70b46335 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -3,6 +3,29 @@ let s:Opener = {} let g:NERDTreeOpener = s:Opener +"FUNCTION: s:Opener._bufInWindows(bnum){{{1 +"[[STOLEN FROM VTREEEXPLORER.VIM]] +"Determine the number of windows open to this buffer number. +"Care of Yegappan Lakshman. Thanks! +" +"Args: +"bnum: the subject buffers buffer number +function! s:Opener._bufInWindows(bnum) + let cnt = 0 + let winnum = 1 + while 1 + let bufnum = winbufnr(winnum) + if bufnum < 0 + break + endif + if bufnum ==# a:bnum + let cnt = cnt + 1 + endif + let winnum = winnum + 1 + endwhile + + return cnt +endfunction "FUNCTION: Opener._checkToCloseTree(newtab) {{{1 "Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see "if the tree should be closed now. @@ -21,6 +44,24 @@ function! s:Opener._checkToCloseTree(newtab) endif endfunction + +"FUNCTION: s:Opener._firstUsableWindow(){{{1 +"find the window number of the first normal window +function! s:Opener._firstUsableWindow() + let i = 1 + while i <= winnr("$") + let bnum = winbufnr(i) + if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + \ && !getwinvar(i, '&previewwindow') + \ && (!getbufvar(bnum, '&modified') || &hidden) + return i + endif + + let i += 1 + endwhile + return -1 +endfunction + "FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTreeType ==# "secondary" @@ -48,6 +89,37 @@ function! s:Opener._gotoTargetWin() endif endfunction +"FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1 +"Returns 0 if opening a file from the tree in the given window requires it to +"be split, 1 otherwise +" +"Args: +"winnumber: the number of the window in question +function! s:Opener._isWindowUsable(winnumber) + "gotta split if theres only one window (i.e. the NERD tree) + if winnr("$") ==# 1 + return 0 + endif + + let oldwinnr = winnr() + call nerdtree#exec(a:winnumber . "wincmd p") + let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') + let modified = &modified + call nerdtree#exec(oldwinnr . "wincmd p") + + "if its a special window e.g. quickfix or another explorer plugin then we + "have to split + if specialWindow + return 0 + endif + + if &hidden + return 1 + endif + + return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2 +endfunction + "FUNCTION: Opener.New(path, opts) {{{1 "Args: " @@ -206,12 +278,12 @@ endfunction "FUNCTION: Opener._previousWindow() {{{1 function! s:Opener._previousWindow() - if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1 + if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1 call self._newSplit() else try - if !nerdtree#isWindowUsable(winnr("#")) - call nerdtree#exec(nerdtree#firstUsableWindow() . "wincmd w") + if !self._isWindowUsable(winnr("#")) + call nerdtree#exec(self._firstUsableWindow() . "wincmd w") else call nerdtree#exec('wincmd p') endif diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 047a72a6..03adefca 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -170,7 +170,7 @@ function! s:Path.copy(dest) let dest = s:Path.WinToUnixPath(a:dest) - let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), nerdtree#escChars()) . " " . escape(dest, nerdtree#escChars()) + let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) let success = system(cmd) if success != 0 throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" @@ -289,6 +289,15 @@ function! s:Path.exists() return filereadable(p) || isdirectory(p) endfunction +"FUNCTION: Path._escChars() {{{1 +function! s:Path._escChars() + if nerdtree#runningWindows() + return " `\|\"#%&,?()\*^<>" + endif + + return " \\`\|\"#%&,?()\*^<>[]" +endfunction + "FUNCTION: Path.getDir() {{{1 " "Returns this path if it is a directory, else this paths parent. @@ -625,7 +634,7 @@ endfunction " " returns a string that can be used with :cd function! s:Path._strForCd() - return escape(self.str(), nerdtree#escChars()) + return escape(self.str(), self._escChars()) endfunction "FUNCTION: Path._strForEdit() {{{1 @@ -633,7 +642,7 @@ endfunction "Return: the string for this path that is suitable to be used with the :edit "command function! s:Path._strForEdit() - let p = escape(self.str({'format': 'UI'}), nerdtree#escChars()) + let p = escape(self.str({'format': 'UI'}), self._escChars()) let cwd = getcwd() . s:Path.Slash() "return a relative path if we can @@ -673,7 +682,7 @@ function! s:Path._strForGlob() let toReturn = lead . join(self.pathSegments, s:Path.Slash()) if !nerdtree#runningWindows() - let toReturn = escape(toReturn, nerdtree#escChars()) + let toReturn = escape(toReturn, self._escChars()) endif return toReturn endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index cbfa884e..fccad3db 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -142,15 +142,8 @@ call nerdtree#loadClassFiles() " SECTION: Commands {{{1 "============================================================ -"init the command that users start the nerd tree with -command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('') -command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') -command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() -command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') -command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() -command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath() -command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() -command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() +call nerdtree#ui_glue#setupCommands() + " SECTION: Auto commands {{{1 "============================================================ augroup NERDTree From 23dfc6d8181da7d423ca89a950c69ee5694ea2c6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 7 Jul 2014 22:59:28 +0100 Subject: [PATCH 145/680] continue breaking down the epic autoload module Add 2 new classes and move code into them from autoload: * NERDTree. Each nerdtree buffer now has a NERDTree object that holds the root node and will old other util functions * UI. Each NERDTree object holds a UI object which is responsible for rendering, getting the current node, etc Still a fair few methods to sort through in autoload (many of which will end up in the above classes) - need sleep though. --- autoload/nerdtree.vim | 192 +---------------------- autoload/nerdtree/ui_glue.vim | 32 ++-- lib/nerdtree/bookmark.vim | 4 +- lib/nerdtree/creator.vim | 35 +++-- lib/nerdtree/nerdtree.vim | 23 +++ lib/nerdtree/opener.vim | 2 +- lib/nerdtree/tree_dir_node.vim | 4 +- lib/nerdtree/tree_file_node.vim | 67 +------- lib/nerdtree/ui.vim | 262 ++++++++++++++++++++++++++++++++ nerdtree_plugin/fs_menu.vim | 4 +- plugin/NERD_tree.vim | 2 +- 11 files changed, 337 insertions(+), 290 deletions(-) create mode 100644 lib/nerdtree/nerdtree.vim create mode 100644 lib/nerdtree/ui.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 61470896..f5becc57 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -74,6 +74,8 @@ function! nerdtree#loadClassFiles() runtime lib/nerdtree/tree_dir_node.vim runtime lib/nerdtree/opener.vim runtime lib/nerdtree/creator.vim + runtime lib/nerdtree/nerdtree.vim + runtime lib/nerdtree/ui.vim endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 @@ -321,75 +323,6 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#getPath(ln) {{{2 -"Gets the full path to the node that is rendered on the given line number -" -"Args: -"ln: the line number to get the path for -" -"Return: -"A path if a node was selected, {} if nothing is selected. -"If the 'up a dir' line was selected then the path to the parent of the -"current root is returned -function! nerdtree#getPath(ln) - let line = getline(a:ln) - - let rootLine = g:NERDTreeFileNode.GetRootLineNum() - - "check to see if we have the root node - if a:ln == rootLine - return b:NERDTreeRoot.path - endif - - if !g:NERDTreeDirArrows - " in case called from outside the tree - if line !~# '^ *[|`▸▾ ]' || line =~# '^$' - return {} - endif - endif - - if line ==# nerdtree#treeUpDirLine() - return b:NERDTreeRoot.path.getParent() - endif - - let indent = nerdtree#indentLevelFor(line) - - "remove the tree parts and the leading space - let curFile = nerdtree#stripMarkupFromLine(line, 0) - - let wasdir = 0 - if curFile =~# '/$' - let wasdir = 1 - let curFile = substitute(curFile, '/\?$', '/', "") - endif - - let dir = "" - let lnum = a:ln - while lnum > 0 - let lnum = lnum - 1 - let curLine = getline(lnum) - let curLineStripped = nerdtree#stripMarkupFromLine(curLine, 1) - - "have we reached the top of the tree? - if lnum == rootLine - let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir - break - endif - if curLineStripped =~# '/$' - let lpindent = nerdtree#indentLevelFor(curLine) - if lpindent < indent - let indent = indent - 1 - - let dir = substitute (curLineStripped,'^\\', "", "") . dir - continue - endif - endif - endwhile - let curFile = b:NERDTreeRoot.path.drive . dir . curFile - let toReturn = g:NERDTreePath.New(curFile) - return toReturn -endfunction - "FUNCTION: nerdtree#getTreeWinNum() {{{2 "gets the nerd tree window number for this tab function! nerdtree#getTreeWinNum() @@ -400,17 +333,6 @@ function! nerdtree#getTreeWinNum() endif endfunction -"FUNCTION: nerdtree#indentLevelFor(line) {{{2 -function! nerdtree#indentLevelFor(line) - let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() - " check if line includes arrows - if match(a:line, '[▸▾]') > -1 - " decrement level as arrow uses 3 ascii chars - let level = level - 1 - endif - return level -endfunction - "FUNCTION: nerdtree#isTreeOpen() {{{2 function! nerdtree#isTreeOpen() return nerdtree#getTreeWinNum() != -1 @@ -427,7 +349,7 @@ function! nerdtree#putCursorOnBookmarkTable() return cursor(1, 2) endif - let rootNodeLine = g:NERDTreeFileNode.GetRootLineNum() + let rootNodeLine = b:NERDTree.ui.getRootLineNum() let line = 1 while getline(line) !~# '^>-\+Bookmarks-\+$' @@ -467,116 +389,10 @@ function! nerdtree#renderBookmarks() endfunction "FUNCTION: nerdtree#renderView {{{2 -"The entry function for rendering the tree function! nerdtree#renderView() - setlocal modifiable - - "remember the top line of the buffer and the current line so we can - "restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") - - "delete all lines in the buffer (being careful not to clobber a register) - silent 1,$delete _ - - call nerdtree#dumpHelp() - - "delete the blank line before the help and add one after it - if g:NERDTreeMinimalUI == 0 - call setline(line(".")+1, "") - call cursor(line(".")+1, col(".")) - endif - - if b:NERDTreeShowBookmarks - call nerdtree#renderBookmarks() - endif - - "add the 'up a dir' line - if !g:NERDTreeMinimalUI - call setline(line(".")+1, nerdtree#treeUpDirLine()) - call cursor(line(".")+1, col(".")) - endif - - "draw the header line - let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) - call setline(line(".")+1, header) - call cursor(line(".")+1, col(".")) - - "draw the tree - let old_o = @o - let @o = b:NERDTreeRoot.renderToString() - silent put o - let @o = old_o - - "delete the blank line at the top of the buffer - silent 1,1delete _ - - "restore the view - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(topLine, 1) - normal! zt - call cursor(curLine, curCol) - let &scrolloff = old_scrolloff - - setlocal nomodifiable -endfunction - -"FUNCTION: nerdtree#renderViewSavingPosition {{{2 -"Renders the tree and ensures the cursor stays on the current node or the -"current nodes parent if it is no longer available upon re-rendering -function! nerdtree#renderViewSavingPosition() - let currentNode = g:NERDTreeFileNode.GetSelected() - - "go up the tree till we find a node that will be visible or till we run - "out of nodes - while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() - let currentNode = currentNode.parent - endwhile - - call nerdtree#renderView() - - if currentNode != {} - call currentNode.putCursorHere(0, 0) - endif + call b:NERDTree.render() endfunction " -"FUNCTION: nerdtree#restoreScreenState() {{{2 -" -"Sets the screen state back to what it was when nerdtree#saveScreenState was last -"called. -" -"Assumes the cursor is in the NERDTree window -function! nerdtree#restoreScreenState() - if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize") - return - endif - exec("silent vertical resize ".b:NERDTreeOldWindowSize) - - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(b:NERDTreeOldTopLine, 0) - normal! zt - call setpos(".", b:NERDTreeOldPos) - let &scrolloff=old_scrolloff -endfunction - -"FUNCTION: nerdtree#saveScreenState() {{{2 -"Saves the current cursor position in the current buffer and the window -"scroll position -function! nerdtree#saveScreenState() - let win = winnr() - try - call nerdtree#putCursorInTreeWin() - let b:NERDTreeOldPos = getpos(".") - let b:NERDTreeOldTopLine = line("w0") - let b:NERDTreeOldWindowSize = winwidth("") - call nerdtree#exec(win . "wincmd w") - catch /^NERDTree.InvalidOperationError/ - endtry -endfunction - "FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2 "returns the given line with all the tree parts stripped off " diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 60c905d3..715c9290 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -119,7 +119,7 @@ function! nerdtree#ui_glue#bookmarkNode(...) endif try call currentNode.bookmark(name) - call nerdtree#renderView() + call b:NERDTree.render() catch /^NERDTree.IllegalBookmarkNameError/ call nerdtree#echo("bookmark names must not contain spaces") endtry @@ -141,7 +141,7 @@ endfunction " changes the current root to the selected one function! s:chRoot(node) call a:node.makeRoot() - call nerdtree#renderView() + call b:NERDTree.render() call b:NERDTreeRoot.putCursorHere(0, 0) endfunction @@ -173,14 +173,14 @@ function! nerdtree#ui_glue#clearBookmarks(bookmarks) call bookmark.delete() endfor endif - call nerdtree#renderView() + call b:NERDTree.render() endfunction " FUNCTION: s:closeChildren(node) {{{1 " closes all childnodes of the current node function! s:closeChildren(node) call a:node.closeChildren() - call nerdtree#renderView() + call b:NERDTree.render() call a:node.putCursorHere(0, 0) endfunction @@ -200,7 +200,7 @@ function! s:closeCurrentDir(node) endif endwhile call parent.close() - call nerdtree#renderView() + call b:NERDTree.render() call parent.putCursorHere(0, 0) endif endfunction @@ -227,7 +227,7 @@ function! s:deleteBookmark(bm) if nr2char(getchar()) ==# 'y' try call a:bm.delete() - call nerdtree#renderView() + call b:NERDTree.render() redraw catch /^NERDTree/ call nerdtree#echoWarning("Could not remove bookmark") @@ -242,7 +242,7 @@ endfunction " toggles the help display function! s:displayHelp() let b:treeShowHelp = b:treeShowHelp ? 0 : 1 - call nerdtree#renderView() + call b:NERDTree.render() call nerdtree#centerView() endfunction @@ -486,7 +486,7 @@ endfunction function! s:openNodeRecursively(node) call nerdtree#echo("Recursively opening node. Please wait...") call a:node.openRecursively() - call nerdtree#renderView() + call b:NERDTree.render() redraw call nerdtree#echo("Recursively opening node. Please wait... DONE") endfunction @@ -523,7 +523,7 @@ endfunction function! s:refreshRoot() call nerdtree#echo("Refreshing the root node. This could take a while...") call b:NERDTreeRoot.refresh() - call nerdtree#renderView() + call b:NERDTree.render() redraw call nerdtree#echo("Refreshing the root node. This could take a while... DONE") endfunction @@ -538,7 +538,7 @@ function! s:refreshCurrent(node) call nerdtree#echo("Refreshing node. This could take a while...") call node.refresh() - call nerdtree#renderView() + call b:NERDTree.render() redraw call nerdtree#echo("Refreshing node. This could take a while... DONE") endfunction @@ -573,7 +573,7 @@ endfunction " toggles the use of the NERDTreeIgnore option function! s:toggleIgnoreFilter() let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled - call nerdtree#renderViewSavingPosition() + call b:NERDTree.ui.renderViewSavingPosition() call nerdtree#centerView() endfunction @@ -582,10 +582,10 @@ endfunction function! s:toggleShowBookmarks() let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks if b:NERDTreeShowBookmarks - call nerdtree#renderView() + call b:NERDTree.render() call nerdtree#putCursorOnBookmarkTable() else - call nerdtree#renderViewSavingPosition() + call b:NERDTree.ui.renderViewSavingPosition() endif call nerdtree#centerView() endfunction @@ -594,7 +594,7 @@ endfunction " toggles the display of hidden files function! s:toggleShowFiles() let b:NERDTreeShowFiles = !b:NERDTreeShowFiles - call nerdtree#renderViewSavingPosition() + call b:NERDTree.ui.renderViewSavingPosition() call nerdtree#centerView() endfunction @@ -602,7 +602,7 @@ endfunction " toggles the display of hidden files function! s:toggleShowHidden() let b:NERDTreeShowHidden = !b:NERDTreeShowHidden - call nerdtree#renderViewSavingPosition() + call b:NERDTree.ui.renderViewSavingPosition() call nerdtree#centerView() endfunction @@ -650,7 +650,7 @@ function! nerdtree#ui_glue#upDir(keepState) call b:NERDTreeRoot.path.changeToDir() endif - call nerdtree#renderView() + call b:NERDTree.render() call oldRoot.putCursorHere(0, 0) endif endfunction diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 84a6099f..6de9be4c 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -275,7 +275,7 @@ function! s:Bookmark.toRoot() let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) endtry call targetNode.makeRoot() - call nerdtree#renderView() + call b:NERDTree.render() call targetNode.putCursorHere(0, 0) endif endfunction @@ -293,7 +293,7 @@ function! s:Bookmark.validate() return 1 else call s:Bookmark.CacheBookmarks(1) - call nerdtree#renderView() + call b:NERDTree.render() call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") return 0 endif diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 0ddc1f1f..b80709ed 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -17,8 +17,8 @@ function! s:Creator._bindMappings() command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') - command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call nerdtree#renderView() - command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call nerdtree#renderView() + command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() + command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() endfunction @@ -56,19 +56,16 @@ function! s:Creator.createPrimary(name) unlet t:NERDTreeBufName endif - let newRoot = g:NERDTreeDirNode.New(path) - call newRoot.open() - call self._createTreeWin() + call self._createNERDTree(path) let b:treeShowHelp = 0 let b:NERDTreeIgnoreEnabled = 1 let b:NERDTreeShowFiles = g:NERDTreeShowFiles let b:NERDTreeShowHidden = g:NERDTreeShowHidden let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - let b:NERDTreeRoot = newRoot let b:NERDTreeType = "primary" - call nerdtree#renderView() + call b:NERDTree.render() call b:NERDTreeRoot.putCursorHere(0, 0) call self._broadcastInitEvent() @@ -99,18 +96,26 @@ function! s:Creator.createSecondary(dir) exec "silent edit " . self._nextBufferName() let b:NERDTreePreviousBuf = bufnr(previousBuf) - - let b:NERDTreeRoot = g:NERDTreeDirNode.New(path) - call b:NERDTreeRoot.open() - + call self._createNERDTree(path) call self._setCommonBufOptions() let b:NERDTreeType = "secondary" - call nerdtree#renderView() + call b:NERDTree.render() call self._broadcastInitEvent() endfunction +" FUNCTION: s:Creator._createNERDTree(path) {{{1 +function! s:Creator._createNERDTree(path) + let b:NERDTree = g:NERDTree.New(a:path) + call b:NERDTree.root.open() + + "TODO: This is kept for compatability only since many things use + "b:NERDTreeRoot instead of the new NERDTree.root + "Remove this one day + let b:NERDTreeRoot = b:NERDTree.root +endfunction + " FUNCTION: s:Creator.CreateMirror() {{{1 function! s:Creator.CreateMirror() let creator = s:Creator.New() @@ -166,7 +171,7 @@ function! s:Creator.createMirror() call self._createTreeWin() exec 'buffer ' . bufferName if !&hidden - call nerdtree#renderView() + call b:NERDTree.render() endif endfunction @@ -326,9 +331,9 @@ function! s:Creator.togglePrimary(dir) if !nerdtree#isTreeOpen() call self._createTreeWin() if !&hidden - call nerdtree#renderView() + call b:NERDTree.render() endif - call nerdtree#restoreScreenState() + call b:NERDTree.ui.restoreScreenState() else call nerdtree#closeTree() endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim new file mode 100644 index 00000000..84ffd3e2 --- /dev/null +++ b/lib/nerdtree/nerdtree.vim @@ -0,0 +1,23 @@ +"CLASS: NERDTree +"============================================================ +let s:NERDTree = {} +let g:NERDTree = s:NERDTree + +function! s:NERDTree.ForCurrentBuf() + return b:NERDTree +endfunction + +function! s:NERDTree.New(path) + let newObj = copy(self) + let newObj.ui = g:NERDTreeUI.New(newObj) + let newObj.root = g:NERDTreeDirNode.New(a:path) + + return newObj +endfunction + +"FUNCTION: s:NERDTree.render() {{{1 +"A convenience function - since this is called often +function! s:NERDTree.render() + call self.ui.render() +endfunction + diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 70b46335..845e55c4 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -262,7 +262,7 @@ function! s:Opener._openDirectory(node) call self._gotoTargetWin() if empty(self._where) call a:node.makeRoot() - call nerdtree#renderView() + call b:NERDTree.render() call a:node.putCursorHere(0, 0) elseif self._where == 't' call g:NERDTreeCreator.CreatePrimary(a:node.path.str()) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 520fca6a..2561ff44 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -21,7 +21,7 @@ unlet s:TreeDirNode.activate function! s:TreeDirNode.activate(...) let opts = a:0 ? a:1 : {} call self.toggleOpen(opts) - call nerdtree#renderView() + call b:NERDTree.render() call self.putCursorHere(0, 0) endfunction @@ -450,7 +450,7 @@ function! s:TreeDirNode.reveal(path) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) - call nerdtree#renderView() + call b:NERDTree.render() call n.putCursorHere(1,0) return endif diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index ab8d3719..87859206 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -178,55 +178,6 @@ function! s:TreeFileNode.findSibling(direction) return {} endfunction -"FUNCTION: TreeFileNode.getLineNum(){{{1 -"returns the line number this node is rendered on, or -1 if it isnt rendered -function! s:TreeFileNode.getLineNum() - "if the node is the root then return the root line no. - if self.isRoot() - return s:TreeFileNode.GetRootLineNum() - endif - - let totalLines = line("$") - - "the path components we have matched so far - let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] - "the index of the component we are searching for - let curPathComponent = 1 - - let fullpath = self.path.str({'format': 'UI'}) - - - let lnum = s:TreeFileNode.GetRootLineNum() - while lnum > 0 - let lnum = lnum + 1 - "have we reached the bottom of the tree? - if lnum ==# totalLines+1 - return -1 - endif - - let curLine = getline(lnum) - - let indent = nerdtree#indentLevelFor(curLine) - if indent ==# curPathComponent - let curLine = nerdtree#stripMarkupFromLine(curLine, 1) - - let curPath = join(pathcomponents, '/') . '/' . curLine - if stridx(fullpath, curPath, 0) ==# 0 - if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' - let curLine = substitute(curLine, '/ *$', '', '') - call add(pathcomponents, curLine) - let curPathComponent = curPathComponent + 1 - - if fullpath ==# curPath - return lnum - endif - endif - endif - endif - endwhile - return -1 -endfunction - "FUNCTION: TreeFileNode.GetRootForTab(){{{1 "get the root node for this tab function! s:TreeFileNode.GetRootForTab() @@ -236,21 +187,11 @@ function! s:TreeFileNode.GetRootForTab() return {} endfunction -"FUNCTION: TreeFileNode.GetRootLineNum(){{{1 -"gets the line number of the root node -function! s:TreeFileNode.GetRootLineNum() - let rootLine = 1 - while getline(rootLine) !~# '^\(/\|<\)' - let rootLine = rootLine + 1 - endwhile - return rootLine -endfunction - "FUNCTION: TreeFileNode.GetSelected() {{{1 "gets the treenode that the cursor is currently over function! s:TreeFileNode.GetSelected() try - let path = nerdtree#getPath(line(".")) + let path = b:NERDTree.ui.getPath(line(".")) if path ==# {} return {} endif @@ -348,7 +289,7 @@ endfunction "recurseUpward: try to put the cursor on the parent if the this node isnt "visible function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) - let ln = self.getLineNum() + let ln = b:NERDTree.ui.getLineNum(self) if ln != -1 if a:isJump mark ' @@ -357,11 +298,11 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) else if a:recurseUpward let node = self - while node != {} && node.getLineNum() ==# -1 + while node != {} && b:NERDTree.ui.getLineNum(node) ==# -1 let node = node.parent call node.open() endwhile - call nerdtree#renderView() + call b:NERDTree.render() call node.putCursorHere(a:isJump, 0) endif endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim new file mode 100644 index 00000000..003e566e --- /dev/null +++ b/lib/nerdtree/ui.vim @@ -0,0 +1,262 @@ +"CLASS: UI +"============================================================ +let s:UI = {} +let g:NERDTreeUI = s:UI + +function! s:UI.New(nerdtree) + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + return newObj +endfunction + +"FUNCTION: s:UI.getPath(ln) {{{1 +"Gets the full path to the node that is rendered on the given line number +" +"Args: +"ln: the line number to get the path for +" +"Return: +"A path if a node was selected, {} if nothing is selected. +"If the 'up a dir' line was selected then the path to the parent of the +"current root is returned +function! s:UI.getPath(ln) + let line = getline(a:ln) + + let rootLine = self.getRootLineNum() + + "check to see if we have the root node + if a:ln == rootLine + return b:NERDTreeRoot.path + endif + + if !g:NERDTreeDirArrows + " in case called from outside the tree + if line !~# '^ *[|`▸▾ ]' || line =~# '^$' + return {} + endif + endif + + if line ==# nerdtree#treeUpDirLine() + return b:NERDTreeRoot.path.getParent() + endif + + let indent = self._indentLevelFor(line) + + "remove the tree parts and the leading space + let curFile = nerdtree#stripMarkupFromLine(line, 0) + + let wasdir = 0 + if curFile =~# '/$' + let wasdir = 1 + let curFile = substitute(curFile, '/\?$', '/', "") + endif + + let dir = "" + let lnum = a:ln + while lnum > 0 + let lnum = lnum - 1 + let curLine = getline(lnum) + let curLineStripped = nerdtree#stripMarkupFromLine(curLine, 1) + + "have we reached the top of the tree? + if lnum == rootLine + let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir + break + endif + if curLineStripped =~# '/$' + let lpindent = self._indentLevelFor(curLine) + if lpindent < indent + let indent = indent - 1 + + let dir = substitute (curLineStripped,'^\\', "", "") . dir + continue + endif + endif + endwhile + let curFile = b:NERDTreeRoot.path.drive . dir . curFile + let toReturn = g:NERDTreePath.New(curFile) + return toReturn +endfunction + +"FUNCTION: s:UI.getLineNum(file_node){{{1 +"returns the line number this node is rendered on, or -1 if it isnt rendered +function! s:UI.getLineNum(file_node) + "if the node is the root then return the root line no. + if a:file_node.isRoot() + return b:NERDTree.ui.getRootLineNum() + endif + + let totalLines = line("$") + + "the path components we have matched so far + let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] + "the index of the component we are searching for + let curPathComponent = 1 + + let fullpath = a:file_node.path.str({'format': 'UI'}) + + let lnum = b:NERDTree.ui.getRootLineNum() + while lnum > 0 + let lnum = lnum + 1 + "have we reached the bottom of the tree? + if lnum ==# totalLines+1 + return -1 + endif + + let curLine = getline(lnum) + + let indent = self._indentLevelFor(curLine) + if indent ==# curPathComponent + let curLine = nerdtree#stripMarkupFromLine(curLine, 1) + + let curPath = join(pathcomponents, '/') . '/' . curLine + if stridx(fullpath, curPath, 0) ==# 0 + if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' + let curLine = substitute(curLine, '/ *$', '', '') + call add(pathcomponents, curLine) + let curPathComponent = curPathComponent + 1 + + if fullpath ==# curPath + return lnum + endif + endif + endif + endif + endwhile + return -1 +endfunction + + +"FUNCTION: s:UI.getRootLineNum(){{{1 +"gets the line number of the root node +function! s:UI.getRootLineNum() + let rootLine = 1 + while getline(rootLine) !~# '^\(/\|<\)' + let rootLine = rootLine + 1 + endwhile + return rootLine +endfunction + +"FUNCTION: s:UI._indentLevelFor(line) {{{2 +function! s:UI._indentLevelFor(line) + let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() + " check if line includes arrows + if match(a:line, '[▸▾]') > -1 + " decrement level as arrow uses 3 ascii chars + let level = level - 1 + endif + return level +endfunction + + +"FUNCTION: s:UI.restoreScreenState() {{{2 +" +"Sets the screen state back to what it was when nerdtree#saveScreenState was last +"called. +" +"Assumes the cursor is in the NERDTree window +function! s:UI.restoreScreenState() + if !has_key(self, '_screenState') + return + endif + exec("silent vertical resize " . self._screenState['oldWindowSize']) + + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(self._screenState['oldTopLine'], 0) + normal! zt + call setpos(".", self._screenState['oldPos']) + let &scrolloff=old_scrolloff +endfunction + +"FUNCTION: s:UI.saveScreenState() {{{2 +"Saves the current cursor position in the current buffer and the window +"scroll position +function! s:UI.saveScreenState() + let win = winnr() + try + call nerdtree#putCursorInTreeWin() + let self._screenState = {} + let self._screenState['oldPos'] = getpos(".") + let self._screenState['oldTopLine'] = line("w0") + let self._screenState['oldWindowSize']= winwidth("") + call nerdtree#exec(win . "wincmd w") + catch /^NERDTree.InvalidOperationError/ + endtry +endfunction + +"FUNCTION: s:UI.render() {{{2 +function! s:UI.render() + setlocal modifiable + + "remember the top line of the buffer and the current line so we can + "restore the view exactly how it was + let curLine = line(".") + let curCol = col(".") + let topLine = line("w0") + + "delete all lines in the buffer (being careful not to clobber a register) + silent 1,$delete _ + + call nerdtree#dumpHelp() + + "delete the blank line before the help and add one after it + if g:NERDTreeMinimalUI == 0 + call setline(line(".")+1, "") + call cursor(line(".")+1, col(".")) + endif + + if b:NERDTreeShowBookmarks + call nerdtree#renderBookmarks() + endif + + "add the 'up a dir' line + if !g:NERDTreeMinimalUI + call setline(line(".")+1, nerdtree#treeUpDirLine()) + call cursor(line(".")+1, col(".")) + endif + + "draw the header line + let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + call setline(line(".")+1, header) + call cursor(line(".")+1, col(".")) + + "draw the tree + let old_o = @o + let @o = b:NERDTreeRoot.renderToString() + silent put o + let @o = old_o + + "delete the blank line at the top of the buffer + silent 1,1delete _ + + "restore the view + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(topLine, 1) + normal! zt + call cursor(curLine, curCol) + let &scrolloff = old_scrolloff + + setlocal nomodifiable +endfunction + + +"FUNCTION: UI.renderViewSavingPosition {{{1 +"Renders the tree and ensures the cursor stays on the current node or the +"current nodes parent if it is no longer available upon re-rendering +function! s:UI.renderViewSavingPosition() + let currentNode = g:NERDTreeFileNode.GetSelected() + + "go up the tree till we find a node that will be visible or till we run + "out of nodes + while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() + let currentNode = currentNode.parent + endwhile + + call b:NERDTree.render() + + if currentNode != {} + call currentNode.putCursorHere(0, 0) + endif +endfunction diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4fdc5d2a..4e03f35e 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -117,7 +117,7 @@ function! NERDTreeAddNode() let newTreeNode = g:NERDTreeFileNode.New(newPath) if empty(parentNode) call b:NERDTreeRoot.refresh() - call nerdtree#renderView() + call b:NERDTree.render() elseif parentNode.isOpen || !empty(parentNode.children) call parentNode.addChild(newTreeNode, 1) call NERDTreeRender() @@ -230,7 +230,7 @@ function! NERDTreeCopyNode() let newNode = currentNode.copy(newNodePath) if empty(newNode) call b:NERDTreeRoot.refresh() - call nerdtree#renderView() + call b:NERDTree.render() else call NERDTreeRender() call newNode.putCursorHere(0, 0) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fccad3db..6ad3cdc2 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,7 +148,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call nerdtree#saveScreenState()" + exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()" "disallow insert mode in the NERDTree exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" From 1784de15dd3e45eb6415bbe6505c00a7221d7f44 Mon Sep 17 00:00:00 2001 From: Lucas Caton Date: Tue, 8 Jul 2014 10:57:39 +1000 Subject: [PATCH 146/680] Updating creator.vim file (this fixes #352) --- lib/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index b80709ed..090bc045 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -8,7 +8,7 @@ let g:NERDTreeCreator = s:Creator "FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() "make do the same as the activate node mapping - nnoremap :call nerdtree#invokeKeyMap(g:NERDTreeMapActivateNode) + nnoremap :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode) call g:NERDTreeKeyMap.BindAll() From eaa66aaf630bee59c71d5c1a22bcde36e18bc4ca Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 8 Jul 2014 09:44:41 +0100 Subject: [PATCH 147/680] fix the NERDTreeFind command - broken in recent refactoring --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 715c9290..02094721 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -550,7 +550,7 @@ function! nerdtree#ui_glue#setupCommands() command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() - command! -n=0 -bar NERDTreeFind call nerdtree#ui_glue#findAndRevealPath() + command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() endfunction From 98a5d1fca77011315ebaad418167470d21eddb4e Mon Sep 17 00:00:00 2001 From: alvan Date: Wed, 9 Jul 2014 15:20:24 +0800 Subject: [PATCH 148/680] Use event BufLeave instead of BufWinLeave to record screen state to avoid undefined b:NERDTree error Use event BufLeave instead of BufWinLeave to record screen state. The BufWinLeave event also triggered when exiting(:qa), will cause an undefined b:NERDTree error. --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 6ad3cdc2..88ad526d 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,7 +148,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()" + exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()" "disallow insert mode in the NERDTree exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" From 1e0d1cbc8f4975bc169dc3e900c14152c03d058c Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 9 Jul 2014 09:25:25 +0100 Subject: [PATCH 149/680] move some more view code into the UI class --- autoload/nerdtree.vim | 14 ------- autoload/nerdtree/ui_glue.vim | 44 +++++----------------- lib/nerdtree/ui.vim | 70 +++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 48 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index f5becc57..64ac5dd4 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -126,20 +126,6 @@ endfunction " SECTION: View Functions {{{1 "============================================================ " -"FUNCTION: nerdtree#centerView() {{{2 -"centers the nerd tree window around the cursor (provided the nerd tree -"options permit) -function! nerdtree#centerView() - if g:NERDTreeAutoCenter - let current_line = winline() - let lines_to_top = current_line - let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line - if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold - normal! zz - endif - endif -endfunction - " FUNCTION: nerdtree#chRoot(node) {{{2 " changes the current root to the selected one function! nerdtree#chRoot(node) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 02094721..6058350b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -243,7 +243,7 @@ endfunction function! s:displayHelp() let b:treeShowHelp = b:treeShowHelp ? 0 : 1 call b:NERDTree.render() - call nerdtree#centerView() + call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:findAndRevealPath() {{{1 @@ -372,7 +372,7 @@ function! s:jumpToChild(currentNode, direction) call targetNode.putCursorHere(1, 0) - call nerdtree#centerView() + call b:NERDTree.ui.centerView() endfunction @@ -400,7 +400,7 @@ endfunction function! s:jumpToParent(node) if !empty(a:node.parent) call a:node.parent.putCursorHere(1, 0) - call nerdtree#centerView() + call b:NERDTree.ui.centerView() else call nerdtree#echo("cannot jump to parent") endif @@ -410,7 +410,7 @@ endfunction " moves the cursor to the root node function! s:jumpToRoot() call b:NERDTreeRoot.putCursorHere(1, 0) - call nerdtree#centerView() + call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:jumpToNextSibling(node) {{{1 @@ -434,7 +434,7 @@ function! s:jumpToSibling(currentNode, forward) if !empty(sibling) call sibling.putCursorHere(1, 0) - call nerdtree#centerView() + call b:NERDTree.ui.centerView() endif endfunction @@ -570,53 +570,29 @@ function! s:showMenu(node) endfunction " FUNCTION: s:toggleIgnoreFilter() {{{1 -" toggles the use of the NERDTreeIgnore option function! s:toggleIgnoreFilter() - let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled - call b:NERDTree.ui.renderViewSavingPosition() - call nerdtree#centerView() + call b:NERDTree.ui.toggleIgnoreFilter() endfunction " FUNCTION: s:toggleShowBookmarks() {{{1 -" toggles the display of bookmarks function! s:toggleShowBookmarks() - let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks - if b:NERDTreeShowBookmarks - call b:NERDTree.render() - call nerdtree#putCursorOnBookmarkTable() - else - call b:NERDTree.ui.renderViewSavingPosition() - endif - call nerdtree#centerView() + call b:NERDTree.ui.toggleShowBookmarks() endfunction " FUNCTION: s:toggleShowFiles() {{{1 -" toggles the display of hidden files function! s:toggleShowFiles() - let b:NERDTreeShowFiles = !b:NERDTreeShowFiles - call b:NERDTree.ui.renderViewSavingPosition() - call nerdtree#centerView() + call b:NERDTree.ui.toggleShowFiles() endfunction " FUNCTION: s:toggleShowHidden() {{{1 " toggles the display of hidden files function! s:toggleShowHidden() - let b:NERDTreeShowHidden = !b:NERDTreeShowHidden - call b:NERDTree.ui.renderViewSavingPosition() - call nerdtree#centerView() + call b:NERDTree.ui.toggleShowHidden() endfunction " FUNCTION: s:toggleZoom() {{{1 -" 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 + call b:NERDTree.ui.toggleZoom() endfunction "FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 003e566e..ed93d80c 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -3,6 +3,26 @@ let s:UI = {} let g:NERDTreeUI = s:UI + +function! s:UI.lolcats() + echomsg "lolcats" +endfunction + +"FUNCTION: s:UI.centerView() {{{2 +"centers the nerd tree window around the cursor (provided the nerd tree +"options permit) +function! s:UI.centerView() + if g:NERDTreeAutoCenter + let current_line = winline() + let lines_to_top = current_line + let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line + if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold + normal! zz + endif + endif +endfunction + +"FUNCTION: s:UI.new(nerdtree) {{{1 function! s:UI.New(nerdtree) let newObj = copy(self) let newObj.nerdtree = a:nerdtree @@ -260,3 +280,53 @@ function! s:UI.renderViewSavingPosition() call currentNode.putCursorHere(0, 0) endif endfunction + +" FUNCTION: s:UI.toggleIgnoreFilter() {{{1 +" toggles the use of the NERDTreeIgnore option +function! s:UI.toggleIgnoreFilter() + let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled + call b:NERDTree.ui.renderViewSavingPosition() + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowBookmarks() {{{1 +" toggles the display of bookmarks +function! s:UI.toggleShowBookmarks() + let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks + if b:NERDTreeShowBookmarks + call b:NERDTree.render() + call nerdtree#putCursorOnBookmarkTable() + else + call b:NERDTree.ui.renderViewSavingPosition() + endif + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowFiles() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowFiles() + let b:NERDTreeShowFiles = !b:NERDTreeShowFiles + call b:NERDTree.ui.renderViewSavingPosition() + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowHidden() + let b:NERDTreeShowHidden = !b:NERDTreeShowHidden + call b:NERDTree.ui.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleZoom() {{{1 +" zoom (maximize/minimize) the NERDTree window +function! s:UI.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 From 579d96a0f3b8414916a158c24d8ee9131c5f6845 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 10 Jul 2014 20:14:41 +0100 Subject: [PATCH 150/680] remove testing git plugin --- nerdtree_plugin/git.vim | 65 ----------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 nerdtree_plugin/git.vim diff --git a/nerdtree_plugin/git.vim b/nerdtree_plugin/git.vim deleted file mode 100644 index 67dff596..00000000 --- a/nerdtree_plugin/git.vim +++ /dev/null @@ -1,65 +0,0 @@ -" ============================================================================ -" File: git.vim -" Description: Expt. plugin to add git flags to the UI -" Maintainer: -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ -if exists("g:loaded_nerdtree_git") - finish -endif -let g:loaded_nerdtree_git = 1 - -call g:NERDTreeRefreshNotifier.AddListener("g:NERDTreeGitRefreshListener") - -function! g:NERDTreeGitRefreshListener(path) - if !isdirectory(b:NERDTreeRoot.path.str() . '/.git') - return - end - - let modifiedFiles = s:GetModifiedFiles() - if index(modifiedFiles, a:path.str()) >= 0 - call a:path.flagSet.addFlag("git", "+") - else - call a:path.flagSet.removeFlag("git", "+") - endif -endfunction - -"Cache the list of modified files for a few seconds - otherwise we must shell -"out to get it for every path that is refreshed which takes ages -function! s:GetModifiedFiles() - if !exists('s:modifiedFiles') || (localtime() - s:modifiedFilesTime > 2) - let s:modifiedFiles = split(system('git -C ' . b:NERDTreeRoot.path.str() . ' ls-files -m')) - let s:modifiedFilesTime = localtime() - call map(s:modifiedFiles, 'b:NERDTreeRoot.path.str() . "/" . v:val') - endif - - return s:modifiedFiles -endfunction - -autocmd filetype nerdtree call s:AddHighlighting() -function! s:AddHighlighting() - syn match NERDTreeGitflag #^ *\zs\[+\]# containedin=NERDTreeFile - hi link NERDTreeGitFlag error -endfunction - -"when a buffer is saved, refresh it in nerdtree -autocmd bufwritepost * call s:FileUpdated(expand("%")) -function! s:FileUpdated(fname) - if !nerdtree#isTreeOpen() - return - endif - - call nerdtree#putCursorInTreeWin() - let node = b:NERDTreeRoot.findNode(g:NERDTreePath.New(a:fname)) - if !empty(node) - call node.refresh() - endif - - call NERDTreeRender() -endfunction - From 2f552e116d20e15a26b78ea765ef15478e6a5b67 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 10 Jul 2014 23:35:42 +0100 Subject: [PATCH 151/680] add highlighting for flags Rename the old NERDTreeFlag syntax item to NERDTreeIgnore. --- syntax/nerdtree.vim | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7cbba6ee..5f7b49cc 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -1,8 +1,6 @@ let s:tree_up_dir_line = '.. (up a dir)' -"NERDTreeFlags are syntax items that should be invisible, but give clues as to -"how things should be highlighted -syn match NERDTreeFlag #\~# -syn match NERDTreeFlag #\[RO\]# +syn match NERDTreeIgnore #\~# +syn match NERDTreeIgnore #\[RO\]# "highlighting for the .. (up dir) line at the top of the tree execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" @@ -14,7 +12,7 @@ syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1 syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1 syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 -syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand +syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeIgnore,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand "highlighting for sym links syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile @@ -33,7 +31,10 @@ if g:NERDTreeDirArrows syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile "highlighting for readonly files - syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeFlag,NERDTreeBookmark,NERDTreeFile + syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile + + syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile + syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir else "highlighting for the ~/+ symbols for the directory nodes syn match NERDTreeClosable #\~\<# @@ -52,7 +53,10 @@ else syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile "highlighting for readonly files - syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile + syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreePart,NERDTreePartFile + + syn match NERDTreeFlags #-\[.\]# containedin=NERDTreeFile,NERDTreePartFile + syn match NERDTreeFlags #[+~]\zs\[.\]# containedin=NERDTreeDir endif syn match NERDTreeCWD #^[ Date: Mon, 14 Jul 2014 09:41:56 +0100 Subject: [PATCH 152/680] fix a bug from recent refactoring RE some NERDTreeCWD --- autoload/nerdtree.vim | 6 ------ autoload/nerdtree/ui_glue.vim | 4 ++-- plugin/NERD_tree.vim | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 4032c50b..618328e2 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -127,12 +127,6 @@ endfunction " SECTION: View Functions {{{1 "============================================================ -" -" FUNCTION: nerdtree#chRoot(node) {{{2 -" changes the current root to the selected one -function! nerdtree#chRoot(node) - call s:chRoot(a:node) -endfunction "FUNCTION: nerdtree#closeTree() {{{2 "Closes the primary NERD tree window for this tab diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 6058350b..a5fdb16b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -157,7 +157,7 @@ function! nerdtree#ui_glue#chRootCwd() if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() return endif - call nerdtree#chRoot(g:NERDTreeDirNode.New(cwd)) + call s:chRoot(g:NERDTreeDirNode.New(cwd)) endfunction " FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 @@ -281,7 +281,7 @@ function! s:findAndRevealPath() call nerdtree#putCursorInTreeWin() endif let b:NERDTreeShowHidden = g:NERDTreeShowHidden - call nerdtree#chRoot(g:NERDTreeDirNode.New(p.getParent())) + call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) else if !nerdtree#isTreeOpen() call g:NERDTreeCreator.TogglePrimary("") diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 6ad3cdc2..1b02a31a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -194,7 +194,7 @@ endfunction function! NERDTreeCWD() call NERDTreeFocus() - call nerdtree#chRootCwd() + call nerdtree#ui_glue#chRootCwd() endfunction " SECTION: Post Source Actions {{{1 call nerdtree#postSourceActions() From f9a933991d8e6033e501603ba2ff6f3319b4f308 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 15 Jul 2014 18:54:57 +0100 Subject: [PATCH 153/680] allow plugins to override the default mappings --- doc/NERD_tree.txt | 3 +++ lib/nerdtree/key_map.vim | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 4ddc2507..79b649ff 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1060,6 +1060,9 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* "callback" - the function the new mapping will be bound to "quickhelpText" - the text that will appear in the quickhelp (see |NERDTree-?|) + "override" - if 1 then this new mapping will override whatever previous + mapping was defined for the key/scope combo. Useful for overriding the + default mappings. Additionally, a "scope" argument may be supplied. This constrains the mapping so that it is only activated if the cursor is on a certain object. diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 27dab556..07311ef6 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -134,8 +134,14 @@ endfunction "FUNCTION: KeyMap.Create(options) {{{1 function! s:KeyMap.Create(options) - let newKeyMap = copy(self) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) + + "dont override other mappings unless the 'override' option is given + if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + return + end + + let newKeyMap = copy(self) let newKeyMap.key = opts['key'] let newKeyMap.quickhelpText = opts['quickhelpText'] let newKeyMap.callback = opts['callback'] From fd14757c04f894919e014629fcec91de3c34892c Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 17 Jul 2014 20:16:57 +0100 Subject: [PATCH 154/680] add proper events and make the notifier class generic Expand the event system to have explicit Event objects and potentially many Notifiers. Previously they was only one notifier and one (implied) event. A lot of this is stolen from #358. --- autoload/nerdtree.vim | 3 ++- lib/nerdtree/event.vim | 13 ++++++++++++ lib/nerdtree/notifier.vim | 35 +++++++++++++++++++++++++++++++ lib/nerdtree/path.vim | 4 ++-- lib/nerdtree/refresh_notifier.vim | 21 ------------------- lib/nerdtree/tree_dir_node.vim | 2 +- 6 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 lib/nerdtree/event.vim create mode 100644 lib/nerdtree/notifier.vim delete mode 100644 lib/nerdtree/refresh_notifier.vim diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 618328e2..7f588b83 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -74,10 +74,11 @@ function! nerdtree#loadClassFiles() runtime lib/nerdtree/tree_dir_node.vim runtime lib/nerdtree/opener.vim runtime lib/nerdtree/creator.vim - runtime lib/nerdtree/refresh_notifier.vim runtime lib/nerdtree/flag_set.vim runtime lib/nerdtree/nerdtree.vim runtime lib/nerdtree/ui.vim + runtime lib/nerdtree/event.vim + runtime lib/nerdtree/notifier.vim endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 diff --git a/lib/nerdtree/event.vim b/lib/nerdtree/event.vim new file mode 100644 index 00000000..964e8ff4 --- /dev/null +++ b/lib/nerdtree/event.vim @@ -0,0 +1,13 @@ +"CLASS: Event +"============================================================ +let s:Event = {} +let g:NERDTreeEvent = s:Event + +function! s:Event.New(nerdtree, subject, action, params) abort + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + let newObj.subject = a:subject + let newObj.action = a:action + let newObj.params = a:params + return newObj +endfunction diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim new file mode 100644 index 00000000..b445f8ad --- /dev/null +++ b/lib/nerdtree/notifier.vim @@ -0,0 +1,35 @@ +"CLASS: Notifier +"============================================================ +let s:Notifier = {} + +function! s:Notifier.AddListener(event, funcname) + let listeners = s:Notifier.GetListenersForEvent(a:event) + if listeners == [] + let listenersMap = s:Notifier.GetListenersMap() + let listenersMap[a:event] = listeners + endif + call add(listeners, a:funcname) +endfunction + +function! s:Notifier.NotifyListeners(event, path, params) + let event = g:NERDTreeEvent.New(b:NERDTree, a:path, a:event, a:params) + + for listener in s:Notifier.GetListenersForEvent(a:event) + call {listener}(event) + endfor +endfunction + +function! s:Notifier.GetListenersMap() + if !exists("s:refreshListenersMap") + let s:refreshListenersMap = {} + endif + return s:refreshListenersMap +endfunction + +function! s:Notifier.GetListenersForEvent(name) + let listenersMap = s:Notifier.GetListenersMap() + return get(listenersMap, a:name, []) +endfunction + +let g:NERDTreePathNotifier = deepcopy(s:Notifier) + diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 5ab6b494..5de1dfe2 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -549,13 +549,13 @@ endfunction "FUNCTION: Path.refresh() {{{1 function! s:Path.refresh() call self.readInfoFromDisk(self.str()) - call g:NERDTreeRefreshNotifier.NotifyListeners(self) + call g:NERDTreePathNotifier.NotifyListeners('refresh', self, {}) call self.cacheDisplayString() endfunction "FUNCTION: Path.refreshFlags() {{{1 function! s:Path.refreshFlags() - call g:NERDTreeRefreshNotifier.NotifyListeners(self) + call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, {}) call self.cacheDisplayString() endfunction diff --git a/lib/nerdtree/refresh_notifier.vim b/lib/nerdtree/refresh_notifier.vim deleted file mode 100644 index 0cc62b05..00000000 --- a/lib/nerdtree/refresh_notifier.vim +++ /dev/null @@ -1,21 +0,0 @@ -"CLASS: RefreshNotifier -"============================================================ -let s:RefreshNotifier = {} -let g:NERDTreeRefreshNotifier = s:RefreshNotifier - -function! s:RefreshNotifier.AddListener(funcname) - call add(s:RefreshNotifier.GetListeners(), a:funcname) -endfunction - -function! s:RefreshNotifier.NotifyListeners(refreshedPath) - for listener in s:RefreshNotifier.GetListeners() - call {listener}(a:refreshedPath) - endfor -endfunction - -function! s:RefreshNotifier.GetListeners() - if !exists("s:refreshListeners") - let s:refreshListeners = [] - endif - return s:refreshListeners -endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index e7cc846f..3f11e933 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -252,7 +252,7 @@ function! s:TreeDirNode._initChildren(silent) try let path = g:NERDTreePath.New(i) call self.createChild(path, 0) - call g:NERDTreeRefreshNotifier.NotifyListeners(path) + call g:NERDTreePathNotifier.NotifyListeners('init', path, {}) catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound += 1 endtry From c2dd750860288b8cf81f6bd5ff49dc5ee76a34d5 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 17 Jul 2014 20:27:21 +0100 Subject: [PATCH 155/680] move nerdtree#treeExists.* methods into the NERDTree class --- autoload/nerdtree.vim | 12 ------------ autoload/nerdtree/ui_glue.vim | 2 +- lib/nerdtree/creator.vim | 6 +++--- lib/nerdtree/key_map.vim | 2 +- lib/nerdtree/nerdtree.vim | 18 +++++++++++++++++- lib/nerdtree/tree_file_node.vim | 4 ++-- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 7f588b83..539e7838 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -95,18 +95,6 @@ function! nerdtree#runningWindows() return has("win16") || has("win32") || has("win64") endfunction -" Function: nerdtree#treeExistsForBuffer() {{{2 -" Returns 1 if a nerd tree root exists in the current buffer -function! nerdtree#treeExistsForBuf() - return exists("b:NERDTreeRoot") -endfunction - -" Function: nerdtree#treeExistsForTab() {{{2 -" Returns 1 if a nerd tree root exists in the current tab -function! nerdtree#treeExistsForTab() - return exists("t:NERDTreeBufName") -endfunction - "FUNCTION: nerdtree#treeMarkupReg(dir) {{{2 function! nerdtree#treeMarkupReg() if g:NERDTreeDirArrows diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index a5fdb16b..8607389d 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -260,7 +260,7 @@ function! s:findAndRevealPath() let g:NERDTreeShowHidden = 1 endif - if !nerdtree#treeExistsForTab() + if !g:NERDTree.ExistsForTab() try let cwd = g:NERDTreePath.New(getcwd()) catch /^NERDTree.InvalidArgumentsError/ diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 37915991..86f951ae 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -49,7 +49,7 @@ function! s:Creator.createPrimary(name) call path.changeToDir() endif - if nerdtree#treeExistsForTab() + if g:NERDTree.ExistsForTab() if nerdtree#isTreeOpen() call nerdtree#closeTree() endif @@ -163,7 +163,7 @@ function! s:Creator.createMirror() return endif - if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen() + if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen() call nerdtree#closeTree() endif @@ -327,7 +327,7 @@ endfunction "dir: the full path for the root node (is only used if the NERD tree is being "initialized. function! s:Creator.togglePrimary(dir) - if nerdtree#treeExistsForTab() + if g:NERDTree.ExistsForTab() if !nerdtree#isTreeOpen() call self._createTreeWin() if !&hidden diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 07311ef6..2411406e 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -85,7 +85,7 @@ function! s:KeyMap.Invoke(key) "is in first " "TODO: remove this check when the vim bug is fixed - if !nerdtree#treeExistsForBuf() + if !g:NERDTree.ExistsForBuf() return {} endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 84ffd3e2..a41490b7 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -3,8 +3,24 @@ let s:NERDTree = {} let g:NERDTree = s:NERDTree +" Function: s:NERDTree.ExistsForBuffer() {{{1 +" Returns 1 if a nerd tree root exists in the current buffer +function! s:NERDTree.ExistsForBuf() + return exists("b:NERDTreeRoot") +endfunction + +" Function: s:NERDTree.ExistsForTab() {{{1 +" Returns 1 if a nerd tree root exists in the current tab +function! s:NERDTree.ExistsForTab() + return exists("t:NERDTreeBufName") +endfunction + function! s:NERDTree.ForCurrentBuf() - return b:NERDTree + if s:NERDTree.ExistsForBuf() + return b:NERDTree + else + return {} + endif endfunction function! s:NERDTree.New(path) diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index c450a52d..b4924d78 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -181,7 +181,7 @@ endfunction "FUNCTION: TreeFileNode.GetRootForTab(){{{1 "get the root node for this tab function! s:TreeFileNode.GetRootForTab() - if nerdtree#treeExistsForTab() + if g:NERDTree.ExistsForTab() return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot') end return {} @@ -211,7 +211,7 @@ endfunction "FUNCTION: TreeFileNode.isRoot() {{{1 "returns 1 if this node is b:NERDTreeRoot function! s:TreeFileNode.isRoot() - if !nerdtree#treeExistsForBuf() + if !g:NERDTree.ExistsForBuf() throw "NERDTree.NoTreeError: No tree exists for the current buffer" endif From 8cd045d0e231a77769d9bd166fec9736c21a3a5c Mon Sep 17 00:00:00 2001 From: Xuyuan Pang Date: Sat, 19 Jul 2014 17:57:41 +0800 Subject: [PATCH 156/680] add refreshDirFlags method to avoid refreshing too many files --- lib/nerdtree/tree_dir_node.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 3f11e933..a24c2704 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -448,6 +448,11 @@ function! s:TreeDirNode.refreshFlags() endfor endfunction +"FUNCTION: TreeDirNode.refreshDirFlags() {{{1 +function! s:TreeDirNode.refreshDirFlags() + call self.path.refreshFlags() +endfunction + "FUNCTION: TreeDirNode.reveal(path) {{{1 "reveal the given path, i.e. cache and open all treenodes needed to display it "in the UI From c4086667efd7f0b487f1eb4361533d69712390ca Mon Sep 17 00:00:00 2001 From: ifsred Date: Wed, 6 Aug 2014 12:32:34 +0300 Subject: [PATCH 157/680] Fix doc map for NERDTreeMapChangeRoot --- doc/NERD_tree.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 79b649ff..5d5b3f6f 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -462,8 +462,8 @@ Jump to the previous sibling of the selected node. ------------------------------------------------------------------------------ *NERDTree-C* Default key: C -Map option: NERDTreeMapChdir -Applies to: directories. +Map option: NERDTreeMapChangeRoot +Applies to: files and directories. Make the selected directory node the new tree root. If a file is selected, its parent is used. From a283c0e03ef3f5822e451a5a7b079cec00d372e3 Mon Sep 17 00:00:00 2001 From: Xuyuan Pang Date: Mon, 1 Sep 2014 16:25:27 +0800 Subject: [PATCH 158/680] fix #363 --- lib/nerdtree/creator.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 86f951ae..ee3a199e 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -43,6 +43,10 @@ endfunction function! s:Creator.createPrimary(name) let path = self._pathForString(a:name) + if path == 0 + return + endif + "if instructed to, then change the vim CWD to the dir the NERDTree is "inited in if g:NERDTreeChDirMode != 0 From 8e06723c04ac2bf2d4b28a7ccffb0798dea0659e Mon Sep 17 00:00:00 2001 From: Xuyuan Pang Date: Mon, 1 Sep 2014 16:25:27 +0800 Subject: [PATCH 159/680] fix #363 --- lib/nerdtree/creator.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 86f951ae..2c56b111 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -43,6 +43,10 @@ endfunction function! s:Creator.createPrimary(name) let path = self._pathForString(a:name) + if path == {} + return + endif + "if instructed to, then change the vim CWD to the dir the NERDTree is "inited in if g:NERDTreeChDirMode != 0 @@ -240,7 +244,7 @@ function! s:Creator._pathForString(str) let path = g:NERDTreePath.New(dir) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echo("No bookmark or directory found for: " . a:str) - return + return {} endtry endif if !path.isDirectory From 6ccf83df24ac3044117e10b99be43d00923dbeea Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 15 Sep 2014 11:14:44 -0400 Subject: [PATCH 160/680] Add menu option to display file/directory properties. --- nerdtree_plugin/fs_menu.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4e03f35e..e9447092 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -23,6 +23,7 @@ endif call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) +call NERDTreeAddMenuItem({'text': 'show (p)roperties of the current node', 'shortcut': 'p', 'callback': 'NERDTreeNodeProperties'}) if has("gui_mac") || has("gui_macvim") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) @@ -206,6 +207,12 @@ function! NERDTreeDeleteNode() endfunction +" FUNCTION: NERDTreeNodeProperties() {{{1 +function! NERDTreeNodeProperties() + let currentNode = g:NERDTreeFileNode.GetSelected() + call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) +endfunction + " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() let currentNode = g:NERDTreeFileNode.GetSelected() From 2fd0aa3ec79556cef1507abca259ecf76fb570f3 Mon Sep 17 00:00:00 2001 From: Artem Baguinski Date: Thu, 25 Sep 2014 11:08:53 +0200 Subject: [PATCH 161/680] Fix reloading renamed file --- nerdtree_plugin/fs_menu.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4e03f35e..7e12c042 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -24,7 +24,7 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if has("gui_mac") || has("gui_macvim") +if has("gui_mac") || has("gui_macvim") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) @@ -86,10 +86,10 @@ function! s:promptToRenameBuffer(bufnum, msg, newFileName) " 1. ensure that a new buffer is loaded exec "badd " . quotedFileName " 2. ensure that all windows which display the just deleted filename - " display a buffer for a new filename. + " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec \":e! " . quotedFileName . "\" | endif" + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec \":e! " . a:newFileName . "\" | endif" exec "tabnext " . s:originalTabNumber exec s:originalWindowNumber . "wincmd w" " 3. We don't need a previous buffer anymore From cd8d87fa5734eeaa5d8ac7e33d4c9c33de16db51 Mon Sep 17 00:00:00 2001 From: mixvin Date: Sun, 10 Feb 2013 13:52:23 +0400 Subject: [PATCH 162/680] Fix opening file path, in Windows --- lib/nerdtree/path.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 5de1dfe2..4cdf1a36 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -658,6 +658,7 @@ function! s:Path._strForEdit() "return a relative path if we can let isRelative = 0 if nerdtree#runningWindows() + let p = self.str() let isRelative = stridx(tolower(p), tolower(cwd)) == 0 else let isRelative = stridx(p, cwd) == 0 From 1c08146224885004be1009b50ca6da5d4337cc90 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 29 Oct 2014 11:20:58 +0000 Subject: [PATCH 163/680] apply @mixvin's windows path fix at the top of the method instead --- lib/nerdtree/path.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 4cdf1a36..00fc7ae2 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -652,13 +652,12 @@ endfunction "Return: the string for this path that is suitable to be used with the :edit "command function! s:Path._strForEdit() - let p = escape(self.str({'format': 'UI'}), self._escChars()) + let p = escape(self.str(), self._escChars()) let cwd = getcwd() . s:Path.Slash() "return a relative path if we can let isRelative = 0 if nerdtree#runningWindows() - let p = self.str() let isRelative = stridx(tolower(p), tolower(cwd)) == 0 else let isRelative = stridx(p, cwd) == 0 From 3ce33f017ebf8da773b03f1cc9dfd6fb34c7f1d2 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 29 Oct 2014 18:35:53 +0000 Subject: [PATCH 164/680] fix escaping for `:edit` when renaming files --- nerdtree_plugin/fs_menu.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 7e12c042..e99a85be 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -89,7 +89,8 @@ function! s:promptToRenameBuffer(bufnum, msg, newFileName) " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec \":e! " . a:newFileName . "\" | endif" + let editStr = g:NERDTreePath.New(a:newFileName).str({'format': 'Edit'}) + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . editStr . "' | endif" exec "tabnext " . s:originalTabNumber exec s:originalWindowNumber . "wincmd w" " 3. We don't need a previous buffer anymore From 3d421b8ec5147ab46d708582290f257f0155d797 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 29 Oct 2014 19:18:28 +0000 Subject: [PATCH 165/680] use the built in fnamemodify() to make a path relative Closes #383 --- lib/nerdtree/path.vim | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 00fc7ae2..ea6aa032 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -653,24 +653,14 @@ endfunction "command function! s:Path._strForEdit() let p = escape(self.str(), self._escChars()) - let cwd = getcwd() . s:Path.Slash() - "return a relative path if we can - let isRelative = 0 - if nerdtree#runningWindows() - let isRelative = stridx(tolower(p), tolower(cwd)) == 0 - else - let isRelative = stridx(p, cwd) == 0 - endif + "make it relative + let p = fnamemodify(p, ':.') - if isRelative - let p = strpart(p, strlen(cwd)) - - "handle the edge case where the file begins with a + (vim interprets - "the +foo in `:e +foo` as an option to :edit) - if p[0] == "+" - let p = '\' . p - endif + "handle the edge case where the file begins with a + (vim interprets + "the +foo in `:e +foo` as an option to :edit) + if p[0] == "+" + let p = '\' . p endif if p ==# '' From a895a53f1fa1b6eec4a9600dea639dada1baf31f Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Wed, 29 Oct 2014 20:00:36 -0400 Subject: [PATCH 166/680] easier to read one of the FAQ answers added space between vimrc insertion & question --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 9dacf682..4234b54f 100644 --- a/README.markdown +++ b/README.markdown @@ -87,7 +87,9 @@ A. Stick this in your vimrc __Q. How can I map a specific key or shortcut to open NERDTree?__ -A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): `map :NERDTreeToggle` +A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): + +`map :NERDTreeToggle` __Q. How can I close vim if the only window left open is a NERDTree?__ From ba2604474632ebcbf014baaffb026194556c3476 Mon Sep 17 00:00:00 2001 From: Giacomo Comitti Date: Thu, 20 Nov 2014 07:50:47 +0100 Subject: [PATCH 167/680] Truncate paths at slashes. --- lib/nerdtree/path.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index ea6aa032..dbecb027 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -623,8 +623,13 @@ function! s:Path.str(...) if has_key(options, 'truncateTo') let limit = options['truncateTo'] - if len(toReturn) > limit - let toReturn = "<" . strpart(toReturn, len(toReturn) - limit + 1) + if len(toReturn) > limit-1 + let toReturn = toReturn[(len(toReturn)-limit+1):] + if len(split(toReturn, '/')) > 1 + let toReturn = ' Date: Sun, 21 Dec 2014 17:44:41 +0000 Subject: [PATCH 168/680] Return early if exception was thrown in pathForString --- lib/nerdtree/creator.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 86f951ae..06977597 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -42,6 +42,11 @@ endfunction "name: the name of a bookmark or a directory function! s:Creator.createPrimary(name) let path = self._pathForString(a:name) + + "abort if exception was thrown (bookmark/dir doesn't exist) + if empty(path) + return + endif "if instructed to, then change the vim CWD to the dir the NERDTree is "inited in From f6cad7e9576bc618187450cd4eb5903ee09d449c Mon Sep 17 00:00:00 2001 From: Curtiss Howard Date: Fri, 17 Apr 2015 17:36:23 -0400 Subject: [PATCH 169/680] Use different arrow characters for compatibility. --- autoload/nerdtree.vim | 2 +- lib/nerdtree/tree_file_node.vim | 4 ++-- lib/nerdtree/ui.vim | 6 +++--- syntax/nerdtree.vim | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 539e7838..07b9744a 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -98,7 +98,7 @@ endfunction "FUNCTION: nerdtree#treeMarkupReg(dir) {{{2 function! nerdtree#treeMarkupReg() if g:NERDTreeDirArrows - return '^\([▾▸] \| \+[▾▸] \| \+\)' + return '^\([▼▶] \| \+[▼▶] \| \+\)' endif return '^[ `|]*[\-+~]' diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index b4924d78..d9f956ee 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -383,13 +383,13 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) if self.path.isDirectory if self.isOpen if g:NERDTreeDirArrows - let treeParts = treeParts . '▾ ' + let treeParts = treeParts . '▼ ' else let treeParts = treeParts . '~' endif else if g:NERDTreeDirArrows - let treeParts = treeParts . '▸ ' + let treeParts = treeParts . '▶ ' else let treeParts = treeParts . '+' endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ed93d80c..418fd2d5 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -51,7 +51,7 @@ function! s:UI.getPath(ln) if !g:NERDTreeDirArrows " in case called from outside the tree - if line !~# '^ *[|`▸▾ ]' || line =~# '^$' + if line !~# '^ *[|`▶▼ ]' || line =~# '^$' return {} endif endif @@ -159,9 +159,9 @@ endfunction "FUNCTION: s:UI._indentLevelFor(line) {{{2 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() + let level = match(a:line, '[^ \-+~▶▼`|]') / nerdtree#treeWid() " check if line includes arrows - if match(a:line, '[▸▾]') > -1 + if match(a:line, '[▶▼]') > -1 " decrement level as arrow uses 3 ascii chars let level = level - 1 endif diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 5f7b49cc..8c328686 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -23,12 +23,12 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrows - syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile + syn match NERDTreeClosable #▼# containedin=NERDTreeDir,NERDTreeFile + syn match NERDTreeOpenable #▶# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeDir #[^▾▸ ].*/# + syn match NERDTreeDir #[^▼▶ ].*/# syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeFile #^[^"\.▼▶] *[^▼▶]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile "highlighting for readonly files syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile From 321de60366fc799e5564a7f7f8b826fd8a9b5fc1 Mon Sep 17 00:00:00 2001 From: Devon Hinton Date: Wed, 22 Apr 2015 01:06:47 -0700 Subject: [PATCH 170/680] Remove NERD_tree.txt typo "If not" -> "If No" --- doc/NERD_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 5d5b3f6f..85dfba63 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -131,7 +131,7 @@ The following features and functionality are provided by the NERD tree: :NERDTreeFind *:NERDTreeFind* Find the current file in the tree. - If not tree exists and the current file is under vim's CWD, then init a + If no tree exists and the current file is under vim's CWD, then init a tree at the CWD and reveal the file. Otherwise init a tree in the current file's directory. From 87b27802b57bbf383a812b57338fbab28499b7e8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 1 May 2015 15:33:06 +0100 Subject: [PATCH 171/680] allow control over whether to reuse windows in different tabs When opening a file we will "reuse" a window if the buffer is already open somewhere. Add an option to NERDTreeOpener to configure it to not reuse windows across tabs. --- autoload/nerdtree/ui_glue.vim | 6 ++--- lib/nerdtree/opener.vim | 42 ++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 8607389d..0dd826d7 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -93,13 +93,13 @@ endfunction "FUNCTION: s:activateDirNode() {{{1 "handle the user activating a tree node function! s:activateDirNode(node) - call a:node.activate({'reuse': 1}) + call a:node.activate() endfunction "FUNCTION: s:activateFileNode() {{{1 "handle the user activating a tree node function! s:activateFileNode(node) - call a:node.activate({'reuse': 1, 'where': 'p'}) + call a:node.activate({'reuse': 'all', 'where': 'p'}) endfunction "FUNCTION: s:activateBookmark() {{{1 @@ -324,7 +324,7 @@ function! s:handleLeftClick() if currentNode.path.isDirectory call currentNode.activate() else - call currentNode.activate({'reuse': 1, 'where': 'p'}) + call currentNode.activate({'reuse': 'all', 'where': 'p'}) endif return endif diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 845e55c4..14d1e2b6 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -131,7 +131,8 @@ endfunction " 'where': Specifies whether the node should be opened in new split/tab or in " the previous window. Can be either 'v' or 'h' or 't' (for open in " new tab) -" 'reuse': if a window is displaying the file then jump the cursor there +" 'reuse': if a window is displaying the file then jump the cursor there. Can +" 'all', 'currenttab' or empty to not reuse. " 'keepopen': dont close the tree window " 'stay': open the file, but keep the cursor in the tree win function! s:Opener.New(path, opts) @@ -139,7 +140,13 @@ function! s:Opener.New(path, opts) let newObj._path = a:path let newObj._stay = nerdtree#has_opt(a:opts, 'stay') - let newObj._reuse = nerdtree#has_opt(a:opts, 'reuse') + + if has_key(a:opts, 'reuse') + let newObj._reuse = a:opts['reuse'] + else + let newObj._reuse = '' + endif + let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen') let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' let newObj._treetype = b:NERDTreeType @@ -235,7 +242,7 @@ endfunction "FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if self._reuse && self._reuseWindow() + if self._reuseWindow() return endif @@ -307,23 +314,32 @@ endfunction " "return 1 if we were successful function! s:Opener._reuseWindow() + if empty(self._reuse) + return 0 + endif + "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') if winnr != -1 call nerdtree#exec(winnr . "wincmd w") call self._checkToCloseTree(0) return 1 - else - "check other tabs - let tabnr = self._path.tabnr() - if tabnr - call self._checkToCloseTree(1) - call nerdtree#exec('normal! ' . tabnr . 'gt') - let winnr = bufwinnr('^' . self._path.str() . '$') - call nerdtree#exec(winnr . "wincmd w") - return 1 - endif endif + + if self._reuse == 'currenttab' + return 0 + endif + + "check other tabs + let tabnr = self._path.tabnr() + if tabnr + call self._checkToCloseTree(1) + call nerdtree#exec('normal! ' . tabnr . 'gt') + let winnr = bufwinnr('^' . self._path.str() . '$') + call nerdtree#exec(winnr . "wincmd w") + return 1 + endif + return 0 endfunction From b3281cc63e44d97888a398d202f75c92ed0a0a04 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 1 May 2015 16:00:52 +0100 Subject: [PATCH 172/680] fix one of the old style arrows See here: 1cbd52aa77541682658f4c8a6d217c77a78c3879 --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 8607389d..ad305943 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -312,7 +312,7 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' + if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▶▼] \?$' call currentNode.activate() return endif From 186f817f5ade23fe39db91267f5a1ce66d711af1 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 11:28:54 +0100 Subject: [PATCH 173/680] Revert "fix one of the old style arrows" This reverts commit b3281cc63e44d97888a398d202f75c92ed0a0a04. --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index ad305943..8607389d 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -312,7 +312,7 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▶▼] \?$' + if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' call currentNode.activate() return endif From f8499462c5728f9f96836c99f24e4faf0774bccd Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 11:29:43 +0100 Subject: [PATCH 174/680] Revert "Use different arrow characters for compatibility." This reverts commit f6cad7e9576bc618187450cd4eb5903ee09d449c. --- autoload/nerdtree.vim | 2 +- lib/nerdtree/tree_file_node.vim | 4 ++-- lib/nerdtree/ui.vim | 6 +++--- syntax/nerdtree.vim | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 07b9744a..539e7838 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -98,7 +98,7 @@ endfunction "FUNCTION: nerdtree#treeMarkupReg(dir) {{{2 function! nerdtree#treeMarkupReg() if g:NERDTreeDirArrows - return '^\([▼▶] \| \+[▼▶] \| \+\)' + return '^\([▾▸] \| \+[▾▸] \| \+\)' endif return '^[ `|]*[\-+~]' diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index d9f956ee..b4924d78 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -383,13 +383,13 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) if self.path.isDirectory if self.isOpen if g:NERDTreeDirArrows - let treeParts = treeParts . '▼ ' + let treeParts = treeParts . '▾ ' else let treeParts = treeParts . '~' endif else if g:NERDTreeDirArrows - let treeParts = treeParts . '▶ ' + let treeParts = treeParts . '▸ ' else let treeParts = treeParts . '+' endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 418fd2d5..ed93d80c 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -51,7 +51,7 @@ function! s:UI.getPath(ln) if !g:NERDTreeDirArrows " in case called from outside the tree - if line !~# '^ *[|`▶▼ ]' || line =~# '^$' + if line !~# '^ *[|`▸▾ ]' || line =~# '^$' return {} endif endif @@ -159,9 +159,9 @@ endfunction "FUNCTION: s:UI._indentLevelFor(line) {{{2 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~▶▼`|]') / nerdtree#treeWid() + let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() " check if line includes arrows - if match(a:line, '[▶▼]') > -1 + if match(a:line, '[▸▾]') > -1 " decrement level as arrow uses 3 ascii chars let level = level - 1 endif diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 8c328686..5f7b49cc 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -23,12 +23,12 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrows - syn match NERDTreeClosable #▼# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeOpenable #▶# containedin=NERDTreeDir,NERDTreeFile + syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile + syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeDir #[^▼▶ ].*/# + syn match NERDTreeDir #[^▾▸ ].*/# syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▼▶] *[^▼▶]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile "highlighting for readonly files syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile From 0e87d45e84b942b1d152cf05b5bc418d9d4ee5b0 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 12:01:22 +0100 Subject: [PATCH 175/680] update readme to add an FAQ, update the FAQ style and rm the changelog --- README.markdown | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/README.markdown b/README.markdown index 4234b54f..880079ae 100644 --- a/README.markdown +++ b/README.markdown @@ -66,48 +66,38 @@ Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. Faq --- -__Q. Can I have the nerdtree on every tab automatically?__ +> Is there any support for `git` flags? -A. Nope. If this is something you want then chances are you aren't using tabs - and buffers as they were intended to be used. Read this - http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers +Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). - If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) -__Q. How can I open a NERDTree automatically when vim starts up?__ +> Can I have the nerdtree on every tab automatically? -A. Stick this in your vimrc: `autocmd vimenter * NERDTree` +Nope. If this is something you want then chances are you aren't using tabs and +buffers as they were intended to be used. Read this +http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers -__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__ +If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) -A. Stick this in your vimrc +> How can I open a NERDTree automatically when vim starts up? + +Stick this in your vimrc: `autocmd vimenter * NERDTree` + +> How can I open a NERDTree automatically when vim starts up if no files were specified? + +Stick this in your vimrc autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif -__Q. How can I map a specific key or shortcut to open NERDTree?__ +> How can I map a specific key or shortcut to open NERDTree? -A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): +Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): `map :NERDTreeToggle` -__Q. How can I close vim if the only window left open is a NERDTree?__ +> How can I close vim if the only window left open is a NERDTree? -A. Stick this in your vimrc: +Stick this in your vimrc: `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif` - - -Changelog ---------- - -4.2.0 (2011-12-28) - - * Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) - * shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) - * Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson) - * tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) - * if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) - * use 'file' completion when doing copying, create, and move operations (EvanDotPro) - * lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) - From 973c9906f8ff548ad60f93b73dfc424356931890 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 12:42:59 +0100 Subject: [PATCH 176/680] refactor 3 more functions out of the monolithic autoload file --- autoload/nerdtree.vim | 21 +-------------------- autoload/nerdtree/ui_glue.vim | 6 +++--- lib/nerdtree/ui.vim | 33 +++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 539e7838..d68faaaf 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -95,25 +95,6 @@ function! nerdtree#runningWindows() return has("win16") || has("win32") || has("win64") endfunction -"FUNCTION: nerdtree#treeMarkupReg(dir) {{{2 -function! nerdtree#treeMarkupReg() - if g:NERDTreeDirArrows - return '^\([▾▸] \| \+[▾▸] \| \+\)' - endif - - return '^[ `|]*[\-+~]' -endfunction - -"FUNCTION: nerdtree#treeUpDirLine(dir) {{{2 -function! nerdtree#treeUpDirLine() - return '.. (up a dir)' -endfunction - -"FUNCTION: nerdtree#treeWid(dir) {{{2 -function! nerdtree#treeWid() - return 2 -endfunction - " SECTION: View Functions {{{1 "============================================================ @@ -374,7 +355,7 @@ endfunction function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) let line = a:line "remove the tree parts and the leading space - let line = substitute (line, nerdtree#treeMarkupReg(),"","") + let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") "strip off any read only flag let line = substitute (line, ' \[RO\]', "","") diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 8607389d..a86011c5 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -85,7 +85,7 @@ endfunction "FUNCTION: s:activateAll() {{{1 "handle the user activating the updir line function! s:activateAll() - if getline(".") ==# nerdtree#treeUpDirLine() + if getline(".") ==# g:NERDTreeUI.UpDirLine() return nerdtree#ui_glue#upDir(0) endif endfunction @@ -312,7 +312,7 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$' + if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$' call currentNode.activate() return endif @@ -320,7 +320,7 @@ function! s:handleLeftClick() if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 let char = strpart(startToCur, strlen(startToCur)-1, 1) - if char !~# nerdtree#treeMarkupReg() + if char !~# g:NERDTreeUI.MarkupReg() if currentNode.path.isDirectory call currentNode.activate() else diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ed93d80c..8382b4fb 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -56,7 +56,7 @@ function! s:UI.getPath(ln) endif endif - if line ==# nerdtree#treeUpDirLine() + if line ==# s:UI.UpDirLine() return b:NERDTreeRoot.path.getParent() endif @@ -146,7 +146,6 @@ function! s:UI.getLineNum(file_node) return -1 endfunction - "FUNCTION: s:UI.getRootLineNum(){{{1 "gets the line number of the root node function! s:UI.getRootLineNum() @@ -157,9 +156,9 @@ function! s:UI.getRootLineNum() return rootLine endfunction -"FUNCTION: s:UI._indentLevelFor(line) {{{2 +"FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid() + let level = match(a:line, '[^ \-+~▸▾`|]') / s:UI.IndentWid() " check if line includes arrows if match(a:line, '[▸▾]') > -1 " decrement level as arrow uses 3 ascii chars @@ -168,8 +167,21 @@ function! s:UI._indentLevelFor(line) return level endfunction +"FUNCTION: s:UI.IndentWid() {{{1 +function! s:UI.IndentWid() + return 2 +endfunction + +"FUNCTION: s:UI.MarkupReg() {{{1 +function! s:UI.MarkupReg() + if g:NERDTreeDirArrows + return '^\([▾▸] \| \+[▾▸] \| \+\)' + endif + + return '^[ `|]*[\-+~]' +endfunction -"FUNCTION: s:UI.restoreScreenState() {{{2 +"FUNCTION: s:UI.restoreScreenState() {{{1 " "Sets the screen state back to what it was when nerdtree#saveScreenState was last "called. @@ -189,7 +201,7 @@ function! s:UI.restoreScreenState() let &scrolloff=old_scrolloff endfunction -"FUNCTION: s:UI.saveScreenState() {{{2 +"FUNCTION: s:UI.saveScreenState() {{{1 "Saves the current cursor position in the current buffer and the window "scroll position function! s:UI.saveScreenState() @@ -205,7 +217,7 @@ function! s:UI.saveScreenState() endtry endfunction -"FUNCTION: s:UI.render() {{{2 +"FUNCTION: s:UI.render() {{{1 function! s:UI.render() setlocal modifiable @@ -232,7 +244,7 @@ function! s:UI.render() "add the 'up a dir' line if !g:NERDTreeMinimalUI - call setline(line(".")+1, nerdtree#treeUpDirLine()) + call setline(line(".")+1, s:UI.UpDirLine()) call cursor(line(".")+1, col(".")) endif @@ -330,3 +342,8 @@ function! s:UI.toggleZoom() let b:NERDTreeZoomed = 1 endif endfunction + +"FUNCTION: s:UI.UpDirLine() {{{1 +function! s:UI.UpDirLine() + return '.. (up a dir)' +endfunction From 8270b6d71782930306b5788b218af82c59b01224 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 14:31:57 +0100 Subject: [PATCH 177/680] move nerdtree#getTreeWinNum out of autoload --- autoload/nerdtree.vim | 18 ++++-------------- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/nerdtree.vim | 10 ++++++++++ lib/nerdtree/ui.vim | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d68faaaf..be1afbe9 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -106,7 +106,7 @@ function! nerdtree#closeTree() endif if winnr("$") != 1 - if winnr() == nerdtree#getTreeWinNum() + if winnr() == g:NERDTree.GetWinNum() call nerdtree#exec("wincmd p") let bufnr = bufnr("") call nerdtree#exec("wincmd p") @@ -114,7 +114,7 @@ function! nerdtree#closeTree() let bufnr = bufnr("") endif - call nerdtree#exec(nerdtree#getTreeWinNum() . " wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . " wincmd w") close call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") else @@ -275,19 +275,9 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#getTreeWinNum() {{{2 -"gets the nerd tree window number for this tab -function! nerdtree#getTreeWinNum() - if exists("t:NERDTreeBufName") - return bufwinnr(t:NERDTreeBufName) - else - return -1 - endif -endfunction - "FUNCTION: nerdtree#isTreeOpen() {{{2 function! nerdtree#isTreeOpen() - return nerdtree#getTreeWinNum() != -1 + return g:NERDTree.GetWinNum() != -1 endfunction "FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 @@ -320,7 +310,7 @@ function! nerdtree#putCursorInTreeWin() throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" endif - call nerdtree#exec(nerdtree#getTreeWinNum() . "wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") endfunction "FUNCTION: nerdtree#renderBookmarks {{{2 diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 6de9be4c..8a94b256 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -253,7 +253,7 @@ endfunction " FUNCTION: Bookmark.str() {{{1 " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() - let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name) + let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name) if &nu let pathStrMaxLen = pathStrMaxLen - &numberwidth endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a41490b7..91ccc532 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -23,6 +23,16 @@ function! s:NERDTree.ForCurrentBuf() endif endfunction +"FUNCTION: s:NERDTree.GetWinNum() {{{1 +"gets the nerd tree window number for this tab +function! s:NERDTree.GetWinNum() + if exists("t:NERDTreeBufName") + return bufwinnr(t:NERDTreeBufName) + else + return -1 + endif +endfunction + function! s:NERDTree.New(path) let newObj = copy(self) let newObj.ui = g:NERDTreeUI.New(newObj) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 8382b4fb..209f8262 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -15,7 +15,7 @@ function! s:UI.centerView() if g:NERDTreeAutoCenter let current_line = winline() let lines_to_top = current_line - let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line + let lines_to_bottom = winheight(g:NERDTree.GetWinNum()) - current_line if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold normal! zz endif From 0d88ce946fc21eca51bc1efef47ae843845e5f16 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 14:44:32 +0100 Subject: [PATCH 178/680] move isTreeOpen() out of autoload --- autoload/nerdtree.vim | 18 ++++-------------- autoload/nerdtree/ui_glue.vim | 4 ++-- lib/nerdtree/creator.vim | 6 +++--- lib/nerdtree/nerdtree.vim | 13 +++++++++++++ plugin/NERD_tree.vim | 2 +- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index be1afbe9..f3fc0be0 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -101,9 +101,7 @@ endfunction "FUNCTION: nerdtree#closeTree() {{{2 "Closes the primary NERD tree window for this tab function! nerdtree#closeTree() - if !nerdtree#isTreeOpen() - throw "NERDTree.NoTreeFoundError: no NERDTree is open" - endif + call g:NERDTree.MustBeOpen() if winnr("$") != 1 if winnr() == g:NERDTree.GetWinNum() @@ -125,7 +123,7 @@ endfunction "FUNCTION: nerdtree#closeTreeIfOpen() {{{2 "Closes the NERD tree window if it is open function! nerdtree#closeTreeIfOpen() - if nerdtree#isTreeOpen() + if g:NERDTree.IsOpen() call nerdtree#closeTree() endif endfunction @@ -133,7 +131,7 @@ endfunction "FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2 "Closes the NERD tree window if the close on open option is set function! nerdtree#closeTreeIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && nerdtree#isTreeOpen() + if g:NERDTreeQuitOnOpen && g:NERDTree.IsOpen() call nerdtree#closeTree() endif endfunction @@ -275,11 +273,6 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#isTreeOpen() {{{2 -function! nerdtree#isTreeOpen() - return g:NERDTree.GetWinNum() != -1 -endfunction - "FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 "Places the cursor at the top of the bookmarks table function! nerdtree#putCursorOnBookmarkTable() @@ -306,10 +299,7 @@ endfunction "FUNCTION: nerdtree#putCursorInTreeWin(){{{2 "Places the cursor in the nerd tree window function! nerdtree#putCursorInTreeWin() - if !nerdtree#isTreeOpen() - throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" - endif - + call g:NERDTree.MustBeOpen() call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index a86011c5..3b9784a1 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -275,7 +275,7 @@ function! s:findAndRevealPath() endif else if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) - if !nerdtree#isTreeOpen() + if !g:NERDTree.IsOpen() call g:NERDTreeCreator.TogglePrimary('') else call nerdtree#putCursorInTreeWin() @@ -283,7 +283,7 @@ function! s:findAndRevealPath() let b:NERDTreeShowHidden = g:NERDTreeShowHidden call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) else - if !nerdtree#isTreeOpen() + if !g:NERDTree.IsOpen() call g:NERDTreeCreator.TogglePrimary("") endif endif diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 06977597..efa9846c 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -55,7 +55,7 @@ function! s:Creator.createPrimary(name) endif if g:NERDTree.ExistsForTab() - if nerdtree#isTreeOpen() + if g:NERDTree.IsOpen() call nerdtree#closeTree() endif unlet t:NERDTreeBufName @@ -168,7 +168,7 @@ function! s:Creator.createMirror() return endif - if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen() + if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen() call nerdtree#closeTree() endif @@ -333,7 +333,7 @@ endfunction "initialized. function! s:Creator.togglePrimary(dir) if g:NERDTree.ExistsForTab() - if !nerdtree#isTreeOpen() + if !g:NERDTree.IsOpen() call self._createTreeWin() if !&hidden call b:NERDTree.render() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 91ccc532..29a5930b 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -33,6 +33,19 @@ function! s:NERDTree.GetWinNum() endif endfunction +"FUNCTION: s:NERDTree.IsOpen() {{{1 +function! s:NERDTree.IsOpen() + return s:NERDTree.GetWinNum() != -1 +endfunction + +"FUNCTION: s:NERDTree.MustBeOpen() {{{1 +function! s:NERDTree.MustBeOpen() + if !s:NERDTree.IsOpen() + throw "NERDTree.TreeNotOpen" + endif +endfunction + +"FUNCTION: s:NERDTree.New() {{{1 function! s:NERDTree.New(path) let newObj = copy(self) let newObj.ui = g:NERDTreeUI.New(newObj) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 28fd3ad1..8038668a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -185,7 +185,7 @@ function! NERDTreeRender() endfunction function! NERDTreeFocus() - if nerdtree#isTreeOpen() + if g:NERDTree.IsOpen() call nerdtree#putCursorInTreeWin() else call g:NERDTreeCreator.TogglePrimary("") From 53d2de86eb9b2fa0e77272dfc9d94ee33467e895 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 15:01:58 +0100 Subject: [PATCH 179/680] move the closeTree functions out of autoload Remove `closeTreeIfOpen` and just make `closeTree` fail silently. --- autoload/nerdtree.vim | 38 ----------------------------------- autoload/nerdtree/ui_glue.vim | 4 ++-- lib/nerdtree/creator.vim | 6 +++--- lib/nerdtree/nerdtree.vim | 33 +++++++++++++++++++++++++++++- lib/nerdtree/opener.vim | 2 +- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index f3fc0be0..bb422dba 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -98,44 +98,6 @@ endfunction " SECTION: View Functions {{{1 "============================================================ -"FUNCTION: nerdtree#closeTree() {{{2 -"Closes the primary NERD tree window for this tab -function! nerdtree#closeTree() - call g:NERDTree.MustBeOpen() - - if winnr("$") != 1 - if winnr() == g:NERDTree.GetWinNum() - call nerdtree#exec("wincmd p") - let bufnr = bufnr("") - call nerdtree#exec("wincmd p") - else - let bufnr = bufnr("") - endif - - call nerdtree#exec(g:NERDTree.GetWinNum() . " wincmd w") - close - call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") - else - close - endif -endfunction - -"FUNCTION: nerdtree#closeTreeIfOpen() {{{2 -"Closes the NERD tree window if it is open -function! nerdtree#closeTreeIfOpen() - if g:NERDTree.IsOpen() - call nerdtree#closeTree() - endif -endfunction - -"FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2 -"Closes the NERD tree window if the close on open option is set -function! nerdtree#closeTreeIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && g:NERDTree.IsOpen() - call nerdtree#closeTree() - endif -endfunction - "FUNCTION: nerdtree#dumpHelp {{{2 "prints out the quick help function! nerdtree#dumpHelp() diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 3b9784a1..1dbfc505 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -212,7 +212,7 @@ function! s:closeTreeWindow() exec "buffer " . b:NERDTreePreviousBuf else if winnr("$") > 1 - call nerdtree#closeTree() + call g:NERDTree.Close() else call nerdtree#echo("Cannot close last window") endif @@ -547,7 +547,7 @@ endfunction function! nerdtree#ui_glue#setupCommands() command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('') command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') - command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen() + command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index efa9846c..2d6a5c2e 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -56,7 +56,7 @@ function! s:Creator.createPrimary(name) if g:NERDTree.ExistsForTab() if g:NERDTree.IsOpen() - call nerdtree#closeTree() + call g:NERDTree.Close() endif unlet t:NERDTreeBufName endif @@ -169,7 +169,7 @@ function! s:Creator.createMirror() endif if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen() - call nerdtree#closeTree() + call g:NERDTree.Close() endif let t:NERDTreeBufName = bufferName @@ -340,7 +340,7 @@ function! s:Creator.togglePrimary(dir) endif call b:NERDTree.ui.restoreScreenState() else - call nerdtree#closeTree() + call g:NERDTree.Close() endif else call self.createPrimary(a:dir) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 29a5930b..7fec67b7 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -3,6 +3,38 @@ let s:NERDTree = {} let g:NERDTree = s:NERDTree +"FUNCTION: s:NERDTree.Close() {{{1 +"Closes the primary NERD tree window for this tab +function! s:NERDTree.Close() + if !s:NERDTree.IsOpen() + return + endif + + if winnr("$") != 1 + if winnr() == s:NERDTree.GetWinNum() + call nerdtree#exec("wincmd p") + let bufnr = bufnr("") + call nerdtree#exec("wincmd p") + else + let bufnr = bufnr("") + endif + + call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w") + close + call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") + else + close + endif +endfunction + +"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 +"Closes the NERD tree window if the close on open option is set +function! s:NERDTree.CloseIfQuitOnOpen() + if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen() + call s:NERDTree.Close() + endif +endfunction + " Function: s:NERDTree.ExistsForBuffer() {{{1 " Returns 1 if a nerd tree root exists in the current buffer function! s:NERDTree.ExistsForBuf() @@ -59,4 +91,3 @@ endfunction function! s:NERDTree.render() call self.ui.render() endfunction - diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 845e55c4..6dea3b0a 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -40,7 +40,7 @@ function! s:Opener._checkToCloseTree(newtab) endif if (a:newtab && self._where == 't') || !a:newtab - call nerdtree#closeTreeIfQuitOnOpen() + call g:NERDTree.CloseIfQuitOnOpen() endif endfunction From b0114d202bd3641cffb232a5f1f4522c02659880 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 15:05:28 +0100 Subject: [PATCH 180/680] move dumpHelp out of autoload --- autoload/nerdtree.vim | 107 ---------------------------------------- lib/nerdtree/ui.vim | 110 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 108 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index bb422dba..48bdb807 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -98,113 +98,6 @@ endfunction " SECTION: View Functions {{{1 "============================================================ -"FUNCTION: nerdtree#dumpHelp {{{2 -"prints out the quick help -function! nerdtree#dumpHelp() - let old_h = @h - if b:treeShowHelp ==# 1 - let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" - let @h=@h."\" ============================\n" - let @h=@h."\" File node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" - let @h=@h."\" ,\n" - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" - else - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" - endif - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" - endif - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" - let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Directory node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" - let @h=@h."\" current node recursively\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Bookmark table mappings~\n" - let @h=@h."\" double-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree navigation mappings~\n" - let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Filesystem mappings~\n" - let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" - let @h=@h."\" but leave old root open\n" - let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" - let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" - - "add quickhelp entries for each custom key map - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Custom mappings~\n" - for i in g:NERDTreeKeyMap.All() - if !empty(i.quickhelpText) - let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" - endif - endfor - - 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" - let @h=@h."\" :Bookmark []\n" - let @h=@h."\" :BookmarkToRoot \n" - let @h=@h."\" :RevealBookmark \n" - let @h=@h."\" :OpenBookmark \n" - let @h=@h."\" :ClearBookmarks []\n" - let @h=@h."\" :ClearAllBookmarks\n" - silent! put h - elseif g:NERDTreeMinimalUI == 0 - let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" - silent! put h - endif - - let @h = old_h -endfunction - "FUNCTION: nerdtree#echo {{{2 "A wrapper for :echo. Appends 'NERDTree:' on the front of all messages " diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 209f8262..b33fc8ba 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -22,6 +22,114 @@ function! s:UI.centerView() endif endfunction +"FUNCTION: s:UI._dumpHelp {{{1 +"prints out the quick help +function! s:UI._dumpHelp() + let old_h = @h + if b:treeShowHelp ==# 1 + let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" + let @h=@h."\" ============================\n" + let @h=@h."\" File node mappings~\n" + let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let @h=@h."\" ,\n" + if b:NERDTreeType ==# "primary" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + else + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" + endif + if b:NERDTreeType ==# "primary" + let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" + endif + let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let @h=@h."\" middle-click,\n" + let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" + let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" + let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" + let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Directory node mappings~\n" + let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" + let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" + let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" + let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let @h=@h."\" current node recursively\n" + let @h=@h."\" middle-click,\n" + let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Bookmark table mappings~\n" + let @h=@h."\" double-click,\n" + let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Tree navigation mappings~\n" + let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" + let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" + let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" + let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" + let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Filesystem mappings~\n" + let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let @h=@h."\" selected dir\n" + let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" + let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let @h=@h."\" but leave old root open\n" + let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" + let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" + let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" + let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let @h=@h."\" selected dir\n" + let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Tree filtering mappings~\n" + let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" + + "add quickhelp entries for each custom key map + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Custom mappings~\n" + for i in g:NERDTreeKeyMap.All() + if !empty(i.quickhelpText) + let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" + endif + endfor + + 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" + let @h=@h."\" :Bookmark []\n" + let @h=@h."\" :BookmarkToRoot \n" + let @h=@h."\" :RevealBookmark \n" + let @h=@h."\" :OpenBookmark \n" + let @h=@h."\" :ClearBookmarks []\n" + let @h=@h."\" :ClearAllBookmarks\n" + silent! put h + elseif g:NERDTreeMinimalUI == 0 + let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" + silent! put h + endif + + let @h = old_h +endfunction + + "FUNCTION: s:UI.new(nerdtree) {{{1 function! s:UI.New(nerdtree) let newObj = copy(self) @@ -230,7 +338,7 @@ function! s:UI.render() "delete all lines in the buffer (being careful not to clobber a register) silent 1,$delete _ - call nerdtree#dumpHelp() + call self._dumpHelp() "delete the blank line before the help and add one after it if g:NERDTreeMinimalUI == 0 From 8b189cb263b17a9cc3393cbcb037c65d99579fb8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 15:24:59 +0100 Subject: [PATCH 181/680] move some rendering and cursor moving functions out of autoload --- autoload/nerdtree.vim | 87 ----------------------------------- autoload/nerdtree/ui_glue.vim | 4 +- lib/nerdtree/nerdtree.vim | 30 ++++++++++++ lib/nerdtree/opener.vim | 6 +-- lib/nerdtree/ui.vim | 69 ++++++++++++++++++++++++--- plugin/NERD_tree.vim | 2 +- 6 files changed, 99 insertions(+), 99 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 48bdb807..22283aab 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -128,96 +128,9 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 -"Places the cursor at the top of the bookmarks table -function! nerdtree#putCursorOnBookmarkTable() - if !b:NERDTreeShowBookmarks - throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" - endif - - if g:NERDTreeMinimalUI - return cursor(1, 2) - endif - - let rootNodeLine = b:NERDTree.ui.getRootLineNum() - - let line = 1 - while getline(line) !~# '^>-\+Bookmarks-\+$' - let line = line + 1 - if line >= rootNodeLine - throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" - endif - endwhile - call cursor(line, 2) -endfunction - -"FUNCTION: nerdtree#putCursorInTreeWin(){{{2 -"Places the cursor in the nerd tree window -function! nerdtree#putCursorInTreeWin() - call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") -endfunction - -"FUNCTION: nerdtree#renderBookmarks {{{2 -function! nerdtree#renderBookmarks() - - if g:NERDTreeMinimalUI == 0 - call setline(line(".")+1, ">----------Bookmarks----------") - call cursor(line(".")+1, col(".")) - endif - - for i in g:NERDTreeBookmark.Bookmarks() - call setline(line(".")+1, i.str()) - call cursor(line(".")+1, col(".")) - endfor - - call setline(line(".")+1, '') - call cursor(line(".")+1, col(".")) -endfunction - "FUNCTION: nerdtree#renderView {{{2 function! nerdtree#renderView() call b:NERDTree.render() endfunction -" -"FUNCTION: nerdtree#stripMarkupFromLine(line, removeLeadingSpaces){{{2 -"returns the given line with all the tree parts stripped off -" -"Args: -"line: the subject line -"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = -"any spaces before the actual text of the node) -function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) - let line = a:line - "remove the tree parts and the leading space - let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") - - "strip off any read only flag - let line = substitute (line, ' \[RO\]', "","") - - "strip off any bookmark flags - let line = substitute (line, ' {[^}]*}', "","") - - "strip off any executable flags - let line = substitute (line, '*\ze\($\| \)', "","") - - "strip off any generic flags - let line = substitute (line, '\[[^]]*\]', "","") - - let wasdir = 0 - if line =~# '/$' - let wasdir = 1 - endif - let line = substitute (line,' -> .*',"","") " remove link to - if wasdir ==# 1 - let line = substitute (line, '/\?$', '/', "") - endif - - if a:removeLeadingSpaces - let line = substitute (line, '^ *', '', '') - endif - - return line -endfunction " vim: set sw=4 sts=4 et fdm=marker: diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 1dbfc505..3bdc1b2f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -278,7 +278,7 @@ function! s:findAndRevealPath() if !g:NERDTree.IsOpen() call g:NERDTreeCreator.TogglePrimary('') else - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() endif let b:NERDTreeShowHidden = g:NERDTreeShowHidden call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) @@ -288,7 +288,7 @@ function! s:findAndRevealPath() endif endif endif - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() call b:NERDTreeRoot.reveal(p) if p.isUnixHiddenFile() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 7fec67b7..8e3bdde5 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -35,6 +35,36 @@ function! s:NERDTree.CloseIfQuitOnOpen() endif endfunction +"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 +"Places the cursor at the top of the bookmarks table +function! s:NERDTree.CursorToBookmarkTable() + if !b:NERDTreeShowBookmarks + throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" + endif + + if g:NERDTreeMinimalUI + return cursor(1, 2) + endif + + let rootNodeLine = b:NERDTree.ui.getRootLineNum() + + let line = 1 + while getline(line) !~# '^>-\+Bookmarks-\+$' + let line = line + 1 + if line >= rootNodeLine + throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" + endif + endwhile + call cursor(line, 2) +endfunction + +"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 +"Places the cursor in the nerd tree window +function! s:NERDTree.CursorToTreeWin() + call g:NERDTree.MustBeOpen() + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") +endfunction + " Function: s:NERDTree.ExistsForBuffer() {{{1 " Returns 1 if a nerd tree root exists in the current buffer function! s:NERDTree.ExistsForBuf() diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 6dea3b0a..cd6619bc 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -189,7 +189,7 @@ function! s:Opener._newSplit() try exec(splitMode." sp ") catch /^Vim\%((\a\+)\)\=:E37/ - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." catch /^Vim\%((\a\+)\)\=:/ "do nothing @@ -219,7 +219,7 @@ function! s:Opener._newVSplit() vnew "resize the nerd tree back to the original size - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() exec("silent vertical resize ". winwidth) call nerdtree#exec('wincmd p') endfunction @@ -288,7 +288,7 @@ function! s:Opener._previousWindow() call nerdtree#exec('wincmd p') endif catch /^Vim\%((\a\+)\)\=:E37/ - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." catch /^Vim\%((\a\+)\)\=:/ echo v:exception diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index b33fc8ba..dfe96a3f 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -171,7 +171,7 @@ function! s:UI.getPath(ln) let indent = self._indentLevelFor(line) "remove the tree parts and the leading space - let curFile = nerdtree#stripMarkupFromLine(line, 0) + let curFile = self._stripMarkup(line, 0) let wasdir = 0 if curFile =~# '/$' @@ -184,7 +184,7 @@ function! s:UI.getPath(ln) while lnum > 0 let lnum = lnum - 1 let curLine = getline(lnum) - let curLineStripped = nerdtree#stripMarkupFromLine(curLine, 1) + let curLineStripped = self._stripMarkup(curLine, 1) "have we reached the top of the tree? if lnum == rootLine @@ -235,7 +235,7 @@ function! s:UI.getLineNum(file_node) let indent = self._indentLevelFor(curLine) if indent ==# curPathComponent - let curLine = nerdtree#stripMarkupFromLine(curLine, 1) + let curLine = self._stripMarkup(curLine, 1) let curPath = join(pathcomponents, '/') . '/' . curLine if stridx(fullpath, curPath, 0) ==# 0 @@ -289,6 +289,23 @@ function! s:UI.MarkupReg() return '^[ `|]*[\-+~]' endfunction +"FUNCTION: s:UI._renderBookmarks {{{1 +function! s:UI._renderBookmarks() + + if g:NERDTreeMinimalUI == 0 + call setline(line(".")+1, ">----------Bookmarks----------") + call cursor(line(".")+1, col(".")) + endif + + for i in g:NERDTreeBookmark.Bookmarks() + call setline(line(".")+1, i.str()) + call cursor(line(".")+1, col(".")) + endfor + + call setline(line(".")+1, '') + call cursor(line(".")+1, col(".")) +endfunction + "FUNCTION: s:UI.restoreScreenState() {{{1 " "Sets the screen state back to what it was when nerdtree#saveScreenState was last @@ -315,7 +332,7 @@ endfunction function! s:UI.saveScreenState() let win = winnr() try - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() let self._screenState = {} let self._screenState['oldPos'] = getpos(".") let self._screenState['oldTopLine'] = line("w0") @@ -325,6 +342,46 @@ function! s:UI.saveScreenState() endtry endfunction +"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 +"returns the given line with all the tree parts stripped off +" +"Args: +"line: the subject line +"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = +"any spaces before the actual text of the node) +function! s:UI._stripMarkup(line, removeLeadingSpaces) + let line = a:line + "remove the tree parts and the leading space + let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") + + "strip off any read only flag + let line = substitute (line, ' \[RO\]', "","") + + "strip off any bookmark flags + let line = substitute (line, ' {[^}]*}', "","") + + "strip off any executable flags + let line = substitute (line, '*\ze\($\| \)', "","") + + "strip off any generic flags + let line = substitute (line, '\[[^]]*\]', "","") + + let wasdir = 0 + if line =~# '/$' + let wasdir = 1 + endif + let line = substitute (line,' -> .*',"","") " remove link to + if wasdir ==# 1 + let line = substitute (line, '/\?$', '/', "") + endif + + if a:removeLeadingSpaces + let line = substitute (line, '^ *', '', '') + endif + + return line +endfunction + "FUNCTION: s:UI.render() {{{1 function! s:UI.render() setlocal modifiable @@ -347,7 +404,7 @@ function! s:UI.render() endif if b:NERDTreeShowBookmarks - call nerdtree#renderBookmarks() + call self._renderBookmarks() endif "add the 'up a dir' line @@ -415,7 +472,7 @@ function! s:UI.toggleShowBookmarks() let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks if b:NERDTreeShowBookmarks call b:NERDTree.render() - call nerdtree#putCursorOnBookmarkTable() + call g:NERDTree.CursorToBookmarkTable() else call b:NERDTree.ui.renderViewSavingPosition() endif diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8038668a..3eae93b5 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -186,7 +186,7 @@ endfunction function! NERDTreeFocus() if g:NERDTree.IsOpen() - call nerdtree#putCursorInTreeWin() + call g:NERDTree.CursorToTreeWin() else call g:NERDTreeCreator.TogglePrimary("") endif From fc4bcb4806bb7f6c123ced3e1caa4ccfc141b00e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 15:26:15 +0100 Subject: [PATCH 182/680] remove UI.lolcats()... not sure what the story is there --- lib/nerdtree/ui.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index dfe96a3f..417e6ae2 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -3,11 +3,6 @@ let s:UI = {} let g:NERDTreeUI = s:UI - -function! s:UI.lolcats() - echomsg "lolcats" -endfunction - "FUNCTION: s:UI.centerView() {{{2 "centers the nerd tree window around the cursor (provided the nerd tree "options permit) From 64a9579c11b63e2fe0242d45ca12455a7a7d2833 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 22:20:59 +0100 Subject: [PATCH 183/680] add a path filter API Add an API to allow custom "path filter callbacks" to be added. Previously we allowed one path filtering function to exist called `NERDTreeCustomIgnoreFilter`. This has been removed and replaced with an API to allow any number of such functions to exist - via the new `NERDTreeAddPathFilter()` --- lib/nerdtree/nerdtree.vim | 14 ++++++++++++++ lib/nerdtree/path.vim | 10 ++++++---- plugin/NERD_tree.vim | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 8e3bdde5..55f3dd75 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -3,6 +3,11 @@ let s:NERDTree = {} let g:NERDTree = s:NERDTree +"FUNCTION: s:NERDTree.AddPathFilter() {{{1 +function! s:NERDTree.AddPathFilter(callback) + call add(s:NERDTree.PathFilters(), a:callback) +endfunction + "FUNCTION: s:NERDTree.Close() {{{1 "Closes the primary NERD tree window for this tab function! s:NERDTree.Close() @@ -116,6 +121,15 @@ function! s:NERDTree.New(path) return newObj endfunction +"FUNCTION: s:NERDTree.PathFilters() {{{1 +function! s:NERDTree.PathFilters() + if !exists('s:NERDTree._PathFilters') + let s:NERDTree._PathFilters = [] + endif + return s:NERDTree._PathFilters +endfunction + + "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often function! s:NERDTree.render() diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index dbecb027..48793eb4 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -392,6 +392,12 @@ function! s:Path.ignore() return 1 endif endfor + + for callback in g:NERDTree.PathFilters() + if {callback}({'path': self, 'nerdtree': b:NERDTree}) + return 1 + endif + endfor endif "dont show hidden files unless instructed to @@ -403,10 +409,6 @@ function! s:Path.ignore() return 1 endif - if exists("*NERDTreeCustomIgnoreFilter") && NERDTreeCustomIgnoreFilter(self) - return 1 - endif - return 0 endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3eae93b5..ed769e96 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -196,6 +196,11 @@ function! NERDTreeCWD() call NERDTreeFocus() call nerdtree#ui_glue#chRootCwd() endfunction + +function! NERDTreeAddPathFilter(callback) + call g:NERDTree.AddPathFilter(a:callback) +endfunction + " SECTION: Post Source Actions {{{1 call nerdtree#postSourceActions() From 7270212214660961df9a06846cdd4a36cf1b6fc0 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 3 May 2015 11:14:34 +0100 Subject: [PATCH 184/680] bugfix for secondary trees occurring when the screen state is saved --- lib/nerdtree/ui.vim | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 417e6ae2..41ec21d9 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -325,16 +325,20 @@ endfunction "Saves the current cursor position in the current buffer and the window "scroll position function! s:UI.saveScreenState() + + "FIXME: b:NERDTreeType should really me moved to b:NERDTree.type. Update + "this when that refactor is done + if b:NERDTreeType == "secondary" + return + endif + let win = winnr() - try - call g:NERDTree.CursorToTreeWin() - let self._screenState = {} - let self._screenState['oldPos'] = getpos(".") - let self._screenState['oldTopLine'] = line("w0") - let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w") - catch /^NERDTree.InvalidOperationError/ - endtry + call g:NERDTree.CursorToTreeWin() + let self._screenState = {} + let self._screenState['oldPos'] = getpos(".") + let self._screenState['oldTopLine'] = line("w0") + let self._screenState['oldWindowSize']= winwidth("") + call nerdtree#exec(win . "wincmd w") endfunction "FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 From da3874cf933e3736f9a8d1a2cfe35943d88fa94b Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 4 May 2015 20:25:03 +0100 Subject: [PATCH 185/680] fix a bug when opening files in a new tab On bufleave we save the nerdtree window state. However, sometimes when bufleave is triggered the tree is no longer open in this tab - e.g. for secondary trees or mappings that open in another tab. Dont bother saving screen state in these cases as the code doing the saving assumes the tree is available in this tab. --- lib/nerdtree/ui.vim | 7 ------- plugin/NERD_tree.vim | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 41ec21d9..22e450c8 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -325,13 +325,6 @@ endfunction "Saves the current cursor position in the current buffer and the window "scroll position function! s:UI.saveScreenState() - - "FIXME: b:NERDTreeType should really me moved to b:NERDTree.type. Update - "this when that refactor is done - if b:NERDTreeType == "secondary" - return - endif - let win = winnr() call g:NERDTree.CursorToTreeWin() let self._screenState = {} diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3eae93b5..bd911c61 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,7 +148,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()" + exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" "disallow insert mode in the NERDTree exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" From 5c2060149f52b31786e9003222d3dc54ba80fed9 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 6 May 2015 21:19:06 +0100 Subject: [PATCH 186/680] doc NERDTreeAddPathFilter() --- doc/NERD_tree.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 85dfba63..6418b575 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -34,6 +34,7 @@ CONTENTS *NERDTree-contents* 4.The NERD tree API.......................|NERDTreeAPI| 4.1.Key map API.......................|NERDTreeKeymapAPI| 4.2.Menu API..........................|NERDTreeMenuAPI| + 4.3.Menu API..........................|NERDTreeAddPathFilter()| 5.About...................................|NERDTreeAbout| 6.Changelog...............................|NERDTreeChangelog| 7.Credits.................................|NERDTreeCredits| @@ -1173,6 +1174,24 @@ Where selecting "a (s)ub menu" will lead to a second menu: > When any of the 3 concrete menu items are selected the function "SomeFunction" will be called. +------------------------------------------------------------------------------ +4.3 NERDTreeAddPathFilter(callback) *NERDTreeAddPathFilter()* + +Path filters are essentially a more powerful version of |NERDTreeIgnore|. +If the simple regex matching in |NERDTreeIgnore| is not enough then use +|NERDTreeAddPathFilter()| to add a callback function that paths will be +checked against when the decision to ignore them is made. Example > + + call NERDTreeAddPathFilter('MyFilter') + + function! MyFilter(params) + "params is a dict containing keys: 'nerdtree' and 'path' which are + "g:NERDTree and g:NERDTreePath objects + + "return 1 to ignore params['path'] or 0 otherwise + endfunction +< + ------------------------------------------------------------------------------ NERDTreeRender() *NERDTreeRender()* Re-renders the NERD tree buffer. Useful if you change the state of the @@ -1203,6 +1222,7 @@ Next - add 'scope' argument to the key map API - add NERDTreeCustomIgnoreFilter hook - needs doc - add magic [[dir]] and [[file]] flags to NERDTreeIgnore + - add support for custom path filters. See :help NERDTreeAddPathFilter() 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars From 1f2531ec3ac2c306e61a98e974b6db2c6099f2cc Mon Sep 17 00:00:00 2001 From: Vincent Tsang Date: Sat, 9 May 2015 22:38:16 +0800 Subject: [PATCH 187/680] Speed up sortChildren() by using sorting token This improves the sorting functions from 12 seconds to 0.66 seconds for ~4000 objects --- autoload/nerdtree.vim | 12 ++++++++++++ lib/nerdtree/tree_dir_node.vim | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 22283aab..cf044fd3 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -34,6 +34,18 @@ function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction +"FUNCTION: nerdtree#compareNodesBySortingToken(n1, n2) {{{2 +function! nerdtree#compareNodesBySortingToken(n1, n2) + return a:n1.path.compareTo(a:n2.path) + if a:n1.sorting_token < a:n2.sorting_token + return -1 + elseif a:n1.sorting_token > a:n2.sorting_token + return 1 + else + return 0 + endif +endfunction + " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a24c2704..9a7f45ae 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -504,7 +504,24 @@ endfunction "directory priority. " function! s:TreeDirNode.sortChildren() - let CompareFunc = function("nerdtree#compareNodes") + let CompareFunc = function("nerdtree#compareNodesBySortingToken") + " To optimize sorting, let's generate the sorting token for comparison + + " calculate how large number is needed to represent " order index + let digit = ceil(log10(len(g:NERDTreeSortOrder))) + let format = "%0" . float2nr(digit) . "d" " e.g. '%04d' + + for child in self.children + let path = child.path.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + let child.sorting_token = printf(format, child.path.getSortOrderIndex()) . path + endfor + call sort(self.children, CompareFunc) endfunction From 57d5bd773101a86c7983b5b0755cd3720ea8be0c Mon Sep 17 00:00:00 2001 From: Vincent Tsang Date: Sat, 9 May 2015 22:38:16 +0800 Subject: [PATCH 188/680] Speed up sortChildren() by using sorting token This improves the sorting functions from 12 seconds to 0.66 seconds for ~4000 objects --- autoload/nerdtree.vim | 11 +++++++++++ lib/nerdtree/tree_dir_node.vim | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 22283aab..0a7e4c77 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -34,6 +34,17 @@ function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction +"FUNCTION: nerdtree#compareNodesBySortingToken(n1, n2) {{{2 +function! nerdtree#compareNodesBySortingToken(n1, n2) + if a:n1.sorting_token < a:n2.sorting_token + return -1 + elseif a:n1.sorting_token > a:n2.sorting_token + return 1 + else + return 0 + endif +endfunction + " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a24c2704..9a7f45ae 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -504,7 +504,24 @@ endfunction "directory priority. " function! s:TreeDirNode.sortChildren() - let CompareFunc = function("nerdtree#compareNodes") + let CompareFunc = function("nerdtree#compareNodesBySortingToken") + " To optimize sorting, let's generate the sorting token for comparison + + " calculate how large number is needed to represent " order index + let digit = ceil(log10(len(g:NERDTreeSortOrder))) + let format = "%0" . float2nr(digit) . "d" " e.g. '%04d' + + for child in self.children + let path = child.path.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + let child.sorting_token = printf(format, child.path.getSortOrderIndex()) . path + endfor + call sort(self.children, CompareFunc) endfunction From 80e184df5615b9f4181abec289437b7fc07b8b5d Mon Sep 17 00:00:00 2001 From: Vincent Tsang Date: Mon, 11 May 2015 11:56:08 +0800 Subject: [PATCH 189/680] Refactor code to use getSortKey() and replace regular expression with simple string comparison in tree_dir_node.vim --- autoload/nerdtree.vim | 8 ++++---- lib/nerdtree/path.vim | 21 ++++++++++++++++++++ lib/nerdtree/tree_dir_node.vim | 35 ++++++++++++++-------------------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 0a7e4c77..d16cd66b 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -34,11 +34,11 @@ function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) endfunction -"FUNCTION: nerdtree#compareNodesBySortingToken(n1, n2) {{{2 -function! nerdtree#compareNodesBySortingToken(n1, n2) - if a:n1.sorting_token < a:n2.sorting_token +"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 +function! nerdtree#compareNodesBySortKey(n1, n2) + if a:n1.path.getSortKey() < a:n2.path.getSortKey() return -1 - elseif a:n1.sorting_token > a:n2.sorting_token + elseif a:n1.path.getSortKey() > a:n2.path.getSortKey() return 1 else return 0 diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 48793eb4..4553418d 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -1,6 +1,9 @@ "we need to use this number many times for sorting... so we calculate it only "once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') +" used in formating sortKey, e.g. '%04d' +let s:format = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" + "CLASS: Path "============================================================ @@ -361,6 +364,24 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction +"FUNCTION: Path.getSortKey() {{{1 +"returns a string used in compare function for sorting +function! s:Path.getSortKey() + if !exists("self.sortKey") + let path = self.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + let self.sortKey = printf(s:format, self.getSortOrderIndex()) . path + endif + + return self.sortKey +endfunction + + "FUNCTION: Path.isUnixHiddenFile() {{{1 "check for unix hidden files function! s:Path.isUnixHiddenFile() diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 9a7f45ae..4d8fd405 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -246,8 +246,13 @@ function! s:TreeDirNode._initChildren(silent) "filter out the .. and . directories "Note: we must match .. AND ../ cos sometimes the globpath returns "../ for path with strange chars (eg $) - if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' - +" if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' +" + " 20150511 + " Regular expression is too expensive. Use simply string comparison + " instead + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + \ i[len(i)-2:1] != "." && i[len(i)-1] != "." "put the next file in a new node and attach it try let path = g:NERDTreePath.New(i) @@ -405,8 +410,13 @@ function! s:TreeDirNode.refresh() "filter out the .. and . directories "Note: we must match .. AND ../ cos sometimes the globpath returns "../ for path with strange chars (eg $) - if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' + "if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' + " 20150511 + " Regular expression is too expensive. Use simply string comparison + " instead + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + \ i[len(i)-2:1] != "." && i[len(i)-1] != "." try "create a new path and see if it exists in this nodes children let path = g:NERDTreePath.New(i) @@ -504,24 +514,7 @@ endfunction "directory priority. " function! s:TreeDirNode.sortChildren() - let CompareFunc = function("nerdtree#compareNodesBySortingToken") - " To optimize sorting, let's generate the sorting token for comparison - - " calculate how large number is needed to represent " order index - let digit = ceil(log10(len(g:NERDTreeSortOrder))) - let format = "%0" . float2nr(digit) . "d" " e.g. '%04d' - - for child in self.children - let path = child.path.getLastPathComponent(1) - if !g:NERDTreeSortHiddenFirst - let path = substitute(path, '^[._]', '', '') - endif - if !g:NERDTreeCaseSensitiveSort - let path = tolower(path) - endif - let child.sorting_token = printf(format, child.path.getSortOrderIndex()) . path - endfor - + let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) endfunction From 10261d60a05c3a2237a2b5e47df9235d52430e57 Mon Sep 17 00:00:00 2001 From: Vincent Tsang Date: Mon, 11 May 2015 11:59:10 +0800 Subject: [PATCH 190/680] Updated the comment --- lib/nerdtree/tree_dir_node.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 4d8fd405..765982df 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -248,7 +248,6 @@ function! s:TreeDirNode._initChildren(silent) "../ for path with strange chars (eg $) " if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' " - " 20150511 " Regular expression is too expensive. Use simply string comparison " instead if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && @@ -412,7 +411,6 @@ function! s:TreeDirNode.refresh() "../ for path with strange chars (eg $) "if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' - " 20150511 " Regular expression is too expensive. Use simply string comparison " instead if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && From dfe260d1d7436367a5e38c8e34a3feae3c7b06b0 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 12 May 2015 20:45:15 +0100 Subject: [PATCH 191/680] doc the path listener API --- doc/NERD_tree.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 6418b575..cfc8ed9b 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -35,6 +35,7 @@ CONTENTS *NERDTree-contents* 4.1.Key map API.......................|NERDTreeKeymapAPI| 4.2.Menu API..........................|NERDTreeMenuAPI| 4.3.Menu API..........................|NERDTreeAddPathFilter()| + 4.4.Path Listener API.................|NERDTreePathListenerAPI| 5.About...................................|NERDTreeAbout| 6.Changelog...............................|NERDTreeChangelog| 7.Credits.................................|NERDTreeCredits| @@ -1191,6 +1192,26 @@ checked against when the decision to ignore them is made. Example > "return 1 to ignore params['path'] or 0 otherwise endfunction < +------------------------------------------------------------------------------ +4.4 Path Listener API *NERDTreePathListenerAPI* + +Use this API if you want to run a callback for events on Path objects. E.G > + + call g:NERDTreePathNotifier.AddListener("init", "MyListener") + + ".... + + function! MyListener(event) + "This function will be called whenever a Path object is created. + + "a:event is an object that contains a bunch of relevant info - + "including the path in question. See lib/event.vim for details. + endfunction +< +Current events supported: + init ~ + refresh ~ + refreshFlags ~ ------------------------------------------------------------------------------ NERDTreeRender() *NERDTreeRender()* @@ -1223,6 +1244,7 @@ Next - add NERDTreeCustomIgnoreFilter hook - needs doc - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - add support for custom path filters. See :help NERDTreeAddPathFilter() + - add path listener API. See :help NERDTreePathListenerAPI. 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars From 2c1ebc37b2b92ff0d6197b543d02584e28005ee8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 12 May 2015 20:57:49 +0100 Subject: [PATCH 192/680] add an FAQ about highlighting file with certain extensions Closes #433 --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 880079ae..851071e7 100644 --- a/README.markdown +++ b/README.markdown @@ -101,3 +101,7 @@ Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever ke Stick this in your vimrc: `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif` + +> Can I have different highlighting for different file extensions? + +See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 From 6018af36bf376a2b881e2b3a035adf9898406b2e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 12 May 2015 20:58:35 +0100 Subject: [PATCH 193/680] pretty up some FAQ code blocks --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 851071e7..0317e624 100644 --- a/README.markdown +++ b/README.markdown @@ -94,13 +94,13 @@ Stick this in your vimrc Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): -`map :NERDTreeToggle` + map :NERDTreeToggle > How can I close vim if the only window left open is a NERDTree? Stick this in your vimrc: - `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif` + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif > Can I have different highlighting for different file extensions? From 99fa465b5d103dba2c9009c84b2eaada6a431675 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 13 May 2015 20:26:16 +0100 Subject: [PATCH 194/680] fix syntax error --- lib/nerdtree/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 4553418d..54553951 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -634,7 +634,7 @@ function! s:Path.str(...) if has_key(self, '_strFor' . format) exec 'let toReturn = self._strFor' . format . '()' else - raise 'NERDTree.UnknownFormatError: unknown format "'. format .'"' + throw 'NERDTree.UnknownFormatError: unknown format "'. format .'"' endif else let toReturn = self._str() From af85499edace2acca27ce41790ac333f62b689bb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 13 May 2015 20:29:03 +0100 Subject: [PATCH 195/680] rename 2 sort key related vars rename s:format to s:sortKeyFormat - purely for descriptive reasons rename self.sortKey to self._sortKey - the convention is to use leading underscores to indicate private vars --- lib/nerdtree/path.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 54553951..c0242d06 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -2,7 +2,7 @@ "once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') " used in formating sortKey, e.g. '%04d' -let s:format = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" +let s:sortKeyFormat = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" "CLASS: Path @@ -367,7 +367,7 @@ endfunction "FUNCTION: Path.getSortKey() {{{1 "returns a string used in compare function for sorting function! s:Path.getSortKey() - if !exists("self.sortKey") + if !exists("self._sortKey") let path = self.getLastPathComponent(1) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') @@ -375,10 +375,10 @@ function! s:Path.getSortKey() if !g:NERDTreeCaseSensitiveSort let path = tolower(path) endif - let self.sortKey = printf(s:format, self.getSortOrderIndex()) . path + let self._sortKey = printf(s:sortKeyFormat, self.getSortOrderIndex()) . path endif - return self.sortKey + return self._sortKey endfunction From 013c607ba4bc2e459f3f5f70a69f9f13bcf77f35 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 22 May 2015 13:14:01 +0200 Subject: [PATCH 196/680] Fixed incompatibility with older Vim versions Fixed incompatibility with older Vim versions that are compiled without float function support such as `log10` and `ceil` This fixes #452 --- lib/nerdtree/path.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index c0242d06..2af07ddb 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -2,8 +2,11 @@ "once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') " used in formating sortKey, e.g. '%04d' -let s:sortKeyFormat = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" - +if exists("log10") + let s:sortKeyFormat = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" +else + let s:sortKeyFormat = "%04d" +endif "CLASS: Path "============================================================ From 93c9726c6d96289d6daa59bfb277dff68efa42ba Mon Sep 17 00:00:00 2001 From: toiffel Date: Mon, 13 Jul 2015 03:03:14 +0600 Subject: [PATCH 197/680] Fixed case-sensitive sorting of tree nodes when 'ignorecase' option is on --- autoload/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d16cd66b..37d7d105 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -36,9 +36,9 @@ endfunction "FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 function! nerdtree#compareNodesBySortKey(n1, n2) - if a:n1.path.getSortKey() < a:n2.path.getSortKey() + if a:n1.path.getSortKey() <# a:n2.path.getSortKey() return -1 - elseif a:n1.path.getSortKey() > a:n2.path.getSortKey() + elseif a:n1.path.getSortKey() ># a:n2.path.getSortKey() return 1 else return 0 From 37f7a6cbe1d28847425e3af1e2975c705222a8f8 Mon Sep 17 00:00:00 2001 From: egalpin Date: Thu, 30 Jul 2015 08:52:17 -0400 Subject: [PATCH 198/680] Update README.markdown Add apt-vim installation recipe. --- README.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 0317e624..571a655a 100644 --- a/README.markdown +++ b/README.markdown @@ -55,7 +55,7 @@ The following features and functionality are provided by the NERD tree: Installation ------------ -[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree. +####[pathogen.vim](https://github.com/tpope/vim-pathogen) cd ~/.vim/bundle git clone https://github.com/scrooloose/nerdtree.git @@ -63,6 +63,12 @@ Installation Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. +####[apt-vim](https://github.com/egalpin/apt-vim) + + apt-vim install -y https://github.com/scrooloose/nerdtree.git + + + Faq --- From f5fd121837493e719caecf7cbed94fbbe5413d55 Mon Sep 17 00:00:00 2001 From: Den Date: Thu, 30 Jul 2015 16:28:11 +0300 Subject: [PATCH 199/680] Incorrect path to event.vim --- doc/NERD_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index cfc8ed9b..fbca0e12 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1205,7 +1205,7 @@ Use this API if you want to run a callback for events on Path objects. E.G > "This function will be called whenever a Path object is created. "a:event is an object that contains a bunch of relevant info - - "including the path in question. See lib/event.vim for details. + "including the path in question. See lib/nerdtree/event.vim for details. endfunction < Current events supported: From 188bd9265892bbd03320e51ad01c253dfd98993f Mon Sep 17 00:00:00 2001 From: Igor Tatarintsev Date: Fri, 11 Sep 2015 23:44:06 +0600 Subject: [PATCH 200/680] Added global variables for changing default arrows --- README.markdown | 8 ++++++++ autoload/nerdtree/ui_glue.vim | 2 +- lib/nerdtree/tree_file_node.vim | 4 ++-- lib/nerdtree/ui.vim | 8 ++++---- plugin/NERD_tree.vim | 2 ++ syntax/nerdtree.vim | 9 +++++---- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 0317e624..bc2741ff 100644 --- a/README.markdown +++ b/README.markdown @@ -105,3 +105,11 @@ Stick this in your vimrc: > Can I have different highlighting for different file extensions? See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 + +> How can I change default arrows? + +Use these variables in your vimrc. Note that below are default arrow symbols + + let g:NERDTreeDirArrows = 1 + let g:NERDTreeDirArrowExpandable = '▸' + let g:NERDTreeDirArrowCollapsable = '▾' diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 1f922df1..e706ee5a 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -312,7 +312,7 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$' + if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \?$' call currentNode.activate() return endif diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index b4924d78..5c386413 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -383,13 +383,13 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) if self.path.isDirectory if self.isOpen if g:NERDTreeDirArrows - let treeParts = treeParts . '▾ ' + let treeParts = treeParts . g:NERDTreeDirArrowCollapsable . ' ' else let treeParts = treeParts . '~' endif else if g:NERDTreeDirArrows - let treeParts = treeParts . '▸ ' + let treeParts = treeParts . g:NERDTreeDirArrowExpandable . ' ' else let treeParts = treeParts . '+' endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 22e450c8..5632ab0f 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -154,7 +154,7 @@ function! s:UI.getPath(ln) if !g:NERDTreeDirArrows " in case called from outside the tree - if line !~# '^ *[|`▸▾ ]' || line =~# '^$' + if line !~# '^ *[|`'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.' ]' || line =~# '^$' return {} endif endif @@ -261,9 +261,9 @@ endfunction "FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~▸▾`|]') / s:UI.IndentWid() + let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'`|]') / s:UI.IndentWid() " check if line includes arrows - if match(a:line, '[▸▾]') > -1 + if match(a:line, '['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.]') > -1 " decrement level as arrow uses 3 ascii chars let level = level - 1 endif @@ -278,7 +278,7 @@ endfunction "FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() if g:NERDTreeDirArrows - return '^\([▾▸] \| \+[▾▸] \| \+\)' + return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \| \+\)' endif return '^[ `|]*[\-+~]' diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 966838c3..7b3dff08 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -68,6 +68,8 @@ call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) +call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") +call s:initVariable("g:NERDTreeDirArrowCollapsable", "▾") call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 5f7b49cc..1d097881 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -23,12 +23,13 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrows - syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile + exec 'syn match NERDTreeClosable #'.g:NERDTreeDirArrowCollapsable.'# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #'.g:NERDTreeDirArrowExpandable.'# containedin=NERDTreeDir,NERDTreeFile' - syn match NERDTreeDir #[^▾▸ ].*/# + let s:dirArrows = g:NERDTreeDirArrowCollapsable.g:NERDTreeDirArrowExpandable + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' "highlighting for readonly files syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile From dc29ec2db3e710cb4034acdcf94b0cc862446d03 Mon Sep 17 00:00:00 2001 From: Igor Tatarintsev Date: Fri, 11 Sep 2015 23:52:37 +0600 Subject: [PATCH 201/680] Added global variables for changing default arrows g:NERDTreeDirArrowExpandable g:NERDTreeDirArrowCollapsable --- README.markdown | 2 +- autoload/nerdtree/ui_glue.vim | 2 +- lib/nerdtree/tree_file_node.vim | 2 +- lib/nerdtree/ui.vim | 8 ++++---- plugin/NERD_tree.vim | 2 +- syntax/nerdtree.vim | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index bc2741ff..c11b1351 100644 --- a/README.markdown +++ b/README.markdown @@ -112,4 +112,4 @@ Use these variables in your vimrc. Note that below are default arrow symbols let g:NERDTreeDirArrows = 1 let g:NERDTreeDirArrowExpandable = '▸' - let g:NERDTreeDirArrowCollapsable = '▾' + let g:NERDTreeDirArrowCollapsible = '▾' diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index e706ee5a..dadb8f87 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -312,7 +312,7 @@ function! s:handleLeftClick() endfor if currentNode.path.isDirectory - if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \?$' + if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$' call currentNode.activate() return endif diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 5c386413..a3fe98f5 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -383,7 +383,7 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) if self.path.isDirectory if self.isOpen if g:NERDTreeDirArrows - let treeParts = treeParts . g:NERDTreeDirArrowCollapsable . ' ' + let treeParts = treeParts . g:NERDTreeDirArrowCollapsible . ' ' else let treeParts = treeParts . '~' endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5632ab0f..74cee9cd 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -154,7 +154,7 @@ function! s:UI.getPath(ln) if !g:NERDTreeDirArrows " in case called from outside the tree - if line !~# '^ *[|`'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.' ]' || line =~# '^$' + if line !~# '^ *[|`'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.' ]' || line =~# '^$' return {} endif endif @@ -261,9 +261,9 @@ endfunction "FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'`|]') / s:UI.IndentWid() + let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'`|]') / s:UI.IndentWid() " check if line includes arrows - if match(a:line, '['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.]') > -1 + if match(a:line, '['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') > -1 " decrement level as arrow uses 3 ascii chars let level = level - 1 endif @@ -278,7 +278,7 @@ endfunction "FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() if g:NERDTreeDirArrows - return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsable.'] \| \+\)' + return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' endif return '^[ `|]*[\-+~]' diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 7b3dff08..6fff0c34 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -69,7 +69,7 @@ call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") -call s:initVariable("g:NERDTreeDirArrowCollapsable", "▾") +call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 1d097881..fd548cf1 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -23,10 +23,10 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrows - exec 'syn match NERDTreeClosable #'.g:NERDTreeDirArrowCollapsable.'# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeClosable #'.g:NERDTreeDirArrowCollapsible.'# containedin=NERDTreeDir,NERDTreeFile' exec 'syn match NERDTreeOpenable #'.g:NERDTreeDirArrowExpandable.'# containedin=NERDTreeDir,NERDTreeFile' - let s:dirArrows = g:NERDTreeDirArrowCollapsable.g:NERDTreeDirArrowExpandable + let s:dirArrows = g:NERDTreeDirArrowCollapsible.g:NERDTreeDirArrowExpandable exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' From 8c8c794104246d0d4f65cf23bc8bbb3722b4c3c2 Mon Sep 17 00:00:00 2001 From: Igor Tatarintsev Date: Tue, 15 Sep 2015 23:22:14 +0600 Subject: [PATCH 202/680] Added character escaping to syn match regexes --- syntax/nerdtree.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index fd548cf1..a48445ad 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -23,10 +23,10 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrows - exec 'syn match NERDTreeClosable #'.g:NERDTreeDirArrowCollapsible.'# containedin=NERDTreeDir,NERDTreeFile' - exec 'syn match NERDTreeOpenable #'.g:NERDTreeDirArrowExpandable.'# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' - let s:dirArrows = g:NERDTreeDirArrowCollapsible.g:NERDTreeDirArrowExpandable + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' From d66370a8e51abf21705756b2ff4c8874a30abc1a Mon Sep 17 00:00:00 2001 From: Xuyuan Pang Date: Thu, 17 Sep 2015 11:30:14 +0800 Subject: [PATCH 203/680] Made NERDTreeFlags contained in NERDTreeExecFile --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index fd548cf1..effb7feb 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -34,7 +34,7 @@ if g:NERDTreeDirArrows "highlighting for readonly files syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile - syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile + syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir else "highlighting for the ~/+ symbols for the directory nodes From 34630f3926eccd35c7c2ae23dd315f67557cde3b Mon Sep 17 00:00:00 2001 From: hiberabyss Date: Sun, 20 Sep 2015 00:53:39 +0800 Subject: [PATCH 204/680] issue #147: add support to ~ expand in bookmarks --- lib/nerdtree/bookmark.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 8a94b256..91648d25 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -87,6 +87,7 @@ function! s:Bookmark.CacheBookmarks(silent) let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') + let path = fnamemodify(path, ':p') try let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path)) @@ -304,7 +305,7 @@ endfunction function! s:Bookmark.Write() let bookmarkStrings = [] for i in s:Bookmark.Bookmarks() - call add(bookmarkStrings, i.name . ' ' . i.path.str()) + call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~')) endfor "add a blank line before the invalid ones From 8996ea5bb56c0af1b1df32f1990f37e224d25112 Mon Sep 17 00:00:00 2001 From: Arseny Zarechnev Date: Sun, 4 Oct 2015 01:54:15 +0100 Subject: [PATCH 205/680] Fix MacOS detection for menu, fixes #478 --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e99a85be..b5569e50 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -24,7 +24,7 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if has("gui_mac") || has("gui_macvim") +if has("gui_mac") || has("gui_macvim") || has("mac") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) From 88104d26ac5935d256e2b2800a5704461529eda5 Mon Sep 17 00:00:00 2001 From: Jonathan Seidel Date: Mon, 2 Nov 2015 11:30:16 -0800 Subject: [PATCH 206/680] Add ability to list file metadata... (Based on a change by github.com/apbarrero)) Add menu/list command to display file metadata Support OSX as well as Unix --- nerdtree_plugin/fs_menu.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e99a85be..7caa6cc9 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -34,6 +34,10 @@ if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif +if has("unix") || has("osx") + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) +endif + "FUNCTION: s:echo(msg){{{1 function! s:echo(msg) redraw @@ -267,4 +271,14 @@ function! NERDTreeExecuteFile() endif endfunction +function! NERDTreeListNode() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') + call s:echo(metadata[0]) + else + call s:echo("No information avaialable") + endif +endfunction + " vim: set sw=4 sts=4 et fdm=marker: From c60f40137170fe9685b15467b53276179cea0fc9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 16:20:20 -0500 Subject: [PATCH 207/680] Merge (p)roperties (for Windows) into the (l)ist menu item. --- nerdtree_plugin/fs_menu.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index db729b49..c26255fb 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -37,6 +37,8 @@ endif if has("unix") || has("osx") call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) +else + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif "FUNCTION: s:echo(msg){{{1 @@ -212,8 +214,8 @@ function! NERDTreeDeleteNode() endfunction -" FUNCTION: NERDTreeNodeProperties() {{{1 -function! NERDTreeNodeProperties() +" FUNCTION: NERDTreeListNodeWin32() {{{1 +function! NERDTreeListNodeWin32 let currentNode = g:NERDTreeFileNode.GetSelected() call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) endfunction From f1af61ddf722132401898daadb833aead09afeb2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 21:29:34 -0500 Subject: [PATCH 208/680] Use the system('DIR /Q...') function to display file info. --- nerdtree_plugin/fs_menu.vim | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index c26255fb..2a6ddd6f 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -23,7 +23,6 @@ endif call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -call NERDTreeAddMenuItem({'text': 'show (p)roperties of the current node', 'shortcut': 'p', 'callback': 'NERDTreeNodeProperties'}) if has("gui_mac") || has("gui_macvim") || has("mac") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) @@ -215,9 +214,15 @@ function! NERDTreeDeleteNode() endfunction " FUNCTION: NERDTreeListNodeWin32() {{{1 -function! NERDTreeListNodeWin32 - let currentNode = g:NERDTreeFileNode.GetSelected() - call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) +function! NERDTreeListNodeWin32() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('dir /q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') + call s:echo(metadata[0]) + else + call s:echo("No information avaialable") + endif + endfunction " FUNCTION: NERDTreeCopyNode() {{{1 @@ -259,6 +264,7 @@ function! NERDTreeCopyNode() redraw endfunction +" FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -266,6 +272,7 @@ function! NERDTreeQuickLook() endif endfunction +" FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -273,6 +280,7 @@ function! NERDTreeRevealInFinder() endif endfunction +" FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -280,6 +288,7 @@ function! NERDTreeExecuteFile() endif endfunction +" FUNCTION: NERDTreeListNode() {{{1 function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} From 3fb18e7399156195bf1e91845ca1da801632967e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 21:38:22 -0500 Subject: [PATCH 209/680] Switch to upper case DIR /Q, in true DOS fashion --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 2a6ddd6f..043e3376 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -217,7 +217,7 @@ endfunction function! NERDTreeListNodeWin32() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} - let metadata = split(system('dir /q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') + let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') call s:echo(metadata[0]) else call s:echo("No information avaialable") From adc11983bc44c9118a0056f1808bf3386f142c83 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 10:44:27 +0000 Subject: [PATCH 210/680] fs_menu: put the NERDTreeListNode* methods together --- nerdtree_plugin/fs_menu.vim | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 043e3376..75f16122 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -213,6 +213,17 @@ function! NERDTreeDeleteNode() endfunction +" FUNCTION: NERDTreeListNode() {{{1 +function! NERDTreeListNode() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') + call s:echo(metadata[0]) + else + call s:echo("No information avaialable") + endif +endfunction + " FUNCTION: NERDTreeListNodeWin32() {{{1 function! NERDTreeListNodeWin32() let treenode = g:NERDTreeFileNode.GetSelected() @@ -287,16 +298,4 @@ function! NERDTreeExecuteFile() let x = system("open '" . treenode.path.str() . "'") endif endfunction - -" FUNCTION: NERDTreeListNode() {{{1 -function! NERDTreeListNode() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') - call s:echo(metadata[0]) - else - call s:echo("No information avaialable") - endif -endfunction - " vim: set sw=4 sts=4 et fdm=marker: From 5b7085d9ae4c6e9257f52b7f6da9aff5250cbca6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 10:46:12 +0000 Subject: [PATCH 211/680] fs menu: remove unused var assigns --- nerdtree_plugin/fs_menu.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 75f16122..076fb5f1 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -287,7 +287,7 @@ endfunction function! NERDTreeRevealInFinder() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} - let x = system("open -R '" . treenode.path.str() . "'") + call system("open -R '" . treenode.path.str() . "'") endif endfunction @@ -295,7 +295,7 @@ endfunction function! NERDTreeExecuteFile() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} - let x = system("open '" . treenode.path.str() . "'") + call system("open '" . treenode.path.str() . "'") endif endfunction " vim: set sw=4 sts=4 et fdm=marker: From e27ab9c5c77c78a356ccce23b1435fd74c8c6c92 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 10:53:42 +0000 Subject: [PATCH 212/680] fsmenu: use nerdtree#echo* methods instead of reimplementing them --- nerdtree_plugin/fs_menu.vim | 39 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 076fb5f1..e8f67d4f 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -40,19 +40,6 @@ else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif -"FUNCTION: s:echo(msg){{{1 -function! s:echo(msg) - redraw - echomsg "NERDTree: " . a:msg -endfunction - -"FUNCTION: s:echoWarning(msg){{{1 -function! s:echoWarning(msg) - echohl warningmsg - call s:echo(a:msg) - echohl normal -endfunction - "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 "prints out the given msg and, if the user responds by pushing 'y' then the "buffer with the given bufnum is deleted @@ -113,7 +100,7 @@ function! NERDTreeAddNode() \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file") if newNodeName ==# '' - call s:echo("Node Creation Aborted.") + call nerdtree#echo("Node Creation Aborted.") return endif @@ -131,7 +118,7 @@ function! NERDTreeAddNode() call newTreeNode.putCursorHere(1, 0) endif catch /^NERDTree/ - call s:echoWarning("Node Not Created.") + call nerdtree#echoWarning("Node Not Created.") endtry endfunction @@ -144,7 +131,7 @@ function! NERDTreeMoveNode() \ "", curNode.path.str(), "file") if newNodePath ==# '' - call s:echo("Node Renaming Aborted.") + call nerdtree#echo("Node Renaming Aborted.") return endif @@ -165,7 +152,7 @@ function! NERDTreeMoveNode() redraw catch /^NERDTree/ - call s:echoWarning("Node Not Renamed.") + call nerdtree#echoWarning("Node Not Renamed.") endtry endfunction @@ -205,10 +192,10 @@ function! NERDTreeDeleteNode() redraw catch /^NERDTree/ - call s:echoWarning("Could not remove node") + call nerdtree#echoWarning("Could not remove node") endtry else - call s:echo("delete aborted") + call nerdtree#echo("delete aborted") endif endfunction @@ -218,9 +205,9 @@ function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') - call s:echo(metadata[0]) + call nerdtree#echo(metadata[0]) else - call s:echo("No information avaialable") + call nerdtree#echo("No information avaialable") endif endfunction @@ -229,9 +216,9 @@ function! NERDTreeListNodeWin32() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') - call s:echo(metadata[0]) + call nerdtree#echo(metadata[0]) else - call s:echo("No information avaialable") + call nerdtree#echo("No information avaialable") endif endfunction @@ -250,7 +237,7 @@ function! NERDTreeCopyNode() let confirmed = 1 if currentNode.path.copyingWillOverwrite(newNodePath) - call s:echo("Warning: copying may overwrite files! Continue? (yN)") + call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)") let choice = nr2char(getchar()) let confirmed = choice ==# 'y' endif @@ -266,11 +253,11 @@ function! NERDTreeCopyNode() call newNode.putCursorHere(0, 0) endif catch /^NERDTree/ - call s:echoWarning("Could not copy node") + call nerdtree#echoWarning("Could not copy node") endtry endif else - call s:echo("Copy aborted.") + call nerdtree#echo("Copy aborted.") endif redraw endfunction From 0c13ebc126f03b6336f2adb59ba6385bb4edfe5d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 15:08:01 +0000 Subject: [PATCH 213/680] remove some old commented code --- lib/nerdtree/tree_dir_node.vim | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 765982df..a1e42147 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -244,13 +244,9 @@ function! s:TreeDirNode._initChildren(silent) for i in files "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns + "Note: we must match .. AND ../ since sometimes the globpath returns "../ for path with strange chars (eg $) -" if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' -" - " Regular expression is too expensive. Use simply string comparison - " instead - if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && \ i[len(i)-2:1] != "." && i[len(i)-1] != "." "put the next file in a new node and attach it try From e4891632f555bf6de67d5440f73cba353bf31fbb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 16:45:11 +0000 Subject: [PATCH 214/680] update changelog --- doc/NERD_tree.txt | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index fbca0e12..1532ac1b 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -1240,11 +1240,52 @@ The latest dev versions are on github 6. Changelog *NERDTreeChangelog* Next - - add 'scope' argument to the key map API - - add NERDTreeCustomIgnoreFilter hook - needs doc + - Refactor the code significantly: + * Break the classes out into their own files. + * Make the majority of the code OO - previously large parts were + effectively a tangle of "global" methods. + - Add an API to assign flags to nodes. This allows VCS plugins like + https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to + Xuyuanp for helping design/test/build said API. + - add 'scope' argument to the key map API see :help NERDTreeAddKeyMap() - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - add support for custom path filters. See :help NERDTreeAddPathFilter() - add path listener API. See :help NERDTreePathListenerAPI. + - expand the fs menu functionality to list file properties (PhilRunninger, + apbarrero, JESii) + - make bookmarks work with `~` home shortcuts (hiberabyss) + - show OSX specific fsmenu options in regular vim on mac (evindor) + - make dir arrow icons configurable (PickRelated) + - optimise node sorting performance when opening large dirs (vtsang) + - make the root note render prettier by truncating it at a path slash (gcmt) + - remove NERDChristmasTree option - its always christmas now + - add "cascade" open and closing for dirs containing only another single + dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) + + Many other fixes, doc updates and contributions from: + actionshrimp + SchDen + egalpin + cperl82 - many small fixes + toiffel + WoLpH + handcraftedbits + devmanhinton + xiaodili + zhangoose + gastropoda + mixvin + alvan + lucascaton + kelaban + shanesmith + staeff + pendulm + stephenprater + franksort + agrussellknives + AndrewRadev + Twinside 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars From 024966c7a8d83321a8b80be866dc32899c4a4f5c Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 16:48:09 +0000 Subject: [PATCH 215/680] move changelog out of the main doc, remove credits section Changelog is not really relevant to the "usage" manual so extract it. Contributors can be viewed on github. --- CHANGELOG | 145 +++++++++++++++++++++++++++++ doc/NERD_tree.txt | 226 +--------------------------------------------- 2 files changed, 147 insertions(+), 224 deletions(-) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 00000000..f034c7b3 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,145 @@ +5.0.0 + - Refactor the code significantly: + * Break the classes out into their own files. + * Make the majority of the code OO - previously large parts were + effectively a tangle of "global" methods. + - Add an API to assign flags to nodes. This allows VCS plugins like + https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to + Xuyuanp for helping design/test/build said API. + - add 'scope' argument to the key map API see :help NERDTreeAddKeyMap() + - add magic [[dir]] and [[file]] flags to NERDTreeIgnore + - add support for custom path filters. See :help NERDTreeAddPathFilter() + - add path listener API. See :help NERDTreePathListenerAPI. + - expand the fs menu functionality to list file properties (PhilRunninger, + apbarrero, JESii) + - make bookmarks work with `~` home shortcuts (hiberabyss) + - show OSX specific fsmenu options in regular vim on mac (evindor) + - make dir arrow icons configurable (PickRelated) + - optimise node sorting performance when opening large dirs (vtsang) + - make the root note render prettier by truncating it at a path slash (gcmt) + - remove NERDChristmasTree option - its always christmas now + - add "cascade" open and closing for dirs containing only another single + dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) + + Many other fixes, doc updates and contributions from: + actionshrimp + SchDen + egalpin + cperl82 - many small fixes + toiffel + WoLpH + handcraftedbits + devmanhinton + xiaodili + zhangoose + gastropoda + mixvin + alvan + lucascaton + kelaban + shanesmith + staeff + pendulm + stephenprater + franksort + agrussellknives + AndrewRadev + Twinside + +4.2.0 + - Add NERDTreeDirArrows option to make the UI use pretty arrow chars + instead of the old +~| chars to define the tree structure (sickill) + - shift the syntax highlighting out into its own syntax file (gnap) + - add some mac specific options to the filesystem menu - for macvim + only (andersonfreitas) + - Add NERDTreeMinimalUI option to remove some non functional parts of the + nerdtree ui (camthompson) + - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the + new behaviour (benjamingeiger) + - if no name is given to :Bookmark, make it default to the name of the + target file/dir (minyoung) + - use 'file' completion when doing copying, create, and move + operations (EvanDotPro) + - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly + Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) + +4.1.0 + features: + - NERDTreeFind to reveal the node for the current buffer in the tree, + see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by + Doug McInnes) into the script. + - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan + Ritter and Rémi Prévost. + - truncate the root node if wider than the tree window. Thanks to Victor + Gonzalez. + + bugfixes: + - really fix window state restoring + - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, + jfilip1024, and Chris Chambers + +4.0.0 + - add a new programmable menu system (see :help NERDTreeMenu). + - add new APIs to add menus/menu-items to the menu system as well as + custom key mappings to the NERD tree buffer (see :help NERDTreeAPI). + - removed the old API functions + - added a mapping to maximize/restore the size of nerd tree window, thanks + to Guillaume Duranceau for the patch. See :help NERDTree-A for details. + + - fix a bug where secondary nerd trees (netrw hijacked trees) and + 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. + - fix a bug when using the x mapping on the tree root, thanks to Bryan + Venteicher for the patch. + - fix a bug where the cursor position/window size of the nerd tree buffer + wasnt being stored on closing the window, thanks to Richard Hart. + - fix a bug where NERDTreeMirror would mirror the wrong tree + +3.1.1 + - fix a bug where a non-listed no-name buffer was getting created every + time the tree windows was created, thanks to Derek Wyatt and owen1 + - make behave the same as the 'o' mapping + - some helptag fixes in the doc, thanks strull + - fix a bug when using :set nohidden and opening a file where the previous + buf was modified. Thanks iElectric + - other minor fixes + +3.1.0 + New features: + - add mappings to open files in a vsplit, see :help NERDTree-s and :help + NERDTree-gs + - make the statusline for the nerd tree window default to something + hopefully more useful. See :help 'NERDTreeStatusline' + Bugfixes: + - make the hijack netrw functionality work when vim is started with "vim + " (thanks to Alf Mikula for the patch). + - fix a bug where the CWD wasnt being changed for some operations even when + NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) + - add -bar to all the nerd tree :commands so they can chain with other + :commands (thanks to tpope) + - fix bugs when ignorecase was set (thanks to nach) + - fix a bug with the relative path code (thanks to nach) + - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach) + + +3.0.1 + Bugfixes: + - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden + was not set + - fix a bug where :NERDTree would fail if was relative and + didnt start with a ./ or ../ Thanks to James Kanze. + - make the q mapping work with secondary (:e style) trees, + thanks to jamessan + - fix a bunch of small bugs with secondary trees + + More insane refactoring. + +3.0.0 + - hijack netrw so that doing an :edit will put a NERD tree in + the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' + - allow sharing of trees across tabs, see :help :NERDTreeMirror + - remove "top" and "bottom" as valid settings for NERDTreeWinPos + - change the '' mapping to 'i' + - change the 'H' mapping to 'I' + - lots of refactoring diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 1532ac1b..963c6c21 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -37,9 +37,7 @@ CONTENTS *NERDTree-contents* 4.3.Menu API..........................|NERDTreeAddPathFilter()| 4.4.Path Listener API.................|NERDTreePathListenerAPI| 5.About...................................|NERDTreeAbout| - 6.Changelog...............................|NERDTreeChangelog| - 7.Credits.................................|NERDTreeCredits| - 8.License.................................|NERDTreeLicense| + 6.License.................................|NERDTreeLicense| ============================================================================== 1. Intro *NERDTree* @@ -1235,228 +1233,8 @@ The latest stable versions can be found at The latest dev versions are on github http://github.com/scrooloose/nerdtree - -============================================================================== -6. Changelog *NERDTreeChangelog* - -Next - - Refactor the code significantly: - * Break the classes out into their own files. - * Make the majority of the code OO - previously large parts were - effectively a tangle of "global" methods. - - Add an API to assign flags to nodes. This allows VCS plugins like - https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to - Xuyuanp for helping design/test/build said API. - - add 'scope' argument to the key map API see :help NERDTreeAddKeyMap() - - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - - add support for custom path filters. See :help NERDTreeAddPathFilter() - - add path listener API. See :help NERDTreePathListenerAPI. - - expand the fs menu functionality to list file properties (PhilRunninger, - apbarrero, JESii) - - make bookmarks work with `~` home shortcuts (hiberabyss) - - show OSX specific fsmenu options in regular vim on mac (evindor) - - make dir arrow icons configurable (PickRelated) - - optimise node sorting performance when opening large dirs (vtsang) - - make the root note render prettier by truncating it at a path slash (gcmt) - - remove NERDChristmasTree option - its always christmas now - - add "cascade" open and closing for dirs containing only another single - dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) - - Many other fixes, doc updates and contributions from: - actionshrimp - SchDen - egalpin - cperl82 - many small fixes - toiffel - WoLpH - handcraftedbits - devmanhinton - xiaodili - zhangoose - gastropoda - mixvin - alvan - lucascaton - kelaban - shanesmith - staeff - pendulm - stephenprater - franksort - agrussellknives - AndrewRadev - Twinside - -4.2.0 - - Add NERDTreeDirArrows option to make the UI use pretty arrow chars - instead of the old +~| chars to define the tree structure (sickill) - - shift the syntax highlighting out into its own syntax file (gnap) - - add some mac specific options to the filesystem menu - for macvim - only (andersonfreitas) - - Add NERDTreeMinimalUI option to remove some non functional parts of the - nerdtree ui (camthompson) - - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the - new behaviour (benjamingeiger) - - if no name is given to :Bookmark, make it default to the name of the - target file/dir (minyoung) - - use 'file' completion when doing copying, create, and move - operations (EvanDotPro) - - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly - Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) - -4.1.0 - features: - - NERDTreeFind to reveal the node for the current buffer in the tree, - see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by - Doug McInnes) into the script. - - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan - Ritter and Rémi Prévost. - - truncate the root node if wider than the tree window. Thanks to Victor - Gonzalez. - - bugfixes: - - really fix window state restoring - - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, - jfilip1024, and Chris Chambers - -4.0.0 - - add a new programmable menu system (see :help NERDTreeMenu). - - add new APIs to add menus/menu-items to the menu system as well as - custom key mappings to the NERD tree buffer (see :help NERDTreeAPI). - - removed the old API functions - - added a mapping to maximize/restore the size of nerd tree window, thanks - to Guillaume Duranceau for the patch. See :help NERDTree-A for details. - - - fix a bug where secondary nerd trees (netrw hijacked trees) and - 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. - - fix a bug when using the x mapping on the tree root, thanks to Bryan - Venteicher for the patch. - - fix a bug where the cursor position/window size of the nerd tree buffer - wasnt being stored on closing the window, thanks to Richard Hart. - - fix a bug where NERDTreeMirror would mirror the wrong tree - -3.1.1 - - fix a bug where a non-listed no-name buffer was getting created every - time the tree windows was created, thanks to Derek Wyatt and owen1 - - make behave the same as the 'o' mapping - - some helptag fixes in the doc, thanks strull - - fix a bug when using :set nohidden and opening a file where the previous - buf was modified. Thanks iElectric - - other minor fixes - -3.1.0 - New features: - - add mappings to open files in a vsplit, see :help NERDTree-s and :help - NERDTree-gs - - make the statusline for the nerd tree window default to something - hopefully more useful. See :help 'NERDTreeStatusline' - Bugfixes: - - make the hijack netrw functionality work when vim is started with "vim - " (thanks to Alf Mikula for the patch). - - fix a bug where the CWD wasnt being changed for some operations even when - NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) - - add -bar to all the nerd tree :commands so they can chain with other - :commands (thanks to tpope) - - fix bugs when ignorecase was set (thanks to nach) - - fix a bug with the relative path code (thanks to nach) - - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach) - - -3.0.1 - Bugfixes: - - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden - was not set - - fix a bug where :NERDTree would fail if was relative and - didnt start with a ./ or ../ Thanks to James Kanze. - - make the q mapping work with secondary (:e style) trees, - thanks to jamessan - - fix a bunch of small bugs with secondary trees - - More insane refactoring. - -3.0.0 - - hijack netrw so that doing an :edit will put a NERD tree in - the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' - - allow sharing of trees across tabs, see :help :NERDTreeMirror - - remove "top" and "bottom" as valid settings for NERDTreeWinPos - - change the '' mapping to 'i' - - change the 'H' mapping to 'I' - - lots of refactoring - -============================================================================== -7. Credits *NERDTreeCredits* - -Thanks to the following people for testing, bug reports, ideas etc. Without -you I probably would have got bored of the hacking the NERD tree and -just downloaded pr0n instead. - - Tim Carey-Smith (halorgium) - Vigil - Nick Brettell - Thomas Scott Urban - Terrance Cohen - Yegappan Lakshmanan - Jason Mills - Michael Geddes (frogonwheels) - Yu Jun - Michael Madsen - AOYAMA Shotaro - Zhang Weiwu - Niels Aan de Brugh - Olivier Yiptong - Zhang Shuhan - Cory Echols - Piotr Czachur - Yuan Jiang - Matan Nassau - Maxim Kim - Charlton Wang - Matt Wozniski (godlygeek) - knekk - Sean Chou - Ryan Penn - Simon Peter Nicholls - Michael Foobar - Tomasz Chomiuk - Denis Pokataev - Tim Pope (tpope) - James Kanze - James Vega (jamessan) - Frederic Chanal (nach) - Alf Mikula - Lucas S. Buchala - Curtis Harvey - Guillaume Duranceau - Richard Hart (hates) - Doug McInnes - Stefan Ritter - Rémi Prévost - Victor Gonzalez - Stephan Baumeister - Ricky - jfilip1024 - Chris Chambers - Vitaly Bogdanov - Patrick O'Loughlin (paddyoloughlin) - Cam Thompson (camthompson) - Marcin Kulik (sickill) - Steve DeWald (sdewald) - Ivan Necas (iNecas) - George Ang (gnap) - Evan Coury (EvanDotPro) - Andrew Radev (AndrewRadev) - Matt Gauger (mathias) - Scott Stevenson (scottstvnsn) - Anderson Freitas (andersonfreitas) - Kamil K. Lemański (kml) - Yehuda Katz (wycats) - Min-Young Wu (minyoung) - Benjamin Geiger (benjamingeiger) - ============================================================================== -8. License *NERDTreeLicense* +6. License *NERDTreeLicense* The NERD tree is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. From f486403b6893d03703c4d8d2efc5883922003adb Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 16:50:15 +0000 Subject: [PATCH 216/680] add license file closes #368 --- LICENCE | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 00000000..8b1a9d81 --- /dev/null +++ b/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. From be8f18914c9beab40801ab66b5064ea73945d158 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 16:54:47 +0000 Subject: [PATCH 217/680] remove some unneeded header comments --- nerdtree_plugin/exec_menuitem.vim | 1 - nerdtree_plugin/fs_menu.vim | 1 - plugin/NERD_tree.vim | 2 -- 3 files changed, 4 deletions(-) diff --git a/nerdtree_plugin/exec_menuitem.vim b/nerdtree_plugin/exec_menuitem.vim index e7a7c532..c53650a5 100644 --- a/nerdtree_plugin/exec_menuitem.vim +++ b/nerdtree_plugin/exec_menuitem.vim @@ -2,7 +2,6 @@ " File: exec_menuitem.vim " Description: plugin for NERD Tree that provides an execute file menu item " Maintainer: Martin Grenfell -" Last Change: 22 July, 2009 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e8f67d4f..2f401a61 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -2,7 +2,6 @@ " File: fs_menu.vim " Description: plugin for the NERD Tree that provides a file system menu " Maintainer: Martin Grenfell -" Last Change: 17 July, 2009 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 6fff0c34..8494a09e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1,8 +1,6 @@ " ============================================================================ " File: NERD_tree.vim -" Description: vim global plugin that provides a nice tree explorer " Maintainer: Martin Grenfell -" Last Change: 28 December, 2011 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You From 4dada8c04fba25e788ea1836c82f9c18c1166b44 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Nov 2015 16:57:21 +0000 Subject: [PATCH 218/680] update version number to 5.0.0 --- autoload/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 37d7d105..c8f96e79 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -4,7 +4,7 @@ endif let g:loaded_nerdtree_autoload = 1 function! nerdtree#version() - return '4.2.0' + return '5.0.0' endfunction " SECTION: General Functions {{{1 From 848857d18bb643247a32942cb0d99213baaccdd4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 14 Nov 2015 11:50:01 +0000 Subject: [PATCH 219/680] rename "primary" and "secondary" trees to "tab" and "window" trees This is much more accurate and descriptive. --- autoload/nerdtree.vim | 4 ++-- autoload/nerdtree/ui_glue.vim | 16 +++++++------- doc/NERD_tree.txt | 6 ++--- lib/nerdtree/creator.vim | 40 +++++++++++++++++----------------- lib/nerdtree/nerdtree.vim | 2 +- lib/nerdtree/opener.vim | 12 +++++----- lib/nerdtree/tree_dir_node.vim | 2 +- lib/nerdtree/ui.vim | 4 ++-- plugin/NERD_tree.vim | 2 +- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index c8f96e79..6d7828d7 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -11,10 +11,10 @@ endfunction "============================================================ "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 -"inits a secondary nerd tree in the current buffer if appropriate +"inits a window tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) if a:dir != '' && isdirectory(a:dir) - call g:NERDTreeCreator.CreateSecondary(a:dir) + call g:NERDTreeCreator.CreateWindowTree(a:dir) endif endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index dadb8f87..50298d2b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -208,7 +208,7 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 + if b:NERDTreeType ==# "window" && b:NERDTreePreviousBuf != -1 exec "buffer " . b:NERDTreePreviousBuf else if winnr("$") > 1 @@ -269,14 +269,14 @@ function! s:findAndRevealPath() endtry if p.isUnder(cwd) - call g:NERDTreeCreator.CreatePrimary(cwd.str()) + call g:NERDTreeCreator.CreateTabTree(cwd.str()) else - call g:NERDTreeCreator.CreatePrimary(p.getParent().str()) + call g:NERDTreeCreator.CreateTabTree(p.getParent().str()) endif else if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) if !g:NERDTree.IsOpen() - call g:NERDTreeCreator.TogglePrimary('') + call g:NERDTreeCreator.ToggleTabTree('') else call g:NERDTree.CursorToTreeWin() endif @@ -284,7 +284,7 @@ function! s:findAndRevealPath() call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) else if !g:NERDTree.IsOpen() - call g:NERDTreeCreator.TogglePrimary("") + call g:NERDTreeCreator.ToggleTabTree("") endif endif endif @@ -545,10 +545,10 @@ endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 function! nerdtree#ui_glue#setupCommands() - command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('') - command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('') + command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') + command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() - command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('') + command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 963c6c21..caab120d 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -776,13 +776,13 @@ Default: 1. If set to 1, doing a > :edit < -will open up a "secondary" NERD tree instead of a netrw in the target window. +will open up a window level NERD tree instead of a netrw in the target window. -Secondary NERD trees behaves slightly different from a regular trees in the +Window level trees behaves slightly different from a regular trees in the following respects: 1. 'o' will open the selected file in the same window as the tree, replacing it. - 2. you can have as many secondary tree as you want in the same tab. + 2. you can have one tree per window - instead of per tab. ------------------------------------------------------------------------------ *'NERDTreeIgnore'* diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 89f03a33..842311c9 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -1,5 +1,5 @@ "CLASS: Creator -"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and +"Creates tab/window/mirror nerdtree windows. Sets up all the window and "buffer options and key mappings etc. "============================================================ let s:Creator = {} @@ -32,15 +32,15 @@ function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction -"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1 -function! s:Creator.CreatePrimary(name) +"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 +function! s:Creator.CreateTabTree(name) let creator = s:Creator.New() - call creator.createPrimary(a:name) + call creator.createTabTree(a:name) endfunction -"FUNCTION: s:Creator.createPrimary(a:name) {{{1 +"FUNCTION: s:Creator.createTabTree(a:name) {{{1 "name: the name of a bookmark or a directory -function! s:Creator.createPrimary(name) +function! s:Creator.createTabTree(name) let path = self._pathForString(a:name) "abort if exception was thrown (bookmark/dir doesn't exist) @@ -67,7 +67,7 @@ function! s:Creator.createPrimary(name) call self._createTreeWin() call self._createNERDTree(path) - let b:NERDTreeType = "primary" + let b:NERDTreeType = "tab" let b:treeShowHelp = 0 let b:NERDTreeIgnoreEnabled = 1 let b:NERDTreeShowFiles = g:NERDTreeShowFiles @@ -80,14 +80,14 @@ function! s:Creator.createPrimary(name) call self._broadcastInitEvent() endfunction -"FUNCTION: s:Creator.CreateSecondary(dir) {{{1 -function! s:Creator.CreateSecondary(dir) +"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1 +function! s:Creator.CreateWindowTree(dir) let creator = s:Creator.New() - call creator.createSecondary(a:dir) + call creator.createWindowTree(a:dir) endfunction -"FUNCTION: s:Creator.createSecondary(dir) {{{1 -function! s:Creator.createSecondary(dir) +"FUNCTION: s:Creator.createWindowTree(dir) {{{1 +function! s:Creator.createWindowTree(dir) try let path = g:NERDTreePath.New(a:dir) catch /^NERDTree.InvalidArgumentsError/ @@ -100,14 +100,14 @@ function! s:Creator.createSecondary(dir) let previousBuf = expand("#") - "we need a unique name for each secondary tree buffer to ensure they are + "we need a unique name for each window tree buffer to ensure they are "all independent exec "silent edit " . self._nextBufferName() let b:NERDTreePreviousBuf = bufnr(previousBuf) call self._createNERDTree(path) call self._setCommonBufOptions() - let b:NERDTreeType = "secondary" + let b:NERDTreeType = "window" call b:NERDTree.render() @@ -322,20 +322,20 @@ function! s:Creator._tabpagevar(tabnr, var) return v endfunction -"FUNCTION: s:Creator.TogglePrimary(dir) {{{1 -function! s:Creator.TogglePrimary(dir) +"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1 +function! s:Creator.ToggleTabTree(dir) let creator = s:Creator.New() - call creator.togglePrimary(a:dir) + call creator.toggleTabTree(a:dir) endfunction -"FUNCTION: s:Creator.togglePrimary(dir) {{{1 +"FUNCTION: s:Creator.toggleTabTree(dir) {{{1 "Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is "closed it is restored or initialized (if it doesnt exist) " "Args: "dir: the full path for the root node (is only used if the NERD tree is being "initialized. -function! s:Creator.togglePrimary(dir) +function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() @@ -347,7 +347,7 @@ function! s:Creator.togglePrimary(dir) call g:NERDTree.Close() endif else - call self.createPrimary(a:dir) + call self.createTabTree(a:dir) endif endfunction diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 55f3dd75..46e7129d 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -9,7 +9,7 @@ function! s:NERDTree.AddPathFilter(callback) endfunction "FUNCTION: s:NERDTree.Close() {{{1 -"Closes the primary NERD tree window for this tab +"Closes the tab tree window for this tab function! s:NERDTree.Close() if !s:NERDTree.IsOpen() return diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 3a6b3924..6740bd46 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -64,7 +64,7 @@ endfunction "FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() - if b:NERDTreeType ==# "secondary" + if b:NERDTreeType ==# "window" if self._where == 'v' vsplit elseif self._where == 'h' @@ -248,7 +248,7 @@ function! s:Opener._openFile() call self._gotoTargetWin() - if self._treetype ==# "secondary" + if self._treetype ==# "window" call self._path.edit() else call self._path.edit() @@ -262,9 +262,9 @@ endfunction "FUNCTION: Opener._openDirectory(node) {{{1 function! s:Opener._openDirectory(node) - if self._treetype ==# "secondary" + if self._treetype ==# "window" call self._gotoTargetWin() - call g:NERDTreeCreator.CreateSecondary(a:node.path.str()) + call g:NERDTreeCreator.CreateWindow(a:node.path.str()) else call self._gotoTargetWin() if empty(self._where) @@ -272,9 +272,9 @@ function! s:Opener._openDirectory(node) call b:NERDTree.render() call a:node.putCursorHere(0, 0) elseif self._where == 't' - call g:NERDTreeCreator.CreatePrimary(a:node.path.str()) + call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else - call g:NERDTreeCreator.CreateSecondary(a:node.path.str()) + call g:NERDTreeCreator.CreateWindow(a:node.path.str()) endif endif diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a1e42147..c7c016cc 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -352,7 +352,7 @@ endfunction "FUNCTION: TreeDirNode._openInNewTab() {{{1 function! s:TreeDirNode._openInNewTab() tabnew - call g:NERDTreeCreator.CreatePrimary(self.path.str()) + call g:NERDTreeCreator.CreateTabTree(self.path.str()) endfunction "FUNCTION: TreeDirNode.openRecursively() {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 74cee9cd..1e188581 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -27,12 +27,12 @@ function! s:UI._dumpHelp() let @h=@h."\" File node mappings~\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" let @h=@h."\" ,\n" - if b:NERDTreeType ==# "primary" + if b:NERDTreeType ==# "tab" let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" else let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" endif - if b:NERDTreeType ==# "primary" + if b:NERDTreeType ==# "tab" let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" endif let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8494a09e..42a3b1e2 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -188,7 +188,7 @@ function! NERDTreeFocus() if g:NERDTree.IsOpen() call g:NERDTree.CursorToTreeWin() else - call g:NERDTreeCreator.TogglePrimary("") + call g:NERDTreeCreator.ToggleTabTree("") endif endfunction From 5c202747616e0d614f8de9117162fcf8e8a4c27e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 14 Nov 2015 12:01:55 +0000 Subject: [PATCH 220/680] move b:NERDTreeType into the NERDTree class and add some query methods --- README.markdown | 2 +- autoload/nerdtree/ui_glue.vim | 2 +- lib/nerdtree/creator.vim | 12 +++++------- lib/nerdtree/nerdtree.vim | 13 ++++++++++++- lib/nerdtree/opener.vim | 8 ++++---- lib/nerdtree/ui.vim | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.markdown b/README.markdown index fd8655c1..66e8896e 100644 --- a/README.markdown +++ b/README.markdown @@ -106,7 +106,7 @@ Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever ke Stick this in your vimrc: - autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif > Can I have different highlighting for different file extensions? diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 50298d2b..5e08a0d3 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -208,7 +208,7 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTreeType ==# "window" && b:NERDTreePreviousBuf != -1 + if b:NERDTree.isWinTree() && b:NERDTreePreviousBuf != -1 exec "buffer " . b:NERDTreePreviousBuf else if winnr("$") > 1 diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 842311c9..87407d73 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -42,7 +42,7 @@ endfunction "name: the name of a bookmark or a directory function! s:Creator.createTabTree(name) let path = self._pathForString(a:name) - + "abort if exception was thrown (bookmark/dir doesn't exist) if empty(path) return @@ -66,8 +66,7 @@ function! s:Creator.createTabTree(name) endif call self._createTreeWin() - call self._createNERDTree(path) - let b:NERDTreeType = "tab" + call self._createNERDTree(path, "tab") let b:treeShowHelp = 0 let b:NERDTreeIgnoreEnabled = 1 let b:NERDTreeShowFiles = g:NERDTreeShowFiles @@ -105,9 +104,8 @@ function! s:Creator.createWindowTree(dir) exec "silent edit " . self._nextBufferName() let b:NERDTreePreviousBuf = bufnr(previousBuf) - call self._createNERDTree(path) + call self._createNERDTree(path, "window") call self._setCommonBufOptions() - let b:NERDTreeType = "window" call b:NERDTree.render() @@ -115,8 +113,8 @@ function! s:Creator.createWindowTree(dir) endfunction " FUNCTION: s:Creator._createNERDTree(path) {{{1 -function! s:Creator._createNERDTree(path) - let b:NERDTree = g:NERDTree.New(a:path) +function! s:Creator._createNERDTree(path, type) + let b:NERDTree = g:NERDTree.New(a:path, a:type) "TODO: This is kept for compatability only since many things use "b:NERDTreeRoot instead of the new NERDTree.root "Remove this one day diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 46e7129d..801282e7 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -105,6 +105,16 @@ function! s:NERDTree.IsOpen() return s:NERDTree.GetWinNum() != -1 endfunction +"FUNCTION: s:NERDTree.isTabTree() {{{1 +function! s:NERDTree.isTabTree() + return self._type == "tab" +endfunction + +"FUNCTION: s:NERDTree.isWinTree() {{{1 +function! s:NERDTree.isWinTree() + return self._type == "window" +endfunction + "FUNCTION: s:NERDTree.MustBeOpen() {{{1 function! s:NERDTree.MustBeOpen() if !s:NERDTree.IsOpen() @@ -113,10 +123,11 @@ function! s:NERDTree.MustBeOpen() endfunction "FUNCTION: s:NERDTree.New() {{{1 -function! s:NERDTree.New(path) +function! s:NERDTree.New(path, type) let newObj = copy(self) let newObj.ui = g:NERDTreeUI.New(newObj) let newObj.root = g:NERDTreeDirNode.New(a:path) + let newObj._type = a:type return newObj endfunction diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 6740bd46..0f8a0052 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -64,7 +64,7 @@ endfunction "FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() - if b:NERDTreeType ==# "window" + if b:NERDTree.isWinTree() if self._where == 'v' vsplit elseif self._where == 'h' @@ -149,7 +149,7 @@ function! s:Opener.New(path, opts) let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen') let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' - let newObj._treetype = b:NERDTreeType + let newObj._nerdtree = b:NERDTree call newObj._saveCursorPos() return newObj @@ -248,7 +248,7 @@ function! s:Opener._openFile() call self._gotoTargetWin() - if self._treetype ==# "window" + if self._nerdtree.isWinTree() call self._path.edit() else call self._path.edit() @@ -262,7 +262,7 @@ endfunction "FUNCTION: Opener._openDirectory(node) {{{1 function! s:Opener._openDirectory(node) - if self._treetype ==# "window" + if self._nerdtree.isWinTree() call self._gotoTargetWin() call g:NERDTreeCreator.CreateWindow(a:node.path.str()) else diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 1e188581..8e18805e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -27,12 +27,12 @@ function! s:UI._dumpHelp() let @h=@h."\" File node mappings~\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" let @h=@h."\" ,\n" - if b:NERDTreeType ==# "tab" + if b:NERDTree.isTabTree() let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" else let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" endif - if b:NERDTreeType ==# "tab" + if b:NERDTree.isTabTree() let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" endif let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" From 4d8a0c90cb10e62a3b21e124af39a951127f0796 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 14 Nov 2015 13:10:08 +0000 Subject: [PATCH 221/680] move b:NERDTreePreviousBuf into NERDTree class --- autoload/nerdtree/ui_glue.vim | 4 ++-- lib/nerdtree/creator.vim | 2 +- lib/nerdtree/nerdtree.vim | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 5e08a0d3..3bd74cea 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -208,8 +208,8 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTree.isWinTree() && b:NERDTreePreviousBuf != -1 - exec "buffer " . b:NERDTreePreviousBuf + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 + exec "buffer " . b:NERDTree.previousBuf() else if winnr("$") > 1 call g:NERDTree.Close() diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 87407d73..7289d3f3 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -103,8 +103,8 @@ function! s:Creator.createWindowTree(dir) "all independent exec "silent edit " . self._nextBufferName() - let b:NERDTreePreviousBuf = bufnr(previousBuf) call self._createNERDTree(path, "window") + let b:NERDTree._previousBuf = bufnr(previousBuf) call self._setCommonBufOptions() call b:NERDTree.render() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 801282e7..db55cb90 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -140,6 +140,10 @@ function! s:NERDTree.PathFilters() return s:NERDTree._PathFilters endfunction +"FUNCTION: s:NERDTree.previousBuf() {{{1 +function! s:NERDTree.previousBuf() + return self._previousBuf +endfunction "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often From 83d108894ee9a7e0a291a1197fede2a39dec5005 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 14 Nov 2015 17:35:07 +0000 Subject: [PATCH 222/680] move a bunch of `b:NERDTree.*` vars into the b:NERDTree.ui obj --- autoload/nerdtree/ui_glue.vim | 4 +-- lib/nerdtree/creator.vim | 12 ------- lib/nerdtree/nerdtree.vim | 3 +- lib/nerdtree/path.vim | 6 ++-- lib/nerdtree/ui.vim | 63 +++++++++++++++++++++++++++++------ 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 3bd74cea..965b2591 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -241,7 +241,7 @@ endfunction " FUNCTION: s:displayHelp() {{{1 " toggles the help display function! s:displayHelp() - let b:treeShowHelp = b:treeShowHelp ? 0 : 1 + call b:NERDTree.ui.toggleHelp() call b:NERDTree.render() call b:NERDTree.ui.centerView() endfunction @@ -280,7 +280,7 @@ function! s:findAndRevealPath() else call g:NERDTree.CursorToTreeWin() endif - let b:NERDTreeShowHidden = g:NERDTreeShowHidden + call b:NERDTree.setShowHidden(g:NERDTreeShowHidden) call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) else if !g:NERDTree.IsOpen() diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 7289d3f3..87d1b1b4 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -67,12 +67,6 @@ function! s:Creator.createTabTree(name) call self._createTreeWin() call self._createNERDTree(path, "tab") - let b:treeShowHelp = 0 - let b:NERDTreeIgnoreEnabled = 1 - let b:NERDTreeShowFiles = g:NERDTreeShowFiles - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - call b:NERDTree.render() call b:NERDTreeRoot.putCursorHere(0, 0) @@ -285,12 +279,6 @@ function! s:Creator._setCommonBufOptions() endif call self._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 self._bindMappings() setlocal filetype=nerdtree endfunction diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index db55cb90..938c5f8d 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -43,7 +43,7 @@ endfunction "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "Places the cursor at the top of the bookmarks table function! s:NERDTree.CursorToBookmarkTable() - if !b:NERDTreeShowBookmarks + if !b:NERDTree.ui.getShowBookmarks() throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" endif @@ -128,7 +128,6 @@ function! s:NERDTree.New(path, type) let newObj.ui = g:NERDTreeUI.New(newObj) let newObj.root = g:NERDTreeDirNode.New(a:path) let newObj._type = a:type - return newObj endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2af07ddb..4a2314e3 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -410,7 +410,7 @@ endfunction "returns true if this path should be ignored function! s:Path.ignore() "filter out the user specified paths to ignore - if b:NERDTreeIgnoreEnabled + if b:NERDTree.ui.isIgnoreFilterEnabled() for i in g:NERDTreeIgnore if self._ignorePatternMatches(i) return 1 @@ -425,11 +425,11 @@ function! s:Path.ignore() endif "dont show hidden files unless instructed to - if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile() + if !b:NERDTree.ui.getShowHidden() && self.isUnixHiddenFile() return 1 endif - if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0 + if b:NERDTree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0 return 1 endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 8e18805e..bacbf63a 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -21,7 +21,7 @@ endfunction "prints out the quick help function! s:UI._dumpHelp() let old_h = @h - if b:treeShowHelp ==# 1 + if self.getShowHelp() let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" let @h=@h."\" ============================\n" let @h=@h."\" File node mappings~\n" @@ -87,10 +87,10 @@ function! s:UI._dumpHelp() let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" + let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" "add quickhelp entries for each custom key map let @h=@h."\"\n\" ----------------------------\n" @@ -129,6 +129,12 @@ endfunction function! s:UI.New(nerdtree) let newObj = copy(self) let newObj.nerdtree = a:nerdtree + let newObj._showHelp = 0 + let newObj._ignoreEnabled = 1 + let newObj._showFiles = g:NERDTreeShowFiles + let newObj._showHidden = g:NERDTreeShowHidden + let newObj._showBookmarks = g:NERDTreeShowBookmarks + return newObj endfunction @@ -259,6 +265,26 @@ function! s:UI.getRootLineNum() return rootLine endfunction +"FUNCTION: s:UI.getShowBookmarks() {{{1 +function! s:UI.getShowBookmarks() + return self._showBookmarks +endfunction + +"FUNCTION: s:UI.getShowFiles() {{{1 +function! s:UI.getShowFiles() + return self._showFiles +endfunction + +"FUNCTION: s:UI.getShowHelp() {{{1 +function! s:UI.getShowHelp() + return self._showHelp +endfunction + +"FUNCTION: s:UI.getShowHidden() {{{1 +function! s:UI.getShowHidden() + return self._showHidden +endfunction + "FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'`|]') / s:UI.IndentWid() @@ -275,6 +301,11 @@ function! s:UI.IndentWid() return 2 endfunction +"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 +function! s:UI.isIgnoreFilterEnabled() + return self._ignoreEnabled == 1 +endfunction + "FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() if g:NERDTreeDirArrows @@ -334,6 +365,11 @@ function! s:UI.saveScreenState() call nerdtree#exec(win . "wincmd w") endfunction +"FUNCTION: s:UI.setShowHidden(val) {{{1 +function! s:UI.setShowHidden(val) + let self._showHidden = a:val +endfunction + "FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 "returns the given line with all the tree parts stripped off " @@ -395,7 +431,7 @@ function! s:UI.render() call cursor(line(".")+1, col(".")) endif - if b:NERDTreeShowBookmarks + if self.getShowBookmarks() call self._renderBookmarks() endif @@ -450,10 +486,15 @@ function! s:UI.renderViewSavingPosition() endif endfunction +"FUNCTION: s:UI.toggleHelp() {{{1 +function! s:UI.toggleHelp() + let self._showHelp = !self._showHelp +endfunction + " FUNCTION: s:UI.toggleIgnoreFilter() {{{1 " toggles the use of the NERDTreeIgnore option function! s:UI.toggleIgnoreFilter() - let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled + let self._ignoreEnabled = !self._ignoreEnabled call b:NERDTree.ui.renderViewSavingPosition() call b:NERDTree.ui.centerView() endfunction @@ -461,8 +502,8 @@ endfunction " FUNCTION: s:UI.toggleShowBookmarks() {{{1 " toggles the display of bookmarks function! s:UI.toggleShowBookmarks() - let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks - if b:NERDTreeShowBookmarks + let self._showBookmarks = !self._showBookmarks + if self.getShowBookmarks() call b:NERDTree.render() call g:NERDTree.CursorToBookmarkTable() else @@ -474,7 +515,7 @@ endfunction " FUNCTION: s:UI.toggleShowFiles() {{{1 " toggles the display of hidden files function! s:UI.toggleShowFiles() - let b:NERDTreeShowFiles = !b:NERDTreeShowFiles + let self._showFiles = !self._showFiles call b:NERDTree.ui.renderViewSavingPosition() call b:NERDTree.ui.centerView() endfunction @@ -482,7 +523,7 @@ endfunction " FUNCTION: s:UI.toggleShowHidden() {{{1 " toggles the display of hidden files function! s:UI.toggleShowHidden() - let b:NERDTreeShowHidden = !b:NERDTreeShowHidden + let self._showHidden = !self._showHidden call b:NERDTree.ui.renderViewSavingPosition() call self.centerView() endfunction From b4fa33c39c3317ef8475c3c831360766708af920 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 15 Nov 2015 01:04:03 +0000 Subject: [PATCH 223/680] remove some confusing redundancy from a few function calls --- lib/nerdtree/ui.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index bacbf63a..f83647ce 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -212,7 +212,7 @@ endfunction function! s:UI.getLineNum(file_node) "if the node is the root then return the root line no. if a:file_node.isRoot() - return b:NERDTree.ui.getRootLineNum() + return self.getRootLineNum() endif let totalLines = line("$") @@ -224,7 +224,7 @@ function! s:UI.getLineNum(file_node) let fullpath = a:file_node.path.str({'format': 'UI'}) - let lnum = b:NERDTree.ui.getRootLineNum() + let lnum = self.getRootLineNum() while lnum > 0 let lnum = lnum + 1 "have we reached the bottom of the tree? @@ -479,7 +479,7 @@ function! s:UI.renderViewSavingPosition() let currentNode = currentNode.parent endwhile - call b:NERDTree.render() + call self.render() if currentNode != {} call currentNode.putCursorHere(0, 0) @@ -495,8 +495,8 @@ endfunction " toggles the use of the NERDTreeIgnore option function! s:UI.toggleIgnoreFilter() let self._ignoreEnabled = !self._ignoreEnabled - call b:NERDTree.ui.renderViewSavingPosition() - call b:NERDTree.ui.centerView() + Vall self.renderViewSavingPosition() + call self.centerView() endfunction " FUNCTION: s:UI.toggleShowBookmarks() {{{1 @@ -507,24 +507,24 @@ function! s:UI.toggleShowBookmarks() call b:NERDTree.render() call g:NERDTree.CursorToBookmarkTable() else - call b:NERDTree.ui.renderViewSavingPosition() + call self.renderViewSavingPosition() endif - call b:NERDTree.ui.centerView() + call self.centerView() endfunction " FUNCTION: s:UI.toggleShowFiles() {{{1 " toggles the display of hidden files function! s:UI.toggleShowFiles() let self._showFiles = !self._showFiles - call b:NERDTree.ui.renderViewSavingPosition() - call b:NERDTree.ui.centerView() + call self.renderViewSavingPosition() + call self.centerView() endfunction " FUNCTION: s:UI.toggleShowHidden() {{{1 " toggles the display of hidden files function! s:UI.toggleShowHidden() let self._showHidden = !self._showHidden - call b:NERDTree.ui.renderViewSavingPosition() + call self.renderViewSavingPosition() call self.centerView() endfunction From 449f2c77ed5e6b921b29c60351a3efc6b58bfdb0 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 15 Nov 2015 11:13:28 +0000 Subject: [PATCH 224/680] update changelog --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f034c7b3..03192408 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Next + - Rename "primary" and "secondary" trees to "tab" and "window" trees. + - Move a bunch of buffer level variables into the NERDTree and UI classes. + 5.0.0 - Refactor the code significantly: * Break the classes out into their own files. From 0b966aa23a8d786414a07eafbef3572bd44c30ea Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Nov 2015 09:35:31 +0000 Subject: [PATCH 225/680] refactor TreeDirNode.reveal slightly --- autoload/nerdtree/ui_glue.vim | 4 +++- lib/nerdtree/tree_dir_node.vim | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 965b2591..5d180446 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -289,7 +289,9 @@ function! s:findAndRevealPath() endif endif call g:NERDTree.CursorToTreeWin() - call b:NERDTreeRoot.reveal(p) + let node = b:NERDTreeRoot.reveal(p) + call b:NERDTree.render() + call node.putCursorHere(1,0) if p.isUnixHiddenFile() let g:NERDTreeShowHidden = showhidden diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index c7c016cc..0fb40168 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -460,7 +460,10 @@ endfunction "FUNCTION: TreeDirNode.reveal(path) {{{1 "reveal the given path, i.e. cache and open all treenodes needed to display it "in the UI -function! s:TreeDirNode.reveal(path) +"Returns the revealed node +function! s:TreeDirNode.reveal(path, ...) + let opts = a:0 ? a:1 : {} + if !a:path.isUnder(self.path) throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() endif @@ -469,9 +472,10 @@ function! s:TreeDirNode.reveal(path) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) - call b:NERDTree.render() - call n.putCursorHere(1,0) - return + if has_key(opts, "open") + call n.open() + endif + return n endif let p = a:path @@ -480,7 +484,7 @@ function! s:TreeDirNode.reveal(path) endwhile let n = self.findNode(p) - call n.reveal(a:path) + return n.reveal(a:path, opts) endfunction "FUNCTION: TreeDirNode.removeChild(treenode) {{{1 From d36b7936566f9913a0fa3925ba57214f17f302a3 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Nov 2015 11:28:24 +0000 Subject: [PATCH 226/680] dont use b:NERDTreeRoot internally, but leave the var there for compat Use b:NERDTree.root instead. I will eventually remove b:NERDTreeRoot altogether - but this will break some other plugins so leave it for now. --- autoload/nerdtree/ui_glue.vim | 26 +++++++++++++------------- doc/NERD_tree.txt | 2 +- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/creator.vim | 4 ++-- lib/nerdtree/nerdtree.vim | 2 +- lib/nerdtree/tree_dir_node.vim | 2 +- lib/nerdtree/tree_file_node.vim | 20 ++++++++++---------- lib/nerdtree/ui.vim | 16 ++++++++-------- nerdtree_plugin/fs_menu.vim | 6 +++--- plugin/NERD_tree.vim | 4 ++-- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 5d180446..23edfe75 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -142,7 +142,7 @@ endfunction function! s:chRoot(node) call a:node.makeRoot() call b:NERDTree.render() - call b:NERDTreeRoot.putCursorHere(0, 0) + call b:NERDTree.root.putCursorHere(0, 0) endfunction " FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 @@ -289,7 +289,7 @@ function! s:findAndRevealPath() endif endif call g:NERDTree.CursorToTreeWin() - let node = b:NERDTreeRoot.reveal(p) + let node = b:NERDTree.root.reveal(p) call b:NERDTree.render() call node.putCursorHere(1,0) @@ -411,7 +411,7 @@ endfunction " FUNCTION: s:jumpToRoot() {{{1 " moves the cursor to the root node function! s:jumpToRoot() - call b:NERDTreeRoot.putCursorHere(1, 0) + call b:NERDTree.root.putCursorHere(1, 0) call b:NERDTree.ui.centerView() endfunction @@ -524,7 +524,7 @@ endfunction " will be reloaded. function! s:refreshRoot() call nerdtree#echo("Refreshing the root node. This could take a while...") - call b:NERDTreeRoot.refresh() + call b:NERDTree.root.refresh() call b:NERDTree.render() redraw call nerdtree#echo("Refreshing the root node. This could take a while... DONE") @@ -604,28 +604,28 @@ endfunction "keepState: 1 if the current root should be left open when the tree is "re-rendered function! nerdtree#ui_glue#upDir(keepState) - let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) + let cwd = b:NERDTree.root.path.str({'format': 'UI'}) if cwd ==# "/" || cwd =~# '^[^/]..$' call nerdtree#echo("already at top dir") else if !a:keepState - call b:NERDTreeRoot.close() + call b:NERDTree.root.close() endif - let oldRoot = b:NERDTreeRoot + let oldRoot = b:NERDTree.root - if empty(b:NERDTreeRoot.parent) - let path = b:NERDTreeRoot.path.getParent() + if empty(b:NERDTree.root.parent) + let path = b:NERDTree.root.path.getParent() let newRoot = g:NERDTreeDirNode.New(path) call newRoot.open() - call newRoot.transplantChild(b:NERDTreeRoot) - let b:NERDTreeRoot = newRoot + call newRoot.transplantChild(b:NERDTree.root) + let b:NERDTree.root = newRoot else - let b:NERDTreeRoot = b:NERDTreeRoot.parent + let b:NERDTree.root = b:NERDTree.root.parent endif if g:NERDTreeChDirMode ==# 2 - call b:NERDTreeRoot.path.changeToDir() + call b:NERDTree.root.path.changeToDir() endif call b:NERDTree.render() diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index caab120d..ccc60b5c 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -945,7 +945,7 @@ Other examples: > ------------------------------------------------------------------------------ *'NERDTreeStatusline'* Values: Any valid statusline setting. -Default: %{b:NERDTreeRoot.path.strForOS(0)} +Default: %{b:NERDTree.root.path.strForOS(0)} Tells the script what to use as the |'statusline'| setting for NERD tree windows. diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 91648d25..1b49f027 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -147,7 +147,7 @@ endfunction " searchFromAbsoluteRoot: specifies whether we should search from the current " tree root, or the highest cached node function! s:Bookmark.getNode(searchFromAbsoluteRoot) - let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot + let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTree.root let targetNode = searchRoot.findNode(self.path) if empty(targetNode) throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 87d1b1b4..61f204f2 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -68,7 +68,7 @@ function! s:Creator.createTabTree(name) call self._createTreeWin() call self._createNERDTree(path, "tab") call b:NERDTree.render() - call b:NERDTreeRoot.putCursorHere(0, 0) + call b:NERDTree.root.putCursorHere(0, 0) call self._broadcastInitEvent() endfunction @@ -141,7 +141,7 @@ function! s:Creator.createMirror() let i = 0 while i < len(treeBufNames) let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTreeRoot") + let treeRoot = getbufvar(bufName, "NERDTree").root let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName let i = i + 1 endwhile diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 938c5f8d..83468cac 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -73,7 +73,7 @@ endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 " Returns 1 if a nerd tree root exists in the current buffer function! s:NERDTree.ExistsForBuf() - return exists("b:NERDTreeRoot") + return exists("b:NERDTree") endfunction " Function: s:NERDTree.ExistsForTab() {{{1 diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 0fb40168..e1e82cb1 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -9,7 +9,7 @@ let g:NERDTreeDirNode = s:TreeDirNode "FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1 "class method that returns the highest cached ancestor of the current root function! s:TreeDirNode.AbsoluteTreeRoot() - let currentNode = b:NERDTreeRoot + let currentNode = b:NERDTree.root while currentNode.parent != {} let currentNode = currentNode.parent endwhile diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index a3fe98f5..b2a536e1 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -59,7 +59,7 @@ endfunction function! s:TreeFileNode.copy(dest) call self.path.copy(a:dest) let newPath = g:NERDTreePath.New(a:dest) - let parent = b:NERDTreeRoot.findNode(newPath.getParent()) + let parent = b:NERDTree.root.findNode(newPath.getParent()) if !empty(parent) call parent.refresh() return parent.findNode(newPath) @@ -182,7 +182,7 @@ endfunction "get the root node for this tab function! s:TreeFileNode.GetRootForTab() if g:NERDTree.ExistsForTab() - return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot') + return getbufvar(t:NERDTreeBufName, 'NERDTree').root end return {} endfunction @@ -195,7 +195,7 @@ function! s:TreeFileNode.GetSelected() if path ==# {} return {} endif - return b:NERDTreeRoot.findNode(path) + return b:NERDTree.root.findNode(path) catch /^NERDTree/ return {} endtry @@ -209,30 +209,30 @@ function! s:TreeFileNode.isVisible() endfunction "FUNCTION: TreeFileNode.isRoot() {{{1 -"returns 1 if this node is b:NERDTreeRoot +"returns 1 if this node is b:NERDTree.root function! s:TreeFileNode.isRoot() if !g:NERDTree.ExistsForBuf() throw "NERDTree.NoTreeError: No tree exists for the current buffer" endif - return self.equals(b:NERDTreeRoot) + return self.equals(b:NERDTree.root) endfunction "FUNCTION: TreeFileNode.makeRoot() {{{1 "Make this node the root of the tree function! s:TreeFileNode.makeRoot() if self.path.isDirectory - let b:NERDTreeRoot = self + let b:NERDTree.root = self else call self.cacheParent() - let b:NERDTreeRoot = self.parent + let b:NERDTree.root = self.parent endif - call b:NERDTreeRoot.open() + call b:NERDTree.root.open() "change dir to the dir of the new root if instructed to if g:NERDTreeChDirMode ==# 2 - exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'}) + exec "cd " . b:NERDTree.root.path.str({'format': 'Edit'}) endif silent doautocmd User NERDTreeNewRoot @@ -326,7 +326,7 @@ function! s:TreeFileNode.rename(newName) call self.parent.removeChild(self) let parentPath = self.path.getParent() - let newParent = b:NERDTreeRoot.findNode(parentPath) + let newParent = b:NERDTree.root.findNode(parentPath) if newParent != {} call newParent.createChild(self.path, 1) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index f83647ce..40c014ee 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -155,7 +155,7 @@ function! s:UI.getPath(ln) "check to see if we have the root node if a:ln == rootLine - return b:NERDTreeRoot.path + return self.nerdtree.root.path endif if !g:NERDTreeDirArrows @@ -166,7 +166,7 @@ function! s:UI.getPath(ln) endif if line ==# s:UI.UpDirLine() - return b:NERDTreeRoot.path.getParent() + return self.nerdtree.root.path.getParent() endif let indent = self._indentLevelFor(line) @@ -189,7 +189,7 @@ function! s:UI.getPath(ln) "have we reached the top of the tree? if lnum == rootLine - let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir + let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir break endif if curLineStripped =~# '/$' @@ -202,7 +202,7 @@ function! s:UI.getPath(ln) endif endif endwhile - let curFile = b:NERDTreeRoot.path.drive . dir . curFile + let curFile = self.nerdtree.root.path.drive . dir . curFile let toReturn = g:NERDTreePath.New(curFile) return toReturn endfunction @@ -218,7 +218,7 @@ function! s:UI.getLineNum(file_node) let totalLines = line("$") "the path components we have matched so far - let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] + let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')] "the index of the component we are searching for let curPathComponent = 1 @@ -442,13 +442,13 @@ function! s:UI.render() endif "draw the header line - let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) call setline(line(".")+1, header) call cursor(line(".")+1, col(".")) "draw the tree let old_o = @o - let @o = b:NERDTreeRoot.renderToString() + let @o = self.nerdtree.root.renderToString() silent put o let @o = old_o @@ -504,7 +504,7 @@ endfunction function! s:UI.toggleShowBookmarks() let self._showBookmarks = !self._showBookmarks if self.getShowBookmarks() - call b:NERDTree.render() + call self.nerdtree.render() call g:NERDTree.CursorToBookmarkTable() else call self.renderViewSavingPosition() diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 2f401a61..315a7894 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -105,11 +105,11 @@ function! NERDTreeAddNode() try let newPath = g:NERDTreePath.Create(newNodeName) - let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) + let parentNode = b:NERDTree.root.findNode(newPath.getParent()) let newTreeNode = g:NERDTreeFileNode.New(newPath) if empty(parentNode) - call b:NERDTreeRoot.refresh() + call b:NERDTree.root.refresh() call b:NERDTree.render() elseif parentNode.isOpen || !empty(parentNode.children) call parentNode.addChild(newTreeNode, 1) @@ -245,7 +245,7 @@ function! NERDTreeCopyNode() try let newNode = currentNode.copy(newNodePath) if empty(newNode) - call b:NERDTreeRoot.refresh() + call b:NERDTree.root.refresh() call b:NERDTree.render() else call NERDTreeRender() diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 42a3b1e2..515bef91 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -83,8 +83,8 @@ if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTreeRoot (its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTreeRoot')?b:NERDTreeRoot.path.str():''}" + "because it doesnt store b:NERDTree(its a b: var, and its a hash) + let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" endif call s:initVariable("g:NERDTreeWinPos", "left") From bf217c75f9cd2207fb42b1f397cf4b98a6c9b616 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Nov 2015 11:29:54 +0000 Subject: [PATCH 227/680] fix a couple of var references in UI --- lib/nerdtree/ui.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 40c014ee..0d731196 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -27,12 +27,12 @@ function! s:UI._dumpHelp() let @h=@h."\" File node mappings~\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" let @h=@h."\" ,\n" - if b:NERDTree.isTabTree() + if self.nerdtree.isTabTree() let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" else let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" endif - if b:NERDTree.isTabTree() + if self.nerdtree.isTabTree() let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" endif let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" From 71ee64fed77cb709e481b7145d88377cea185a04 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Nov 2015 11:30:16 +0000 Subject: [PATCH 228/680] add TreeDirNode.getDirChildren() - using this in a plugin --- lib/nerdtree/tree_dir_node.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index e1e82cb1..4943b9b6 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -171,6 +171,12 @@ function! s:TreeDirNode.getChildIndex(path) return -1 endfunction +"FUNCTION: TreeDirNode.getDirChildren() {{{1 +"Get all children that are directories +function! s:TreeDirNode.getDirChildren() + return filter(self.children, 'v:val.path.isDirectory == 1') +endfunction + "FUNCTION: TreeDirNode.GetSelected() {{{1 "Returns the current node if it is a dir node, or else returns the current "nodes parent From cedb40b4f584948133af1939247131a632837021 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Mon, 16 Nov 2015 13:17:59 +0000 Subject: [PATCH 229/680] move TreeFileNode.makeRoot() to NERDTree.changeRoot(node) --- autoload/nerdtree/ui_glue.vim | 4 +--- lib/nerdtree/bookmark.vim | 4 +--- lib/nerdtree/nerdtree.vim | 22 ++++++++++++++++++++++ lib/nerdtree/opener.vim | 4 +--- lib/nerdtree/tree_file_node.vim | 20 -------------------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 23edfe75..604a6375 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -140,9 +140,7 @@ endfunction " FUNCTION: s:chRoot(node) {{{1 " changes the current root to the selected one function! s:chRoot(node) - call a:node.makeRoot() - call b:NERDTree.render() - call b:NERDTree.root.putCursorHere(0, 0) + call b:NERDTree.changeRoot(a:node) endfunction " FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 1b49f027..f4815014 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -275,9 +275,7 @@ function! s:Bookmark.toRoot() catch /^NERDTree.BookmarkedNodeNotFoundError/ let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) endtry - call targetNode.makeRoot() - call b:NERDTree.render() - call targetNode.putCursorHere(0, 0) + call b:NERDTree.changeRoot(targetNode) endif endfunction diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 83468cac..9e38b3ad 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -8,6 +8,28 @@ function! s:NERDTree.AddPathFilter(callback) call add(s:NERDTree.PathFilters(), a:callback) endfunction +"FUNCTION: s:NERDTree.changeRoot(node) {{{1 +function! s:NERDTree.changeRoot(node) + if a:node.path.isDirectory + let self.root = a:node + else + call a:node.cacheParent() + let self.root = self.parent + endif + + call self.root.open() + + "change dir to the dir of the new root if instructed to + if g:NERDTreeChDirMode ==# 2 + exec "cd " . self.root.path.str({'format': 'Edit'}) + endif + + call self.render() + call self.root.putCursorHere(0, 0) + + silent doautocmd User NERDTreeNewRoot +endfunction + "FUNCTION: s:NERDTree.Close() {{{1 "Closes the tab tree window for this tab function! s:NERDTree.Close() diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 0f8a0052..480d91d4 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -268,9 +268,7 @@ function! s:Opener._openDirectory(node) else call self._gotoTargetWin() if empty(self._where) - call a:node.makeRoot() - call b:NERDTree.render() - call a:node.putCursorHere(0, 0) + call b:NERDTree.changeRoot(a:node) elseif self._where == 't' call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index b2a536e1..150b03a5 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -218,26 +218,6 @@ function! s:TreeFileNode.isRoot() return self.equals(b:NERDTree.root) endfunction -"FUNCTION: TreeFileNode.makeRoot() {{{1 -"Make this node the root of the tree -function! s:TreeFileNode.makeRoot() - if self.path.isDirectory - let b:NERDTree.root = self - else - call self.cacheParent() - let b:NERDTree.root = self.parent - endif - - call b:NERDTree.root.open() - - "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 - exec "cd " . b:NERDTree.root.path.str({'format': 'Edit'}) - endif - - silent doautocmd User NERDTreeNewRoot -endfunction - "FUNCTION: TreeFileNode.New(path) {{{1 "Returns a new TreeNode object with the given path and parent " From a0de028688b4802de65c1b17963d7e5479035530 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 19 Nov 2015 23:44:39 +0000 Subject: [PATCH 230/680] wipeout "stale" nerdtree bufs When :NERDTree is called several times and &hidden is set, stale nerdtree bufs will exist. Wipe them out. --- lib/nerdtree/creator.vim | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 61f204f2..21411703 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -62,7 +62,8 @@ function! s:Creator.createTabTree(name) if g:NERDTree.IsOpen() call g:NERDTree.Close() endif - unlet t:NERDTreeBufName + + call self._removeTreeBufForTab() endif call self._createTreeWin() @@ -197,6 +198,15 @@ function! s:Creator._createTreeWin() call self._setCommonBufOptions() endfunction +"FUNCTION: s:Creator._isBufHidden(nr) {{{1 +function! s:Creator._isBufHidden(nr) + redir => bufs + ls! + redir END + + return bufs =~ a:nr . '..h' +endfunction + "FUNCTION: s:Creator.New() {{{1 function! s:Creator.New() let newCreator = copy(self) @@ -251,6 +261,23 @@ function! s:Creator._pathForString(str) return path endfunction +" Function: s:Creator._removeTreeBufForTab() {{{1 +function! s:Creator._removeTreeBufForTab() + let buf = bufnr(t:NERDTreeBufName) + + "if &hidden is not set then it will already be gone + if buf != -1 + + "nerdtree buf may be mirrored/displayed elsewhere + if self._isBufHidden(buf) + exec "bwipeout " . buf + endif + + endif + + unlet t:NERDTreeBufName +endfunction + "FUNCTION: s:Creator._setCommonBufOptions() {{{1 function! s:Creator._setCommonBufOptions() "throwaway buffer options From 665f326577e319f4fd1321ee664365b0a81b8d37 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 01:44:12 +0000 Subject: [PATCH 231/680] remove dependency on b:NERDTree from classes that dont need it Inject it where needed. --- autoload/nerdtree/ui_glue.vim | 16 +++++----- lib/nerdtree/bookmark.vim | 52 +++++++++++++++------------------ lib/nerdtree/creator.vim | 2 +- lib/nerdtree/nerdtree.vim | 2 +- lib/nerdtree/notifier.vim | 4 +-- lib/nerdtree/path.vim | 24 +++++++-------- lib/nerdtree/tree_dir_node.vim | 27 ++++++++--------- lib/nerdtree/tree_file_node.vim | 40 ++++++++++++++----------- nerdtree_plugin/fs_menu.vim | 2 +- 9 files changed, 86 insertions(+), 83 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 604a6375..05f03c96 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -105,7 +105,7 @@ endfunction "FUNCTION: s:activateBookmark() {{{1 "handle the user activating a bookmark function! s:activateBookmark(bm) - call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) endfunction " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 @@ -155,7 +155,7 @@ function! nerdtree#ui_glue#chRootCwd() if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() return endif - call s:chRoot(g:NERDTreeDirNode.New(cwd)) + call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree)) endfunction " FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 @@ -171,6 +171,7 @@ function! nerdtree#ui_glue#clearBookmarks(bookmarks) call bookmark.delete() endfor endif + call b:NERDTree.root.refresh() call b:NERDTree.render() endfunction @@ -225,6 +226,7 @@ function! s:deleteBookmark(bm) if nr2char(getchar()) ==# 'y' try call a:bm.delete() + call b:NERDTree.root.refresh() call b:NERDTree.render() redraw catch /^NERDTree/ @@ -279,7 +281,7 @@ function! s:findAndRevealPath() call g:NERDTree.CursorToTreeWin() endif call b:NERDTree.setShowHidden(g:NERDTreeShowHidden) - call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) + call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree)) else if !g:NERDTree.IsOpen() call g:NERDTreeCreator.ToggleTabTree("") @@ -442,13 +444,13 @@ endfunction " put the cursor on the given bookmark and, if its a file, open it function! nerdtree#ui_glue#openBookmark(name) try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) redraw! catch /^NERDTree.BookmarkedNodeNotFoundError/ call nerdtree#echo("note - target node is not cached") let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) - let targetNode = g:NERDTreeFileNode.New(bookmark.path) + let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree) endtry if targetNode.path.isDirectory call targetNode.openExplorer() @@ -510,7 +512,7 @@ endfunction " put the cursor on the node associate with the given name function! nerdtree#ui_glue#revealBookmark(name) try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0) + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) catch /^NERDTree.BookmarkNotFoundError/ call nerdtree#echo("Bookmark isnt cached under the current root") @@ -614,7 +616,7 @@ function! nerdtree#ui_glue#upDir(keepState) if empty(b:NERDTree.root.parent) let path = b:NERDTree.root.path.getParent() - let newRoot = g:NERDTreeDirNode.New(path) + let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree) call newRoot.open() call newRoot.transplantChild(b:NERDTree.root) let b:NERDTree.root = newRoot diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index f4815014..81242605 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -3,9 +3,9 @@ let s:Bookmark = {} let g:NERDTreeBookmark = s:Bookmark -" FUNCTION: Bookmark.activate() {{{1 -function! s:Bookmark.activate(...) - call self.open(a:0 ? a:1 : {}) +" FUNCTION: Bookmark.activate(nerdtree) {{{1 +function! s:Bookmark.activate(nerdtree, ...) + call self.open(a:nerdtree, a:0 ? a:1 : {}) endfunction " FUNCTION: Bookmark.AddBookmark(name, path) {{{1 @@ -128,26 +128,18 @@ endfunction " Delete this bookmark. If the node for this bookmark is under the current " root, then recache bookmarks for its Path object function! s:Bookmark.delete() - let node = {} - try - let node = self.getNode(1) - catch /^NERDTree.BookmarkedNodeNotFoundError/ - endtry call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) - if !empty(node) - call node.path.cacheDisplayString() - endif call s:Bookmark.Write() endfunction -" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1 +" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " Gets the treenode for this bookmark " " Args: " searchFromAbsoluteRoot: specifies whether we should search from the current " tree root, or the highest cached node -function! s:Bookmark.getNode(searchFromAbsoluteRoot) - let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTree.root +function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) + let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root let targetNode = searchRoot.findNode(self.path) if empty(targetNode) throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name @@ -155,12 +147,12 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot) return targetNode endfunction -" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1 +" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 " Class method that finds the bookmark with the given name and returns the " treenode for it. -function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) +function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) let bookmark = s:Bookmark.BookmarkFor(a:name) - return bookmark.getNode(a:searchFromAbsoluteRoot) + return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot) endfunction " FUNCTION: Bookmark.GetSelected() {{{1 @@ -210,8 +202,11 @@ function! s:Bookmark.New(name, path) return newBookmark endfunction -" FUNCTION: Bookmark.open([options]) {{{1 +" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1 "Args: +" +"nerdtree: the tree to load open the bookmark in +" "A dictionary containing the following keys (all optional): " 'where': Specifies whether the node should be opened in new split/tab or in " the previous window. Can be either 'v' (vertical split), 'h' @@ -220,11 +215,11 @@ endfunction " 'keepopen': dont close the tree window " 'stay': open the file, but keep the cursor in the tree win " -function! s:Bookmark.open(...) +function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} if self.path.isDirectory && !has_key(opts, 'where') - call self.toRoot() + call self.toRoot(a:nerdtree) else let opener = g:NERDTreeOpener.New(self.path, opts) call opener.open(self) @@ -266,24 +261,24 @@ function! s:Bookmark.str() return '>' . self.name . ' ' . pathStr endfunction -" FUNCTION: Bookmark.toRoot() {{{1 +" FUNCTION: Bookmark.toRoot(nerdtree) {{{1 " Make the node for this bookmark the new tree root -function! s:Bookmark.toRoot() +function! s:Bookmark.toRoot(nerdtree) if self.validate() try - let targetNode = self.getNode(1) + let targetNode = self.getNode(a:nerdtree, 1) catch /^NERDTree.BookmarkedNodeNotFoundError/ - let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) + let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) endtry - call b:NERDTree.changeRoot(targetNode) + call a:nerdtree.changeRoot(targetNode) endif endfunction -" FUNCTION: Bookmark.ToRoot(name) {{{1 +" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1 " Make the node for this bookmark the new tree root -function! s:Bookmark.ToRoot(name) +function! s:Bookmark.ToRoot(name, nerdtree) let bookmark = s:Bookmark.BookmarkFor(a:name) - call bookmark.toRoot() + call bookmark.toRoot(a:nerdtree) endfunction " FUNCTION: Bookmark.validate() {{{1 @@ -292,7 +287,6 @@ function! s:Bookmark.validate() return 1 else call s:Bookmark.CacheBookmarks(1) - call b:NERDTree.render() call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") return 0 endif diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 21411703..f6e857d6 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -16,7 +16,7 @@ function! s:Creator._bindMappings() command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 9e38b3ad..284111ab 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -148,7 +148,7 @@ endfunction function! s:NERDTree.New(path, type) let newObj = copy(self) let newObj.ui = g:NERDTreeUI.New(newObj) - let newObj.root = g:NERDTreeDirNode.New(a:path) + let newObj.root = g:NERDTreeDirNode.New(a:path, newObj) let newObj._type = a:type return newObj endfunction diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index b445f8ad..00041b85 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -11,8 +11,8 @@ function! s:Notifier.AddListener(event, funcname) call add(listeners, a:funcname) endfunction -function! s:Notifier.NotifyListeners(event, path, params) - let event = g:NERDTreeEvent.New(b:NERDTree, a:path, a:event, a:params) +function! s:Notifier.NotifyListeners(event, path, nerdtree, params) + let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) for listener in s:Notifier.GetListenersForEvent(a:event) call {listener}(event) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 4a2314e3..f52426db 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -406,11 +406,11 @@ function! s:Path.isUnixHiddenPath() endif endfunction -"FUNCTION: Path.ignore() {{{1 +"FUNCTION: Path.ignore(nerdtree) {{{1 "returns true if this path should be ignored -function! s:Path.ignore() +function! s:Path.ignore(nerdtree) "filter out the user specified paths to ignore - if b:NERDTree.ui.isIgnoreFilterEnabled() + if a:nerdtree.ui.isIgnoreFilterEnabled() for i in g:NERDTreeIgnore if self._ignorePatternMatches(i) return 1 @@ -418,18 +418,18 @@ function! s:Path.ignore() endfor for callback in g:NERDTree.PathFilters() - if {callback}({'path': self, 'nerdtree': b:NERDTree}) + if {callback}({'path': self, 'nerdtree': a:nerdtree}) return 1 endif endfor endif "dont show hidden files unless instructed to - if !b:NERDTree.ui.getShowHidden() && self.isUnixHiddenFile() + if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile() return 1 endif - if b:NERDTree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0 + if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0 return 1 endif @@ -572,16 +572,16 @@ function! s:Path.readInfoFromDisk(fullpath) endif endfunction -"FUNCTION: Path.refresh() {{{1 -function! s:Path.refresh() +"FUNCTION: Path.refresh(nerdtree) {{{1 +function! s:Path.refresh(nerdtree) call self.readInfoFromDisk(self.str()) - call g:NERDTreePathNotifier.NotifyListeners('refresh', self, {}) + call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {}) call self.cacheDisplayString() endfunction -"FUNCTION: Path.refreshFlags() {{{1 -function! s:Path.refreshFlags() - call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, {}) +"FUNCTION: Path.refreshFlags(nerdtree) {{{1 +function! s:Path.refreshFlags(nerdtree) + call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {}) call self.cacheDisplayString() endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 4943b9b6..673f4523 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -21,7 +21,7 @@ unlet s:TreeDirNode.activate function! s:TreeDirNode.activate(...) let opts = a:0 ? a:1 : {} call self.toggleOpen(opts) - call b:NERDTree.render() + call self.getNerdtree().render() call self.putCursorHere(0, 0) endfunction @@ -68,7 +68,7 @@ endfunction "Returns: "the newly created node function! s:TreeDirNode.createChild(path, inOrder) - let newTreeNode = g:NERDTreeFileNode.New(a:path) + let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree()) call self.addChild(newTreeNode, a:inOrder) return newTreeNode endfunction @@ -205,7 +205,7 @@ endfunction function! s:TreeDirNode.getVisibleChildren() let toReturn = [] for i in self.children - if i.path.ignore() ==# 0 + if i.path.ignore(self.getNerdtree()) ==# 0 call add(toReturn, i) endif endfor @@ -258,7 +258,7 @@ function! s:TreeDirNode._initChildren(silent) try let path = g:NERDTreePath.New(i) call self.createChild(path, 0) - call g:NERDTreePathNotifier.NotifyListeners('init', path, {}) + call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound += 1 endtry @@ -277,13 +277,13 @@ function! s:TreeDirNode._initChildren(silent) return self.getChildCount() endfunction -"FUNCTION: TreeDirNode.New(path) {{{1 +"FUNCTION: TreeDirNode.New(path, nerdtree) {{{1 "Returns a new TreeNode object with the given path and parent " "Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -unlet s:TreeDirNode.New -function! s:TreeDirNode.New(path) +"path: dir that the node represents +"nerdtree: the tree the node belongs to +function! s:TreeDirNode.New(path, nerdtree) if a:path.isDirectory != 1 throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." endif @@ -295,6 +295,7 @@ function! s:TreeDirNode.New(path) let newTreeNode.children = [] let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree return newTreeNode endfunction @@ -379,7 +380,7 @@ endfunction "Args: "forceOpen: 1 if this node should be opened regardless of file filters function! s:TreeDirNode._openRecursively2(forceOpen) - if self.path.ignore() ==# 0 || a:forceOpen + if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen let self.isOpen = 1 if self.children ==# [] call self._initChildren(1) @@ -396,7 +397,7 @@ endfunction "FUNCTION: TreeDirNode.refresh() {{{1 unlet s:TreeDirNode.refresh function! s:TreeDirNode.refresh() - call self.path.refresh() + call self.path.refresh(self.getNerdtree()) "if this node was ever opened, refresh its children if self.isOpen || !empty(self.children) @@ -427,7 +428,7 @@ function! s:TreeDirNode.refresh() "the node doesnt exist so create it else - let newNode = g:NERDTreeFileNode.New(path) + let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree()) let newNode.parent = self call add(newChildNodes, newNode) endif @@ -452,7 +453,7 @@ endfunction "FUNCTION: TreeDirNode.refreshFlags() {{{1 unlet s:TreeDirNode.refreshFlags function! s:TreeDirNode.refreshFlags() - call self.path.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) for i in self.children call i.refreshFlags() endfor @@ -460,7 +461,7 @@ endfunction "FUNCTION: TreeDirNode.refreshDirFlags() {{{1 function! s:TreeDirNode.refreshDirFlags() - call self.path.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) endfunction "FUNCTION: TreeDirNode.reveal(path) {{{1 diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 150b03a5..ac2f31c4 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -19,7 +19,7 @@ function! s:TreeFileNode.bookmark(name) "it so we can update its display string let oldMarkedNode = {} try - let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1) + let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree()) catch /^NERDTree.BookmarkNotFoundError/ catch /^NERDTree.BookmarkedNodeNotFoundError/ endtry @@ -41,7 +41,7 @@ function! s:TreeFileNode.cacheParent() if parentPath.equals(self.path) throw "NERDTree.CannotCacheParentError: already at root" endif - let self.parent = s:TreeFileNode.New(parentPath) + let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree()) endif endfunction @@ -59,7 +59,7 @@ endfunction function! s:TreeFileNode.copy(dest) call self.path.copy(a:dest) let newPath = g:NERDTreePath.New(a:dest) - let parent = b:NERDTree.root.findNode(newPath.getParent()) + let parent = self.getNerdtree().root.findNode(newPath.getParent()) if !empty(parent) call parent.refresh() return parent.findNode(newPath) @@ -165,7 +165,7 @@ function! s:TreeFileNode.findSibling(direction) "if the next node is not an ignored node (i.e. wont show up in the "view) then return it - if self.parent.children[siblingIndx].path.ignore() ==# 0 + if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0 return self.parent.children[siblingIndx] endif @@ -178,6 +178,11 @@ function! s:TreeFileNode.findSibling(direction) return {} endfunction +"FUNCTION: TreeFileNode.getNerdtree(){{{1 +function! s:TreeFileNode.getNerdtree() + return self._nerdtree +endfunction + "FUNCTION: TreeFileNode.GetRootForTab(){{{1 "get the root node for this tab function! s:TreeFileNode.GetRootForTab() @@ -205,31 +210,32 @@ endfunction "returns 1 if this node should be visible according to the tree filters and "hidden file filters (and their on/off status) function! s:TreeFileNode.isVisible() - return !self.path.ignore() + return !self.path.ignore(self.getNerdtree()) endfunction "FUNCTION: TreeFileNode.isRoot() {{{1 -"returns 1 if this node is b:NERDTree.root function! s:TreeFileNode.isRoot() if !g:NERDTree.ExistsForBuf() throw "NERDTree.NoTreeError: No tree exists for the current buffer" endif - return self.equals(b:NERDTree.root) + return self.equals(self.getNerdtree().root) endfunction -"FUNCTION: TreeFileNode.New(path) {{{1 +"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1 "Returns a new TreeNode object with the given path and parent " "Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -function! s:TreeFileNode.New(path) +"path: file/dir that the node represents +"nerdtree: the tree the node belongs to +function! s:TreeFileNode.New(path, nerdtree) if a:path.isDirectory - return g:NERDTreeDirNode.New(a:path) + return g:NERDTreeDirNode.New(a:path, a:nerdtree) else let newTreeNode = copy(self) let newTreeNode.path = a:path let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree return newTreeNode endif endfunction @@ -269,7 +275,7 @@ endfunction "recurseUpward: try to put the cursor on the parent if the this node isnt "visible function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) - let ln = b:NERDTree.ui.getLineNum(self) + let ln = self.getNerdtree().ui.getLineNum(self) if ln != -1 if a:isJump mark ' @@ -278,11 +284,11 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) else if a:recurseUpward let node = self - while node != {} && b:NERDTree.ui.getLineNum(node) ==# -1 + while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1 let node = node.parent call node.open() endwhile - call b:NERDTree.render() + call self.getNerdtree().render() call node.putCursorHere(a:isJump, 0) endif endif @@ -290,12 +296,12 @@ endfunction "FUNCTION: TreeFileNode.refresh() {{{1 function! s:TreeFileNode.refresh() - call self.path.refresh() + call self.path.refresh(self.getNerdtree()) endfunction "FUNCTION: TreeFileNode.refreshFlags() {{{1 function! s:TreeFileNode.refreshFlags() - call self.path.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) endfunction "FUNCTION: TreeFileNode.rename() {{{1 @@ -306,7 +312,7 @@ function! s:TreeFileNode.rename(newName) call self.parent.removeChild(self) let parentPath = self.path.getParent() - let newParent = b:NERDTree.root.findNode(parentPath) + let newParent = self.getNerdtree().root.findNode(parentPath) if newParent != {} call newParent.createChild(self.path, 1) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 315a7894..20a9fcd3 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -107,7 +107,7 @@ function! NERDTreeAddNode() let newPath = g:NERDTreePath.Create(newNodeName) let parentNode = b:NERDTree.root.findNode(newPath.getParent()) - let newTreeNode = g:NERDTreeFileNode.New(newPath) + let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) if empty(parentNode) call b:NERDTree.root.refresh() call b:NERDTree.render() From c4f8681b775e42807697155a1155adf2670e1037 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 01:52:38 +0000 Subject: [PATCH 232/680] add NERDTree.getRoot() and NERDTree.ForCurrentTab() --- lib/nerdtree/nerdtree.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 284111ab..ac34e896 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -112,6 +112,16 @@ function! s:NERDTree.ForCurrentBuf() endif endfunction +"FUNCTION: s:NERDTree.ForCurrentTab() {{{1 +function! s:NERDTree.ForCurrentTab() + if !s:NERDTree.ExistsForTab() + return + endif + + let bufnr = bufnr(t:NERDTreeBufName) + return getbufvar(bufnr, "NERDTree") +endfunction + "FUNCTION: s:NERDTree.GetWinNum() {{{1 "gets the nerd tree window number for this tab function! s:NERDTree.GetWinNum() From a60bd34a3359ba8de47eed4dbfbb5e3a1af10b5e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 16:15:39 +0000 Subject: [PATCH 233/680] add NERDTree.getroot() Eventually 'root' will become a "private" instance var '_root' --- lib/nerdtree/nerdtree.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index ac34e896..f794998c 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -122,6 +122,11 @@ function! s:NERDTree.ForCurrentTab() return getbufvar(bufnr, "NERDTree") endfunction +"FUNCTION: s:NERDTree.getRoot() {{{1 +function! s:NERDTree.getRoot() + return self.root +endfunction + "FUNCTION: s:NERDTree.GetWinNum() {{{1 "gets the nerd tree window number for this tab function! s:NERDTree.GetWinNum() From 7c6795c5a25c2d56286eb81e62e98e96bac999b8 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 16:45:05 +0000 Subject: [PATCH 234/680] fix a typo --- lib/nerdtree/ui.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 0d731196..4276f8c9 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -495,7 +495,7 @@ endfunction " toggles the use of the NERDTreeIgnore option function! s:UI.toggleIgnoreFilter() let self._ignoreEnabled = !self._ignoreEnabled - Vall self.renderViewSavingPosition() + call self.renderViewSavingPosition() call self.centerView() endfunction From 9eb0004278f1243245e10b1692215aad05ea273d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 19:15:37 +0000 Subject: [PATCH 235/680] fix a syntax issue for older versions of vim closes #508 --- lib/nerdtree/tree_file_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index ac2f31c4..e30f7077 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -288,7 +288,7 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) let node = node.parent call node.open() endwhile - call self.getNerdtree().render() + call self._nerdtree.render() call node.putCursorHere(a:isJump, 0) endif endif From dd754c7bc64f8802ab6ff660776e1dee0e0e2761 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 19:16:07 +0000 Subject: [PATCH 236/680] add path.isAncestor --- lib/nerdtree/path.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index f52426db..c83e36cc 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -455,10 +455,22 @@ function! s:Path._ignorePatternMatches(pattern) return self.getLastPathComponent(0) =~# pat endfunction -"FUNCTION: Path.isUnder(path) {{{1 -"return 1 if this path is somewhere under the given path in the filesystem. +"FUNCTION: Path.isAncestor(path) {{{1 +"return 1 if this path is somewhere above the given path in the filesystem. " "a:path should be a dir +function! s:Path.isAncestor(path) + if !self.isDirectory + return 0 + endif + + let this = self.str() + let that = a:path.str() + return stridx(that, this) == 0 +endfunction + +"FUNCTION: Path.isUnder(path) {{{1 +"return 1 if this path is somewhere under the given path in the filesystem. function! s:Path.isUnder(path) if a:path.isDirectory == 0 return 0 From ee4d42cfed64deb249988cbada025011032a3ff4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 22 Nov 2015 14:02:56 +0000 Subject: [PATCH 237/680] encapsulate dep on g:NERDTreeMinimalUI in a function --- lib/nerdtree/ui.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 4276f8c9..55edb602 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -116,7 +116,7 @@ function! s:UI._dumpHelp() let @h=@h."\" :ClearBookmarks []\n" let @h=@h."\" :ClearAllBookmarks\n" silent! put h - elseif g:NERDTreeMinimalUI == 0 + elseif !self.isMinimal() let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" silent! put h endif @@ -306,6 +306,11 @@ function! s:UI.isIgnoreFilterEnabled() return self._ignoreEnabled == 1 endfunction +"FUNCTION: s:UI.isMinimal() {{{1 +function! s:UI.isMinimal() + return g:NERDTreeMinimalUI +endfunction + "FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() if g:NERDTreeDirArrows @@ -318,7 +323,7 @@ endfunction "FUNCTION: s:UI._renderBookmarks {{{1 function! s:UI._renderBookmarks() - if g:NERDTreeMinimalUI == 0 + if !self.isMinimal() call setline(line(".")+1, ">----------Bookmarks----------") call cursor(line(".")+1, col(".")) endif @@ -426,7 +431,7 @@ function! s:UI.render() call self._dumpHelp() "delete the blank line before the help and add one after it - if g:NERDTreeMinimalUI == 0 + if !self.isMinimal() call setline(line(".")+1, "") call cursor(line(".")+1, col(".")) endif @@ -436,7 +441,7 @@ function! s:UI.render() endif "add the 'up a dir' line - if !g:NERDTreeMinimalUI + if !self.isMinimal() call setline(line(".")+1, s:UI.UpDirLine()) call cursor(line(".")+1, col(".")) endif From 2cef8bb6022b9e450cdee23d03024822e1dbeeea Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 24 Nov 2015 11:18:25 +0000 Subject: [PATCH 238/680] make cascading dirs more compact Render cascading dirs on one line i.e. > foo/bar/baz file1 instead of > foo > bar > baz > file1 This should be useful things like java projects that have deep dir structures. Remove the old UI view (pre the dir arrows) as this simply isnt worth supporting for a proof of concept. This may get added back - or not. --- lib/nerdtree/tree_dir_node.vim | 25 +++++++++++ lib/nerdtree/tree_file_node.vim | 76 +++++++-------------------------- 2 files changed, 40 insertions(+), 61 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 673f4523..259456f8 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -73,6 +73,24 @@ function! s:TreeDirNode.createChild(path, inOrder) return newTreeNode endfunction +"FUNCTION: TreeDirNode.displayString() {{{1 +unlet s:TreeDirNode.displayString +function! s:TreeDirNode.displayString() + let vc = self.getVisibleChildren() + if len(vc) != 1 + return self.path.displayString() + endif + + let visChild = vc[0] + + "TODO: optimize + if !visChild.path.isDirectory + return self.path.displayString() + endif + + return self.path.getLastPathComponent(1) . visChild.displayString() +endfunction + "FUNCTION: TreeDirNode.findNode(path) {{{1 "Will find one of the children (recursively) that has the given path " @@ -218,6 +236,13 @@ function! s:TreeDirNode.hasVisibleChildren() return self.getVisibleChildCount() != 0 endfunction +"FUNCTION: TreeDirNode.isCascadable() {{{1 +"true if this dir has only one visible child - which is also a dir +function! s:TreeDirNode.isCascadable() + let c = self.getVisibleChildren() + return len(c) == 1 && c[0].path.isDirectory +endfunction + "FUNCTION: TreeDirNode._initChildren() {{{1 "Removes all childen from this node and re-reads them " diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index e30f7077..c69ae715 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -323,70 +323,27 @@ endfunction "FUNCTION: TreeFileNode.renderToString {{{1 "returns a string representation for this tree to be rendered in the view function! s:TreeFileNode.renderToString() - return self._renderToString(0, 0, [], self.getChildCount() ==# 1) + return self._renderToString(0, 0) endfunction "Args: "depth: the current depth in the tree for this call "drawText: 1 if we should actually draw the line for this node (if 0 then the "child nodes are rendered only) -"vertMap: a binary array that indicates whether a vertical bar should be draw "for each depth in the tree -"isLastChild:true if this curNode is the last child of its parent -function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) +function! s:TreeFileNode._renderToString(depth, drawText) let output = "" if a:drawText ==# 1 - let treeParts = '' - - "get all the leading spaces and vertical tree parts for this line - if a:depth > 1 - for j in a:vertMap[0:-2] - if g:NERDTreeDirArrows - let treeParts = treeParts . ' ' - else - if j ==# 1 - let treeParts = treeParts . '| ' - else - let treeParts = treeParts . ' ' - endif - endif - endfor - endif - - "get the last vertical tree part for this line which will be different - "if this node is the last child of its parent - if !g:NERDTreeDirArrows - if a:isLastChild - let treeParts = treeParts . '`' - else - let treeParts = treeParts . '|' - endif - endif + let treeParts = repeat(' ', a:depth - 1) - "smack the appropriate dir/file symbol on the line before the file/dir - "name itself if self.path.isDirectory - if self.isOpen - if g:NERDTreeDirArrows - let treeParts = treeParts . g:NERDTreeDirArrowCollapsible . ' ' - else - let treeParts = treeParts . '~' - endif - else - if g:NERDTreeDirArrows - let treeParts = treeParts . g:NERDTreeDirArrowExpandable . ' ' - else - let treeParts = treeParts . '+' - endif - endif + let sym = self.isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable + let treeParts = treeParts . sym . ' ' else - if g:NERDTreeDirArrows - let treeParts = treeParts . ' ' - else - let treeParts = treeParts . '-' - endif + let treeParts = treeParts . ' ' endif + let line = treeParts . self.displayString() let output = output . line . "\n" @@ -396,18 +353,15 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) if self.path.isDirectory ==# 1 && self.isOpen ==# 1 let childNodesToDraw = self.getVisibleChildren() - if len(childNodesToDraw) > 0 - - "draw all the nodes children except the last - let lastIndx = len(childNodesToDraw)-1 - if lastIndx > 0 - for i in childNodesToDraw[0:lastIndx-1] - let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0) - endfor - endif - "draw the last child, indicating that it IS the last - let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1) + if self.isCascadable() && a:depth > 0 + + let output = output . childNodesToDraw[0]._renderToString(a:depth, 0) + + elseif len(childNodesToDraw) > 0 + for i in childNodesToDraw + let output = output . i._renderToString(a:depth + 1, 1) + endfor endif endif From af39458989358d7dbf8e77a298883c17dc3f238d Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 24 Nov 2015 22:06:04 +0000 Subject: [PATCH 239/680] rework the cascading slightly to correctly show open/closed dir arrows --- lib/nerdtree/tree_dir_node.vim | 45 +++++++++++++++++++++++++-------- lib/nerdtree/tree_file_node.vim | 5 +--- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 259456f8..41fb76b7 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -76,19 +76,15 @@ endfunction "FUNCTION: TreeDirNode.displayString() {{{1 unlet s:TreeDirNode.displayString function! s:TreeDirNode.displayString() - let vc = self.getVisibleChildren() - if len(vc) != 1 - return self.path.displayString() - endif + let cascade = self.getCascade() + let rv = "" + for node in cascade + let rv = rv . node.path.displayString() + endfor - let visChild = vc[0] + let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable - "TODO: optimize - if !visChild.path.isDirectory - return self.path.displayString() - endif - - return self.path.getLastPathComponent(1) . visChild.displayString() + return sym . ' ' . rv endfunction "FUNCTION: TreeDirNode.findNode(path) {{{1 @@ -116,6 +112,33 @@ function! s:TreeDirNode.findNode(path) return {} endfunction +"FUNCTION: TreeDirNode.getCascade() {{{1 +"Return an array of dir nodes (starting from self) that can be cascade opened. +function! s:TreeDirNode.getCascade() + + let rv = [self] + let node = self + + while 1 + let vc = node.getVisibleChildren() + if len(vc) != 1 + break + endif + + let visChild = vc[0] + + "TODO: optimize + if !visChild.path.isDirectory + break + endif + + call add(rv, visChild) + let node = visChild + endwhile + + return rv +endfunction + "FUNCTION: TreeDirNode.getChildCount() {{{1 "Returns the number of children this node has function! s:TreeDirNode.getChildCount() diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index c69ae715..54e5291b 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -337,10 +337,7 @@ function! s:TreeFileNode._renderToString(depth, drawText) let treeParts = repeat(' ', a:depth - 1) - if self.path.isDirectory - let sym = self.isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable - let treeParts = treeParts . sym . ' ' - else + if !self.path.isDirectory let treeParts = treeParts . ' ' endif From fb15cfbf4504660f7b23dbe099b8736071fb0665 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 25 Nov 2015 22:12:52 +0000 Subject: [PATCH 240/680] fix flag rendering for cascading dirs Use the innermost dirs flags only. Previously each dirs flags were rendered inline i.e. [x]dir1/[y]dir2/[z]dir3/ This looked bad and broke the UI. Now we only render the flags for dir3 - and render them on the left side of the cascade. Not sure if this is ultimately the right decision - but will do for now. --- lib/nerdtree/path.vim | 4 +--- lib/nerdtree/tree_dir_node.vim | 4 +++- lib/nerdtree/tree_file_node.vim | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index c83e36cc..df18505f 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -40,9 +40,7 @@ endfunction "FUNCTION: Path.cacheDisplayString() {{{1 function! s:Path.cacheDisplayString() abort - let self.cachedDisplayString = self.flagSet.renderToString() - - let self.cachedDisplayString .= self.getLastPathComponent(1) + let self.cachedDisplayString = self.getLastPathComponent(1) if self.isExecutable let self.cachedDisplayString = self.cachedDisplayString . '*' diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 41fb76b7..48e9bda3 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -84,7 +84,9 @@ function! s:TreeDirNode.displayString() let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable - return sym . ' ' . rv + let flags = cascade[-1].path.flagSet.renderToString() + + return sym . ' ' . flags . rv endfunction "FUNCTION: TreeDirNode.findNode(path) {{{1 diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 54e5291b..adb0e96b 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -83,7 +83,7 @@ endfunction "Return: "a string that can be used in the view to represent this node function! s:TreeFileNode.displayString() - return self.path.displayString() + return self.path.flagSet.renderToString() . self.path.displayString() endfunction "FUNCTION: TreeFileNode.equals(treenode) {{{1 From 677a83b2b63fda1c52205acd39973fe1b44e8b54 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 25 Nov 2015 23:29:00 +0000 Subject: [PATCH 241/680] remove NERDTreeDirArrows option Use +/~ for windows - which seems to not have the arrow chars in its default font. TBH I don't really understand this. Inprove the UI indent matching so that it should handle any combo of open/close symbol lengths e.g. the fancy arrows are 3 bytes each, whereas +/~ are 1 byte each. --- doc/NERD_tree.txt | 16 ---------------- lib/nerdtree/ui.vim | 12 +++++------- plugin/NERD_tree.vim | 11 ++++++++--- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index ccc60b5c..1ad8e181 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -671,9 +671,6 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and 'Press ? for help' text. -|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of - + ~ chars when displaying directories. - |'NERDTreeCascadeOpenSingleChildDir'| Cascade open while selected directory has only one child that also is a directory. @@ -986,19 +983,6 @@ of the following lines to set this option: > let NERDTreeMinimalUI=1 < ------------------------------------------------------------------------------- - *'NERDTreeDirArrows'* -Values: 0 or 1 -Default: 0. - -This option is used to change the default look of directory nodes displayed in -the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to -1 it shows right and down arrows. Use one of the follow lines to set this -option: > - let NERDTreeDirArrows=0 - let NERDTreeDirArrows=1 -< - ------------------------------------------------------------------------------ *'NERDTreeCascadeOpenSingleChildDir'* Values: 0 or 1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 55edb602..ed235263 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -287,13 +287,11 @@ endfunction "FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'`|]') / s:UI.IndentWid() - " check if line includes arrows - if match(a:line, '['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') > -1 - " decrement level as arrow uses 3 ascii chars - let level = level - 1 - endif - return level + "have to do this work around because match() returns bytes, not chars + let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') + let leadChars = strchars(a:line[0:numLeadBytes-1]) + + return leadChars / s:UI.IndentWid() endfunction "FUNCTION: s:UI.IndentWid() {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 515bef91..bbcc55f6 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -65,9 +65,14 @@ call s:initVariable("g:NERDTreeShowFiles", 1) call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows()) -call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") -call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") + +if !nerdtree#runningWindows() + call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") +else + call s:initVariable("g:NERDTreeDirArrowExpandable", "+") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") +endif call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") From 4f9e981a60ea1b2354200bf4fd252a0b59a486dc Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 25 Nov 2015 23:52:05 +0000 Subject: [PATCH 242/680] update changelog --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 03192408..2e08dd2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ Next - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. + - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) + - Remove the old style UI - Remove 'NERDTreeDirArrows' option. + - On windows default to + and ~ for expand/collapse directory symbols. + - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. 5.0.0 - Refactor the code significantly: From a2b06bbac35ef2e6478486b85b6153f04658dcc1 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Nov 2015 00:24:44 +0000 Subject: [PATCH 243/680] remove references to NERDTreeDirArrows Closes #515 --- README.markdown | 1 - lib/nerdtree/ui.vim | 13 +----------- syntax/nerdtree.vim | 50 ++++++++++++--------------------------------- 3 files changed, 14 insertions(+), 50 deletions(-) diff --git a/README.markdown b/README.markdown index 66e8896e..5debfa93 100644 --- a/README.markdown +++ b/README.markdown @@ -116,6 +116,5 @@ See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-9259069 Use these variables in your vimrc. Note that below are default arrow symbols - let g:NERDTreeDirArrows = 1 let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ed235263..1ad44698 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -158,13 +158,6 @@ function! s:UI.getPath(ln) return self.nerdtree.root.path endif - if !g:NERDTreeDirArrows - " in case called from outside the tree - if line !~# '^ *[|`'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.' ]' || line =~# '^$' - return {} - endif - endif - if line ==# s:UI.UpDirLine() return self.nerdtree.root.path.getParent() endif @@ -311,11 +304,7 @@ endfunction "FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() - if g:NERDTreeDirArrows - return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' - endif - - return '^[ `|]*[\-+~]' + return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' endfunction "FUNCTION: s:UI._renderBookmarks {{{1 diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 846cf493..8a4e4245 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -22,43 +22,19 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir -if g:NERDTreeDirArrows - exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' - exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' - - let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') - exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' - syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' - - "highlighting for readonly files - syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile - - syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile - syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir -else - "highlighting for the ~/+ symbols for the directory nodes - syn match NERDTreeClosable #\~\<# - syn match NERDTreeClosable #\~\.# - syn match NERDTreeOpenable #+\<# - syn match NERDTreeOpenable #+\.#he=e-1 - - "highlighting for the tree structural parts - syn match NERDTreePart #|# - syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart - - syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable - syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - - "highlighting for readonly files - syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreePart,NERDTreePartFile - - syn match NERDTreeFlags #-\[.\]# containedin=NERDTreeFile,NERDTreePartFile - syn match NERDTreeFlags #[+~]\zs\[.\]# containedin=NERDTreeDir -endif +exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' +exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' + +let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') +exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' +syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark +exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' + +"highlighting for readonly files +syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile + +syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile +syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir syn match NERDTreeCWD #^[ Date: Thu, 26 Nov 2015 09:27:44 +0000 Subject: [PATCH 244/680] fix a bug with `C` mapping Closes #512 --- lib/nerdtree/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index f794998c..a4995f85 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -14,7 +14,7 @@ function! s:NERDTree.changeRoot(node) let self.root = a:node else call a:node.cacheParent() - let self.root = self.parent + let self.root = a:node.parent endif call self.root.open() From fddac60afb026a458babc6d3bd2455d5f967d45e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Nov 2015 09:31:55 +0000 Subject: [PATCH 245/680] fix a bug that occurs when opening window trees Closes #507 --- lib/nerdtree/opener.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 480d91d4..852aba8d 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -272,7 +272,7 @@ function! s:Opener._openDirectory(node) elseif self._where == 't' call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else - call g:NERDTreeCreator.CreateWindow(a:node.path.str()) + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) endif endif From 73ded483a0481cd7e29616830af8a3c9ab496e40 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Nov 2015 18:57:38 +0000 Subject: [PATCH 246/680] update FAQ about opening nerdtree automatically on startup Closes #494 --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 5debfa93..f4ca8607 100644 --- a/README.markdown +++ b/README.markdown @@ -91,11 +91,13 @@ Stick this in your vimrc: `autocmd vimenter * NERDTree` > How can I open a NERDTree automatically when vim starts up if no files were specified? -Stick this in your vimrc +Stick this in your vimrc: autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +Note: Now start vim with plain `vim`, not `vim .` + > How can I map a specific key or shortcut to open NERDTree? Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): From 0544ff524c5209cf885984739dde941fd9fd37af Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Nov 2015 19:14:51 +0000 Subject: [PATCH 247/680] handle tab tree buffers being :bdeleted Closes #375 --- lib/nerdtree/nerdtree.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a4995f85..73a30f7a 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -101,7 +101,12 @@ endfunction " Function: s:NERDTree.ExistsForTab() {{{1 " Returns 1 if a nerd tree root exists in the current tab function! s:NERDTree.ExistsForTab() - return exists("t:NERDTreeBufName") + if !exists("t:NERDTreeBufName") + return + end + + "check b:NERDTree is still there and hasn't been e.g. :bdeleted + return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree')) endfunction function! s:NERDTree.ForCurrentBuf() @@ -132,9 +137,9 @@ endfunction function! s:NERDTree.GetWinNum() if exists("t:NERDTreeBufName") return bufwinnr(t:NERDTreeBufName) - else - return -1 endif + + return -1 endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 From bbb819d69670e772a635150dd1ae37407e404b2e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 26 Nov 2015 19:52:40 +0000 Subject: [PATCH 248/680] bugfix for win trees when using "stay in current win" command variants Previously maps like T would not restore the cursor position. Not sure why the code was like this in the first place... hopefully I haven't just broken a bunch of shit. Closes #146. --- lib/nerdtree/opener.vim | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 852aba8d..00947cdb 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -247,16 +247,9 @@ function! s:Opener._openFile() endif call self._gotoTargetWin() - - if self._nerdtree.isWinTree() - call self._path.edit() - else - call self._path.edit() - - - if self._stay - call self._restoreCursorPos() - endif + call self._path.edit() + if self._stay + call self._restoreCursorPos() endif endfunction From 2f8a72144fe1e96804f000b6cf9bf9c4057e5ddd Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 27 Nov 2015 10:14:45 +0000 Subject: [PATCH 249/680] silence an `ls!` call --- lib/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index f6e857d6..9775d31c 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -201,7 +201,7 @@ endfunction "FUNCTION: s:Creator._isBufHidden(nr) {{{1 function! s:Creator._isBufHidden(nr) redir => bufs - ls! + silent ls! redir END return bufs =~ a:nr . '..h' From 4ebbb533c3faf2c480211db2b547972bb3b60f2b Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 2 Dec 2015 21:16:34 +0000 Subject: [PATCH 250/680] silence bookmark errors on startup Just disable the warning for now. The bookmark system will be replaced with the project system soon - so no sense putting much effort into this. Closes #168 --- autoload/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 6d7828d7..3ad2a031 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -94,7 +94,7 @@ endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 function! nerdtree#postSourceActions() - call g:NERDTreeBookmark.CacheBookmarks(0) + call g:NERDTreeBookmark.CacheBookmarks(1) call nerdtree#ui_glue#createDefaultBindings() "load all nerdtree plugins From afe99a46d88b4ee59f676f4364100732f6d207cf Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Sun, 17 Jan 2016 18:51:36 -0500 Subject: [PATCH 251/680] update api call to open directory tree in window --- lib/nerdtree/opener.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 00947cdb..ac0f92eb 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -257,7 +257,7 @@ endfunction function! s:Opener._openDirectory(node) if self._nerdtree.isWinTree() call self._gotoTargetWin() - call g:NERDTreeCreator.CreateWindow(a:node.path.str()) + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) else call self._gotoTargetWin() if empty(self._where) From 6251ab1e6377f302c0c9b9337af6855b3638db98 Mon Sep 17 00:00:00 2001 From: Maxim Bublis Date: Tue, 19 Jan 2016 00:21:13 -0800 Subject: [PATCH 252/680] Add support for natural sorting order. --- autoload/nerdtree.vim | 28 ++++++++++++++++++++++++++-- doc/NERD_tree.txt | 30 ++++++++++++++++++++++++++++++ lib/nerdtree/path.vim | 29 +++++++++++++++++++++-------- plugin/NERD_tree.vim | 1 + 4 files changed, 78 insertions(+), 10 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3ad2a031..24fbe9c1 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -36,9 +36,33 @@ endfunction "FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 function! nerdtree#compareNodesBySortKey(n1, n2) - if a:n1.path.getSortKey() <# a:n2.path.getSortKey() + let sortKey1 = a:n1.path.getSortKey() + let sortKey2 = a:n2.path.getSortKey() + + let i = 0 + while i < min([len(sortKey1), len(sortKey2)]) + " Compare chunks upto common length. + " If chunks have different type, the one which has + " integer type is the lesser. + if type(sortKey1[i]) == type(sortKey2[i]) + if sortKey1[i] <# sortKey2[i] + return - 1 + elseif sortKey1[i] ># sortKey2[i] + return 1 + endif + elseif sortKey1[i] == type(0) + return -1 + elseif sortKey2[i] == type(0) + return 1 + endif + let i = i + 1 + endwhile + + " Keys are identical upto common length. + " The key which has smaller chunks is the lesser one. + if len(sortKey1) < len(sortKey2) return -1 - elseif a:n1.path.getSortKey() ># a:n2.path.getSortKey() + elseif len(sortKey1) > len(sortKey2) return 1 else return 0 diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 1ad8e181..d09ee323 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -618,6 +618,9 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case sensitive or not when sorting nodes. +|'NERDTreeNaturalSort'| Tells the NERD tree whether to use + natural sort order or not when sorting nodes. + |'NERDTreeSortHiddenFirst'| Tells the NERD tree whether to take the dot at the beginning of the hidden file names into account when sorting nodes. @@ -734,6 +737,33 @@ account. The above nodes would then be sorted like this: > blarg.c boner.c < +------------------------------------------------------------------------------ + *'NERDTreeNaturalSort'* +Values: 0 or 1. +Default: 0. + +By default the NERD tree does not sort nodes in natural sort order, i.e. nodes +could appear like this: > + z1.txt + z10.txt + z100.txt + z11.txt + z110.txt + z2.txt + z20.txt + z3.txt +< +But if you set this option to 1 then the natural sort order will be used. The +above nodes would then be sorted like this: > + z1.txt + z2.txt + z3.txt + z10.txt + z11.txt + z20.txt + z100.txt + z110.txt +< ------------------------------------------------------------------------------ *'NERDTreeChDirMode'* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index df18505f..fc067a17 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -1,12 +1,6 @@ "we need to use this number many times for sorting... so we calculate it only "once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') -" used in formating sortKey, e.g. '%04d' -if exists("log10") - let s:sortKeyFormat = "%0" . float2nr(ceil(log10(len(g:NERDTreeSortOrder)))) . "d" -else - let s:sortKeyFormat = "%04d" -endif "CLASS: Path "============================================================ @@ -365,8 +359,23 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction +"FUNCTION: Path._splitChunks(path) {{{1 +"returns a list of path chunks +function! s:Path._splitChunks(path) + let chunks = split(a:path, '\(\D\+\|\d\+\)\zs') + let i = 0 + while i < len(chunks) + "convert number literals to numbers + if match(chunks[i], '^\d\+$') == 0 + let chunks[i] = str2nr(chunks[i]) + endif + let i = i + 1 + endwhile + return chunks +endfunction + "FUNCTION: Path.getSortKey() {{{1 -"returns a string used in compare function for sorting +"returns a key used in compare function for sorting function! s:Path.getSortKey() if !exists("self._sortKey") let path = self.getLastPathComponent(1) @@ -376,7 +385,11 @@ function! s:Path.getSortKey() if !g:NERDTreeCaseSensitiveSort let path = tolower(path) endif - let self._sortKey = printf(s:sortKeyFormat, self.getSortOrderIndex()) . path + if !g:NERDTreeNaturalSort + let self._sortKey = [self.getSortOrderIndex(), path] + else + let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + endif endif return self._sortKey diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index bbcc55f6..8d41be7c 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -46,6 +46,7 @@ endfunction call s:initVariable("g:NERDTreeAutoCenter", 1) call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) +call s:initVariable("g:NERDTreeNaturalSort", 0) call s:initVariable("g:NERDTreeSortHiddenFirst", 1) call s:initVariable("g:NERDTreeChDirMode", 0) call s:initVariable("g:NERDTreeMinimalUI", 0) From e2bbedff099e6058aed3975d76c1ec08074cb829 Mon Sep 17 00:00:00 2001 From: brook hong Date: Tue, 2 Feb 2016 22:31:17 +0800 Subject: [PATCH 253/680] Fix #520 E716: Key not present in Dictionary: setShowHidden --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 05f03c96..0912faff 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -280,7 +280,7 @@ function! s:findAndRevealPath() else call g:NERDTree.CursorToTreeWin() endif - call b:NERDTree.setShowHidden(g:NERDTreeShowHidden) + call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden) call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree)) else if !g:NERDTree.IsOpen() From 28560e2e1be3a544c9b47c5f49410f0ab8fe4201 Mon Sep 17 00:00:00 2001 From: Grzegorz Wilk Date: Thu, 4 Feb 2016 11:24:45 +0100 Subject: [PATCH 254/680] changed arrows for NERDTreeDirArrowExpandable and NERDTreeDirArrowCollapsible --- README.markdown | 4 ++-- plugin/NERD_tree.vim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index f4ca8607..15c35e9d 100644 --- a/README.markdown +++ b/README.markdown @@ -118,5 +118,5 @@ See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-9259069 Use these variables in your vimrc. Note that below are default arrow symbols - let g:NERDTreeDirArrowExpandable = '▸' - let g:NERDTreeDirArrowCollapsible = '▾' + let g:NERDTreeDirArrowExpandable = '►' + let g:NERDTreeDirArrowCollapsible = '▼' diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index bbcc55f6..e6bae4f8 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -67,8 +67,8 @@ call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) if !nerdtree#runningWindows() - call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") + call s:initVariable("g:NERDTreeDirArrowExpandable", "►") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "▼") else call s:initVariable("g:NERDTreeDirArrowExpandable", "+") call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") From 68dce4f9944c6df49163166e0e805b3028c7144d Mon Sep 17 00:00:00 2001 From: Aditya Natraj Date: Sat, 6 Feb 2016 18:11:52 -0500 Subject: [PATCH 255/680] Issue #537: Fix dir arrows not functioning properly added characters that are special when within character classes in a regular expression to the `escape(...)` call when building `s:dirArrows`. this does not fix when `' '` or `''` are your `dirArrows` and you can't open up subdirs. i think that's an issue with how nerdtree distinguishes things to traverse in the filetree. --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 8a4e4245..bc28fe31 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -25,7 +25,7 @@ syn match NERDTreeDirSlash #/# containedin=NERDTreeDir exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') +let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' From 9843fd3686a3fd1aee08fe82012fe9a85440a58f Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Tue, 9 Feb 2016 00:11:44 -0800 Subject: [PATCH 256/680] Make window creation command configurable This commit adds a `NERDTreeCreatePrefix` setting that can be used to prefix the `:edit` command that is used to create the NERDTree tree window. Defaults to "silent", meaning that out of the box the window will be created with "silent edit". Users may wish to configure this to produce other effects. For example, `NERDTreeCreatePrefix` can be set to "silent keepalt keepjumps" in order to make NERDTree create its window with "silent keepalt keepjumps edit". This can be used to create an effect analogous to the `g:netrw_altfile` setting in netrw. An example of why you might want to do this is described here: https://github.com/tpope/vim-vinegar/issues/25 I'm not using vim-vinegar myself, but I am using something like it here: https://github.com/wincent/wincent/blob/3efaa8fa50895/roles/dotfiles/files/.vim/plugin/mappings.vim#L60 And having `NERDTreeCreatePrefix` enables me to map "-" to show the current file in context, and `^-6` to jump back to it. --- doc/NERD_tree.txt | 14 ++++++++++++++ lib/nerdtree/creator.vim | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 1ad8e181..bf1ab5a8 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -679,6 +679,9 @@ NERD tree. These options should be set in your vimrc. a buffer when a file is being deleted or renamed via a context menu command. +|'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the + NERDTree window. + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* @@ -1010,6 +1013,17 @@ option: > let NERDTreeAutoDeleteBuffer=0 let NERDTreeAutoDeleteBuffer=1 < +------------------------------------------------------------------------------ + *'NERDTreeCreatePrefix'* +Values: Any valid command prefix. +Default: "silent". + +Internally, NERDTree uses the |:edit| command to create a buffer in which to +display its tree view. You can augment this behavior by specifying a prefix +string such as "keepalt" or similar. For example, to have NERDTree create its +tree window using `silent keepalt keepjumps edit`: + let NERDTreeCreatePrefix='silent keepalt keepjumps' +< ============================================================================== 4. The NERD tree API *NERDTreeAPI* diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 9775d31c..8dd6c2ca 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -96,7 +96,8 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - exec "silent edit " . self._nextBufferName() + let prefix = get(g:, "NERDTreeCreatePrefix", "silent") + exec prefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") let b:NERDTree._previousBuf = bufnr(previousBuf) From dfb91117860a33ae911646223d37ffd28907ac21 Mon Sep 17 00:00:00 2001 From: Alex Carlson Date: Fri, 26 Feb 2016 17:57:40 -0800 Subject: [PATCH 257/680] Allow user-defined RO indicator. (inspired by overwriting g:NERDTreeDirArrowCollapsible/Expandable) Replace instances of the RO string with a variable that the user can override. Useful for custom unicode glyphs, i.e. Font Awesome. * Initialize variable g:NERDTreeGlyphReadOnly = "RO". -> plugin/NERD_tree.vim * Replace instances of 'RO' with g:NERDTreeGlyphReadOnly --- lib/nerdtree/path.vim | 2 +- lib/nerdtree/ui.vim | 2 +- plugin/NERD_tree.vim | 2 ++ syntax/nerdtree.vim | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index df18505f..674ca03e 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -61,7 +61,7 @@ function! s:Path.cacheDisplayString() abort endif if self.isReadOnly - let self.cachedDisplayString .= ' [RO]' + let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' endif endfunction diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 1ad44698..c6831989 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -375,7 +375,7 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces) let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") "strip off any read only flag - let line = substitute (line, ' \[RO\]', "","") + exec 'let line = substitute (line, " \['.g:NERDTreeGlyphReadOnly.'\]", "","")' "strip off any bookmark flags let line = substitute (line, ' {[^}]*}', "","") diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index bbcc55f6..8ce0a2be 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -84,6 +84,8 @@ else endif endif +call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") + if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 8a4e4245..d2a94834 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -1,6 +1,6 @@ let s:tree_up_dir_line = '.. (up a dir)' syn match NERDTreeIgnore #\~# -syn match NERDTreeIgnore #\[RO\]# +exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' "highlighting for the .. (up dir) line at the top of the tree execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" @@ -31,7 +31,7 @@ syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmar exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' "highlighting for readonly files -syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile +exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir From 7f6c608a35bea5443db0ef9c82517f363b0ae5da Mon Sep 17 00:00:00 2001 From: Juan Ibiapina Date: Sat, 5 Mar 2016 13:35:41 -0300 Subject: [PATCH 258/680] Remove extra whitespace at the end of the line --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 48e9bda3..96e7257c 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -466,7 +466,7 @@ function! s:TreeDirNode.refresh() " Regular expression is too expensive. Use simply string comparison " instead - if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && \ i[len(i)-2:1] != "." && i[len(i)-1] != "." try "create a new path and see if it exists in this nodes children From 88946e9832dcb35e13c811f3026f47112b79951c Mon Sep 17 00:00:00 2001 From: Juan Ibiapina Date: Sat, 5 Mar 2016 13:59:27 -0300 Subject: [PATCH 259/680] Rewrite getCascade recursively --- lib/nerdtree/tree_dir_node.vim | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 96e7257c..6bac917a 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -117,28 +117,14 @@ endfunction "FUNCTION: TreeDirNode.getCascade() {{{1 "Return an array of dir nodes (starting from self) that can be cascade opened. function! s:TreeDirNode.getCascade() + if !self.isCascadable() + return [self] + endif - let rv = [self] - let node = self - - while 1 - let vc = node.getVisibleChildren() - if len(vc) != 1 - break - endif - - let visChild = vc[0] - - "TODO: optimize - if !visChild.path.isDirectory - break - endif - - call add(rv, visChild) - let node = visChild - endwhile + let vc = self.getVisibleChildren() + let visChild = vc[0] - return rv + return [self] + visChild.getCascade() endfunction "FUNCTION: TreeDirNode.getChildCount() {{{1 From b2bbed41fad5fa494493386fe3c1a76eed201db2 Mon Sep 17 00:00:00 2001 From: Juan Ibiapina Date: Sat, 5 Mar 2016 14:20:04 -0300 Subject: [PATCH 260/680] Add option to disable collapsing of diretory names --- doc/NERD_tree.txt | 23 +++++++++++++++++++---- lib/nerdtree/tree_dir_node.vim | 4 ++++ plugin/NERD_tree.vim | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 1ad8e181..0cd32345 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -668,14 +668,18 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeWinSize'| Sets the window size when the NERD tree is opened. -|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and +|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and 'Press ? for help' text. +|'NERDTreeCascadeSingleChildDir'| + Collapses on the same line directories that + have only one child directory. + |'NERDTreeCascadeOpenSingleChildDir'| Cascade open while selected directory has only one child that also is a directory. -|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove +|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove a buffer when a file is being deleted or renamed via a context menu command. @@ -984,7 +988,18 @@ of the following lines to set this option: > < ------------------------------------------------------------------------------ - *'NERDTreeCascadeOpenSingleChildDir'* + *'NERDTreeCascadeSingleChildDir'* +Values: 0 or 1 +Default: 1. + +When displaying dir nodes, this option tells NERDTree to collapse dirs that +have only one child. Use one of the follow lines to set this option: > + let NERDTreeCascadeSingleChildDir=0 + let NERDTreeCascadeSingleChildDir=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeCascadeOpenSingleChildDir'* Values: 0 or 1 Default: 1. @@ -998,7 +1013,7 @@ useful for Java projects. Use one of the follow lines to set this option: > < ------------------------------------------------------------------------------ - *'NERDTreeAutoDeleteBuffer'* + *'NERDTreeAutoDeleteBuffer'* Values: 0 or 1 Default: 0. diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 6bac917a..c41077df 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -250,6 +250,10 @@ endfunction "FUNCTION: TreeDirNode.isCascadable() {{{1 "true if this dir has only one visible child - which is also a dir function! s:TreeDirNode.isCascadable() + if g:NERDTreeCascadeSingleChildDir == 0 + return 0 + endif + let c = self.getVisibleChildren() return len(c) == 1 && c[0].path.isDirectory endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index bbcc55f6..fdaa5b2c 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -74,6 +74,7 @@ else call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") endif call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) +call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] From 0e4c270d19564832ec0deae8f81d5f50d91d42b2 Mon Sep 17 00:00:00 2001 From: Noah Huppert Date: Sat, 5 Mar 2016 17:03:23 -0500 Subject: [PATCH 261/680] Added horizontal rules to FAQ section in readme --- README.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.markdown b/README.markdown index f4ca8607..3fb9ee70 100644 --- a/README.markdown +++ b/README.markdown @@ -76,6 +76,7 @@ Faq Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). +--- > Can I have the nerdtree on every tab automatically? @@ -85,10 +86,12 @@ http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) +--- > How can I open a NERDTree automatically when vim starts up? Stick this in your vimrc: `autocmd vimenter * NERDTree` +--- > How can I open a NERDTree automatically when vim starts up if no files were specified? Stick this in your vimrc: @@ -98,22 +101,26 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` +--- > How can I map a specific key or shortcut to open NERDTree? Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): map :NERDTreeToggle +--- > How can I close vim if the only window left open is a NERDTree? Stick this in your vimrc: autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +--- > Can I have different highlighting for different file extensions? See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 +--- > How can I change default arrows? Use these variables in your vimrc. Note that below are default arrow symbols From 1a55a93788f5e8378104498dfa893e5708fecfae Mon Sep 17 00:00:00 2001 From: "d.chernyatiev" Date: Mon, 25 Apr 2016 19:05:17 +0400 Subject: [PATCH 262/680] Remove empty segments --- lib/nerdtree/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 58bb0138..39ecfe70 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -472,7 +472,7 @@ function! s:Path.readInfoFromDisk(fullpath) throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath endif - let self.pathSegments = split(fullpath, '/') + let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)') let self.isReadOnly = 0 if isdirectory(a:fullpath) From 35c859179da4ad4f96eb8255e428904436a0b4b4 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 26 Apr 2016 09:15:08 +0100 Subject: [PATCH 263/680] update initialization of default value for g:NERDTreeCreatePrefix Init it with the rest of the option defaults - rather than specify the default at point of use. For consistency. See #550. --- lib/nerdtree/creator.vim | 3 +-- plugin/NERD_tree.vim | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 8dd6c2ca..952811c1 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -96,8 +96,7 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - let prefix = get(g:, "NERDTreeCreatePrefix", "silent") - exec prefix . " edit " . self._nextBufferName() + exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") let b:NERDTree._previousBuf = bufnr(previousBuf) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8ce0a2be..0bcfe968 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) call s:initVariable("g:NERDTreeSortHiddenFirst", 1) call s:initVariable("g:NERDTreeChDirMode", 0) +call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeMinimalUI", 0) if !exists("g:NERDTreeIgnore") let g:NERDTreeIgnore = ['\~$'] From 5458680265083095b54b296f2decc58c85f92591 Mon Sep 17 00:00:00 2001 From: Mike Zueff Date: Sat, 30 Apr 2016 04:08:18 +0300 Subject: [PATCH 264/680] Fixed read-only files opening. --- lib/nerdtree/ui.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index c6831989..c8482d04 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -375,7 +375,7 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces) let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") "strip off any read only flag - exec 'let line = substitute (line, " \['.g:NERDTreeGlyphReadOnly.'\]", "","")' + exec 'let line = substitute (line, " \\['.g:NERDTreeGlyphReadOnly.'\\]", "","")' "strip off any bookmark flags let line = substitute (line, ' {[^}]*}', "","") From 35b04fa3dfdef5cbfbcd6ada59fce3a7bc31eeaa Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Thu, 5 May 2016 09:32:19 -0700 Subject: [PATCH 265/680] Suppress autocmds less aggressively This is the counterpart to a PR I just submitted to undotree (https://github.com/mbbill/undotree/pull/61). I noticed that my statusline doesn't update properly when using NERDTree to move between revisions of a file with `go` or `gi` (https://github.com/wincent/wincent/issues/16). I established that this was because it was using `'eventignore'` to suppress all autocmds, which in turn prevents the statusline from updating. Commenting out the `set eventignore=all` line makes the failure to update go away, at the cost of firing more autocmds. I considered adding an option for opting out of this behavior (eg. `let g:NERDTreeEventignore=0` or something), or rearchitecting my statusline to use an approach like vim-airline does based on CursorMoved autocmds (see https://github.com/vim-airline/vim-airline/issues/82; see also https://github.com/vim-airline/vim-airline/blob/30f078daf569e7d5e4f7829e39316387af349b41/plugin/airline.vim#L36-L50 for current implementation), but then realized that a simpler fix is to have NERDTree just disable only the autocmds that it uses instead of disabling all of them. This is probably not enough to unbreak every bit of code in the world that depends on those autocmds, but it does at least unbreak my use case, because it allows my `WinLeave` autocmd to run and update the statusline. --- autoload/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3ad2a031..7302daca 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -64,7 +64,7 @@ endfunction " same as :exec cmd but eventignore=all is set for the duration function! nerdtree#exec(cmd) let old_ei = &ei - set ei=all + set ei=BufEnter,BufLeave,VimEnter exec a:cmd let &ei = old_ei endfunction From 15445be5fb2559829ac7a1f05af5d713586e8ec9 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 11 May 2016 16:28:34 +0100 Subject: [PATCH 266/680] remove unneeded exec As @mkoskar pointed out at: https://github.com/scrooloose/nerdtree/pull/576#issuecomment-218470556 --- lib/nerdtree/ui.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index c8482d04..094fa0f9 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -375,7 +375,7 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces) let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") "strip off any read only flag - exec 'let line = substitute (line, " \\['.g:NERDTreeGlyphReadOnly.'\\]", "","")' + let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","") "strip off any bookmark flags let line = substitute (line, ' {[^}]*}', "","") From 1ac98de88a7c60d931d29367336f2efd5e29d539 Mon Sep 17 00:00:00 2001 From: Zane Hitchcox Date: Mon, 23 May 2016 10:59:07 -0500 Subject: [PATCH 267/680] Update README.markdown --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 3fb9ee70..1ab334c8 100644 --- a/README.markdown +++ b/README.markdown @@ -57,8 +57,7 @@ Installation ####[pathogen.vim](https://github.com/tpope/vim-pathogen) - cd ~/.vim/bundle - git clone https://github.com/scrooloose/nerdtree.git + git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. From c99312442b0961241eb0de3d6d65893c52f4d9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Adamczak?= Date: Wed, 22 Jun 2016 13:32:44 +0200 Subject: [PATCH 268/680] Fix upward traversal when closing a cascade --- autoload/nerdtree/ui_glue.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 0912faff..4cbfb386 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -191,8 +191,8 @@ function! s:closeCurrentDir(node) call nerdtree#echo("cannot close tree root") else while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot() - if parent.parent.getVisibleChildCount() == 1 - call parent.close() + let childNodes = parent.getVisibleChildren() + if len(childNodes) == 1 && childNodes[0].path.isDirectory let parent = parent.parent else break From 2924ab207162ca18cf5844d00b351ade1b5122f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Adamczak?= Date: Wed, 22 Jun 2016 13:59:49 +0200 Subject: [PATCH 269/680] Verify we haven't reached root when traversing cascade --- autoload/nerdtree/ui_glue.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 4cbfb386..2aa3bece 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -187,17 +187,17 @@ endfunction " closes the parent dir of the current node function! s:closeCurrentDir(node) let parent = a:node.parent + while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot() + let childNodes = parent.getVisibleChildren() + if len(childNodes) == 1 && childNodes[0].path.isDirectory + let parent = parent.parent + else + break + endif + endwhile if parent ==# {} || parent.isRoot() call nerdtree#echo("cannot close tree root") else - while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot() - let childNodes = parent.getVisibleChildren() - if len(childNodes) == 1 && childNodes[0].path.isDirectory - let parent = parent.parent - else - break - endif - endwhile call parent.close() call b:NERDTree.render() call parent.putCursorHere(0, 0) From d2509d279e0d725b58dddc0f76db82e17b9bc799 Mon Sep 17 00:00:00 2001 From: Mike Perri Date: Thu, 7 Jan 2016 09:53:28 -0600 Subject: [PATCH 270/680] Don't require user to type 'yes' to delete an empty directory --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 20a9fcd3..dfceaf2c 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -160,7 +160,7 @@ function! NERDTreeDeleteNode() let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 - if currentNode.path.isDirectory + if currentNode.path.isDirectory && currentNode.getChildCount() > 0 let choice =input("Delete the current node\n" . \ "==========================================================\n" . \ "STOP! To delete this entire directory, type 'yes'\n" . From 0ef5b6be4f3e7106faa07a804b6e29a07bfa65a3 Mon Sep 17 00:00:00 2001 From: Isaac Rogers Date: Mon, 27 Jun 2016 19:11:07 -0400 Subject: [PATCH 271/680] Add FAQ: how to unfocus nerdtree window on start --- README.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.markdown b/README.markdown index 3fb9ee70..5dd3aa58 100644 --- a/README.markdown +++ b/README.markdown @@ -101,6 +101,16 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` +--- +> How can I open NERDTree on startup, and have my cursor start in the other window? + +Stick this in your vimrc: + + autocmd vimenter * NERDTree + autocmd vimenter * wincmd p + + *via [stackoverflow/Yohann](http://stackoverflow.com/questions/4277808/nerdtree-auto-focus-to-file-when-opened-in-new-tab/19330023#19330023)* + --- > How can I map a specific key or shortcut to open NERDTree? From 916f6b8f8f7db66cf6d52b1cacd182d13a9e8794 Mon Sep 17 00:00:00 2001 From: Zachary Voase Date: Thu, 30 Jun 2016 16:21:13 -0700 Subject: [PATCH 272/680] Use fnameescape to quote filenames for :badd. --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 20a9fcd3..703a3eaa 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -74,7 +74,7 @@ endfunction function! s:promptToRenameBuffer(bufnum, msg, newFileName) echo a:msg if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' - let quotedFileName = "'" . a:newFileName . "'" + let quotedFileName = fnameescape(a:newFilename) " 1. ensure that a new buffer is loaded exec "badd " . quotedFileName " 2. ensure that all windows which display the just deleted filename From 40993e90101332e88b68c15d1ea4fd3ea84ab2a4 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 25 Aug 2016 08:23:02 -0400 Subject: [PATCH 273/680] Corrected case of :Helptags to :helptags --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 3fb9ee70..d4f62077 100644 --- a/README.markdown +++ b/README.markdown @@ -60,7 +60,7 @@ Installation cd ~/.vim/bundle git clone https://github.com/scrooloose/nerdtree.git -Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. +Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`. ####[apt-vim](https://github.com/egalpin/apt-vim) From b5519197e9b27a3a99f6310148084c84f8ef3d4a Mon Sep 17 00:00:00 2001 From: Skyler Lipthay Date: Wed, 23 Jan 2013 00:23:56 -0800 Subject: [PATCH 274/680] Added support for the copy command for both file and directory nodes on Windows systems --- lib/nerdtree/path.vim | 26 ++++++++++++++++++++++---- plugin/NERD_tree.vim | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 674ca03e..223b61fa 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -174,11 +174,25 @@ function! s:Path.copy(dest) call s:Path.createParentDirectories(a:dest) - let dest = s:Path.WinToUnixPath(a:dest) + if !nerdtree#runningWindows() + let dest = s:Path.WinToUnixPath(a:dest) + else + let dest = a:dest + endif - let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) + if !exists('g:NERDTreeCopyCmd') + if self.isDirectory + let cmd_prefix = g:NERDTreeCopyDirCmd + else + let cmd_prefix = g:NERDTreeCopyFileCmd + endif + else + let cmd_prefix = g:NERDTreeCopyCmd + end + + let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) let success = system(cmd) - if success != 0 + if v:shell_error != 0 throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" endif endfunction @@ -187,7 +201,11 @@ endfunction " "returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() - return exists('g:NERDTreeCopyCmd') + if !exists('g:NERDTreeCopyCmd') + return exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd') + endif + + return 1 endfunction "FUNCTION: Path.copyingWillOverwrite(dest) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 0bcfe968..15cc2d90 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -103,6 +103,8 @@ call s:initVariable("g:NERDTreeWinSize", 31) "Note: the space after the command is important if nerdtree#runningWindows() call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') + call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') + call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') else call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') From 7730c8731a010fd2eb41a0b3b9a7c7f7d466170c Mon Sep 17 00:00:00 2001 From: Skyler Date: Wed, 23 Jan 2013 10:28:18 -0800 Subject: [PATCH 275/680] Quick syntax issue fix --- lib/nerdtree/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 223b61fa..86fb5f76 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -188,7 +188,7 @@ function! s:Path.copy(dest) endif else let cmd_prefix = g:NERDTreeCopyCmd - end + endif let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) let success = system(cmd) From 0b73db93685f9e15d889c51eaf2a6335fa9f417b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 26 Aug 2016 01:32:04 -0400 Subject: [PATCH 276/680] Simplify some statements. Don't convert path WinToUnix. --- lib/nerdtree/path.vim | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 86fb5f76..5f3b16ad 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -174,23 +174,13 @@ function! s:Path.copy(dest) call s:Path.createParentDirectories(a:dest) - if !nerdtree#runningWindows() - let dest = s:Path.WinToUnixPath(a:dest) - else - let dest = a:dest - endif - - if !exists('g:NERDTreeCopyCmd') - if self.isDirectory - let cmd_prefix = g:NERDTreeCopyDirCmd - else - let cmd_prefix = g:NERDTreeCopyFileCmd - endif - else + if exists('g:NERDTreeCopyCmd') let cmd_prefix = g:NERDTreeCopyCmd + else + let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) endif - let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) + let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(a:dest, self._escChars()) let success = system(cmd) if v:shell_error != 0 throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" @@ -201,11 +191,7 @@ endfunction " "returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() - if !exists('g:NERDTreeCopyCmd') - return exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd') - endif - - return 1 + return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd')) endfunction "FUNCTION: Path.copyingWillOverwrite(dest) {{{1 @@ -231,7 +217,7 @@ endfunction "FUNCTION: Path.createParentDirectories(path) {{{1 " "create parent directories for this path if needed -"without throwing any errors is those directories already exist +"without throwing any errors if those directories already exist " "Args: "path: full path of the node whose parent directories may need to be created @@ -244,8 +230,7 @@ endfunction "FUNCTION: Path.delete() {{{1 " -"Deletes the file represented by this path. -"Deletion of directories is not supported +"Deletes the file or directory represented by this path. " "Throws NERDTree.Path.Deletion exceptions function! s:Path.delete() From 4428aba2a299cbd117c80e7d18068b2cbb222fff Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 26 Aug 2016 08:59:25 -0400 Subject: [PATCH 277/680] Replace strchars() with a backward compatible workaround. --- lib/nerdtree/ui.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 094fa0f9..d107814c 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -282,7 +282,8 @@ endfunction function! s:UI._indentLevelFor(line) "have to do this work around because match() returns bytes, not chars let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') - let leadChars = strchars(a:line[0:numLeadBytes-1]) + " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ + let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) return leadChars / s:UI.IndentWid() endfunction From 29cf96e45b4830a9a2351514fe102bb7a95a27d5 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 8 Sep 2016 01:57:38 -0400 Subject: [PATCH 278/680] Update change log. --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2e08dd2a..6be2d887 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,8 @@ Next + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 + - Replace strchars() with backward compatible workaround. + - Add support for copy command in Windows (SkylerLipthay) #231 + - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) From 9aae0be31893b30946832560124158b2a95c7eaf Mon Sep 17 00:00:00 2001 From: Curran Kelleher Date: Sat, 17 Sep 2016 15:27:19 +0530 Subject: [PATCH 279/680] Correct broken helptags command in docs. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index d4f62077..a84e002b 100644 --- a/README.markdown +++ b/README.markdown @@ -60,7 +60,7 @@ Installation cd ~/.vim/bundle git clone https://github.com/scrooloose/nerdtree.git -Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`. +Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`. ####[apt-vim](https://github.com/egalpin/apt-vim) From b9ad20c0b19ea39bbcf38fd3eca9543ebc359b72 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 21 Sep 2016 22:36:58 -0400 Subject: [PATCH 280/680] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 6be2d887..45bf68f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Next + - Fixed incomplete escaping of folder arrows (adityanatraj) #548 - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 - Replace strchars() with backward compatible workaround. - Add support for copy command in Windows (SkylerLipthay) #231 From 4ebd7de207fbe61523aea4fa0f2ad0bfe080f18c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 22 Sep 2016 11:19:58 -0400 Subject: [PATCH 281/680] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 45bf68f6..50422bdd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Next + - Fixed incorrect :helptags command in README (curran) #619 - Fixed incomplete escaping of folder arrows (adityanatraj) #548 - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 - Replace strchars() with backward compatible workaround. From f640646f2cca72d39344fc48516a4978aca7cbe2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 22 Sep 2016 16:42:17 -0400 Subject: [PATCH 282/680] Change confirmation prompt when deleting non-empty directory. --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 154305bf..dff4027e 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -163,7 +163,7 @@ function! NERDTreeDeleteNode() if currentNode.path.isDirectory && currentNode.getChildCount() > 0 let choice =input("Delete the current node\n" . \ "==========================================================\n" . - \ "STOP! To delete this entire directory, type 'yes'\n" . + \ "STOP! Directory is not empty! To delete, type 'yes'\n" . \ "" . currentNode.path.str() . ": ") let confirmed = choice ==# 'yes' else From 26b40d162cdc7b8ed249f4775bd66525bfdd43c9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 22 Sep 2016 16:56:23 -0400 Subject: [PATCH 283/680] Update CHANGELOG --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 50422bdd..3e92c408 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,10 @@ Next + - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 + - Fix API call to open directory tree in window (devm33) #533 + - Change default arrows to ones available in more Windows fonts (gwilk) #546 + - Update to README - combine cd and git clone (zwhitchcox) #584 + - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 + - Escape filename when moving an open buffer (zacharyvoase) #595 - Fixed incorrect :helptags command in README (curran) #619 - Fixed incomplete escaping of folder arrows (adityanatraj) #548 - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 From af64474ebd604e817e3242a79f23c06a5d48d927 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 23 Sep 2016 16:08:02 -0400 Subject: [PATCH 284/680] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3e92c408..a06c1669 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ Next - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 - Fix API call to open directory tree in window (devm33) #533 - - Change default arrows to ones available in more Windows fonts (gwilk) #546 + - Change default arrows on non-Windows platforms (gwilk) #546 - Update to README - combine cd and git clone (zwhitchcox) #584 - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 - Escape filename when moving an open buffer (zacharyvoase) #595 From 682a7b64db3ef9769532aa208f2ec1b101781011 Mon Sep 17 00:00:00 2001 From: Dan Schaub Date: Mon, 3 Oct 2016 18:04:50 -0400 Subject: [PATCH 285/680] Fix typo in argument usage in promptToRenameBuffer --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index dff4027e..e563a947 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -74,7 +74,7 @@ endfunction function! s:promptToRenameBuffer(bufnum, msg, newFileName) echo a:msg if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' - let quotedFileName = fnameescape(a:newFilename) + let quotedFileName = fnameescape(a:newFileName) " 1. ensure that a new buffer is loaded exec "badd " . quotedFileName " 2. ensure that all windows which display the just deleted filename From 408f7a572c88167b3b99d060f36c4a5f6f6e9b78 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 4 Oct 2016 17:52:12 -0400 Subject: [PATCH 286/680] =?UTF-8?q?Revert=20"changed=20arrows=20for=20NERD?= =?UTF-8?q?TreeDirArrowExpandable=20and=20NERDTreeDirArrowCol=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.markdown | 4 ++-- plugin/NERD_tree.vim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index b25b97ef..de28e05b 100644 --- a/README.markdown +++ b/README.markdown @@ -134,5 +134,5 @@ See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-9259069 Use these variables in your vimrc. Note that below are default arrow symbols - let g:NERDTreeDirArrowExpandable = '►' - let g:NERDTreeDirArrowCollapsible = '▼' + let g:NERDTreeDirArrowExpandable = '▸' + let g:NERDTreeDirArrowCollapsible = '▾' diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a27714f4..451b431b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -68,8 +68,8 @@ call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) if !nerdtree#runningWindows() - call s:initVariable("g:NERDTreeDirArrowExpandable", "►") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "▼") + call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") + call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") else call s:initVariable("g:NERDTreeDirArrowExpandable", "+") call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") From a9a5aec9c05bccc2e43b7b629141f0f1622013a2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 6 Oct 2016 17:51:22 -0400 Subject: [PATCH 287/680] Determine if we're running in Cygwin on Windows. --- autoload/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3ad2a031..90f35882 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -103,7 +103,7 @@ endfunction "FUNCTION: nerdtree#runningWindows(dir) {{{2 function! nerdtree#runningWindows() - return has("win16") || has("win32") || has("win64") + return has("win16") || has("win32") || has("win64") || has("win32unix") endfunction " SECTION: View Functions {{{1 From 4cb97629991fcfe83e35ec4e0e347b71617009ab Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 15:11:27 +0800 Subject: [PATCH 288/680] Update readme, trick to avoid hiding nerdtree after first file open. --- README.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.markdown b/README.markdown index de28e05b..372b28aa 100644 --- a/README.markdown +++ b/README.markdown @@ -100,6 +100,11 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` +Or use the following directives if you prefer using `vim .`: + + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 1 && argv()[0] == '.' && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + --- > How can I open NERDTree on startup, and have my cursor start in the other window? From 1c0d9efe6c10c42815782e6a3609a73a335ec46b Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 15:26:48 +0800 Subject: [PATCH 289/680] Update readme, trick to open NERDTree as a tab window. --- README.markdown | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 372b28aa..a72894a7 100644 --- a/README.markdown +++ b/README.markdown @@ -100,10 +100,14 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` -Or use the following directives if you prefer using `vim .`: + +--- +> How can I open NERDTree as a tab window automatically when vim opens a directory? autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && argv()[0] == '.' && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + +This trick also prevents NERDTree from hiding when first select a file. --- > How can I open NERDTree on startup, and have my cursor start in the other window? From b78fa833730de846c132a7318a00d8fb4fe29581 Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 20:28:33 +0800 Subject: [PATCH 290/680] Fix opening current directory in NERDTree tab. --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index a72894a7..34b9ef14 100644 --- a/README.markdown +++ b/README.markdown @@ -102,10 +102,10 @@ Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree as a tab window automatically when vim opens a directory? +> How can I open NERDTree as a tab window automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif This trick also prevents NERDTree from hiding when first select a file. From a229d8bb610e522b2777ddad9374c4f8afa85fbf Mon Sep 17 00:00:00 2001 From: Ggicci Date: Tue, 11 Oct 2016 00:02:29 +0800 Subject: [PATCH 291/680] Remove a similar tip in README file. --- README.markdown | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 34b9ef14..9fcba09c 100644 --- a/README.markdown +++ b/README.markdown @@ -102,23 +102,13 @@ Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree as a tab window automatically when vim starts up on opening a directory? +> How can I open NERDTree as a window automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif This trick also prevents NERDTree from hiding when first select a file. ---- -> How can I open NERDTree on startup, and have my cursor start in the other window? - -Stick this in your vimrc: - - autocmd vimenter * NERDTree - autocmd vimenter * wincmd p - - *via [stackoverflow/Yohann](http://stackoverflow.com/questions/4277808/nerdtree-auto-focus-to-file-when-opened-in-new-tab/19330023#19330023)* - --- > How can I map a specific key or shortcut to open NERDTree? From 10ac799808bd5a2b919fd300074b50dd36be10f4 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 10 Oct 2016 15:16:00 -0400 Subject: [PATCH 292/680] Update README.markdown Adjusted the wording of one of the tips, and added a sentence about the type of NERDTree window that is displayed. See pull reqest #628. --- README.markdown | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 9fcba09c..4f5133a2 100644 --- a/README.markdown +++ b/README.markdown @@ -100,14 +100,13 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` - --- -> How can I open NERDTree as a window automatically when vim starts up on opening a directory? +> How can I open NERDTree automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif -This trick also prevents NERDTree from hiding when first select a file. +This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. --- > How can I map a specific key or shortcut to open NERDTree? From b9b53d814bea6a2d901f0a263cc1a29df4f5c067 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 10 Oct 2016 15:18:14 -0400 Subject: [PATCH 293/680] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index a06c1669..532969a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Next + - Improved a tip in README.markdown (ggicci) #628 - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 - Fix API call to open directory tree in window (devm33) #533 - Change default arrows on non-Windows platforms (gwilk) #546 From 32186f166032efcc952441370c45dbd4829df8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=93=9C=E7=89=9B?= Date: Thu, 13 Oct 2016 13:38:36 +0800 Subject: [PATCH 294/680] Update NERDTreeOpenable and NERDTreeClosable color It is more comfortable --- syntax/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index efdd9436..e93ca1df 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -72,8 +72,8 @@ hi def link NERDTreeDir Directory hi def link NERDTreeUp Directory hi def link NERDTreeFile Normal hi def link NERDTreeCWD Statement -hi def link NERDTreeOpenable Title -hi def link NERDTreeClosable Title +hi def link NERDTreeOpenable Directory +hi def link NERDTreeClosable Directory hi def link NERDTreeIgnore ignore hi def link NERDTreeRO WarningMsg hi def link NERDTreeBookmark Statement From 334fb0e68797cf56d17db42bf56f39030f226cf8 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 13 Oct 2016 16:10:27 -0400 Subject: [PATCH 295/680] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 532969a4..bbb66c8e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Next + - Change color of arrow (Leeiio) #630 - Improved a tip in README.markdown (ggicci) #628 - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 - Fix API call to open directory tree in window (devm33) #533 From 84e7a77a7eb0be904bedb594ae3a42820c65137e Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 14 Oct 2016 16:34:08 +0100 Subject: [PATCH 296/680] reuse win trees when editing the same dir again If you do ``` :edit some/dir/ ``` then do the same thing at a later point, then the same nerdtree buffer will be loaded/shown the second time. --- autoload/nerdtree.vim | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3ad2a031..bbf60873 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -13,9 +13,33 @@ endfunction "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) - if a:dir != '' && isdirectory(a:dir) - call g:NERDTreeCreator.CreateWindowTree(a:dir) + if !isdirectory(a:dir) + return endif + + if s:reuseWin(a:dir) + return + endif + + call g:NERDTreeCreator.CreateWindowTree(a:dir) +endfunction + +function! s:reuseWin(dir) abort + let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) + + for i in range(1, bufnr("$")) + let nt = getbufvar(i, "NERDTree") + if empty(nt) + continue + endif + + if nt.isWinTree() && nt.root.path.equals(path) + exec "buffer " . i + return 1 + endif + endfor + + return 0 endfunction " FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 From 4477078170628be9cd5e36a57c3cd4e6e3709e6c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 17 Oct 2016 10:05:50 -0400 Subject: [PATCH 297/680] Unlet! the nt variable before letting it. Some will have a "NERDTree" buffer variable and others will not. In the ones that do, getbufvar will return a dictionary. getbufvar will return an empty string from the other buffers. When looping through the buffers, let will throw an error if nt already exists and is a different type than what is trying to be put into it. This easily can be illustrated by these two statements: :let x = "" :let x = {} E706: Variable type mismatch for: x This commit gets rid of the variable before setting it so that the mismatch cannot occur. --- autoload/nerdtree.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index bbf60873..b0eb1033 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -24,10 +24,13 @@ function! nerdtree#checkForBrowse(dir) call g:NERDTreeCreator.CreateWindowTree(a:dir) endfunction +"FUNCTION: s:reuseWin(dir) {{{2 +"finds a NERDTree buffer with root of dir, and opens it. function! s:reuseWin(dir) abort let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) for i in range(1, bufnr("$")) + unlet! nt let nt = getbufvar(i, "NERDTree") if empty(nt) continue From 2027ae03dbaff8fd31832915ae216c0b0d6c24d6 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 19 Oct 2016 13:28:44 +0100 Subject: [PATCH 298/680] remove NERDTree.previousBuf() and related code We were using this when closing a wintree - to go to the previous buffer. Not sure why we weren't just using `:bprev` ... --- autoload/nerdtree/ui_glue.vim | 15 ++++++++------- lib/nerdtree/creator.vim | 3 --- lib/nerdtree/nerdtree.vim | 5 ----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2aa3bece..592d220f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -207,14 +207,15 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 - exec "buffer " . b:NERDTree.previousBuf() + if b:NERDTree.isWinTree() + bp + return + endif + + if winnr("$") > 1 + call g:NERDTree.Close() else - if winnr("$") > 1 - call g:NERDTree.Close() - else - call nerdtree#echo("Cannot close last window") - endif + call nerdtree#echo("Cannot close last window") endif endfunction diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 952811c1..20bd32a8 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -92,14 +92,11 @@ function! s:Creator.createWindowTree(dir) "we want the directory buffer to disappear when we do the :edit below setlocal bufhidden=wipe - let previousBuf = expand("#") - "we need a unique name for each window tree buffer to ensure they are "all independent exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") - let b:NERDTree._previousBuf = bufnr(previousBuf) call self._setCommonBufOptions() call b:NERDTree.render() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 73a30f7a..32897058 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -181,11 +181,6 @@ function! s:NERDTree.PathFilters() return s:NERDTree._PathFilters endfunction -"FUNCTION: s:NERDTree.previousBuf() {{{1 -function! s:NERDTree.previousBuf() - return self._previousBuf -endfunction - "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often function! s:NERDTree.render() From 513bf6455568a1a1e8182ab877df809d125e6421 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Wed, 19 Oct 2016 14:11:40 +0100 Subject: [PATCH 299/680] update changelog --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index bbb66c8e..a23884a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ Next + - Reuse/reopen existing window trees where possible #244 + - Remove NERDTree.previousBuf() - Change color of arrow (Leeiio) #630 - Improved a tip in README.markdown (ggicci) #628 - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 From 48df6bfd6eec34ccf00ad7e01af26864ad75f62f Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 21 Oct 2016 14:40:18 +0100 Subject: [PATCH 300/680] Revert "remove NERDTree.previousBuf() and related code" This reverts commit 2027ae03dbaff8fd31832915ae216c0b0d6c24d6. --- autoload/nerdtree/ui_glue.vim | 15 +++++++-------- lib/nerdtree/creator.vim | 3 +++ lib/nerdtree/nerdtree.vim | 5 +++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 592d220f..2aa3bece 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -207,15 +207,14 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTree.isWinTree() - bp - return - endif - - if winnr("$") > 1 - call g:NERDTree.Close() + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 + exec "buffer " . b:NERDTree.previousBuf() else - call nerdtree#echo("Cannot close last window") + if winnr("$") > 1 + call g:NERDTree.Close() + else + call nerdtree#echo("Cannot close last window") + endif endif endfunction diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 20bd32a8..952811c1 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -92,11 +92,14 @@ function! s:Creator.createWindowTree(dir) "we want the directory buffer to disappear when we do the :edit below setlocal bufhidden=wipe + let previousBuf = expand("#") + "we need a unique name for each window tree buffer to ensure they are "all independent exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") + let b:NERDTree._previousBuf = bufnr(previousBuf) call self._setCommonBufOptions() call b:NERDTree.render() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 32897058..73a30f7a 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -181,6 +181,11 @@ function! s:NERDTree.PathFilters() return s:NERDTree._PathFilters endfunction +"FUNCTION: s:NERDTree.previousBuf() {{{1 +function! s:NERDTree.previousBuf() + return self._previousBuf +endfunction + "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often function! s:NERDTree.render() From eee431dbd44111c858c6d33ffd366cae1f17f8b3 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 21 Oct 2016 14:47:09 +0100 Subject: [PATCH 301/680] really fix the previous buffer issue when closing a tree win So :bprev was failing to jump back to the right buffer. I dont fully understand this yet, but I'm fairly sure this is because there is a magic buffer that we delete when creating a wintree :-/ Anyway, we are explicitly storing the prev buffer again - and updating it when reusing treewins. It's worky, but there may be a superior way... --- autoload/nerdtree.vim | 1 + lib/nerdtree/nerdtree.vim | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b0eb1033..e0d86efa 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -37,6 +37,7 @@ function! s:reuseWin(dir) abort endif if nt.isWinTree() && nt.root.path.equals(path) + call nt.setPreviousBuf(bufnr("#")) exec "buffer " . i return 1 endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 73a30f7a..1404cee0 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -186,6 +186,10 @@ function! s:NERDTree.previousBuf() return self._previousBuf endfunction +function! s:NERDTree.setPreviousBuf(bnum) + let self._previousBuf = a:bnum +endfunction + "FUNCTION: s:NERDTree.render() {{{1 "A convenience function - since this is called often function! s:NERDTree.render() From dee152d08f0deecf012c0ea49a9ff3dd364e239c Mon Sep 17 00:00:00 2001 From: cntoplolicon Date: Fri, 23 Dec 2016 17:51:36 +0800 Subject: [PATCH 302/680] correct NERDTreeIgnore pattern in doc --- doc/NERD_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index d0af4a82..3b7b9504 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -806,7 +806,7 @@ then all files ending in .vim or ~ will be ignored. There are 2 magic flags that can be appended to the end of each regular expression to specify that the regex should match only files or only dirs. These flags are "[[dir]]" and "[[file]]". Example: > - let NERDTreeIgnore=['.d$[[dir]]', '.o$[[file]]'] + let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]'] < This will cause all dirs ending in ".d" to be ignored and all files ending in ".o" to be ignored. From 9c73a19f567d1a6fa1aa3a7084d343ae0b4d7987 Mon Sep 17 00:00:00 2001 From: Alex Geana Date: Thu, 29 Dec 2016 23:11:05 +0100 Subject: [PATCH 303/680] fix bug with files and directories that have dollar sign in name --- lib/nerdtree/path.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 5f3b16ad..26db4a31 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -301,10 +301,10 @@ endfunction "FUNCTION: Path._escChars() {{{1 function! s:Path._escChars() if nerdtree#runningWindows() - return " `\|\"#%&,?()\*^<>" + return " `\|\"#%&,?()\*^<>$" endif - return " \\`\|\"#%&,?()\*^<>[]" + return " \\`\|\"#%&,?()\*^<>[]$" endfunction "FUNCTION: Path.getDir() {{{1 From e671e403dd1ec1da59f70605c73aaedb6cb0e637 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 25 Feb 2017 15:20:25 +0000 Subject: [PATCH 304/680] don't touch @o and @h registers when rendering This just isn't needed, and leaves traces as it turns out: http://stackoverflow.com/questions/42455953/ho-automatically-writes-vim-registers Thanks @romainl --- lib/nerdtree/ui.vim | 176 +++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 91 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index d107814c..65ebfd91 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -20,108 +20,105 @@ endfunction "FUNCTION: s:UI._dumpHelp {{{1 "prints out the quick help function! s:UI._dumpHelp() - let old_h = @h if self.getShowHelp() - let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" - let @h=@h."\" ============================\n" - let @h=@h."\" File node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" - let @h=@h."\" ,\n" + let help = "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" + let help .= "\" ============================\n" + let help .= "\" File node mappings~\n" + let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let help .= "\" ,\n" if self.nerdtree.isTabTree() - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n" else - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open in current window\n" endif if self.nerdtree.isTabTree() - let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" + let help .= "\" ". g:NERDTreeMapPreview .": preview\n" endif - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" - let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Directory node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" - let @h=@h."\" current node recursively\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Bookmark table mappings~\n" - let @h=@h."\" double-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree navigation mappings~\n" - let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Filesystem mappings~\n" - let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" - let @h=@h."\" but leave old root open\n" - let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" - let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" middle-click,\n" + let help .= "\" ". g:NERDTreeMapOpenSplit .": open split\n" + let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Directory node mappings~\n" + let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n" + let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" + let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let help .= "\" current node recursively\n" + let help .= "\" middle-click,\n" + let help .= "\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark table mappings~\n" + let help .= "\" double-click,\n" + let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n" + let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree navigation mappings~\n" + let help .= "\" ". g:NERDTreeMapJumpRoot .": go to root\n" + let help .= "\" ". g:NERDTreeMapJumpParent .": go to parent\n" + let help .= "\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" + let help .= "\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" + let help .= "\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let help .= "\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Filesystem mappings~\n" + let help .= "\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let help .= "\" selected dir\n" + let help .= "\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" + let help .= "\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let help .= "\" but leave old root open\n" + let help .= "\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" + let help .= "\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" + let help .= "\" ". g:NERDTreeMapMenu .": Show menu\n" + let help .= "\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let help .= "\" selected dir\n" + let help .= "\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree filtering mappings~\n" + let help .= "\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" + let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" "add quickhelp entries for each custom key map - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Custom mappings~\n" + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Custom mappings~\n" for i in g:NERDTreeKeyMap.All() if !empty(i.quickhelpText) - let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" + let help .= "\" ". i.key .": ". i.quickhelpText ."\n" endif endfor - 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" - let @h=@h."\" :Bookmark []\n" - let @h=@h."\" :BookmarkToRoot \n" - let @h=@h."\" :RevealBookmark \n" - let @h=@h."\" :OpenBookmark \n" - let @h=@h."\" :ClearBookmarks []\n" - let @h=@h."\" :ClearAllBookmarks\n" - silent! put h + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Other mappings~\n" + let help .= "\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" + let help .= "\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let help .= "\" the NERDTree window\n" + let help .= "\" ". g:NERDTreeMapHelp .": toggle help\n" + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark commands~\n" + let help .= "\" :Bookmark []\n" + let help .= "\" :BookmarkToRoot \n" + let help .= "\" :RevealBookmark \n" + let help .= "\" :OpenBookmark \n" + let help .= "\" :ClearBookmarks []\n" + let help .= "\" :ClearAllBookmarks\n" + silent! put =help elseif !self.isMinimal() - let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" - silent! put h + let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" + silent! put =help endif - - let @h = old_h endfunction @@ -440,10 +437,7 @@ function! s:UI.render() call cursor(line(".")+1, col(".")) "draw the tree - let old_o = @o - let @o = self.nerdtree.root.renderToString() - silent put o - let @o = old_o + silent put =self.nerdtree.root.renderToString() "delete the blank line at the top of the buffer silent 1,1delete _ From bf193320f8e4608dab7cfeab79878d7bc3b4b249 Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Sun, 26 Mar 2017 14:51:09 -0400 Subject: [PATCH 305/680] Fix headers in readme --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 4f5133a2..19b841bc 100644 --- a/README.markdown +++ b/README.markdown @@ -55,14 +55,14 @@ The following features and functionality are provided by the NERD tree: Installation ------------ -####[pathogen.vim](https://github.com/tpope/vim-pathogen) +#### [pathogen.vim](https://github.com/tpope/vim-pathogen) git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`. -####[apt-vim](https://github.com/egalpin/apt-vim) +#### [apt-vim](https://github.com/egalpin/apt-vim) apt-vim install -y https://github.com/scrooloose/nerdtree.git From 97d2d70f6c548ed797b47e4e49c37ab8295fdfd6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 29 Mar 2017 11:27:04 -0400 Subject: [PATCH 306/680] Add an Issue template to ask for more information up front. --- .github/ISSUE_TEMPLATE.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..69aa7d9b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,37 @@ +_To assist in resolving your issue, provide as much information as possible, in place of the ellipses (`…`) below._ + +--- +**Environment:** _Describe your Vim/NERDTree setup._ + +>* Operating System: … +>* Vim version `:version`: … +>* NERDTree version `git rev-parse --short HEAD`: … +>* NERDTree settings applied in your vimrc, if any: +> +> ``` +> … +> ``` + +**Process:** _List the steps that will recreate the issue._ + +>1. … + +**Current Result:** _Describe what you you currently experience from this process._ + +>… + +**Expected Result:** _Describe what you would expect to have resulted from this process._ + +>… + +--- +**Optional** + +**Screenshot(s):** + +>… + +**Possible Fix:** _(Have you poked around in the code?)_ + +>… + From 0caa46685451096201ff949c11fd208bc54c6050 Mon Sep 17 00:00:00 2001 From: Jason Cheatham Date: Fri, 17 Mar 2017 11:53:09 -0400 Subject: [PATCH 307/680] Use relative path with globpath Wildignore rules that involve directories aren't handled properly (or at least as one might expect) when globpath uses absolute paths. For example, when wildignore contains `src/*.js`, `globpath("src", "*")` works as expected, while `globpath("/home/user/project/src", "*")` doesn't. --- lib/nerdtree/tree_dir_node.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index c41077df..8e30a032 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -272,7 +272,9 @@ function! s:TreeDirNode._initChildren(silent) "get an array of all the files in the nodes dir let dir = self.path - let globDir = dir.str({'format': 'Glob'}) + + "use a relative globDir so that relative wildignore rules will be obeyed + let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.') if version >= 703 let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore) @@ -445,7 +447,7 @@ function! s:TreeDirNode.refresh() let newChildNodes = [] let invalidFilesFound = 0 let dir = self.path - let globDir = dir.str({'format': 'Glob'}) + let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.') let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') let files = split(filesStr, "\n") for i in files From 0c0bde3106531cadeabb879ba3061021ba0192a8 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Thu, 18 May 2017 07:02:02 -0700 Subject: [PATCH 308/680] Update stale comments @lifecrisis pointed out this stale comment here: https://github.com/scrooloose/nerdtree/pull/578#issuecomment-302392831 Closes: #640 --- autoload/nerdtree.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 4402b4f4..63fa5c13 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -89,7 +89,9 @@ function! nerdtree#deprecated(func, ...) endfunction " FUNCTION: nerdtree#exec(cmd) {{{2 -" same as :exec cmd but eventignore=all is set for the duration +" Same as :exec cmd but with eventignore set for the duration +" to disable the autocommands used by NERDTree (BufEnter, +" BufLeave and VimEnter) function! nerdtree#exec(cmd) let old_ei = &ei set ei=BufEnter,BufLeave,VimEnter From d99967cadd44517469ec33c506f83fc4345e33da Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 23 May 2017 07:15:35 -0400 Subject: [PATCH 309/680] Revert "Determine if we're running in Cygwin on Windows." --- autoload/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b0275a0b..63fa5c13 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -133,7 +133,7 @@ endfunction "FUNCTION: nerdtree#runningWindows(dir) {{{2 function! nerdtree#runningWindows() - return has("win16") || has("win32") || has("win64") || has("win32unix") + return has("win16") || has("win32") || has("win64") endfunction " SECTION: View Functions {{{1 From 519436ad2047b108573788cb71f77ebdcd3d56d6 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 26 May 2017 08:27:14 -0400 Subject: [PATCH 310/680] Apply consistent spacing before fold markers The trailing fold markers in "bookmark.vim" varied in how far they were from the end of the line. This created an unpleasant visual effect when folding was in use. --- lib/nerdtree/bookmark.vim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 81242605..9ac4d270 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -24,7 +24,7 @@ function! s:Bookmark.AddBookmark(name, path) endif endfunction -" FUNCTION: Bookmark.Bookmarks() {{{1 +" FUNCTION: Bookmark.Bookmarks() {{{1 " Class method to get all bookmarks. Lazily initializes the bookmarks global " variable function! s:Bookmark.Bookmarks() @@ -34,7 +34,7 @@ function! s:Bookmark.Bookmarks() return g:NERDTreeBookmarks endfunction -" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1 +" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1 " class method that returns 1 if a bookmark with the given name is found, 0 " otherwise function! s:Bookmark.BookmarkExistsFor(name) @@ -46,7 +46,7 @@ function! s:Bookmark.BookmarkExistsFor(name) endtry endfunction -" FUNCTION: Bookmark.BookmarkFor(name) {{{1 +" FUNCTION: Bookmark.BookmarkFor(name) {{{1 " Class method to get the bookmark that has the given name. {} is return if no " bookmark is found function! s:Bookmark.BookmarkFor(name) @@ -58,7 +58,7 @@ function! s:Bookmark.BookmarkFor(name) throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' endfunction -" FUNCTION: Bookmark.BookmarkNames() {{{1 +" FUNCTION: Bookmark.BookmarkNames() {{{1 " Class method to return an array of all bookmark names function! s:Bookmark.BookmarkNames() let names = [] @@ -170,7 +170,7 @@ function! s:Bookmark.GetSelected() return {} endfunction -" FUNCTION: Bookmark.InvalidBookmarks() {{{1 +" FUNCTION: Bookmark.InvalidBookmarks() {{{1 " Class method to get all invalid bookmark strings read from the bookmarks " file function! s:Bookmark.InvalidBookmarks() @@ -233,20 +233,20 @@ function! s:Bookmark.openInNewTab(options) call self.open(a:options) endfunction -" FUNCTION: Bookmark.setPath(path) {{{1 +" FUNCTION: Bookmark.setPath(path) {{{1 " makes this bookmark point to the given path function! s:Bookmark.setPath(path) let self.path = a:path endfunction -" FUNCTION: Bookmark.Sort() {{{1 +" FUNCTION: Bookmark.Sort() {{{1 " Class method that sorts all bookmarks function! s:Bookmark.Sort() let CompareFunc = function("nerdtree#compareBookmarks") call sort(s:Bookmark.Bookmarks(), CompareFunc) endfunction -" FUNCTION: Bookmark.str() {{{1 +" FUNCTION: Bookmark.str() {{{1 " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name) @@ -292,7 +292,7 @@ function! s:Bookmark.validate() endif endfunction -" FUNCTION: Bookmark.Write() {{{1 +" FUNCTION: Bookmark.Write() {{{1 " Class method to write all bookmarks to the bookmarks file function! s:Bookmark.Write() let bookmarkStrings = [] From 5aec5ecfef767de0bd1de168509a5aae3cdf8c22 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 26 May 2017 08:48:38 -0400 Subject: [PATCH 311/680] Rename the class method for sorting bookmarks A more intention-revealing name was chosen for the script-local sorting function. The function comment was also rewritten. --- lib/nerdtree/bookmark.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 9ac4d270..9ca8f6f5 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -20,7 +20,7 @@ function! s:Bookmark.AddBookmark(name, path) endfor call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) if g:NERDTreeBookmarksSort ==# 1 - call s:Bookmark.Sort() + call s:Bookmark.SortBookmarksList() endif endfunction @@ -105,7 +105,7 @@ function! s:Bookmark.CacheBookmarks(silent) endif endif if g:NERDTreeBookmarksSort ==# 1 - call s:Bookmark.Sort() + call s:Bookmark.SortBookmarksList() endif endif endfunction @@ -239,9 +239,9 @@ function! s:Bookmark.setPath(path) let self.path = a:path endfunction -" FUNCTION: Bookmark.Sort() {{{1 -" Class method that sorts all bookmarks -function! s:Bookmark.Sort() +" FUNCTION: Bookmark.SortBookmarksList() {{{1 +" Class method that sorts the global list of bookmarks by name. +function! s:Bookmark.SortBookmarksList() let CompareFunc = function("nerdtree#compareBookmarks") call sort(s:Bookmark.Bookmarks(), CompareFunc) endfunction From 0b650891222918011ae7d4f823943a1fa45d5854 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 26 May 2017 13:23:05 -0400 Subject: [PATCH 312/680] Reimplement the bookmark comparison method Sorting the list of user bookmarks requires care to ensure that Vim's builtin sort function is called correctly. Previously, this function was called incorrectly. This is why the sorting of bookmarks never worked. The offending functions have been removed here and replaced with "s:Bookmark.CompareBookmarksByName". To understand the necessity for this change, read ":h sort()" for the requirements of the function reference argument (esp., note that it must return -1, 0, or 1). In addition to fixing this problem, the new comparison function will inspect the "g:NERDTreeBookmarksSort" setting to determine whether case-sensitivity is preferred in the sort. The documentation has been modified to accurately reflect this adjustment. The change is also made in such a way as not to break any existing configurations. Fixes #361 ("My bookmarks aren't sorted"). --- autoload/nerdtree.vim | 5 ----- doc/NERD_tree.txt | 10 +++++++--- lib/nerdtree/bookmark.vim | 35 ++++++++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 63fa5c13..7c5db89d 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -52,11 +52,6 @@ function! nerdtree#completeBookmarks(A,L,P) return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction -"FUNCTION: nerdtree#compareBookmarks(dir) {{{2 -function! nerdtree#compareBookmarks(first, second) - return a:first.compareTo(a:second) -endfunction - "FUNCTION: nerdtree#compareNodes(dir) {{{2 function! nerdtree#compareNodes(n1, n2) return a:n1.path.compareTo(a:n2.path) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 3b7b9504..6cbdc613 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -835,11 +835,15 @@ This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. ------------------------------------------------------------------------------ *'NERDTreeBookmarksSort'* -Values: 0 or 1 +Values: 0, 1, or 2 Default: 1 -If set to 0 then the bookmarks list is not sorted. -If set to 1 the bookmarks list is sorted. +This option controls the method by which the list of user bookmarks is +sorted. When sorted, bookmarks will render in alphabetical order by name. + +If set to 0, the bookmarks list is not sorted. +If set to 1, the bookmarks list is sorted in a case-insensitive manner. +If set to 2, the bookmarks list is sorted in a case-sensitive manner. ------------------------------------------------------------------------------ *'NERDTreeMouseMode'* diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 9ca8f6f5..8bd95fe1 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -19,7 +19,7 @@ function! s:Bookmark.AddBookmark(name, path) endif endfor call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) - if g:NERDTreeBookmarksSort ==# 1 + if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 call s:Bookmark.SortBookmarksList() endif endfunction @@ -104,17 +104,34 @@ function! s:Bookmark.CacheBookmarks(silent) call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") endif endif - if g:NERDTreeBookmarksSort ==# 1 + if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 call s:Bookmark.SortBookmarksList() endif endif endfunction -" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1 -" Compare these two bookmarks for sorting purposes -function! s:Bookmark.compareTo(otherbookmark) - return a:otherbookmark.name < self.name +" FUNCTION: Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) {{{1 +" Class method that indicates the relative position of two bookmarks when +" placed in alphabetical order by name. Case-sensitivity is determined by an +" option. Supports the "s:Bookmark.SortBookmarksList()" method. +function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) + let l:result = 0 + if g:NERDTreeBookmarksSort == 1 + if a:firstBookmark.name ? a:secondBookmark.name + let l:result = 1 + endif + elseif g:NERDTreeBookmarksSort == 2 + if a:firstBookmark.name <# a:secondBookmark.name + let l:result = -1 + elseif a:firstBookmark.name ># a:secondBookmark.name + let l:result = 1 + endif + endif + return l:result endfunction + " FUNCTION: Bookmark.ClearAll() {{{1 " Class method to delete all bookmarks. function! s:Bookmark.ClearAll() @@ -240,10 +257,10 @@ function! s:Bookmark.setPath(path) endfunction " FUNCTION: Bookmark.SortBookmarksList() {{{1 -" Class method that sorts the global list of bookmarks by name. +" Class method that sorts the global list of bookmarks alphabetically by name. +" Note that case-sensitivity is determined by a user option. function! s:Bookmark.SortBookmarksList() - let CompareFunc = function("nerdtree#compareBookmarks") - call sort(s:Bookmark.Bookmarks(), CompareFunc) + call sort(s:Bookmark.Bookmarks(), s:Bookmark.CompareBookmarksByName) endfunction " FUNCTION: Bookmark.str() {{{1 From 2a7a375729dc04bfcbb0411d00839e5349f59193 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 26 May 2017 13:46:09 -0400 Subject: [PATCH 313/680] Remove code duplication from sorting bookmarks It makes the most sense to sort the global bookmarks list just before rendering them in the NERDTree window. Since Vim's sort function is fast and stable, and since users are very unlikely to have a number of bookmarks that is too large, we can sort before rendering without concern for the negligible performance penalty. This has two benefits: 1. Users can change their sort settings and have them take effect on the next render or refresh. 2. As mentioned, code duplication is avoided. --- lib/nerdtree/bookmark.vim | 6 ------ lib/nerdtree/ui.vim | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 8bd95fe1..ad8c3d1d 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -19,9 +19,6 @@ function! s:Bookmark.AddBookmark(name, path) endif endfor call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) - if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 - call s:Bookmark.SortBookmarksList() - endif endfunction " FUNCTION: Bookmark.Bookmarks() {{{1 @@ -104,9 +101,6 @@ function! s:Bookmark.CacheBookmarks(silent) call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") endif endif - if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 - call s:Bookmark.SortBookmarksList() - endif endif endfunction diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 65ebfd91..e169dbbf 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -313,6 +313,10 @@ function! s:UI._renderBookmarks() call cursor(line(".")+1, col(".")) endif + if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 + call g:NERDTreeBookmark.SortBookmarksList() + endif + for i in g:NERDTreeBookmark.Bookmarks() call setline(line(".")+1, i.str()) call cursor(line(".")+1, col(".")) From 3a7293d450ccb3c11960823c01570619d02a3be9 Mon Sep 17 00:00:00 2001 From: asnr Date: Sun, 4 Jun 2017 19:11:46 +1000 Subject: [PATCH 314/680] Update docs with already existing mapping variables --- doc/NERD_tree.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 6cbdc613..d50cfb21 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -282,13 +282,13 @@ previous window. ------------------------------------------------------------------------------ *NERDTree-go* Default key: go -Map option: None +Map option: NERDTreeMapPreview Applies to: files. If a file node is selected, it is opened in the previous window, but the cursor does not move. -The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see +The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). ------------------------------------------------------------------------------ @@ -324,12 +324,12 @@ window. ------------------------------------------------------------------------------ *NERDTree-gi* Default key: gi -Map option: None +Map option: NERDTreeMapPreviewSplit Applies to: files. The same as |NERDTree-i| except that the cursor is not moved. -The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see +The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see |NERDTree-i|). ------------------------------------------------------------------------------ @@ -344,12 +344,12 @@ the new window. ------------------------------------------------------------------------------ *NERDTree-gs* Default key: gs -Map option: None +Map option: NERDTreeMapPreviewVSplit Applies to: files. The same as |NERDTree-s| except that the cursor is not moved. -The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see +The default key combo for this mapping is "g" + NERDTreeMapOpenVSplit (see |NERDTree-s|). ------------------------------------------------------------------------------ From a9ab90198be0581fe961125bba3f282a666ef7ff Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 5 Jun 2017 09:00:31 -0400 Subject: [PATCH 315/680] Update CHANGELOG, giving contributors their due. --- CHANGELOG | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a23884a9..3d377ab2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,13 @@ Next + - Update doc with already existing mapping variables (asnr) #699 + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696 + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648 + - Remove empty segments when splitting path (sooth-sayer) #574 + - Suppress autocmds less agressively (wincent) #578 #691 + - Add an Issues template to ask for more info initially. + - Fix markdown headers in readme (josephfrazier) #676 + - Don't touch @o and @h registers when rendering + - Fix bug with files and directories with dollar signs (alegen) #649 - Reuse/reopen existing window trees where possible #244 - Remove NERDTree.previousBuf() - Change color of arrow (Leeiio) #630 From 81a42acb97deac6b83db464999d77036c5bf42da Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 09:20:52 -0400 Subject: [PATCH 316/680] Refactor the bookmark query function The function in "bookmark.vim" that allows the caller to query the list of Bookmarks by name had stale commentary. In addition, the internals of the function needed to be reworked to improve readability. Making this function very clean is important because it is heavily used elsewhere. As a side note, it might be beneficial to later rename this function to something like "GetBookmarkByName" to further improve readability. That change is not critical and can be safely delayed. --- lib/nerdtree/bookmark.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index ad8c3d1d..9024077a 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -44,15 +44,20 @@ function! s:Bookmark.BookmarkExistsFor(name) endfunction " FUNCTION: Bookmark.BookmarkFor(name) {{{1 -" Class method to get the bookmark that has the given name. {} is return if no -" bookmark is found +" Class method that returns the Bookmark object having the specified name. +" Throws "NERDTree.BookmarkNotFoundError" if no Bookmark is found. function! s:Bookmark.BookmarkFor(name) - for i in s:Bookmark.Bookmarks() - if i.name ==# a:name - return i + let l:result = {} + for l:bookmark in s:Bookmark.Bookmarks() + if l:bookmark.name ==# a:name + let l:result = l:bookmark + break endif endfor - throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' + if empty(l:result) + throw 'NERDTree.BookmarkNotFoundError: "' . a:name . '" not found' + endif + return l:result endfunction " FUNCTION: Bookmark.BookmarkNames() {{{1 From b0f60552eabede5d698cb95fba2b17dbceb6e734 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 09:57:18 -0400 Subject: [PATCH 317/680] Rewrite and expand the header in bookmark.vim The header in "bookmark.vim" was pretty weak. It provided no description of the class it contains and no direction for the reader. In particular it did not note the dual purpose of the "Bookmark" class. The fact that the "Bookmark" class serves two purposes must be noted because many readers will expect class definitions to obey the single responsibility principle! If there is a chance for a major refactor of this class in the future, a priority would be splitting the class in two so that a "BookmarkList" class can assume the responsibility for providing a container for all "Bookmark" objects. --- lib/nerdtree/bookmark.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 9024077a..d56407fd 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -1,5 +1,13 @@ -"CLASS: Bookmark -"============================================================ +" ============================================================================ +" CLASS: Bookmark +" +" The Bookmark class serves two purposes: +" (1) It is the top-level prototype for new, concrete Bookmark objects. +" (2) It provides an interface for client code to query and manipulate the +" global list of Bookmark objects within the current Vim session. +" ============================================================================ + + let s:Bookmark = {} let g:NERDTreeBookmark = s:Bookmark From c0b90811b08b336c4378cff17e0b6af578ae2b18 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 11:02:28 -0400 Subject: [PATCH 318/680] Add an argument sigil in a Bookmark class method A missing argument sigil is effectively a syntax error in VimL. The function in which the error occurred was called in the execution of at least three buffer-local NERDTree commands: 1. :Bookmark (specifically, when trying to overwrite a Bookmark) 2. :OpenBookmark 3. :RevealBookmark Only one specific type of error message associated with these commands is fixed here (see issue #677). The problems with the above commands are not fully addressed by this commit, and their behavior can be improved immensely by further refactoring. However, no one has been able to even use these commands at all before now because the fix given here was not in place. More work will need to be done to improve the behavior of these commands so that they truly function as any reasonable user would expect. Fixes #677. --- lib/nerdtree/bookmark.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index d56407fd..bf95621a 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -172,11 +172,13 @@ function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) endfunction " FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 -" Class method that finds the bookmark with the given name and returns the -" treenode for it. +" Class method that returns the tree node object for the Bookmark with the +" given name. Throws "NERDTree.BookmarkNotFoundError" if a Bookmark with the +" name does not exist. Throws "NERDTree.BookmarkedNodeNotFoundError" if a +" tree node for the named Bookmark could not be found. function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) - let bookmark = s:Bookmark.BookmarkFor(a:name) - return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot) + let l:bookmark = s:Bookmark.BookmarkFor(a:name) + return l:bookmark.getNode(a:nerdtree, a:searchFromAbsoluteRoot) endfunction " FUNCTION: Bookmark.GetSelected() {{{1 From a03a639390011a51358ec3460a3be58d6cd86e8a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 13:29:27 -0400 Subject: [PATCH 319/680] Refactor and re-document Bookmark.getNode() A few minor changes were made to the "Bookmark.getNode()" function for the purposes of improving readability and documentation clarity. This process also led me to the conclusion that the "findNode()" function should be refactored to throw an error if a node cannot be found. This would lead to greater uniformity in the reporting of failures to find a node. It is generally better style to have an error thrown as close to the source as possible. A substantial change like this should wait for now. --- lib/nerdtree/bookmark.vim | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index bf95621a..268664b3 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -157,18 +157,23 @@ function! s:Bookmark.delete() endfunction " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 -" Gets the treenode for this bookmark +" Returns the tree node object associated with this Bookmark. +" Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. " " Args: -" searchFromAbsoluteRoot: specifies whether we should search from the current -" tree root, or the highest cached node +" searchFromAbsoluteRoot: boolean flag, search from the highest cached node +" if true and from the current tree root if false function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) - let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root - let targetNode = searchRoot.findNode(self.path) - if empty(targetNode) - throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name + if a:searchFromAbsoluteRoot + let l:searchRoot = a:nerdtree.root.AbsoluteTreeRoot() + else + let l:searchRoot = a:nerdtree.root + endif + let l:targetNode = l:searchRoot.findNode(self.path) + if empty(l:targetNode) + throw 'NERDTree.BookmarkedNodeNotFoundError: node for bookmark "' . self.name . '" not found' endif - return targetNode + return l:targetNode endfunction " FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 From 3063dfb76631ecadde1b947d21b1422a3c8a53c4 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 15:59:56 -0400 Subject: [PATCH 320/680] Refactor the :OpenBookmark command I altered the behavior of the ":OpenBookmark" command to match that of the "NERDTree-o" mapping. This is acceptable for the following reasons: 1. It was broken, so no one was using it. 2. The name matches its behavior. If a bookmark is to be opened in an explorer window, we should have a command with a matching name for that behavior (":ExploreBookmark", for example). This can be added later if there is enough demand for the feature. Otherwise, this is a perfectly valid change. --- autoload/nerdtree/ui_glue.vim | 20 +++++++++----------- doc/NERD_tree.txt | 11 ++++++----- lib/nerdtree/creator.vim | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2aa3bece..2478fd3f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -441,21 +441,19 @@ function! s:jumpToSibling(currentNode, forward) endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 -" put the cursor on the given bookmark and, if its a file, open it +" Open the Bookmark that has the specified name. This function provides the +" implementation for the ":OpenBookmark" command. function! nerdtree#ui_glue#openBookmark(name) try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) - call targetNode.putCursorHere(0, 1) - redraw! - catch /^NERDTree.BookmarkedNodeNotFoundError/ - call nerdtree#echo("note - target node is not cached") - let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) - let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree) + let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echoError('bookmark "' . a:name . '" not found') + return endtry - if targetNode.path.isDirectory - call targetNode.openExplorer() + if l:bookmark.path.isDirectory + call l:bookmark.open(b:NERDTree) else - call targetNode.open({'where': 'p'}) + call l:bookmark.open(b:NERDTree, {'where': 'p'}) endif endfunction diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index d50cfb21..e9766152 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -158,7 +158,7 @@ click bookmarks or use the |NERDTree-o| mapping to activate them. See also, ------------------------------------------------------------------------------ 2.2.2. Bookmark commands *NERDTreeBookmarkCommands* -Note that the following commands are only available in the NERD tree buffer. +Note: The following commands are only available within the NERDTree buffer. :Bookmark [] Bookmark the current node as . If there is already a @@ -178,10 +178,11 @@ Note that the following commands are only available in the NERD tree buffer. (i.e. directory nodes above it will be opened) and the cursor will be placed on it. -:OpenBookmark - must point to a file. The file is opened as though |NERDTree-o| - was applied. If the node is cached under the current root then it will be - revealed and the cursor will be placed on it. +:OpenBookmark + The Bookmark named is opened as if |NERDTree-o| was applied to + its entry in the Bookmark table. If the Bookmark points to a directory, + it is made the new root of the current NERDTree. If the Bookmark points + to a file, that file is opened for editing in another window. :ClearBookmarks [] Remove all the given bookmarks. If no bookmarks are given then remove all diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 952811c1..92e1abeb 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -14,7 +14,7 @@ function! s:Creator._bindMappings() command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark call nerdtree#ui_glue#openBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() From 471a03c9d91615f58f26206d284c57f58b0a1376 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 10 Jun 2017 17:07:57 -0400 Subject: [PATCH 321/680] Implement the g:NERDTreeMarkBookmarks setting The setting is self-explanatory. See the added documentation for further details. --- doc/NERD_tree.txt | 9 +++++++++ lib/nerdtree/path.vim | 2 +- plugin/NERD_tree.vim | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index d50cfb21..cc040d17 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -845,6 +845,15 @@ If set to 0, the bookmarks list is not sorted. If set to 1, the bookmarks list is sorted in a case-insensitive manner. If set to 2, the bookmarks list is sorted in a case-sensitive manner. +------------------------------------------------------------------------------ + *'NERDTreeMarkBookmarks'* +Values: 0 or 1 +Default: 1 + +If set to 1, Bookmarks will be specially marked whenever the NERDTree is +rendered. Users of the |'NERDTreeMinimalUI'| setting may prefer to disable +this setting for even less visual clutter. + ------------------------------------------------------------------------------ *'NERDTreeMouseMode'* Values: 1, 2 or 3. diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 6f48a188..805e4a6a 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -52,7 +52,7 @@ function! s:Path.cacheDisplayString() abort call add(self._bookmarkNames, i.name) endif endfor - if !empty(self._bookmarkNames) + if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' endif diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 451b431b..5960d0ba 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -57,6 +57,7 @@ call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBook call s:initVariable("g:NERDTreeBookmarksSort", 1) call s:initVariable("g:NERDTreeHighlightCursorline", 1) call s:initVariable("g:NERDTreeHijackNetrw", 1) +call s:initVariable('g:NERDTreeMarkBookmarks', 1) call s:initVariable("g:NERDTreeMouseMode", 1) call s:initVariable("g:NERDTreeNotificationThreshold", 100) call s:initVariable("g:NERDTreeQuitOnOpen", 0) From 9b3487db64c6888c6f03ebadc45084ec339b64e3 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 11 Jun 2017 09:47:50 -0400 Subject: [PATCH 322/680] Update the option summary It came to my attention that the option summary has been neglected for the past few commits. I added the new option in this feature branch and updated the descriptions of two nearby options. This section could use some focused editing. --- doc/NERD_tree.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index cc040d17..3b9f6280 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -637,11 +637,11 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeBookmarksFile'| Where the bookmarks are stored. -|'NERDTreeBookmarksSort'| Whether the bookmarks list is sorted on - display. +|'NERDTreeBookmarksSort'| Control how the Bookmark table is sorted. -|'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse - clicks. +|'NERDTreeMarkBookmarks'| Render bookmarked nodes with markers. + +|'NERDTreeMouseMode'| Manage the interpretation of mouse clicks. |'NERDTreeQuitOnOpen'| Closes the tree window after opening a file. From 5f3a44d066a1ab356cc12476ac9f4d271d72645a Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Fri, 16 Jun 2017 08:50:21 -0400 Subject: [PATCH 323/680] Document the :NERDTreeFocus command. Closes #706. --- doc/NERD_tree.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 1cc7b41d..ed4adc37 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -117,6 +117,10 @@ The following features and functionality are provided by the NERD tree: again. If no NERD tree exists for this tab then this command acts the same as the |:NERDTree| command. +:NERDTreeFocus *:NERDTreeFocus* + Opens (or reopens) the NERD Tree if it is not currently visible; + otherwise, the cursor is moved to the already-open NERD Tree. + :NERDTreeMirror *:NERDTreeMirror* Shares an existing NERD tree, from another tab, in the current tab. Changes made to one tree are reflected in both as they are actually the From 1d83e4c1ceb3ea07a906b17baa48d6d83963590c Mon Sep 17 00:00:00 2001 From: Jason Cheatham Date: Sat, 17 Jun 2017 22:04:06 -0400 Subject: [PATCH 324/680] Handle non-relative globDir properly in Windows In Windows, fnamemodify with ':.' will strip the drive letter from a path that isn't under CWD. This update ensures such a path has the drive letter. references #709 --- lib/nerdtree/tree_dir_node.vim | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 8e30a032..aaa8d339 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -206,6 +206,25 @@ function! s:TreeDirNode.getDirChildren() return filter(self.children, 'v:val.path.isDirectory == 1') endfunction +"FUNCTION: TreeDirNode._getGlobDir() {{{1 +"Return a string giving the pathname related to this TreeDirNode. The returned +"pathname is in a glob-friendly format and is relative to the current working +"directory, if this TreeDirNode's path is under the current working directory. +function! s:TreeDirNode._getGlobDir() + " Gets a relative path, if possible. This ensures that 'wildignore' rules + " for relative paths will be obeyed. + let l:globDir = fnamemodify(self.path.str({'format': 'Glob'}), ':.') + + " Calling fnamemodify() with ':.' on Windows systems strips the leading + " drive letter from paths that aren't under the working directory. Here, + " the drive letter is added back to the pathname. + if nerdtree#runningWindows() && l:globDir[0] == '\' + let l:globDir = self.path.drive . l:globDir + endif + + return l:globDir +endfunction + "FUNCTION: TreeDirNode.GetSelected() {{{1 "Returns the current node if it is a dir node, or else returns the current "nodes parent @@ -271,10 +290,7 @@ function! s:TreeDirNode._initChildren(silent) let self.children = [] "get an array of all the files in the nodes dir - let dir = self.path - - "use a relative globDir so that relative wildignore rules will be obeyed - let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.') + let globDir = self._getGlobDir() if version >= 703 let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore) @@ -446,8 +462,7 @@ function! s:TreeDirNode.refresh() "go thru all the files/dirs under this node let newChildNodes = [] let invalidFilesFound = 0 - let dir = self.path - let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.') + let globDir = self._getGlobDir() let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') let files = split(filesStr, "\n") for i in files From c934b50c0d59b98ec5424b171575e46d7b230e2a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 19 Jun 2017 17:28:41 -0400 Subject: [PATCH 325/680] Repair the broken middle mouse click handler Issues #597, #642, and #650 all report problems with the NERDTree handler function for middle mouse clicks. In all cases, the problems arose from the use of a function that didn't exist and from the use of a bad argument in the call to the "g:NERDTreeAddKeyMap" function. The fix for the first problem is obvious, but the solution to the second bug merits explanation. Previously, middle click events in the NERDTree window were triggered with the "" Vim key code. Since "" is always triggered before "", The error in #642 was bound to occur (because of the default behavior for middle mouse clicks). Thus, the problem was easily solved by using "" instead of "" in the mapping. As an enhancement, I added the trigger of a "" event as the first command in the handler function. This will cause the middle click to reposition the cursor below the pointer before continuing with its normal behavior. The benefits of this are clear. This mapping has no defined behavior for bookmarks. Unless an issue is raised to address this, it will be left just so for now. Fixes #597, fixes #642, and fixes #650. --- autoload/nerdtree/ui_glue.vim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2478fd3f..90ce872c 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -7,7 +7,7 @@ let g:loaded_nerdtree_ui_glue_autoload = 1 function! nerdtree#ui_glue#createDefaultBindings() let s = '' . s:SID() . '_' - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleMiddleMouse" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s . 'handleMiddleMouse' }) call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) @@ -336,16 +336,22 @@ endfunction " FUNCTION: s:handleMiddleMouse() {{{1 function! s:handleMiddleMouse() - let curNode = g:NERDTreeFileNode.GetSelected() - if curNode ==# {} - call nerdtree#echo("Put the cursor on a node first" ) + + " A middle mouse click does not automatically position the cursor as one + " would expect. Forcing the execution of a regular left mouse click here + " fixes this problem. + execute "normal! \" + + let l:currentNode = g:NERDTreeFileNode.GetSelected() + if empty(l:currentNode) + call nerdtree#echoError('use the pointer to select a node') return endif - if curNode.path.isDirectory - call nerdtree#openExplorer(curNode) + if l:currentNode.path.isDirectory + call l:currentNode.openExplorer() else - call curNode.open({'where': 'h'}) + call l:currentNode.open({'where': 'h'}) endif endfunction From 4a487474c493a9fb6207804347d3bf0712e21931 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 22 Jun 2017 17:15:51 -0400 Subject: [PATCH 326/680] Modify call to sort() for older versions of Vim (#714) Older Vim versions seem to require that calls to sort() specify a dictionary when the compare function argument is a dictionary function. This seems to be required even when the dictionary is not used. Since this change does not seem to affect behavior in later Vim editions, I see no harm in including it. --- lib/nerdtree/bookmark.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 268664b3..f8606ee6 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -274,7 +274,7 @@ endfunction " Class method that sorts the global list of bookmarks alphabetically by name. " Note that case-sensitivity is determined by a user option. function! s:Bookmark.SortBookmarksList() - call sort(s:Bookmark.Bookmarks(), s:Bookmark.CompareBookmarksByName) + call sort(s:Bookmark.Bookmarks(), s:Bookmark.CompareBookmarksByName, s:Bookmark) endfunction " FUNCTION: Bookmark.str() {{{1 From b0c44c7be1a094dc6b9e8e93bd5c4325ab99ad04 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 24 Jun 2017 10:44:28 -0400 Subject: [PATCH 327/680] Refactor the TreeDirNode glob method Pull request #710 correctly noted that TreeDirNode directories must be passed to "globpath()" as relative paths (i.e., to the working directory) if 'wildignore' rules for relative paths are to be obeyed. The solution was to use "fnamemodify()" to get a relative path to the TreeDirNode object's directory, if possible. However, this method does not modify our TreeDirNode path if it IS the current working directory. Thus, immediate children of the node are seen as absolute paths in glob results when our PWD is pointing to their parent. This is not consistent behavior. This commit defines the result of this function as ',' when this special case arises to fix this problem. See ":h 'path'" for an explanation of how this works. --- lib/nerdtree/tree_dir_node.vim | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index aaa8d339..1ae944e6 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -206,23 +206,27 @@ function! s:TreeDirNode.getDirChildren() return filter(self.children, 'v:val.path.isDirectory == 1') endfunction -"FUNCTION: TreeDirNode._getGlobDir() {{{1 -"Return a string giving the pathname related to this TreeDirNode. The returned -"pathname is in a glob-friendly format and is relative to the current working -"directory, if this TreeDirNode's path is under the current working directory. +" FUNCTION: TreeDirNode._getGlobDir() {{{1 +" Return a path specification for this TreeDirNode that is suitable as an +" argument to "globpath()". +" +" Note: The result is constructed such that "globpath()" will return paths +" relative to the working directory, if possible. This is necessary to ensure +" that 'wildignore' rules for relative paths are obeyed. function! s:TreeDirNode._getGlobDir() - " Gets a relative path, if possible. This ensures that 'wildignore' rules - " for relative paths will be obeyed. - let l:globDir = fnamemodify(self.path.str({'format': 'Glob'}), ':.') - - " Calling fnamemodify() with ':.' on Windows systems strips the leading - " drive letter from paths that aren't under the working directory. Here, - " the drive letter is added back to the pathname. - if nerdtree#runningWindows() && l:globDir[0] == '\' - let l:globDir = self.path.drive . l:globDir + + if self.path.str() == getcwd() + let l:pathSpec = ',' + else + let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.') + + " On Windows, the drive letter may be removed by "fnamemodify()". + if nerdtree#runningWindows() && l:pathSpec[0] == '\' + let l:pathSpec = self.path.drive . l:pathSpec + endif endif - return l:globDir + return l:pathSpec endfunction "FUNCTION: TreeDirNode.GetSelected() {{{1 From b877fc65d80421fe44bb719e53c7806186337293 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 24 Jun 2017 14:09:21 -0400 Subject: [PATCH 328/680] Rename and expand the TreeDirNode glob method Pull request #710 also brought to my attention some glaring code duplication in the TreeDirNode class. This commit renames and expands the glob method defined in PR #710 into a more general purpose helper method. The new method also ensures that 'wildignore' rules are applied consistently. Issue #569 noted that the application of the 'wildignore' setting in populating a node's children was unpredictable. When a node was rendered, "_initChildren()" would load the children with its own call to "globpath()". Refreshing the same node would then invoke "globpath()" again, but with different arguments. The result was that a node's children were initialized using the 'g:NERDTreeRespectWildIgnore' setting, but refreshing ignored this setting. So, if it the setting was 0, "test.class" might render when the parent was initialized, and then be removed on refresh (if 'wildignore' contained '*.class'). This commit solves this problem by ensuring that the NERDTree setting mentioned above is only checked and applied to a node's children in one place by cleaning up the duplication. Fixes #569. --- lib/nerdtree/tree_dir_node.vim | 152 ++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 68 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 1ae944e6..0686ddb8 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -206,15 +206,23 @@ function! s:TreeDirNode.getDirChildren() return filter(self.children, 'v:val.path.isDirectory == 1') endfunction -" FUNCTION: TreeDirNode._getGlobDir() {{{1 -" Return a path specification for this TreeDirNode that is suitable as an -" argument to "globpath()". +" FUNCTION: TreeDirNode._glob(pattern, all) {{{1 +" Return a list of strings naming the descendants of the directory in this +" TreeDirNode object that match the specified glob pattern. " -" Note: The result is constructed such that "globpath()" will return paths -" relative to the working directory, if possible. This is necessary to ensure -" that 'wildignore' rules for relative paths are obeyed. -function! s:TreeDirNode._getGlobDir() - +" Args: +" pattern: (string) the glob pattern to apply +" all: (0 or 1) if 1, include "." and ".." if they match "pattern"; if 0, +" always exclude them +" +" Note: If the pathnames in the result list are below the working directory, +" they are returned as pathnames relative to that directory. This is because +" this function, internally, attempts to obey 'wildignore' rules that use +" relative paths. +function! s:TreeDirNode._glob(pattern, all) + + " Construct a path specification such that "globpath()" will return + " relative pathnames, if possible. if self.path.str() == getcwd() let l:pathSpec = ',' else @@ -226,7 +234,48 @@ function! s:TreeDirNode._getGlobDir() endif endif - return l:pathSpec + let l:globList = [] + + " See ":h version7.txt" for the details of the progression of the "glob()" + " and "globpath()" functions. + if v:version >= 704 + let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) + elseif v:version >= 703 + let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) + let l:globList = split(l:globString, "\n") + else + let l:globString = globpath(l:pathSpec, a:pattern) + let l:globList = split(l:globString, "\n") + endif + + " If "a:all" is false, filter "." and ".." from the output. + if !a:all + + let l:toRemove = [] + + for l:file in l:globList + let l:tail = fnamemodify(l:file, ':t') + + " Double the modifier if only a separator was stripped. + if l:tail == '' + let l:tail = fnamemodify(l:file, ':t:t') + endif + + if l:tail == '.' || l:tail == '..' + call add(l:toRemove, l:file) + if len(l:toRemove) == 2 + break + endif + endif + endfor + + if !empty(l:toRemove) + call remove(l:globList, index(l:globList, l:toRemove[0])) + call remove(l:globList, index(l:globList, l:toRemove[1])) + endif + endif + + return l:globList endfunction "FUNCTION: TreeDirNode.GetSelected() {{{1 @@ -293,16 +342,7 @@ function! s:TreeDirNode._initChildren(silent) "remove all the current child nodes let self.children = [] - "get an array of all the files in the nodes dir - let globDir = self._getGlobDir() - - if version >= 703 - let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore) - else - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - endif - - let files = split(filesStr, "\n") + let files = self._glob('*', 1) + self._glob('.*', 0) if !a:silent && len(files) > g:NERDTreeNotificationThreshold call nerdtree#echo("Please wait, caching a large dir ...") @@ -310,21 +350,13 @@ function! s:TreeDirNode._initChildren(silent) let invalidFilesFound = 0 for i in files - - "filter out the .. and . directories - "Note: we must match .. AND ../ since sometimes the globpath returns - "../ for path with strange chars (eg $) - if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && - \ i[len(i)-2:1] != "." && i[len(i)-1] != "." - "put the next file in a new node and attach it - try - let path = g:NERDTreePath.New(i) - call self.createChild(path, 0) - call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) - catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound += 1 - endtry - endif + try + let path = g:NERDTreePath.New(i) + call self.createChild(path, 0) + call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound += 1 + endtry endfor call self.sortChildren() @@ -457,48 +489,32 @@ function! s:TreeDirNode._openRecursively2(forceOpen) endfunction "FUNCTION: TreeDirNode.refresh() {{{1 -unlet s:TreeDirNode.refresh function! s:TreeDirNode.refresh() call self.path.refresh(self.getNerdtree()) "if this node was ever opened, refresh its children if self.isOpen || !empty(self.children) - "go thru all the files/dirs under this node + let files = self._glob('*', 1) + self._glob('.*', 0) let newChildNodes = [] let invalidFilesFound = 0 - let globDir = self._getGlobDir() - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - let files = split(filesStr, "\n") for i in files - "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns - "../ for path with strange chars (eg $) - "if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$' - - " Regular expression is too expensive. Use simply string comparison - " instead - if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && - \ i[len(i)-2:1] != "." && i[len(i)-1] != "." - try - "create a new path and see if it exists in this nodes children - let path = g:NERDTreePath.New(i) - let newNode = self.getChild(path) - if newNode != {} - call newNode.refresh() - call add(newChildNodes, newNode) - - "the node doesnt exist so create it - else - let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree()) - let newNode.parent = self - call add(newChildNodes, newNode) - endif - - - catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound = 1 - endtry - endif + try + "create a new path and see if it exists in this nodes children + let path = g:NERDTreePath.New(i) + let newNode = self.getChild(path) + if newNode != {} + call newNode.refresh() + call add(newChildNodes, newNode) + + "the node doesnt exist so create it + else + let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree()) + let newNode.parent = self + call add(newChildNodes, newNode) + endif + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound = 1 + endtry endfor "swap this nodes children out for the children we just read/refreshed From 2a97fb0fdaac05096a92d3dba35a05f5694298f6 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 24 Jun 2017 16:05:55 -0400 Subject: [PATCH 329/680] Reformat the commentary in the TreeDirNode script The commentary in "tree_dir_node.vim" needed to be cleaned up a little. Spaces after leading quotes are a good idea, to avoid the "clustered" appearance that comments can sometimes have. Use the following substitution command... :s/^"\ze\S/" / to make this change to longer scripts. --- lib/nerdtree/tree_dir_node.vim | 247 +++++++++++++++++---------------- 1 file changed, 124 insertions(+), 123 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 0686ddb8..feee7720 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -1,13 +1,17 @@ -"CLASS: TreeDirNode -"A subclass of NERDTreeFileNode. +" ============================================================================ +" CLASS: TreeDirNode " -"The 'composite' part of the file/dir composite. -"============================================================ +" A subclass of NERDTreeFileNode. +" +" The 'composite' part of the file/dir composite. +" ============================================================================ + + let s:TreeDirNode = copy(g:NERDTreeFileNode) let g:NERDTreeDirNode = s:TreeDirNode -"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1 -"class method that returns the highest cached ancestor of the current root +" FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1 +" Class method that returns the highest cached ancestor of the current root. function! s:TreeDirNode.AbsoluteTreeRoot() let currentNode = b:NERDTree.root while currentNode.parent != {} @@ -16,7 +20,7 @@ function! s:TreeDirNode.AbsoluteTreeRoot() return currentNode endfunction -"FUNCTION: TreeDirNode.activate([options]) {{{1 +" FUNCTION: TreeDirNode.activate([options]) {{{1 unlet s:TreeDirNode.activate function! s:TreeDirNode.activate(...) let opts = a:0 ? a:1 : {} @@ -25,12 +29,12 @@ function! s:TreeDirNode.activate(...) call self.putCursorHere(0, 0) endfunction -"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1 -"Adds the given treenode to the list of children for this node +" FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1 +" Adds the given treenode to the list of children for this node " -"Args: -"-treenode: the node to add -"-inOrder: 1 if the new node should be inserted in sorted order +" Args: +" -treenode: the node to add +" -inOrder: 1 if the new node should be inserted in sorted order function! s:TreeDirNode.addChild(treenode, inOrder) call add(self.children, a:treenode) let a:treenode.parent = self @@ -40,14 +44,14 @@ function! s:TreeDirNode.addChild(treenode, inOrder) endif endfunction -"FUNCTION: TreeDirNode.close() {{{1 -"Closes this directory +" FUNCTION: TreeDirNode.close() {{{1 +" Closes this directory function! s:TreeDirNode.close() let self.isOpen = 0 endfunction -"FUNCTION: TreeDirNode.closeChildren() {{{1 -"Closes all the child dir nodes of this node +" FUNCTION: TreeDirNode.closeChildren() {{{1 +" Closes all the child dir nodes of this node function! s:TreeDirNode.closeChildren() for i in self.children if i.path.isDirectory @@ -57,23 +61,23 @@ function! s:TreeDirNode.closeChildren() endfor endfunction -"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1 -"Instantiates a new child node for this node with the given path. The new -"nodes parent is set to this node. +" FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1 +" Instantiates a new child node for this node with the given path. The new +" nodes parent is set to this node. " -"Args: -"path: a Path object that this node will represent/contain -"inOrder: 1 if the new node should be inserted in sorted order +" Args: +" path: a Path object that this node will represent/contain +" inOrder: 1 if the new node should be inserted in sorted order " -"Returns: -"the newly created node +" Returns: +" the newly created node function! s:TreeDirNode.createChild(path, inOrder) let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree()) call self.addChild(newTreeNode, a:inOrder) return newTreeNode endfunction -"FUNCTION: TreeDirNode.displayString() {{{1 +" FUNCTION: TreeDirNode.displayString() {{{1 unlet s:TreeDirNode.displayString function! s:TreeDirNode.displayString() let cascade = self.getCascade() @@ -89,11 +93,11 @@ function! s:TreeDirNode.displayString() return sym . ' ' . flags . rv endfunction -"FUNCTION: TreeDirNode.findNode(path) {{{1 -"Will find one of the children (recursively) that has the given path +" FUNCTION: TreeDirNode.findNode(path) {{{1 +" Will find one of the children (recursively) that has the given path " -"Args: -"path: a path object +" Args: +" path: a path object unlet s:TreeDirNode.findNode function! s:TreeDirNode.findNode(path) if a:path.equals(self.path) @@ -114,8 +118,8 @@ function! s:TreeDirNode.findNode(path) return {} endfunction -"FUNCTION: TreeDirNode.getCascade() {{{1 -"Return an array of dir nodes (starting from self) that can be cascade opened. +" FUNCTION: TreeDirNode.getCascade() {{{1 +" Return an array of dir nodes (starting from self) that can be cascade opened. function! s:TreeDirNode.getCascade() if !self.isCascadable() return [self] @@ -127,20 +131,20 @@ function! s:TreeDirNode.getCascade() return [self] + visChild.getCascade() endfunction -"FUNCTION: TreeDirNode.getChildCount() {{{1 -"Returns the number of children this node has +" FUNCTION: TreeDirNode.getChildCount() {{{1 +" Returns the number of children this node has function! s:TreeDirNode.getChildCount() return len(self.children) endfunction -"FUNCTION: TreeDirNode.getChild(path) {{{1 -"Returns child node of this node that has the given path or {} if no such node -"exists. +" FUNCTION: TreeDirNode.getChild(path) {{{1 +" Returns child node of this node that has the given path or {} if no such node +" exists. " -"This function doesnt not recurse into child dir nodes +" This function doesnt not recurse into child dir nodes " -"Args: -"path: a path object +" Args: +" path: a path object function! s:TreeDirNode.getChild(path) if stridx(a:path.str(), self.path.str(), 0) ==# -1 return {} @@ -155,12 +159,13 @@ function! s:TreeDirNode.getChild(path) endfunction -"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1 -"returns the child at the given index -"Args: -"indx: the index to get the child from -"visible: 1 if only the visible children array should be used, 0 if all the -"children should be searched. +" FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1 +" returns the child at the given index +" +" Args: +" indx: the index to get the child from +" visible: 1 if only the visible children array should be used, 0 if all the +" children should be searched. function! s:TreeDirNode.getChildByIndex(indx, visible) let array_to_search = a:visible? self.getVisibleChildren() : self.children if a:indx > len(array_to_search) @@ -169,14 +174,14 @@ function! s:TreeDirNode.getChildByIndex(indx, visible) return array_to_search[a:indx] endfunction -"FUNCTION: TreeDirNode.getChildIndex(path) {{{1 -"Returns the index of the child node of this node that has the given path or -"-1 if no such node exists. +" FUNCTION: TreeDirNode.getChildIndex(path) {{{1 +" Returns the index of the child node of this node that has the given path or +" -1 if no such node exists. " -"This function doesnt not recurse into child dir nodes +" This function doesnt not recurse into child dir nodes " -"Args: -"path: a path object +" Args: +" path: a path object function! s:TreeDirNode.getChildIndex(path) if stridx(a:path.str(), self.path.str(), 0) ==# -1 return -1 @@ -200,8 +205,9 @@ function! s:TreeDirNode.getChildIndex(path) return -1 endfunction -"FUNCTION: TreeDirNode.getDirChildren() {{{1 -"Get all children that are directories +" FUNCTION: TreeDirNode.getDirChildren() {{{1 +" Return a list of all child nodes from "self.children" that are of type +" TreeDirNode. function! s:TreeDirNode.getDirChildren() return filter(self.children, 'v:val.path.isDirectory == 1') endfunction @@ -278,9 +284,9 @@ function! s:TreeDirNode._glob(pattern, all) return l:globList endfunction -"FUNCTION: TreeDirNode.GetSelected() {{{1 -"Returns the current node if it is a dir node, or else returns the current -"nodes parent +" FUNCTION: TreeDirNode.GetSelected() {{{1 +" Returns the current node if it is a dir node, or else returns the current +" nodes parent unlet s:TreeDirNode.GetSelected function! s:TreeDirNode.GetSelected() let currentDir = g:NERDTreeFileNode.GetSelected() @@ -292,17 +298,17 @@ function! s:TreeDirNode.GetSelected() return currentDir endfunction -"FUNCTION: TreeDirNode.getVisibleChildCount() {{{1 -"Returns the number of visible children this node has +" FUNCTION: TreeDirNode.getVisibleChildCount() {{{1 +" Returns the number of visible children this node has function! s:TreeDirNode.getVisibleChildCount() return len(self.getVisibleChildren()) endfunction -"FUNCTION: TreeDirNode.getVisibleChildren() {{{1 -"Returns a list of children to display for this node, in the correct order +" FUNCTION: TreeDirNode.getVisibleChildren() {{{1 +" Returns a list of children to display for this node, in the correct order " -"Return: -"an array of treenodes +" Return: +" an array of treenodes function! s:TreeDirNode.getVisibleChildren() let toReturn = [] for i in self.children @@ -313,14 +319,14 @@ function! s:TreeDirNode.getVisibleChildren() return toReturn endfunction -"FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 -"returns 1 if this node has any childre, 0 otherwise.. +" FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 +" returns 1 if this node has any childre, 0 otherwise.. function! s:TreeDirNode.hasVisibleChildren() return self.getVisibleChildCount() != 0 endfunction -"FUNCTION: TreeDirNode.isCascadable() {{{1 -"true if this dir has only one visible child - which is also a dir +" FUNCTION: TreeDirNode.isCascadable() {{{1 +" true if this dir has only one visible child - which is also a dir function! s:TreeDirNode.isCascadable() if g:NERDTreeCascadeSingleChildDir == 0 return 0 @@ -330,14 +336,14 @@ function! s:TreeDirNode.isCascadable() return len(c) == 1 && c[0].path.isDirectory endfunction -"FUNCTION: TreeDirNode._initChildren() {{{1 -"Removes all childen from this node and re-reads them +" FUNCTION: TreeDirNode._initChildren() {{{1 +" Removes all childen from this node and re-reads them " -"Args: -"silent: 1 if the function should not echo any "please wait" messages for -"large directories +" Args: +" silent: 1 if the function should not echo any "please wait" messages for +" large directories " -"Return: the number of child nodes read +" Return: the number of child nodes read function! s:TreeDirNode._initChildren(silent) "remove all the current child nodes let self.children = [] @@ -371,12 +377,12 @@ function! s:TreeDirNode._initChildren(silent) return self.getChildCount() endfunction -"FUNCTION: TreeDirNode.New(path, nerdtree) {{{1 -"Returns a new TreeNode object with the given path and parent +" FUNCTION: TreeDirNode.New(path, nerdtree) {{{1 +" Return a new TreeDirNode object with the given path and parent. " -"Args: -"path: dir that the node represents -"nerdtree: the tree the node belongs to +" Args: +" path: dir that the node represents +" nerdtree: the tree the node belongs to function! s:TreeDirNode.New(path, nerdtree) if a:path.isDirectory != 1 throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." @@ -394,10 +400,10 @@ function! s:TreeDirNode.New(path, nerdtree) return newTreeNode endfunction -"FUNCTION: TreeDirNode.open([opts]) {{{1 -"Open the dir in the current tree or in a new tree elsewhere. +" FUNCTION: TreeDirNode.open([opts]) {{{1 +" Open the dir in the current tree or in a new tree elsewhere. " -"If opening in the current tree, return the number of cached nodes. +" If opening in the current tree, return the number of cached nodes. unlet s:TreeDirNode.open function! s:TreeDirNode.open(...) let opts = a:0 ? a:1 : {} @@ -415,10 +421,10 @@ function! s:TreeDirNode.open(...) endif endfunction -"FUNCTION: TreeDirNode.openAlong([opts]) {{{1 -"recursive open the dir if it has only one directory child. +" FUNCTION: TreeDirNode.openAlong([opts]) {{{1 +" recursive open the dir if it has only one directory child. " -"return the level of opened directories. +" return the level of opened directories. function! s:TreeDirNode.openAlong(...) let opts = a:0 ? a:1 : {} let level = 0 @@ -437,42 +443,42 @@ function! s:TreeDirNode.openAlong(...) endfunction " FUNCTION: TreeDirNode.openExplorer() {{{1 -" opens an explorer window for this node in the previous window (could be a -" nerd tree or a netrw) +" Open an explorer window for this node in the previous window. The explorer +" can be a NERDTree window or a netrw window. function! s:TreeDirNode.openExplorer() call self.open({'where': 'p'}) endfunction -"FUNCTION: TreeDirNode.openInNewTab(options) {{{1 +" FUNCTION: TreeDirNode.openInNewTab(options) {{{1 unlet s:TreeDirNode.openInNewTab function! s:TreeDirNode.openInNewTab(options) call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') call self.open({'where': 't'}) endfunction -"FUNCTION: TreeDirNode._openInNewTab() {{{1 +" FUNCTION: TreeDirNode._openInNewTab() {{{1 function! s:TreeDirNode._openInNewTab() tabnew call g:NERDTreeCreator.CreateTabTree(self.path.str()) endfunction -"FUNCTION: TreeDirNode.openRecursively() {{{1 -"Opens this treenode and all of its children whose paths arent 'ignored' -"because of the file filters. +" FUNCTION: TreeDirNode.openRecursively() {{{1 +" Opens this treenode and all of its children whose paths arent 'ignored' +" because of the file filters. " -"This method is actually a wrapper for the OpenRecursively2 method which does -"the work. +" This method is actually a wrapper for the OpenRecursively2 method which does +" the work. function! s:TreeDirNode.openRecursively() call self._openRecursively2(1) endfunction -"FUNCTION: TreeDirNode._openRecursively2() {{{1 -"Opens this all children of this treenode recursively if either: +" FUNCTION: TreeDirNode._openRecursively2() {{{1 +" Opens this all children of this treenode recursively if either: " *they arent filtered by file filters " *a:forceOpen is 1 " -"Args: -"forceOpen: 1 if this node should be opened regardless of file filters +" Args: +" forceOpen: 1 if this node should be opened regardless of file filters function! s:TreeDirNode._openRecursively2(forceOpen) if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen let self.isOpen = 1 @@ -488,7 +494,7 @@ function! s:TreeDirNode._openRecursively2(forceOpen) endif endfunction -"FUNCTION: TreeDirNode.refresh() {{{1 +" FUNCTION: TreeDirNode.refresh() {{{1 function! s:TreeDirNode.refresh() call self.path.refresh(self.getNerdtree()) @@ -527,7 +533,7 @@ function! s:TreeDirNode.refresh() endif endfunction -"FUNCTION: TreeDirNode.refreshFlags() {{{1 +" FUNCTION: TreeDirNode.refreshFlags() {{{1 unlet s:TreeDirNode.refreshFlags function! s:TreeDirNode.refreshFlags() call self.path.refreshFlags(self.getNerdtree()) @@ -536,15 +542,15 @@ function! s:TreeDirNode.refreshFlags() endfor endfunction -"FUNCTION: TreeDirNode.refreshDirFlags() {{{1 +" FUNCTION: TreeDirNode.refreshDirFlags() {{{1 function! s:TreeDirNode.refreshDirFlags() call self.path.refreshFlags(self.getNerdtree()) endfunction -"FUNCTION: TreeDirNode.reveal(path) {{{1 -"reveal the given path, i.e. cache and open all treenodes needed to display it -"in the UI -"Returns the revealed node +" FUNCTION: TreeDirNode.reveal(path) {{{1 +" reveal the given path, i.e. cache and open all treenodes needed to display it +" in the UI +" Returns the revealed node function! s:TreeDirNode.reveal(path, ...) let opts = a:0 ? a:1 : {} @@ -571,14 +577,12 @@ function! s:TreeDirNode.reveal(path, ...) return n.reveal(a:path, opts) endfunction -"FUNCTION: TreeDirNode.removeChild(treenode) {{{1 -" -"Removes the given treenode from this nodes set of children +" FUNCTION: TreeDirNode.removeChild(treenode) {{{1 +" Remove the given treenode from "self.children". +" Throws "NERDTree.ChildNotFoundError" if the node is not found. " -"Args: -"treenode: the node to remove -" -"Throws a NERDTree.ChildNotFoundError if the given treenode is not found +" Args: +" treenode: the node object to remove function! s:TreeDirNode.removeChild(treenode) for i in range(0, self.getChildCount()-1) if self.children[i].equals(a:treenode) @@ -590,18 +594,15 @@ function! s:TreeDirNode.removeChild(treenode) throw "NERDTree.ChildNotFoundError: child node was not found" endfunction -"FUNCTION: TreeDirNode.sortChildren() {{{1 -" -"Sorts the children of this node according to alphabetical order and the -"directory priority. -" +" FUNCTION: TreeDirNode.sortChildren() {{{1 +" Sort "self.children" by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) endfunction -"FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 -"Opens this directory if it is closed and vice versa +" FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 +" Opens this directory if it is closed and vice versa function! s:TreeDirNode.toggleOpen(...) let opts = a:0 ? a:1 : {} if self.isOpen ==# 1 @@ -615,13 +616,13 @@ function! s:TreeDirNode.toggleOpen(...) endif endfunction -"FUNCTION: TreeDirNode.transplantChild(newNode) {{{1 -"Replaces the child of this with the given node (where the child node's full -"path matches a:newNode's fullpath). The search for the matching node is -"non-recursive +" FUNCTION: TreeDirNode.transplantChild(newNode) {{{1 +" Replaces the child of this with the given node (where the child node's full +" path matches a:newNode's fullpath). The search for the matching node is +" non-recursive " -"Arg: -"newNode: the node to graft into the tree +" Arg: +" newNode: the node to graft into the tree function! s:TreeDirNode.transplantChild(newNode) for i in range(0, self.getChildCount()-1) if self.children[i].equals(a:newNode) From 779e13374a29b736d25f255c281383862637f5ac Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 27 Jun 2017 11:10:52 -0400 Subject: [PATCH 330/680] Edit the filter in the TreeDirNode glob method A better style for executing the removal of each filtered name was chosen. This is a minor change, but I viewed it as necessary. --- lib/nerdtree/tree_dir_node.vim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index feee7720..a693c6d3 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -256,7 +256,6 @@ function! s:TreeDirNode._glob(pattern, all) " If "a:all" is false, filter "." and ".." from the output. if !a:all - let l:toRemove = [] for l:file in l:globList @@ -275,10 +274,9 @@ function! s:TreeDirNode._glob(pattern, all) endif endfor - if !empty(l:toRemove) - call remove(l:globList, index(l:globList, l:toRemove[0])) - call remove(l:globList, index(l:globList, l:toRemove[1])) - endif + for l:file in l:toRemove + call remove(l:globList, index(l:globList, l:file)) + endfor endif return l:globList From 2b2b35ceda038d695e9d8d158c93aa1b81bac110 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 30 Jun 2017 10:10:26 -0400 Subject: [PATCH 331/680] Fix an inaccurate version check Calling the function "globpath()" is complex when one is trying to support multiple versions of Vim because this particular function developed rapidly (as did "glob()") during the life of Vim 7.0. This commit makes the version check for calling "globpath()" much clearer. It also allows for rendering dead links in the NERDTree by changing the "globpath()" call for versions of Vim that include patch 7.4.654. This can be done later when the effects are known and the feature is officially requested. Fixes #718. --- lib/nerdtree/tree_dir_node.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a693c6d3..61f72e4a 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -242,11 +242,13 @@ function! s:TreeDirNode._glob(pattern, all) let l:globList = [] - " See ":h version7.txt" for the details of the progression of the "glob()" - " and "globpath()" functions. - if v:version >= 704 + " See ":h version7.txt" and ":h version8.txt" for details on the + " development of the "glob()" and "globpath()" functions. + if v:version > 704 || (v:version == 704 && has('patch654')) + let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) + elseif v:version == 704 && has('patch279') let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) - elseif v:version >= 703 + elseif v:version > 702 || (v:version == 702 && has('patch051')) let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) let l:globList = split(l:globString, "\n") else From 18f04e082493c553f5f5e3323a1b84c12d77cc24 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 29 Jun 2017 17:53:47 -0400 Subject: [PATCH 332/680] Refactor the "TreeDirNode.displayString()" method I found this method to be unreadable and cumbersome. Cleaning it up helped me to understand the design ideas behind it. --- lib/nerdtree/tree_dir_node.vim | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 61f72e4a..70fa1aa5 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -78,19 +78,29 @@ function! s:TreeDirNode.createChild(path, inOrder) endfunction " FUNCTION: TreeDirNode.displayString() {{{1 -unlet s:TreeDirNode.displayString +" Assemble and return a string that can represent this TreeDirNode object in +" the NERDTree window. function! s:TreeDirNode.displayString() - let cascade = self.getCascade() - let rv = "" - for node in cascade - let rv = rv . node.path.displayString() + let l:result = '' + + " Build a label that identifies this TreeDirNode. + let l:label = '' + let l:cascade = self.getCascade() + for l:dirNode in l:cascade + let l:label .= l:dirNode.path.displayString() endfor - let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable + " Select the appropriate open/closed status indicator symbol. + if l:cascade[-1].isOpen + let l:symbol = g:NERDTreeDirArrowCollapsible + else + let l:symbol = g:NERDTreeDirArrowExpandable + endif - let flags = cascade[-1].path.flagSet.renderToString() + let l:flags = l:cascade[-1].path.flagSet.renderToString() - return sym . ' ' . flags . rv + let l:result = l:symbol . ' ' . l:flags . l:label + return l:result endfunction " FUNCTION: TreeDirNode.findNode(path) {{{1 From 86605413339960e0f32e5197d1d38b547bf141cf Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 2 Jul 2017 11:51:32 -0400 Subject: [PATCH 333/680] Fix the "TreeDirNode.open()" method Issues #547 and #526 reported a problem with the "open()" method in the "TreeDirNode" class. Specifically, opening a cascade in the NERDTree will perform the opening operation on the tail of the cascade. This is a problem when other operations (such as the "u" mapping) close intermediate cascaded directories, which causes opening the tail to have no effect (other than toggling the arrow). Here, the "open()" method was modified to open all directories in a cascade whenever the tail is opened. This is the only reasonable fix for this type of problem. Fixes #547 and fixes #526. --- lib/nerdtree/tree_dir_node.vim | 42 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 70fa1aa5..19597f5c 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -410,25 +410,39 @@ function! s:TreeDirNode.New(path, nerdtree) return newTreeNode endfunction -" FUNCTION: TreeDirNode.open([opts]) {{{1 -" Open the dir in the current tree or in a new tree elsewhere. -" -" If opening in the current tree, return the number of cached nodes. -unlet s:TreeDirNode.open +" FUNCTION: TreeDirNode.open([options]) {{{1 +" Open this directory node in the current tree or elsewhere if special options +" are provided. Return 0 if options were processed. Otherwise, return the +" number of new cached nodes. function! s:TreeDirNode.open(...) - let opts = a:0 ? a:1 : {} + let l:options = a:0 ? a:1 : {} - if has_key(opts, 'where') && !empty(opts['where']) - let opener = g:NERDTreeOpener.New(self.path, opts) - call opener.open(self) - else - let self.isOpen = 1 - if self.children ==# [] - return self._initChildren(0) + " If special options were specified, process them and return. + if has_key(l:options, 'where') && !empty(l:options['where']) + let l:opener = g:NERDTreeOpener.New(self.path, l:options) + call l:opener.open(self) + return 0 + endif + + " Open any ancestors of this node that render within the same cascade. + let l:parent = self.parent + while l:parent != b:NERDTree.root && !empty(l:parent) + if index(l:parent.getCascade(), self) >= 0 + let l:parent.isOpen = 1 + let l:parent = l:parent.parent else - return 0 + break endif + endwhile + + let self.isOpen = 1 + + let l:numChildrenCached = 0 + if empty(self.children) + let l:numChildrenCached = self._initChildren(0) endif + + return l:numChildrenCached endfunction " FUNCTION: TreeDirNode.openAlong([opts]) {{{1 From ebc206e58d959dd244ddbb82e5e784d51b6c2c6b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 2 Jul 2017 12:03:45 -0400 Subject: [PATCH 334/680] Refactor "TreeDirNode.close()" method This method required adjustment to take cascades into consideration. Since the arrow in the NERDTree window reflects the status of the tail directory of the associated cascade, an arrow indicating open status can be present when a higher directory in the cascade was closed. This commit will automatically close child nodes within the same cascade of a closed directory node so that the arrow accurately reflects what is rendered. --- lib/nerdtree/tree_dir_node.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 19597f5c..ac89c82b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -45,9 +45,14 @@ function! s:TreeDirNode.addChild(treenode, inOrder) endfunction " FUNCTION: TreeDirNode.close() {{{1 -" Closes this directory +" Mark this TreeDirNode as closed. function! s:TreeDirNode.close() - let self.isOpen = 0 + + " Close all directories in this directory node's cascade. This is + " necessary to ensure consistency when cascades are rendered. + for l:dirNode in self.getCascade() + let l:dirNode.isOpen = 0 + endfor endfunction " FUNCTION: TreeDirNode.closeChildren() {{{1 From 7f4a7205dca12736b7fb03334b57ab3342c56b0d Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 2 Jul 2017 14:57:33 -0400 Subject: [PATCH 335/680] Replace an equality test with an instance method A proper instance method was substituted for the more brittle equality test in the "TreeDirNode.open()" method. Note that the order of the tests was reversed to account for the fact that the "isRoot()" method can only be called after the first test has passed. --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index ac89c82b..5c9fe727 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -431,7 +431,7 @@ function! s:TreeDirNode.open(...) " Open any ancestors of this node that render within the same cascade. let l:parent = self.parent - while l:parent != b:NERDTree.root && !empty(l:parent) + while !empty(l:parent) && !l:parent.isRoot() if index(l:parent.getCascade(), self) >= 0 let l:parent.isOpen = 1 let l:parent = l:parent.parent From ef35ee891870a6f2cff856c71849f8307e623a5c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 4 Jul 2017 09:45:06 -0400 Subject: [PATCH 336/680] Remove the helper function for "openRecursively()" The support function for this method was unnecessary, so I took the time to remove it. Since "TreeDirNode.openRecursively()" now calls the "open()" method, it can take advantage of the improvements made to that function in recent commits. Specifically, this method will reflect the bugfix provided in pull request #720. --- lib/nerdtree/tree_dir_node.vim | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 5c9fe727..5ca94d4f 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -492,35 +492,16 @@ function! s:TreeDirNode._openInNewTab() endfunction " FUNCTION: TreeDirNode.openRecursively() {{{1 -" Opens this treenode and all of its children whose paths arent 'ignored' -" because of the file filters. -" -" This method is actually a wrapper for the OpenRecursively2 method which does -" the work. +" Open this directory node and any descendant directory nodes whose pathnames +" are not ignored. function! s:TreeDirNode.openRecursively() - call self._openRecursively2(1) -endfunction + silent call self.open() -" FUNCTION: TreeDirNode._openRecursively2() {{{1 -" Opens this all children of this treenode recursively if either: -" *they arent filtered by file filters -" *a:forceOpen is 1 -" -" Args: -" forceOpen: 1 if this node should be opened regardless of file filters -function! s:TreeDirNode._openRecursively2(forceOpen) - if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen - let self.isOpen = 1 - if self.children ==# [] - call self._initChildren(1) + for l:child in self.children + if l:child.path.isDirectory && !l:child.path.ignore(l:child.getNerdtree()) + call l:child.openRecursively() endif - - for i in self.children - if i.path.isDirectory ==# 1 - call i._openRecursively2(0) - endif - endfor - endif + endfor endfunction " FUNCTION: TreeDirNode.refresh() {{{1 From c1b71dcfc5aaf9140361a1631a06a9dd5c88e526 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 4 Jul 2017 10:14:35 -0400 Subject: [PATCH 337/680] Rename the help file to "NERDTree.txt" I thought renaming this file was important so that the NERDTree name is printed with consistency. Branding is important. --- README.markdown | 2 +- doc/{NERD_tree.txt => NERDTree.txt} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename doc/{NERD_tree.txt => NERDTree.txt} (99%) diff --git a/README.markdown b/README.markdown index 19b841bc..48d216b9 100644 --- a/README.markdown +++ b/README.markdown @@ -59,7 +59,7 @@ Installation git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree -Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`. +Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERDTree.txt`. #### [apt-vim](https://github.com/egalpin/apt-vim) diff --git a/doc/NERD_tree.txt b/doc/NERDTree.txt similarity index 99% rename from doc/NERD_tree.txt rename to doc/NERDTree.txt index 427e90c7..f68880cd 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERDTree.txt @@ -1,4 +1,4 @@ -*NERD_tree.txt* A tree explorer plugin that owns your momma! +*NERDTree.txt* A tree explorer plugin that owns your momma! From 49c165a1036415e8de038d257adb3735535b6b17 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 8 Jul 2017 10:53:05 -0400 Subject: [PATCH 338/680] Update the function that drives the `p` mapping As reported in issue #67, the function driving the `p` mapping was not updated to work as expected when the cursor is positioned on a cascade. This problem is addressed here. Fixes #67. --- autoload/nerdtree/ui_glue.vim | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 90ce872c..2d94fd9a 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -404,13 +404,27 @@ function! s:jumpToLastChild(node) endfunction " FUNCTION: s:jumpToParent(node) {{{1 -" moves the cursor to the parent of the current node +" Move the cursor to the parent of the specified node. For a cascade, move to +" the parent of the cascade's highest node. At the root, do nothing. function! s:jumpToParent(node) - if !empty(a:node.parent) - call a:node.parent.putCursorHere(1, 0) + let l:parent = a:node.parent + + " If "a:node" represents a directory, back out of its cascade. + if a:node.path.isDirectory + while !empty(l:parent) && !l:parent.isRoot() + if index(l:parent.getCascade(), a:node) >= 0 + let l:parent = l:parent.parent + else + break + endif + endwhile + endif + + if !empty(l:parent) + call l:parent.putCursorHere(1, 0) call b:NERDTree.ui.centerView() else - call nerdtree#echo("cannot jump to parent") + call nerdtree#echo('could not jump to parent node') endif endfunction From 3245007f0e9c3a99040591ac8fc2a647d6ced4ee Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 14 Jul 2017 17:17:25 -0400 Subject: [PATCH 339/680] Remove a method from the TreeDirNode class The "TreeDirNode.getDirChildren()" method is never called and can be safely removed. Further, note that this method has a bug. It calls the "filter()" builtin function, which modifies "self.children" in-place. This is obviously not a desirable side effect of calling this function. If the functionality is genuinely required later, "filter()" should be called on a copy of "self.children" to achieve the desired result. --- lib/nerdtree/tree_dir_node.vim | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 5ca94d4f..88ea9e65 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -220,13 +220,6 @@ function! s:TreeDirNode.getChildIndex(path) return -1 endfunction -" FUNCTION: TreeDirNode.getDirChildren() {{{1 -" Return a list of all child nodes from "self.children" that are of type -" TreeDirNode. -function! s:TreeDirNode.getDirChildren() - return filter(self.children, 'v:val.path.isDirectory == 1') -endfunction - " FUNCTION: TreeDirNode._glob(pattern, all) {{{1 " Return a list of strings naming the descendants of the directory in this " TreeDirNode object that match the specified glob pattern. From 1f089a362b859f8879f70f1ccdb7e40d1e5ba822 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 14 Jul 2017 17:36:09 -0400 Subject: [PATCH 340/680] Rework the "TreeDirNode.closeChildren()" method This function needed polishing; in the choice of variable names and in the leading comment. --- lib/nerdtree/tree_dir_node.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 88ea9e65..4a6d2137 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -56,12 +56,12 @@ function! s:TreeDirNode.close() endfunction " FUNCTION: TreeDirNode.closeChildren() {{{1 -" Closes all the child dir nodes of this node +" Recursively close any directory nodes that are descendants of this node. function! s:TreeDirNode.closeChildren() - for i in self.children - if i.path.isDirectory - call i.close() - call i.closeChildren() + for l:child in self.children + if l:child.path.isDirectory + call l:child.close() + call l:child.closeChildren() endif endfor endfunction From 3a7694aa555f2b421ce6d685c0a8f19861161ed9 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 14 Jul 2017 17:52:00 -0400 Subject: [PATCH 341/680] Add a call to close the children of bookmarks When bookmarks are opened normally (i.e., when a bookmark is made the root of the current NERDTree), any open children of that bookmark will remain open. This is often inconvenient, especially for users who want bookmarks to appear "fresh" when opened. --- lib/nerdtree/bookmark.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index f8606ee6..d7b9d3df 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -293,15 +293,17 @@ function! s:Bookmark.str() endfunction " FUNCTION: Bookmark.toRoot(nerdtree) {{{1 -" Make the node for this bookmark the new tree root +" Set the root of the given NERDTree to the node for this Bookmark. If a node +" for this Bookmark does not exist, a new one is initialized. function! s:Bookmark.toRoot(nerdtree) if self.validate() try - let targetNode = self.getNode(a:nerdtree, 1) + let l:targetNode = self.getNode(a:nerdtree, 1) + call l:targetNode.closeChildren() catch /^NERDTree.BookmarkedNodeNotFoundError/ - let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) + let l:targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) endtry - call a:nerdtree.changeRoot(targetNode) + call a:nerdtree.changeRoot(l:targetNode) endif endfunction From 5daec4c7b7baaa1525b92a6a9ec08f7cd102aa59 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 14 Jul 2017 18:02:02 -0400 Subject: [PATCH 342/680] Edit stale commentary and add proper sigils --- lib/nerdtree/bookmark.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index d7b9d3df..45f9950e 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -308,10 +308,11 @@ function! s:Bookmark.toRoot(nerdtree) endfunction " FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1 -" Make the node for this bookmark the new tree root +" Class method that makes the Bookmark with the given name the root of +" specified NERDTree. function! s:Bookmark.ToRoot(name, nerdtree) - let bookmark = s:Bookmark.BookmarkFor(a:name) - call bookmark.toRoot(a:nerdtree) + let l:bookmark = s:Bookmark.BookmarkFor(a:name) + call l:bookmark.toRoot(a:nerdtree) endfunction " FUNCTION: Bookmark.validate() {{{1 From eae5d02fa9d6218710c121a19295bb8f0a1c499c Mon Sep 17 00:00:00 2001 From: Parker Kemp Date: Mon, 24 Jul 2017 15:32:59 -0400 Subject: [PATCH 343/680] Use window number when opening in new vsplit --- lib/nerdtree/opener.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index ac0f92eb..d1bd05a5 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -225,10 +225,12 @@ function! s:Opener._newVSplit() call nerdtree#exec("wincmd p") vnew + let currentWin = winnr() + "resize the nerd tree back to the original size call g:NERDTree.CursorToTreeWin() exec("silent vertical resize ". winwidth) - call nerdtree#exec('wincmd p') + exe currentWin . "wincmd w" endfunction "FUNCTION: Opener.open(target) {{{1 From 6efef8651ef0a4fc3dec568e75d0042ec07fe075 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 28 Jul 2017 20:38:26 -0400 Subject: [PATCH 344/680] Edit the README file Two key changes were made: 1. A screenshot was added for visual appeal. 2. The massive (and noisy) feature list was removed. This information is adequately covered in the docs. Fixes #573. --- README.markdown | 68 +++++++++--------------------------------------- screenshot.png | Bin 0 -> 87896 bytes 2 files changed, 13 insertions(+), 55 deletions(-) create mode 100644 screenshot.png diff --git a/README.markdown b/README.markdown index 48d216b9..2550331f 100644 --- a/README.markdown +++ b/README.markdown @@ -1,56 +1,16 @@ -The NERD Tree +The NERDTree ============= -Intro ------ - -The NERD tree allows you to explore your filesystem and to open files and -directories. It presents the filesystem to you in the form of a tree which you -manipulate with the keyboard and/or mouse. It also allows you to perform -simple filesystem operations. - -The following features and functionality are provided by the NERD tree: - - * Files and directories are displayed in a hierarchical tree structure - * Different highlighting is provided for the following types of nodes: - * files - * directories - * sym-links - * windows .lnk files - * read-only files - * executable files - * Many (customisable) mappings are provided to manipulate the tree: - * Mappings to open/close/explore directory nodes - * Mappings to open files in new/existing windows/tabs - * Mappings to change the current root of the tree - * Mappings to navigate around the tree - * ... - * Directories and files can be bookmarked. - * Most NERD tree navigation can also be done with the mouse - * Filtering of tree content (can be toggled at runtime) - * custom file filters to prevent e.g. vim backup files being displayed - * optional displaying of hidden files (. files) - * files can be "turned off" so that only directories are displayed - * The position and size of the NERD tree window can be customised - * The order in which the nodes in the tree are listed can be customised. - * A model of your filesystem is created/maintained as you explore it. This - has several advantages: - * All filesystem information is cached and is only re-read on demand - * If you revisit a part of the tree that you left earlier in your - session, the directory nodes will be opened/closed as you left them - * The script remembers the cursor position and window position in the NERD - tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear exactly - as you left it - * You can have a separate NERD tree for each tab, share trees across tabs, - or a mix of both. - * By default the script overrides the default file browser (netrw), so if - you :edit a directory a (slightly modified) NERD tree will appear in the - current window - * A programmable menu system is provided (simulates right clicking on a node) - * one default menu plugin is provided to perform basic filesystem - operations (create/delete/move/copy files/directories) - * There's an API for adding your own keymappings +Introduction +------------ + +The NERDTree is a file system explorer for the Vim editor. Using this plugin, +you can visually browse complex directory hierarchies, quickly open files for +reading or editing, and perform basic file system operations. This plugin can +also be extended with custom mappings using a special API. The details of this +API and other NERDTree features is described in the included documentation. + +![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png) Installation ------------ @@ -66,10 +26,8 @@ Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:he apt-vim install -y https://github.com/scrooloose/nerdtree.git - - -Faq ---- +F.A.Q. +------ > Is there any support for `git` flags? diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..c410c5dbb648c394dc74b90393939aa0ea252bb2 GIT binary patch literal 87896 zcmZ6xby$;c_&%(3cc%!WQxPPmbVy5%93UtS5)wnCOFE<`N{C3e#H70$2^kyFjeRVOE5A-Q+&9=WE5is8L`c;D~c!xbXJ zxp(h=%Ge4Q_KW*IhU!Z9D#zG%u@`tw&vl;PyH}G$in7DUUK4w2nETwjN74Q7b-&-^ zo5Q_(cg312&tC>uAE4Jf*wi!sChotgx#eral@xcjeZbgeUD2OTWI*L+mR`J0M5EEv zNAp~BMP*t?ggjitq9nq+&@DbkVmp$ccESFachV%2{qF3lB;Ng%6UGmO6|27qBKj;3 zA`|8pT+oEvpKpV7<*8HnPSuS~YT^b36*=+J__*~{UKzjIG)iFxUZR2fchPp=!V9{9 z=v}?r%fmDPvs$WAz~%s7Eo!qY3j3+_Dc>EnW)8r#57Qlr(p!xyO(qiyB=Ptmd@01H zAU`G^lYCp?_Dw!AT5lYh4N8A-xv0vC3nDWIPk-=nXV1+jj#&Q4d_#X?JS+{Xt&Mpg zVOC2=p*|2YF0~`zD&ua`b*K3FF`6KO7O8%t<3~cMA|L7S?1YX&LC&9KoTDpr%eN`m ze=7Q+I{I#|OJzU79H44O5?z222)-jH@9M1KU+8Kl@33&SJHE;;urt(Go z(299$jE7&)^}O5g>A6E`wU}|tL;1+?sAA8Z#aJU}Xdn=(=xoZ|$az{Sj`6Mm+BM?p zuB+RH9_p=km5l^kO(Ea@H13)k?>iC&NL-C=C4!T6U=R-!m zJPCYgCmbV@L6z1`MOf7S4r2Mxk(s?Z-MB6CW5K{<@MCpe_&v_paX{xD#lL4^LyYo+ zt9lq42{tv~@4+!pZ8B8Ad0Ei4oHcu9Y9t)#Q9|kLU2Z%ekggo3e&OoEK>*g$6G3T9 zC(``e{H@Xn>y{R%IQsj`_v4fS%E@bZ+8(ce+3P(gGp7e75FIdutAEvq)BuSskyc}2 ztL#bQf=OPi`}bZxQdti}2cM5ai-^KVe^_bdu02K2Em4cf(s20mw?L(24#*iAmjezZ zzDnWzI2-tdU2l52Qp-!~hv2VyR$k>+vqDShN-y^S@}U>SX0265qkNfC#h#eO>FCvE z0^!K;5-b9>rEa`Q%&VN0F?4;PZ^9dlj4-*_-91skKXfMO%#`1Mw+T_BwA!t53$@em zlw_jNF){@}vAC(vGvb(Y6B2HIpPGfvdr5t%#)h>2Ks_g*GB`}%pVMO$z;vep`d-YN;H&S}4uym77tGH{fgc_IC&PRMn ze-eAuE~%D#HHZi|Z97)$1=jHQv#St?L>ggiEX7L2O<9)eMva(AKeY={kz#S!ZS)T= zc1OAm`FnUVrPU$bq^N+wuvZL?KIS#+`2WKSkPvmk4K-8OxAU0~)DH3zJC@8ytS%PZ zLrHw9c)eTWgXlyXt&=y>vjbk5Dk&!`==K{TyXKQFgX;LqNC-#ARy6iuWxuSrK2YD{ zgZQ;~cf?cEQF)!*OsL8f=;LaD#^{R=ObF?ZKjwmEjcz~$dT$hg$qHpDat?W%T4Q-X zhRnmbViMEnj*F=Sv<7;Q@&BcFnS7*SoBm%OmB4TIJw|3rG9p(#eY%rTExOMnJ&iH| z@-?U}oBb)4AQJ4R@P(3W1&*V07I>dVo`U*5Vj{X2vwE8tiWIRsx!Q1pqrLta%NIK~ zoa+K?l7Lcu=TL^$8v|@~{-csfqZpgLF2sX~ko4{;Bjit3X}u3NS+j{Utt|b6aolbz zZ+$xZI_qqIeZ<|eGmaT_Ow+;VF=X>@WwQQ9wnIh>Rh&%1=3j}-Bbi^edVygu}AQbP1*dr_tdC)G}TE!A+pBMU^eN)Of;6S z1b~snNfUwPuQqiHE5O^$Es#!-W4e3Bz-8Gb&Z0p2G%w%o;xu^;RKdEJSh?u^9McD3 zyBWOFGvthyyfH2 z0f#c`O_ao@qV}lx39A6JBsTRa_5KH*|DqE}!W<=ia7)Yl>Kuih3%h_G+zxs`;JSO$ zdOfR6dYF&RA`Xm*+qF9mg5fpKIx*AsHQfOP8`~Yz|CI82SmB)y%!Sv~gaI({U3g`` zU9$$^`N-YEGnXeugsaIk3W9&_zJ+JYEVB+a!$dvU>~LbeY&aJ1YJK{2uvj!o$ozUD zX_wT`=WLtH5qbw?^4?B5XD@)QmxP`9Q;4W`d+v&hD+cm3X?GDqQ{Dx@MKU1p_vQX$fmy+8Z9G>NDJ-dI~LH zkRebNc^qk5e{USEK8;xze@(IdwDcPF_XhuM+gQVa4|_>zvQ{uvi}d8#)m93kf0_`g z$BCNUC$#H%kZT*0o7f|m$*JQAsu73^z!a4bbJw;&8YGcAh1x+0ExThO=P7B7ZcJXj zdYw1jo^@3hQ6H_iU`Ftyta$%gsQ9)tFwJrN1Vzp=#~GEoiE6*gFkyNt?qcc_6ScOi z@Ch@zD4K8N#QVyfphC8eXQ^a;=Nz9&zjo(6GBVa{AUCk!%7W=Eg(*u*VV%1?RpsF0 zHRTiKve4d-ysa(!gU7S*)w75ud27jghKo4n>csn z%fRK%bt_71dGSmjWZGd(8a+BX z{-t7lYK^y?ciC!ci;^PA1MPZnXC166SmIY6!Fn~FedX>_E%B8JyOL(jF&kkJI*={n z4*jU)>x4Y;i0{s9>BjXYJZZj3G3`P5G-q&Q$7^fajt1Ux_#adD01nCZX}?R(cUnU> zN1qn`oX>9Yw-a1xLopqY`n$#;{A_zUF-|-ThD~zuTKVZ+j+7nE23i`W85yRtLNjht zgT~t>4M(H9PNkiP#-SR2J|&7hh%no$n{ZRO8#(!UraM;F?xn3{Nk1lRm0_b7(92>9 zswk47eV~!i2;u9=2qo>(L7U7} zVkymMN|G%TI+46A{LAq7+$r?~Y~?i7KfCqshPCM{0Pb$jo;`Bg-tMRD zs&1_=wmg_>Z$ey|ylJwyy+f`;gM8`-pg=dC`y0EA?G2x*H;2}~?wZ;LLq1{@;LCy49csIxMZw_UAz=IX`4M54)WZ4=?zjzfas8}`5Q~J_aoStj zKFqIo)ywPZIxA#4@#4Uf#pTZ8U3v2GpB>){e&%hg}_xf#`>48= zR|!+R^3Z`~LBV008&sM4x6tsC8x(!fmuSMmr=d=IqZhq4g(nz0N zcY#*E__Y|>M63DxmxE9ak7I(0P*?4mSfxnUC957$@zwZKq^K?jj)`MSP9t2)RD!>- z=c)Z`t;R~-c!iIMBa_m)me`uvDt@D;rxGbFs&%NV z_;0k`#@mzn)V}?1_fEIQK@=5Tq<4N5?`1ZA zsa7YwZKZ@o8#}^pSD9X8;qTXs@kAd2&rHfM#*ZB@i5?$pACE}GmZk;Go`xQ|FV@(p z=nRFz-YezC{ygLvInGg7uoWQux18G!-O{}Q=7qP2kA8{jus4k6SMOfso|d}tMohTk z$P9n9#6alfMpd;0{P|DA% z@zx~Hzi$|QITGQhd<82jYvpTP@5T;Ez89udyC=wB1;d_BT~6)Nt>v3fI%>b z2WI1%Ff-yHkaCf0^aqvE2o2zPh1;oZMfW7)ci*oPxGmFK2-3;0JB|DKi?*g=L8+Gf z1Vt=|)Q;Zr?P_>qIOH$zMKk3mKpVt`qsNTTwXJ)P8ByNUtbK>tZ?xN(Jk=6V$+48W zX?)*;qB=8ybDRW;z|iB+Eg@oW1MOtv9*?wTv=PZNH(x*imEdKQ8ondFdyygrHTa1Y zZwB@}4Hg=Az=ga>ch5EIS%W$;?q6~}w3^htn@GkvpUcD9K0YWMf{Huj{^RuxXei{J z4xiXZ;I!}JD`fN%9(o#MH>N+KTlS>9qI0ZbCH4L6Jfm-t`nXMB(f40fx-T1m(_yJ^ zPbKCdn(_^9h8otvl7a;>35s*ioa?Hrh_LE!^bX^#Cl|zhbxS+?lyNTAFWZn8{1x`F zb{2#W=gq|}8Kkd`D3p&h;2~ws!I{U{`f*`Xp|ub*fe0p>Cmxo#+4iW{9D`O|UTn4V zkF6zUTu)(g9d7?y@HjNRalz<%D06P2oTKxtYFp^i>9%YY(w!1=;xZ+axC^bqPd!Y@ zgYluiJvM`1gJdc$u11l++e6kWc7IS5I7LK#JSJVd?k0aM3e6V4qv9_7&G}^gO1lG% zCyV1AB>}VRnQb=C6hGi)lJXXtUO=avN9I2b<@?J(3BBxoLu%*@Uely=PV|a`A0@-9 z_uLx;9B79>F_CVkbqFuevEzX_)#d&88u1pXd2c;`qj@`nNf)bA*fQy0c{IgUZh4V}wFmWTJ^;+J(jhol!}rGl_k#Fuo{#r>|hPWL=YfjDO$ISi&y&E`E+?X9hV&W{K0cq;Kg=Oll^8DV09D|tK+HM?5~^U)u@kj zNw`IxD(hu}y0dKqg?q~$}q$;Yuq@A%IA4jB3{ zLQ=&9C-nCB+R^W(<8De|&-atGwdSo3D4UG8N`hX&-WvhnVkt%FO&YIfEYV`T2Jxv0 zGwcq1eD|*@0|6wbKcnlqY@t%RAqtJ8nc}g)K{yAkn_W_&BHqD|*Vf+#YI^!fXd1JK zfA$uoyNXN>dNKa1dKkA7Bp?v58{J4sD%vNyB3E>fGp_YHv0Wl7)P-+LWk`=LP5y68 z1^8=~+xhe4e6H0S4Z-xE-MrRAu%O?$#iJqe1W{HTo-2LjR+;>yX7Hgbny^#>2_g#| z#}EzkYkk&WB)w8pvL8S{I?~HNu~V(cmN2jTz2lo^uT)_skeau%)%Wv7-eQ10UgN;u zo7qTW(P)TFAXyW^m%&^cE(ap!2Ae|X6N^pm`SYue+`TPK`>?FgbYI?*d+fRn&JsA( z4s3bUyaNg^u5N)mKk5P7?tdyS$JQv5PCl;%18EFt=WvN%r+%l&P6VtHlx_3|ezx6@ zlT)t2TlK6me$Q{{cxRX^H1O2c&r9xBy^0fcbfKJ7Y9-%D02NDe9_Sr7RUaG6^mD1M zF$OEj%73)d9yz0p?un5Y7%dSbS0$IXL`cD%nTnsqgmcDlrPQWZ;1I;nGw`-0vGYDp zUaKc{`D;GhlhA{#N4y@LqKj%s*BPK1pST!I#9W12FNJV%*3=|m9K@cH^Au@*FX-Vn z>_5xQb(jQ2nen;CU5+bBNKtXMe)0o&UUfH7J1p1{V}G}l@oVGApO^P@Jn(7nuPUP+ zTcJ!BP)K%msnF1>n((Tb{H`e(f|!IO@1<8?qFgMYcz`DjbnQVj60bNWbON5KG-lN3 zUg@Mv)?d-G5k`6G$l2FpGXsaplWQ%GA=1>C+{x47>f}7iI*b7Qc>hijy?+6 zLR`%A7LoA5zGv?3#Vk7&={oc7X~T9lH`6jo=byvQm^jQnBso*e;SN?$`x4V-ls~3+ zXgagFBG7)o>?fQ4OvK|=4*P;>Bgd*jMvv`vPZ>O1+&&3Oc67zZkEUkIYgwmu^KGeHyPvj6_y(9>NYX!FLB8!u^t`m@r_+8jW&C zB5+xzf_9pn zWF9y(nZjX^dEnMh^8rmE8v4lcM3an5=L_IuU;P%=_LtCHNzYPvEmV0;^A9BWHnoz& zp8(bS5zPZmaP58M&&WvyU|C=}yCY^M_!br+IrvQ>wr0UV@Mvusk+Pakw_!r$QYEIv zLtsC(g>_&&G$1R7qTq?iue+iVvkm3aZhXJq?sw&ID7&BYt^fVmhnuiL$G>*m6~Q?z z@Zsfai#Ewx?OImmEt=-}XUEoW*9Alek0Joc$-KKi@!sggOvvqaKEec{_TC3=S;PUV z-=vdJ^@s4Ymp}Y?{6J;pJ>P17&&!sI8=rb5C+~t^OG;&w$=S&2m^hKJL7kP9F4ht`TuESmam>pw#oMeJAR zgg`dG_#pOP0uKx!0x>BnKiTkN6V@sgjBi62mew9Bn?IcO-`47T3utAV!&Oh*#{iir zmNK3Jr&OAio48h6xOEZ@YrKE#JA*e0>>E&T{Q52$XXafXP?2f0r_&JgoBp2=)ya zYLRNC2v5fS6r_Kjl_0gSB%EMq#Uc~@)sL?ysAa~` z6UO*^4vm_Ahujd*mEgT6Lf>6_nEHjFKw&e{nn)|gai+UL-)9A5C5DjSh{LglEJc^dw>v7l!B z6%n)K|AC9XeA%c?%1}t~(osQSKhw;`*%QqDa!w7&iNwjb_KqDJZPX9_16T`>x0G|4 z3}8&qTPwkV(!TA{kUgZ^z_#iORAvOqUrFQsn+IGvhD~@&{{7Asjja4{Y;)gnt1NQR z_X*>zG*SSHY_PF9b;D!!GsD3u90g!P(f3|JUox({+}U}r;SCRgO9UDIf2+d&lK`Y> zkJAy2{S*DBqvj*?A<61Coe^|U)7ZO>)BSiCY&+N5zZ~3OOx4uUY8OS8KVb*-sI*$K z%(2LyyAPzsW2b&=p)T4rhaHa$d)p~BfnSdA2s|LLr>dxIMPykneRZcYI6j7_kaQ=4 z?-_0iG`c@}O%01hc4-v-`pC=DN9Xp(A;r*)a=EuT6&8D1G9xI}x3;0(V4k|7+)CrT z_ALEj;6lxo)9dycn?qGMV)-D8C)Kr~pII&~ zIFd-m|p| z?RXDd5OvZ^wmTm&@&A<_3ILVA7Yv@0Q+URM!W*6 z8GnSd34`1vWxWcZ=MBYOtmxt0%}3}~E6MF*{F?G-LF?;{=+GmP+N^=BUr*&wz4|9T zY6-&jSoWsrVH$Zv89GQJb!r*pG!=A}1h1N470M5d?}O&wxR!|Xs>*xc#!@8#6xkcQ zXte{D0v2j}q))Joi{r~bPy=GWgrv)@v;@Kb1Al)#$73GvaVt0ouVMbbe#?o>5TLu_B5i z0i=EcRJP|0Zcj-N@2&`wyOUCaFkhzZd)$3$TK4evz{gy-y9zNI|Ccnu#43lJu#OY? zdkfhO6+a@?>lSF3`b+sSB#DPgt!@HZ1E1H^n3QsgtccrcFCse;g>ycr1y|VwSg0Q7F~%3-OVz*g)0XGTK^xT=+E^O<#o>ee#_9=(R1AUXAt@6XEp_ zSpw)Xd-ymo0Eb;*=G$A9)92rtNo5Fv@^DNdv%{bEYjkpCC`1wEp`SA}rhfdtf>4VW zS7O&(NVp!N%(Kc(_}#;I08OGG+|b#Axl-bB@WjSkBW+Xr!MVxLXd##`!B+2IfTX|ku zjo2urus1=`iE?}zQU0V4lq?n4S8+JqSHib=ygtJhnA%SK1Z!KEk7&$-S?vbfTgJR3 zeVvc<`bQ54#rb$0stL8OKqDfJ3GtYfBZ-lf-QB&jxfj1z{59CPjdA=F3Wiy^Wa{zY zP0J@ytU~cE*ouy`?(BKTvgM0>TO)P_`Hs@A#9K-q316kAvOVO+Eii~*j&W`kQaxWP z680Dt;PKaKdj@0I-0XPaboWixeq+NVB4bzDea(n77KZi%t3$&Gf>Y-T(|*3>rMAbd zbPYbGXAE~Ft0lG)I%winG*bu;$jxw^ zvkwabi80tS(M?iiy)WV2VQJ*h0O%3oS)%bI@2RIrdTFN0bYxQ)K_(}RB?4k?tTJ}d zV0XJ3@4r%)nTd&o_!gr=^qR;9b$MuntF1IJmYmVFCVP2!t8WT9qh%z7aEAhSUp@-0 zJs#lG+q(1Uc}B*?bBdj}tb(Fmpe+}t0boTLZyvg$H8z=3;-L(bCUY7bNh^{HlX*y- z2Z%|^)&t6QJx%J*477Pq@P zVj17^u|qFqJD)|R%ZnX~x*fHai+tgw2=I13_`RNlL)l1&H#9NKE{o8z$%~($CA-1Y zqTDfSA+9s-4`)2oPd?3z-OM5}^`ZZzzRT8m_EQaOvxnA(otYo-ID3ZO9q2(d^<@sU zfoht9i-CR;yNX%2u4H7b@_&A+-lzQ@$0|}4duyudFLI{%9{I^ijOW+w~ z#*f_xP<_<@Ya%+i^}S0}h=pJ@ZGytODG{^MWy5N~{j)zL$Ds{2CU#Bhex-}wpKx}o z-oeJ{;@5_TT=&hGygJ0aIk;LARnYpbA8n?K(=}fhqAyG>9@Gf;wzR*0`RuHv9{Be` z@A%eoi><$E%grY^V@nIf7du+c>h3r%^@&(0vr@P$E1>&9cDUn?C8aG&JS+o_&Iz zC5>TPiXcQt=&VAS4;{B|l>f$uCGrH*4x(AjpLrAu2o~nI$aOyzhgs&vZjE|a>|EG7X6JPIir*_f369qMwZHQ@QV_juUFVzoNq z^ZP|OBdA7&6|^CAQFVOq?OrAWP$??rloMJ*|BX(ZDSr_ks7TB#dbxF@LuP;lU$?Fa zN-;+^d$Dt%H@!!X9d)XbDIUeyUYRnt_SXYfzFf&zkl3-;W9p7DK>NtdY&y#qzYl%4 z4jA!BEgFF(Tj{#7|xc|_rq3kqu3f4C>u4Z=Vnm# zZ)r8%#?H7Qn&nHbjzf&ZM&g#ih9;)-Vq!0lG@{oUDQQfuvVx(a*2AbCvP{Iix8=Bq z0m5th<5lRv{g-IVlrw-1Ndg^>Ku{x+i$EKZUd;0jqSW|3yibokb?VfBA7b${j~)HB z)ZJI2V@5_#qBi>vr;%~wqYI(X(|2l&)+ti+4c`U;qQ$zdZs55b8s$oeq}yceW^lEN zpqF0(v-Eh<8X3D?@`NM2CHBiVa&RSh*Z%xo&qT;|Ko;d`|0*@5)1#&8BX#VS&ysQ_ z8Z;ptD?m8T7qyKS5+?oyV8pO7>gfXB;?}|KQrioUb_9-fiIc~a<20b582Rq^wZ=1q zOS1Qc5UcBlaCX)&F6LLLrj^9R8kEl3dS?N=!32n;SA-4U^cr=3}tVFyU zet$V(NpU*`9i#r@jtF`P7@~s_>cQTJ!TCT2EY#fcW|x%WCLNufN(KK4M%!oQlK#zgmiARv*+R(g(zZe03` zjeHB=Vt35ov=|tnOx6fy-ay=Y^|?V&|2st5WMLzWjGR5rru+%OSKel?i0$Y0C-a2g zESc5_2Z7gsSKIMW4VzpOv4{hy|Ds@qB6^(=j1aoC^YDBcdx<5-uAu{B51L1KJmESq z>)Qq`MasGlyyp$SLxdp?F*_$4b&KmfOGXwbBIbwxJt3+Cxz)FtxZcA0O^$KV6}iTV zc_;en*E)<2%;aZ^1&>}W`zV?{2Ct!!;MDV;}ZBE!>#>{iV6%;*)S`_uhF%=(CXhjK!E zbpPGSd6xRP6%4EMwSmX}l%eSJbJ$t8`cj`YNR7TuZzPQJT z(InL)GyLUHhA#}l98PLmjOe4N?v64XO)vlUWNHL3gwx5GYn8ROwb&d$SF&bdsGG@9 z#XvLde~t;da)tjQZnWyyp;zw%1MI4vNb^}6Lq)YpLWCI#ZZg=P(asq!;vSQA(toFR ze|a_xs7S~JHt6|I7v*GKMk5`iz>3_7#A;CkoN?{8T?R4q#KQ#33+DR`y|Mm^nLn4W zN5|)+83C^j^EJ&g{^XM_2&%E&5Xm4jmX2Q&SCUu7Z}xSOi1nvN(nE@F!uUoh~ph# z%OO_=Btz}1V;mNC^--HR-kpqXPjiOdKkFiHQ2~aR5ycZx6ulm9XZCbtmT<#+FFpTI z!8abcU-WWsR@WD+DrNHb(b$m0=@_DJa)8XTZ_vnPa%F8g0TBp$%6{{CG$)rFC1*R; z6q6>RHNXj2GMVn^>TP8_?F@w37=KqZ6o#<5ejsDqJmUAC^RYPh@BWNP0h4`;nfUv;`>Ljex1RA+ckOq&o1Lm@B*ZKY^T8jPPf43?k;9J`Ut0|F^irm5;it{Ru z*M2tnv!#+Y#CDgr>>MiU+FmWI5E)Pdnr8e%%$dL8&2nb{Mo@r^i_ogqWP9fdr?uGz zv21x7RMStD_#GUjq~S;Zf9-@YBtlZH6&}6BZV_~|&Qs9W$z89+)C5kOp>K$eSOA^L zoyeEeBSn57*Tsb^`!d3EGOS3-_p`>Em$IsCG*J;R$F=0+K_O)PefFtVjAFhm&Bolr z-pXxB#PnTXl7!RHIRP+Xu?efgT(XM*%v)NJXE}_74{v7t;wn({w#*drL96%L`g$_9+9Jz&1DQT3(3#BE^YP+Mt`_?gIJ135Y)kl$8&p z<`517WxdMNTds2yI>>*w3>IJj+5tk&AFA&E)+Z`1x;BfZgQ-tjoKzcwC!9%9C&v)c z;UZ+@F`l*nM9{wm*+TeIk0X?;iAR8^HvQHBMR9TKl?srkHMY-7YO<2|rUeTYHrtqM zIV_WUSL@?O6V0L3qC?RqK@|+e9@+mDF|v$6)WAXJs-dr{IpWM7ud(#6a+aVt5^D4M znrl$2=4&dKG262P~B13l5oF&(%UPD6Ox7==8^701B%h`E#;CR;H>REUk^f)X< z2m-K=iwap>UcQn~8gx6LlXj5Y(MJ`1xf{v&*~+R(`&hvK$h?aVT&?mv17LU=B6^saru8zEk`$RUNyvts(p&W`p_IT)mVX~!pzSWxL3{5d&ZzGSEXZD8B z0>x{INPC%DI<7-{;-u}-DY0leqSK+d{I_VP#e-G*&Ml4l{r{JC0*32zu}sMKS8LB! z_1p?txE(DKFneTLyB3Fzkj|zqQAPxPDA8Lg>V|nb}8amTRwAdmaW zMhr$eKV)4%0G{Y<>4BY^3QlPAi`*~u$V0)KQ?x!>jcE=|^qLH7YFNJ3B75(17bwh? z+>95zxeWx_do|Fpd*gr{>7V2=i76sLdxbHT(o-d&di+;L>}q4h?Aw@P%mbY!GZfZX2ozOM4%dUa{XZ0= z8+)IPgpATWyT=c!1@V;CtYx?H$S&VopjeK_yz}-{6HqI zWS7tGa?#xW>0?Bk(!P9XK*@t`?3dl{{-HMQx<_cX#G)!}aS{du>$6VkaB=orWq}bO zGxK_*AL-tQ#%tZ|QR(&DRUJHt7z4s)e7z>MfoD4>JNONxbn@nX_o=b&;14Y)^Z|sB zppf4PHdgmrX=`F{Df(#sGB))eTV}M+-bx*k$L?1YsR+te!B!N2ypcnz<6si)bxCx!Aa>k~J=I@$q1^ zl*4s25I$Bb{is0vBZF;iziQ%{8!Aqh_c)3~9fZNww`J6ndUP;xo(PEcr5smL97XT= z6MqurHVv7#jFt==jZwv>^5$9=v5SLnzAxK-O-Cp=SKDjxa2>X%o+1f2Z{ne!q5Cs? z8TD=?iXOrcuy%@%<19JBIt*}^Pc=pGzfiMRiCgQ6Qw;2^O+U#^OSV#p{t2B~D`MIB zI<@@?Y`+ts&+UEiCz)2}Lb)@(moi-av*^{~Td7W5aBcB=jtPD-Jd0fQ`M|UFB)$K) zl>d)@mgrytWo_%^1wVSY$ZWMk#5(4^FS^~xStnUr;M@CWDRVY}72 z6LA8+(`HqYz00V?ox~})`T*7BdjIxEO>@f4I8H8Q!u@|@%Gg`=lK3$97dx*hYO{ZP zefmr@cRZHaqu%1`c;(HgwTX-Om@1OVykk}NixjwPE@786ci*(#?Nj!1)L)Bb?RnTw zoh2HEImx@PW&--3{BAx7AIM+i?z5zc4l7bGdI`ou>7>g3?BZsKzk~It1UW^eIqTIR ziG@ms1Ld2+mnoSw+_k~}rvs&xZN!`{V~E|0iInHg@hk61AQp%dFm%i&G zseQL{UG?s1^1tqmia z`5~34bTYv(F8ZEiQc}ejb#(Qc1$^_~?%a+UCZ9b%tm%WpmG~izPT@ba5OugO-h&6d zB3hd}Z(G>@#ImJtB_b0@{(w$XDlx*I&q$^!k)Os?20zop zu^K)n$we4+ZG1|#WBh!tR^>Z}0VcknBE$eB)5v~jTehkAlZz#g#|%XT^g;$>G~=W-5olildIl?qbLUP;5X**vrMkihB6^!d0_x0bA zZ>gt)d6b@gJ^DHIsN8X|-lj%X=!@ILxp8YPZ=>5WO|_!Zt>2h1B!~fne8Df`5kW@u zpSt;AOODc0{B+gjRk8F)o<0=QK4}Y_52$Er5<#bWs@>YH&EOLRj)^;PNi6H5<%`<%0P}|g_azqMigf@{mLI_Jxp)$u27MLU z9x}%m17XOAT)R4vBl1>;7SoGDQW9%n$mQd`JywfLTheMo>q8(xA6bu0Bp@fPJ*B z%ut^u1jJzd&eK=HvI~&#VEXxUUiu9L^C4eDnK$;S0Vgk`Pmj%?RuCND_~y71DWHaLK9e?AS)shFH?=))-W_j!S#v88&S5jjXyuk zAI0>O1`0bG30o9$g0sZ?ji)^%N03s$S!^-o2C=l4X;H_dX+4 zH~ESqnvIj;SD0c(D(=@wHfJ!68hVKZ7Q<_un)weG&qb(Z7Ubj02An6<&~N$ih>s@o zI2pM7;)o;FH$pnoPMM>iLS4mnu)V{Y<8yEQ?%6qUI;A78_^DDZp1m|9;N4QY5#mf)mu+HI?G$K(TAg5F{P2UG zvt6TiWPXCpQ#m1tOeTg8+@n@(pp;-hc=c>+4TE8K<4JI?5FG> z#q;n;au;@XsO)QtpT|L2ug?Ik7c~)N*e2DP$ulk6qe7Wizn94A;yJmx@&6N2M?}!+ zxgFLYU|V@7na7J8#%^tkf9&rDxgP6vU)F3rGed<_v zdi6l|tp!vP4=`bLD-*ZRQ-Nk21478Wn-&8CbJT$NWF=DJ-9c$}2AnU74w#{$yv&k? zLwDR++eA2z)5ic?7)|O;BBQpNM_bwy7Ewv5>Y|C5W&dlt>=YwgK8@z~Gr+JIH@xbm zkr+D1{~u`&44EXClnq+^r|oezjbtE^Tx~~S0pKi_`5M+zqTO5JH~tjkc#TJ8lt=qT zkyj5pFgFm89(Mwnu4E%$$uzWBpEe{P)*bIpWU8JVFLyu7zXY__*&uI(*ykOx&cg@G zIB#0AF8$Ocrl+3BT)_o(%=s zizSqi+qE*N`jkU7FP-{6%%Ip2~4woR-b5nHaz8 z_MH2QP43+1a_q79VF&#WbdyQ1Kz1$#x%{rvj8a=mzS>XN4CAVe@iwt%FaI6w=oMtF zv~E4|f6zxDLch;gWb3Tyd97idI$QnZ8~kQAwY~MF@ok(&!K9Hp`9S~8ZQk!MtwNhG zZgBo#g8++?#7QeecYKGHQYA7!dm5VG*dLC9pJtZzy?mUUm1Z@yAwkD6{x)ClH=%s% zdM>jL);D#i+00!XjHArLEBN$$YeBB$5DLPda z%`Q|8?}T4T(4(e+R)PMi9v8H}yTQ)Cz3?Vv`7EKVdM%io1cZ+J8bBr!y)2QnO?CR5 zjLnnm@@YI2r)4pSVc=b#{j=cPagC*JPUzvcGY2r^#8IM>LL(G+7yqBg{5Mt7h=X2w zd-}GSxL89bT*~*w^}>5@espA_|uqpRCoc!|?E^8)Jlo;+jyI;NAx z0AzQ42!ui3fsB_@(~@5a2tXbvx_kACy}MT@6c26uIR|grA!K=xofqV|Pck5B@)}HynXmx@+)fqp; zP@AmmFCe4Gxvk9bG9~Y3#q3i?oXrnB6ZjC1#lHRS%|l;~=I7W0GZuUzjVyA^-Z%&c zk5n;8g?POvK|SP4_~v)AxWoVnu+ziXme%zkE=>#eSEi{hcDbRK0mfhz8UGSwuO06Y zG?+lD>4|6fRXs?qgq{_2KiKtzb)X>Pe@k|ze0VemrP&8?|Di^%j;eRaNMsjo2F7H4 zZ?jKpgTLD2@2qLmOJ%HnVe211zpyeh&hD?&(%zMvW}Ou2`WC{BvgEFD@`w7QQh)z0 zy%4U19M9rPBKI6m3_wu&*LLB+Wl3wF0m`HI^ zNuFJ(b71izyoJ|opi<8Ub+p#{#OLTRgVG}w9Us)>-pVit3_gYp?+u-^0&mr=@;?={ zgkldZ&AdEOry|@=Ya(Qa^G#L<816y9^%VID5*2eyN0Q&zetwW($kh1evB&uF_4KDd zUlG}Y6G(MX)AyPHnlg)M-d^V0E)&GamhI({fI>mLKB_<=B;fpH*GbQVQ11A_dK4%w z>8VCDwwq7mbL^D&dm?VHt&&F-m`-lEu(K>4Q zhCtQiMP#;@Fkq!GT(AgyHX62 z8a}?f#dbw+U(Ld;-ho7~?}}~3^%skkBfgB|3(#1+TAhB#Vn4IkiyZ+)0Oi}!`&Zt8 zlYbM6CJC-Q$faE3JpAhXvbS52z9W?QFy5x^<>qol-W;gZl5f(l6RI`OW?1#ml9GnD zYJBn$s@8cW>AR1f(RC7!U;{MFb@0rUXPlLXd8e7Lbw{l?G`E zsS%_@x?`l9LApn}a~NWVnf-3Of9IU%`Ml@Ze-58v_FikRYhBkju0Ct( z5G{2B6GbW8ZJZ?!_-#$DQ7(b*fFs6>zkIqp7kWC$e}>S|pN9sS0!5;2=))SshFMfofLnhmm(Z($H2sMTvd`T81w zb~dZ08t|kirdGK+^t%-Pn(av(`^%SbKC&2F9u{l+TrtSRQN3I=GMj|7lH1i5d<0%c zf|IynwR@|($K_vBDxM9hvPeq_oH)!@KG2>LDV|JfzxWlUE!u_3!6VKOFG8m-F%_*7f#wqDA@NK!Zc(gZ6m`T((fllu&UAYiu+zUULL(5um zIIZUhlr;U(ow?VwRQz>m;)qoMTea|yrPE5ALD~_r$v1VRCRWVxr-_4V|19VbogiTg zc(2@mg&eIers2CX1WlS)T`&a3yB14UBt=Hc?lM={en#_etGH0k?DpN0&K#L6k-D)G zI{`gqh0ncU#v8n&C_&bD%DX+Sc<<&q7nuEUy3$6}4ri|HE|`X)2+8#1i6DB(Zn_f^ zl3Jsg$<_KXeactw+)p51oxt#g&{KZI;7;pyM6qn_LoG|ZLHgsEP?9&$5QoJof^Q~e zDPBeBpR+tz04UrVMZBS$+IkI0Y}Jc^a|UDB3L3!l6>pG|()bCxfV9mu>k>B2r#0?d zTJ%%Nsc30N*U-5He&aVUOrEm$6*&x!u1AKBtxKtl!6<_XMqX_B2A&G*E@7v43);7ON67 zq;Ax-OmnDDL=DYY!BxH-c|Jd^gfkxmL{t6RLU}AagHH#us7G3#V84sryL68N>Qc{D zr~wp3RXMB@8!z;8KwOuj->RztndH_rc8Tf=gfmH1{cB^@rfY{^Al2(ymEnaLIc9v@ zxnl9S<-l3gk=l;zM$$tDjq6JlA$;Y_UAE5b34vw0Om9YMiEo^Lf_&>RbNHhu(Z=;Q ze_sAiMV-6evAOFnK~@qU`Giu`I-Q$F={Exj5A7-21=q{olE^&V2oFFvk%B5y6AH8Vps6QeCbD90ic0Ru>p%pd{*dE|LRN4v^!3d+6i4&U3xs2MVRph zC$Uu1o4^jf)R+Yv;!R!&xb9_dT*j2#`R+3czUww&Et@7j%%^TA{(9=L{cknTsA8JL z|K6Ie&MH1khBH2``Q8FU(1syGVDmQ_qxP)G}yoxN2v$0%JHcs5)WPL(G29{*Vm^arUoiIJF5d`<5Cy#heC}ASz<@vz$5rN;F$d<%+0VDmBTs3Vd zjBHY}IBGdHq9*nY?Jl7zGJ_X*h=Dg>QXp9>{rX-(Ju+7xZa$riiW=zh`^gn{Rw?5Y zyHsN{f~1}z2k*%{!gv#w2`l5vtG?@Y*Go`Tru_lE*Fe{Iu`iRMQOYUP6>BCVFm^B& zUp3l5sgiBntI^fHy6+(+dL!vt70Jyy``ADLeA zA@&(DTb2-h6f8*~n}`+iCzrX#s(B1Hm!ty!Sd2(}VfVk0dZ^bq#Ap>Rp8wgP_Y=1i^6WpZf==uO@gW#w@U)v_iGcMRoaX=4s$fX(|!U{2b;oBd3|Bx z`k{-sc=h8RkbJpU5zihFo%5X_?BC6@b+M1IHm#%Px+oy)I5B`l4K*fZOndPYpgc)$ zU=c1YNkc~Bp&ox$TPY@SxV;gCD?zF}C_X*)@H0RsFD$i6w6bM16Vj3lB)3(;U-A8+ zh#!G97e9X+aRpDxIxnoEky%RX`>{$ZhlSU=C%AqfJUfRlx1NKR0Anb2|IAuw^x{=! zyLu6}UrKL6*aDs?SmVPjUe_!YS3Nqsmmk<|oQ6eBb#x@BUF1ve12-Y7mP1r|d&_HH zzmi5XVdK(%12c|Awr1`dd`>aRqoW9H8tP&rSGZVQR#?vD#1TZ52ge+2`1;>vL)Q%0 z1=atZrbpm3UG5EjceL-RyKr{Y!r+p^aBmxYS3#Pp_q&@#ByH zzug3L&J(P5_MBRJ1Zz3{7EDn9aVP+3JdBZmK=9`X!utLx;=BZ~RoCRtJ5*)~;BCE6A1oiTLbvRyilXU?*4&_a~3;kfLml#+)qDwHVrxXh* zeRqJQzZoNP4(9cHX^hYhyY;*R^Ji9H5GM`6&S$~7HCAU^xwa~`&L~E=&jVVYEj`(P zHhV}^$dz`*&D@u9X?PuS4go#4{6U{SWfTtmAXFuYavvc*l!6Hzuflgo_rxoZ(AT#r z#A_vs)7myuCy~`YC;JQIP%)asCITJ@+{K+Z5f0ZExD4Q8SvSkoc9%_#>&|OjdT73FlWu&P7-H{ESIOgFKr{J(Z9b=54AGL zFN0P|10dI`==pVioz@~k%e#e=QB;G~v72>BQfQPmfl}b^n-STy`v$oVuABb&bp7!c z{CEd`WKyZ`Ki-9X=17)z$FKyY-_WW($VVg{li?`>g00sWWgCUd-!l70SAMuir-x(o zT;4(+P55(9A>awe7?goORpiXN8WST)C4d9fS2bPiy}1X7hMzr1Bi-N=$F)Nc@vbCv zF%FuVnyx?mH!Y!b$<4C(_=jy-TLFl& z#1b!_g|maJ^93!_<6YAp=&BBMNfpQZ*<@F>{zc=N?DiLV$mC~Y5Hsx6Iqf*ZY0YiH z+bx1eF=kLdStZC+H6cyELn2gY_d%-sY0bw)_JglIH#gVe!^%K2IfX3LqgA&6R=XiL z#_O`@SjCY$*VK>)+e!&9Ke{`V+`&bp0WAWOy}xnF94hbJcVN0Npqj$mR(}FF{Lq&h z=r<|J=Sa;@-Z9a?xfcoT`Y8_nX2lWu%sQz}X>HT>Mt;^$0_Lhm6kV%tD!4o25Te(= zI$0lq1*Q_!ril=kmElRjXrn}g508U{9#k4ps$~MG_4BbDbAU0dSwj~n;uH6n&7a;;slS^{VtKH5oLzC* z{LiCrm-X<&Z^UF<3AvjOuQ0xYFY>zhXvnr(5dg{;U=~&forcP}fgovXKqCZdd2yIu zpuNrTwcUU*;r&5KyU&L`kmFUe&@YZ^r+beX$47`AkPvE&otQ(bYa1IfI>q+vhZ7$A znt_7z&rvqW_7|IyRdpgu17wi8Ql0cQ+hE^_u5-~u@sm!m3hljanHsomWCo)(CG_++ zI#H04f6@@~r3tKAs`6;OrCsbQ6T&8_TV080oZS4g z>QzdhgZd921|>F`PD&cJM{6ho*M1}7M=boZ*=3OOHJ=Sb3ykP+n2stB&Zv;pP^RWx zkxQWf*Avb#k^7}dI+@z^X))I3ov0rQ@pBOdudK1H1;-5V;q0=dG^5*&V|BD6VNtUu zQ9(X*9PfD!H5!C}PCKF184?-p)5B9Te<;~WIi&9@8QLoao)`D79*+&IDWqdV?`NLs zwFu*)jN%x}RMcCKTuNmYpWq}Q<=Ak!T~bkdw%*;*76 z7O(PM8#gI+m6n_tCW)2&MzHd#4`KU}Lm(mLd9al9)x3&amiPh99l8F7xMp+C%jxev zetKD2QK?2nbM~d(yQcW3%>!Xm2kmZ=2|V9SHgm8n>oa2Mf;;>2w+4^hBvNueDuux1 zs)%~cq{`@1a=9qqcXwExkv=73t10;@UD7wg`Oqh!Uuc&{OYhGElTcYM?J3PfH)=KF zjY}v%Sk4#E?j7?I@gy@ZB;=V*Q8@{la0Ws6>er}?Jx{ev4qKD5J?BI)Bs?#sZZP;ss*{@aDZ+WveL>eDaI1zr`nV8NV8`gbKv41>RWqrWw z^v5L>d$N3yM-W7cukT&2X!_DC0aanfOEly;5$J3^J_VmDEUI!g7A2P#^WC;%Jc{^A zqubLG&NUzXtzi@Fcd*;PnNkpqnD2=7&8}44!uRb>kI=t^*~27v5#FwE&Ucy%q)T3Y zu&?t~h?T715L&2s3iSF6TX5kU1?5`&pd!uOK*1iWbEZ-RDc*JG&^gSi*_wVs*{1*& z?1o8OlWxH6HN(8gXeUAkOt|oa4*K5bbx6(h1TsFUap2M37sFRW1;4&V&@b%Owe!ZKksZ`ut5*Rw%rlPdDYjzBdzkP7wJ!+Zys!R79H(GzlG@Mr~q-9prt} zH<}b|#o*1~JyM6pAv5xK&DgDHt(NES$JEwM`mS)Prl6yw=_(-y+DuW)96?N>;r-xa zMVIb-#SdH9W#hu`OZ!dKEBesQ3KkxIqKe8mLIQ=$leUIkn2-lQx7T9jZWM#*T?xB_w*ubTg!XN)# zW5^#*65=Rj?^+U1Bfi{sJKEdd=;ee*<(M4kNIhQ*bn^G@FbMv6j+ZdSrPuz7%Qaco z+Pw)mVQ6HIrAuVO#=CReDvj23n{&r_Ig>F*P3>-hy?xgB%ocG#YBL#oz)>KWVugCM zt)bS^^y3+c^qVI=VW@|dFy%)!@f!APnhMN#G*gPyLh+Y87#sr413HcUDn@VJ$BG^w z3ZDRHM}50MIM~RsQg#fFPXW75r6B3g!`QGh9`(l`lpIhudf}*d^COk!>PF63&I$kU zlnE0;oWu1dNJP zDiSS~%~-D`*g7x| zX_bJ2nWzjHMB4(9q!AY5)zStitbOK~IAUX!$4*;*%V8KO2=fejpQT`sz6R#dh=2)2pYvNeW&A zd%o^F%*>PC*sE~mv9;bQDqok`7^;cMTCjZfqqjMxv-N5 zyKEOe@5zIq&oupIy}>+|_1&jJ#p%qmNA=u6+HD_qn4D~O@@f>y+eB!p3aShxT;D#> zW=?Scs9}ZQs`)bJRL`nZiEUzKq<|x#J8Aj~XPjbSwFz#%E&sl?KfqF5N$V&RmZ3g& zi>)Dik6!V{-y%IezJrmUmkBL6!#N@FQs=<%XdqNKUESN8)9bVKYSXbRJ-_h-S;Q#-o?)zO$F|u1H&<06mZp;1Vq->cjrLwWsn&;7qdn&8O~=v(wY4VEppo#^IuuIQ`E*XnNlcFaB{ z1L91Iy;Yu8ziWa)UlOxPJln%S8yEbUy^cNQ90kSf4QSt{@H#`OCFUKoxG4korxL#1 zw$Yw$d~Lf4wnNf$a`0Ci5rFyq)2_b4CpxH-PgvOup*lNU>glM9)4I_llV$4Q?cga9 zSxB8Mok2bt*Oe^vlYE`V9^au=+qvjwUIOtpa`Pq=YbU?uP)n%GM-LPqQi-s&DM3-d zg5%1&IHtfqOE;Hy?YzT46l{8E9pk#1Vv>KY`CtU&6au;e0W+{pdrjl)T#Q|wdR-_ z8!O>pH(^337Cvn+(|5tIfG=w4M0(Twwww7*ft^7qmNRC*Y=U#%uDjj}$_ce%wz$4wC%qeaBkYPVHNP)@R<|>`D@%5_2s4%}&ce zFGP}~gz*aofEU`F%&N(KpoShb(MhWwD1c`DUV$#)D|~FJOUS)_r?>7mz2W}p;OZ;8 zW;tf$J%tH9M|uLhkd|uHZ%@%@vD>=a4UA|1x$S?m&;JcYEhX$sc`&#gIbBzm?puZJ zv4gsl*sV3=F+e^4ExjBun_QPW3XpOZ;M`|vZH9L@6)HX2(a9uC`EaA!z~COxtnhJ2 zz9HTZO#38f#t}{fl8V&;u4Y6aoCNRfcmC_gQl^7|^xeWS#rahbw{0Va!$joh|5oUi z{#NM!Z`h(i`~tR^shjYecCzu3)2Z;Ba3To`Xjn%kqDe|F6*GI$VQ)j7T@^#3U~4tm zzQxN*L6v}(1fEpjdfG0$A6ysX$0z%cxxR&TzD{fPWlPst<`nlX%_0u|R?KCnv23;Y)SP7=dUf zQkwmVkL)F|PX(?H_&`sW1+=LgMu4!}6Opayn+8@69v6^F<;VqO;vf7!kV(fSu+>hQ zZVP#Eh;_WOPoh2N&QDp(k^+K*Vpy&J7>k!(a1ha zVL<_NQrT^L=_GqDgQrwmBL{}%9&XJM{)s;+1;k84Po5=LKYAv;iiuRVPmf)0IpjhB zTD{^36Yp23o*vEjY5|+*tMkt!j|8e6sP0tk?H3{1CGU>#v3{FjJ91Uj@1Z%fv;mR- z?kPtc{W{H)7aL9ld z^6-{523i?_JGnX~le_yr<_ELGxba#pzVm(czY?j1)%RV5z4gAn*y*XmG1|?GG&VSI zrHTqMUdex6$3dNx?Z((AR9p2XdLawTGV*^7fcE1(zqQ2g#Z%Z8NP6CUkK)ABQWbwegKgVbW>#3Y- zVju}57pdCn!+RlD-HYA3QHz6B&^`55FOQhJ@0i1=P!Ae_5A$;c>UMa%?G#3tc#8e# zH4rX(YpnPejZlw2Nbe+S4;4=mI#w;pcHS=f?zFhXs*g3x3v>uIbnWC+i-4?S8cLWq z{XJEBDnWtq#?hXE#5Xxd#~)wODaJFrU{)sI))-%t7TZ*{TB#cG0=Tko@<95+P4Phnip z;W|y#_$z!cdrj8o2+k#D@*k6#7_JYa-sh5rjm;15%Er)6dQu`k;u=nl+ z;%Eg({hcd5cK^my&F0;V{;7BH{80?`)K5VJz+N^x1=Shi}S>tU8)-kSdQnFxyNxoj+-^ zI_A-ynj5DlVUzfEOA>e=_W;ZSH_Ov18w`f-iIJo=Q7>cK65L_q%m6+@k{f$M6Oft21VtXw+%#I zboTQ6?eRawRp`A_zhL1yLLDr+u)p}w8WdVY7#|@Kq@k`7lOCRz8~Z{_0`J05)iZgc zP_{+@RDVit>$gl!e3FW7Lc0oFpRWrD(ZJw^UTnf0uN>}s2?L!S&1Ww%Nun-OmrLe@b8IrMCR&L}I*2Etfk}Ns@ zSz*$@GwDH~`0U`D2mAgU805zant%lQ*zhrY?(oc6f-n_c`g?F?x=?WbF=H1S4PFc9 zuV){UPYRo7rpb zPld6buzGV2S6X2c(V;fQ4lT|4iN`Rno$F^1p~|jz=gI1YjNCo}VVwaD;ou(eg>Zpb zPNp<1;i|8SzS9ReGCg26@Y5bs(6!WtpGQc>-ScVmYd1BjhnFY5JTsaGFlqE)lI=Te z$GT*^ z)Ka2OK(^a`T?1GI&mUROs%rd1@Hv(WJ2v5e-}Iq6TkgZWn~>PL?S5hs(Pl~0D&CcQ z0s^mt2)vm|K|eFfO(6%|f5VI5qxBhrN-$n2k&Ww>xL2>l7Dg^P2H${1-W+ zc%;KrpYECDoOQp?aAn$w0`Zg-Sne{UKr>wys~&})+|~JY3==q@@ZJ1D&VHOPx|p0@ zysK4G%wis!gmhf@H&Fz1bY|B%gVizxe2|mJ0!e6@te;>)7Ceg*sMa^h*_$tzMugah z2$7wb^khd624CVS@fFgUJazq6Jm%)0j&URh*Bk!QnI*HpXa6Ua!H(c-NJ{l!Gcj8O zku+c*0}p0s{^8>7i}|$#^cN zsij^R4rg*cgQ+poHS;BaeaYKc1IPrL*5M+O&N7xgO-ej6)x9}j-5yC^@sBCNu~Iy= zy1w(o=W>5bTGMgg{LEjxHYbA6aRPgLcF(1D-~?7&mIw*7`6|C=87hW~SK9;TJ;?w0 z&Oanc;@LD&hVOHrfqN&?Em>_ejhr}?pAYX~s~Mdx6ZSu)fkS!iH`F_IoYUj{+i7S4 zvllKAhTjwb?ovIt?R)AN6>XN=g+=*SlDrT>YW%7eJP=wi}b8sA=-HP z%y~CU982U_^tC@?h&I#9If$qd7GtG~5C3r0Dhx}tq@a6EFty>H2)EhqE^N4C3z0h$ zaNVM|-E)dw^13&fi24@0V7WXV$&!mHJCOB()*PYy1m|q$>ItMpon9)uVsLXUdfD!w z-(4rL>3r535Jm2{xv(Ff-@dZvtdk(|#gO$e9?ta5#Fsij*nV7^K|Hzo)v59V)^Zne z!w8_}Gp?NVn5+olTPVp?nk+)LO>4b2pYm3S> z*1-(aEHP-{+f=AX>Z)BSg*2qwyN+*p{tOi5DYeRH)Pz(T?z@~Oz)Mp;a^qdUETo|# zI^sktNzW%+1>3z@RP7iO#y?$!Lx}IKVJl!;i$4fnHCzFMUDFfBs@H}=?F0R3G34QD zwxWfyKA6$FPmcleZQAsR=hKhhdJ|1d;xo4WCp0&s?3o^kKrDw8+t#tI<(=*Fe)B9~aB3 zntNu`TM+$b-lG0h?3D{~7roRb*i6GMTNY?Fq@0?S8|)6jT925Q-zSO9t)fvYHZC*T z3$8QqVZ_rM^xg2uxX`1R{y`((y!{K(x?ciGtp7_4W`TE_)Jr?=>@F>J2fJs3rwq&) zrr0>qJT|PHfPxhL6|xA=rN9!zu%92p^Vj$OurBycXt9VaMl~FSETul(g4la7t!ZR7 z5i;ERk*7D>%Cae*T^`{Dzbpor{gI z?eQU4f6R6=X&IAoyrJXh6rCvHuRXX0ru?)s4&C;37WcrNNY)N3`@YnsgUGSAh7LVt zIPB3RGOu~mGu0E}XTI7Gb^_jdx_#{VF5q$s(sn<_=ZWTLChG{K-_iNX4@Y_ibkq6> z!PP2hsnVIl1lM7j?lKgty9(s^{9sZ`UdrZYy2txa|f3+MXAC;$Wslz7p;z*XZi zP67qes1_9-HqqU*GuYi#zT$9%j5u2?b63n`=bvDxj75+obq_XIP2G93o3@7_Go zh!&R-Y57NAZy-A&B}`r{bedyQ!p2-enFjg8QOiqz?Lu#~+t>VI!Lh1aF;;2%P{Qq- z`Zr%aBj&==T!H1tE*pPQhv^sF%m+CpYZWuTZn!#^_9fochhbb^bWyoU2#oXJLQT~l z75JmKQ;p=#y-jK0_JeTqaXu9TrZXXRMm&21`~^GF;ArHlf<=MYd&ULKuS7tfC&=>r z7o8*c8ZT#ZD(!OO+%uci7Se63fOmQvdFFL`r#r(YD#C%>~bsqFL0dOIj`Z=Mlk?T`v{J$}rDhNOrbt zaJRW9>!H4px|ivYbjDnrmv-#nfnTJ8V35aN$g|t%GRa@s^%;c?8)(AI@(-nwMXoKn zTky|kQUCIMrFM^+#fwYKj#haqPp*NeNHppr4ZTroo~D=r>c5?*+vKHT`dflPR+@w41>Keb{)->^;4`PYfZehMI2s9 zzish-qTwY;?(xvOAzF9d+c~_$U*ebHckKz@| zy1|tyvW3N9W9-Uv1W(4McZfY&l6si_0_-R_a(W%@9XFe`NFHfV6mxl9#(z7=g4Htk zFUjZRc@eaO(yFmFjh~33bo)KW8RD=#ORpq7eGZREBS(U_XEI!amn9CA$ z!Tm%K$U_S9!@(WR=`Z7hQoGP9QIh^Aj|>EvvaB>h207`oay8U~s?_VwndTysKXDNc z$+Y=`0t!6*rg!igay@r^35Ec4Kn8ClDpOX58YNnK+tBR42`Bf)ZyywR_R36)MmE5~ zhdCAi*&s$zM>y_5 zgv4&K7zJI?9)Iw=^6r=mH}3t?r{z+~2aZo$4eip5)EMy%RN{@n8bcheLb9Xx=cjg* z0QWBzb|v+Kr(nyM$okIg(iL1l6jwy&1S3RjSG1?%-j2u#PSBDlOex6vghclwZX#}9Fh{?m!sGg}2+ThY;uFYyu|&Lh6* zn#9C!gaV&mKYm+)Q7?0CMuF|$iydFbr`UVmaX&h@I;kf`x8gi(KJ?LCccXFLVxB_g zJo%X{?%N`4uK~2@W)6f~6mWGOGc3Dv^yX%~D~#|E_fG8*WGL{_X96y<@!-%USI?8dogt5o(PQ>;2k>)n-!1H1qcORqVaH zP+@jqbz#qBL01_lyUvDz2TRV3^CuDKi_YTTN>*e38I$L{HJUxG$r$(G-NE!TZTn)w z8%0r_m%Y1(!~W@sD$P#-}!r|Hwq5xY`})yPj)w2 zINKRnk!%irc3DTWmzkneQ=p0qxJv0)UF?-pi4S}zrmRteeual+1P5t$Hs4Pmu>1-u z8r#iBd!hr*nN%KOfxmx9`E^?fht-E9^9fSg=7*u}Pz-kn664-t+4n z5%E5DR@exWfU|)foDD7_r{>>jcZJu z!PT~x0pT8gUS*Vew2rf|r0|1dNkI@ig3hZL0}JIYi3;P?PN5O*RyhatB+9FSBwQ z^V5^@(Cj2V|Ln=mlBoT}Ui!D*XTuk<{`Rz@+uE_FtvN{`UUxs<5dZp~Sz~0H(LFH^ zORRNN%WfY_g%peOXSsM&-)TSSC?bOb=809&lVv3AA618+AC#a*7&Ic+-^dx^z4t_p zIDQxWxvCl_eOAf#eiUJS0waTi4f`V)Xpa0tJ|PdcZIpGg&%zPB6{-u9=~7KQ&3Pkr zzAIrLZ$ln(lx996gc@>^c*&8jB(+11gyA*dYqB0yGJ zj}lThgx3KW`L^ml`MBU>?>pxnW<(dyB`&klZ-r$Q6vL(jlYAd^r7}gK(k81AkWJKn zuejmVk3%f3fY8Qy|~(pNk^f7-7-xK z$N10-r;){foJRlo+Rl*^D%fwN*>_Y4q>g?s>nI&cAZ+bO44O;Zz)T=T7ROJwlSiKMi3U z#-ynGp-H5_6z#^Ts=K`!W+RGusm#atK29jo=TNzOKYs)oLI1sQ$OydUA2;v+5D2+e zO%Kf|ClKM$+;5|ltCWE-Z1CIP4@+Q@;B=(XepwKrHjo-6WQpJ4oYEhH z&IPJagQyGW8`uaZ$ef$jB>r;2k8}!*VRb3~HFc?k5)|Z#n#RDv2k)>U5yU{jVf@1V zf6Wo`zf&s@Dgk@%$qj(AU+d3w3f;hXQDJQmtQK_28`9RhQC1OdE5KxzmZVbc&e;0XdO+}qx?b71SpZjO z{@=!_8{UYfGEdFjw%&|57ttW-6Xs$d>+HfueA362Wx4JBU7I<?p|4vx2D~byLX(-SH0-UMl1V&8qI7OMhoQuR?54*4smq)48G=EzoAr&PDs^) zdImhtc(6;$C{Ve`C0^i->Cz~5n6B%g+>4TC;DE0e$zWz3m`5trn1wr6wWn)tqrcP%0^TalS&AKDf0q-XapQ&^y}iOX@QL?1r^PwXA_s1D?3qdz0c)cLIU zni*Vj!#;smMig7!N|1N$?2PK%4Q%3uY~9ZAhq2VQG?Sxybv21iKuXFNT50keLZXTx z-G0)mNY>xQ`!6&pTBk+c&a$nWc=WadvnBTs{qhE2C`}e;W2>k}0 zG!5EcFoocHuW#RihrHa1pr1#g!kXsS$EEjM6DPu`U(ecr>r9V=O1pM6hM?+Y1l_^*7hK+n zHX}K6rK;{yQX3|Dg?jccLO;Ye8eTg%v(5v))f-&~dmcdK)BtXmNj}idLF202r3fx~ z-;5>#IeX}vJ^jtCi*PLS4@gD-bu;v>Z=l{?!prSzfTQG234%6%YaG45dGHeYLVJA^ z{BU#xAvggbRqv)+U|U<|3nx3Vpc)o;;;4N3w%YA4`zvi+izsu4Ip}{;PxB9$&}tyJ zPN-k+uLKW+N^rJM9>WwWn%%M7x`T&4fM*7T-l>TP?Lx$0fwH+_(ueU;6gU-UqI!US zQ;3NvQy@iFES+7y9_6qdT}$dyA~E+U~c@ow4Y6tC+05H zS0=kGiNf7_3G}m|z}E-V!byl2=mKv9VD+BuGx>W-xKs!TJhxUU7)p4H1%=a z=AY96^pbgaL3VY?a0j=Ao<4@kda_Xep+o4Cum~R=v=_*K17O)I$A@%X z(cXscFEDp{4yq@UGbQj1_&nRYKYoUe&~}iV z^O{IcqXruH+Z6f01#uW;2i$Avk_V4xO@~DJ_FuSGR79~JHZZ>{Ck`*Uy%QpD$*F>m zFq2=a{FXCK01bswKzxEURmFzW3by-`(sIkIoI zY|lQVtVM_)c+KFRewmGAb;ImU+T#cJ!2h>7@(P#OC@>Fv%}g7;@P97w{x=(%fD-&8f$fwFTp|)7o2cJyOJovEf1?gBXg;{|H41s* zkb20C*=v}fSTT=ekv{UlnzCuOvMr^aYM-w8tN5)SSV}i@OF|bsCOCldB`5mmwJ2lg z>5tZ&$c!0Z<-B|tX-AC7ucN@g&;)p}l$EP;aL@ry+P)T5eDuIsjp}m`XIFed%Dg&f zYlP6s&3B!(BI4|(rPsH{V^YzZ*jN3JUt{XF557JUZ0jK=xg+%$?=6`&hgG;ydd_7Z zn;jA{k<#N2QDyd#ypz2OOzL`Mq!S|en9w>#v+v6vEVaJquiZG(7H|?b z`Xmds{NSzelTc{5R<(UpAzd6UdUn71`oRK&`6}I1!L8l53aLK!Pen>#{J|gsu%wik z!c>uBHNhxzWow#$V^$tW zMJ94K_RHh@e5hw6e29!5q7o-0bF0Mgq{mcnb$77Mpq)=L=ix&Z|6QH|t#;m<2CH#d z#na%8ClHv$LkIUnb)K(f^IbOgPmX&qo_TGyC4&;IGN`zLkMc2JLwrga_u&WoEO)UW@Y~7+&_&8R z3PdJZCn?^_nC6tBb$l#9Vzgy4#6WY)OLgFQrRwJ0ku<`}p}?}u$US)loW;%3(bSP?gEz^a_qnF6&jz{bt;m-U(#Gd~){~phaeIh?U z_uwk#JXwY7<(T3SG*y|iciEMV$d(5!mvUt%omLZee!ofI?p}TPr7KG3)bQ4YakME4 z_xBz(SiJxulJ=27%A-4`Pbdp8$kY4Pn|ae}7L+941aXIi*R-@`1RYYN^H8~vU})^* zxkI{$gA19)Osr&@Yxf9tvXU0J$qz>R@ldg}^NiI~c-gQ8obXVFey+Ec;T}c7J>|w6 zYKd{b_FK=t#}sglLsjj{4sx2~7Yc)Dgg%fhTxS1@+;g_MNffO-*G`rtF2tm#Z&WdRP1Gk1Vf)=(OX>N zg?U5jaYouK&j;2E^XrQ!&?y@U@2pmuz@AJmo=r5?dE^zsT;t}S%ba{H@&bP|n*S4F zqunpldJh(#$RDamjAqK`b= zfI{3&p)(uH(c;lyAMFkG#GYIfP}Pd?8N~ZOERlERn~}ha0_)Bt@-0+) z;6>^_aDnozLq7j^!u09CKjnhJFLYa4WQM@dV1+8|Or)quYaZu)4Rq*=(ybv`4&6I1 zqLI#qB+R*&4O*FJOkr+?1ii8}FyDqwtyjdZv8m<68c?f%Bo#A%8D@VDR8-K7V&aeZq(hSTkI7hWub zA4;lt3Bj64Th)Yh6JeJ&Ji9B80Q|CKk7)+{|1b}03A>&kSwpAce3t8_KYZ@XL81)$aMk-col8d+R!4%q z1q>V*5TW%BtN29?ajbR1@Pe>!LVogI4_n}nko!O^y|zJ;!=Y)9vxn1a< zkUKb5B0X>P3C$ZmD%#_n20B#N1Hlfs|iLb>@v~#%7r8G2P5K6rC#cTSPaGriSvz zv)^4=s@vJc8h)n_M}H&!5yc=v@66t7ik zvdS`89($YTxdrxH%m`*rD6cb9i?o2-D)3ru+XG zd(W_@*6!VRxe!rNQBgq<5J6Z9h@f;xlp-J{N>y5<2+~!gmn@YcB3+8K(5ry-PDH6v zf^b)E1h4FYI^o@EreREh9YUt@VM|3Gn*zmPP!2NJ(xIu$Auv`S66?GJ{QAXHK%X3F z-%OWjZ+9{k~px!-1KQ4znIEC z5JbOD@K>&$elQ(1nSIrJXH$hk=^$u0UL4pK0sJV>BaDReq)yZVXv*#W5oE2- zdBl)6ef!@a}ixJzq8@cb}mYvEgp|n@_!Sb0s?bNtn+K*@$Ffze6wnh>i$rFI&JSQOv7>Q zO?K1lu}Tj24}mZ?Qvm7?yRbk#e1e&@jdio$%mx{i!0pg95(28LPbFY?4&oMCHLI>} zyZto+NumXvVa6(w4-;(gSXDLCk-{-F8Z zKC@2F8KEM7z0jRIrDu9p0{3NL#O}I=&hiqPp`AtDP6zL$K6+U3NJ6F^vgt<_Pe*CN zUq>_DMvTO?6@?R~x6TzDVdyeRIcr3$jKeUL3xD*h)bXDpwQ3rwvZFCgr#Iv_|9(Rp z^zVlcF#W%E{{Of7Hv-vbUcyyHG>lWlh5fg913o4r9+ZY!(ADg?MJwWvEIqOb~k_7x}ygY^^07l$=(VRr#`tI@X#{Et<8@g zmZSZSWY1u{ne*mnpwY4KUqk3Ld>roFd&0f@P{1~&g)c{f=PRYR&P@BUY}LMuLr;(( zs;Ze(6Z$$(zk3u~;%lvK&gr�OkEM>-if5oLqld#XMc7@CEE>NzgY860qx#tdl$~ zL?Q2Sfdsx}razIdqqx1;O(PWn_w`XIF_{S2_ImqsoKS)X^?JasNN5dn<`URTwH(Y# zBCHp9e@{M2OCHS`h4&EC_?6>&f8qz;uIW{kIN2-O^x&ce*9r_*ji&|_LtdrOH8&`p zdvTF3Nc|WT5qS!E41B^Tca7D^s{5agY)bFyBVPf2381My|Jy-Bt*Y^a%TRO)8iT^hCQS`$4S z!sYc&wniOG#qWkwlj>~ZDvIfKOn-gH^uU#PFWexX;JZ-Wi~It4LD)wOpwda75qMmQ z9*xL8aEK<-hj3hRNE{onpI2N!d3u{DwB(+puE%31+u4}GZ1pu}KVf_mwTA@hV9;CK z+)~K%HY8z4Z*hr%+E7ZOoO80NY>tHP*LOVI2m_t?(~`6>dqe0ZVuf#RSf7MlD7}-n zk#Onx^f~^?eJu&Icdd?>vE$ar8TiR~BhG;Rm7O6CN9%s>aM59SG~e#6m-~g!UjHp; zzF#&kP~F{u>u(IH6D)AvU)y{z<-VDuN)qovzKZh(x21~;fg&8EPukbF3t^)ee~i6M z;TWt}R2tFkT0$GJm&wahWE98~-SreGs3W5-YH{XNDe5q&yy%AS<+;ISn!YwV>%92T zK;IO4eE?b#fzojvORnAEnjeZ7tnl5$IyV6rz^`6fLTYj`=k1W$LN;CFYtwrDLc>o3mwjKW*sUt0;2 z9YwdH>}m2nzmuf_%#*n(9u7JZ^RZ*sM2dy}M0t?0l4jxqkGcpBLDiJnizq-{Jh8EE@CbxR|Je@T}Ti zD+{%0U9t-wYLNPcEg+abWP1-E&+XN@l(L)|$oJWq{Ktixjo&FV>(BBJdRp${L-c|q zvGB6tq2U+o+lb`{g-UNckEFT*ryYd=3ne(XGl=8gOd-8v_icOg{v3^8E? z1Js0>GZtnq5W5XQGOKtO_&NU$xr)GEO2snBle|b zGGlhv4-cHYvc#E>ItKnsuz^PV69u0I-Vm!7f0L4a?&bZjvNofd9v;_+n&%B@UN!bv zs8Z{hDyt@yiTeA-_qG{1o+cmkOA%XWRp9&D?qH{F5@OS^(5vBdOl@*=8!QR|k$V&f zyabnET3oWy=sIcnX;7&FG@au0OUHHO2LJ{T7LQM@Af+RR=Wz*=>ZMVA^o29wisWaw4!g zy|mLriN^Y4x~a}q>hn*<857`Vc=B1#>lo*hB(#z8bZY5k712H`AhB{>qOmG|Nk@Z~ z=i8PxFdZu{56y{xN{(Rs@TO+Sbo#JLW$ky^FWqbkzC)~HjCWmdK!)bn^oD}ATm6Nt z;!U(RTK^uLO&9KdPGjA1X^IR(^!J^n9VYRHl!e)gY^(ThbK0IFoNztIwd$0N;s`W2 zOTvg^&3*O(7jIycEN*F*IGH$_t>I5wVX9S6_BjUXtmb9(5P9H^O;8?k#gZiKZZ;O9!I#nU@?oCJ*7ZQQ}DbRyy8 zcjl>eM~?qgGS8p?+U6VqFZ}JWJ`yG$b%)guYK<6>+B_jI-LwJr0McotLy&({Q-g+P zfVv_3=4qfq1qbT!B}kVAeJcH#n@0Br+xfN`a6DKBC1LpP)^F(+8q z)LdH^dUP55tJUV<GQ<1G2h^_*z8cFy$Z_00lP z;=^Bl+PGF}DwoUh(#(8#oZ3OY+n~8byeNU(tvpzK4GHtjhqRP_>tBCWm!h&c{=E?V zo=n#n=KP7n{`nv|iLMWL0$y&31qG-x{fv?biT7!5&9wc2u>(=GrwRgFfotx{0s_NbP&dHsj zx)+>q>1jECYxxf+joc_i(K8eAcRu!Y=hsKUXAg7f5_{lO@TT+hQ5z>@j$4g;(_Dvd zlcvJ8;Lhw_Sr+rmW>#(!D`L%VvF>A;Q3J)O5g(jl@#l*G0Pr#X!-TO6n!`JSI(NnI z+?WT_+g%3!=jrf|pTdyfF6pdZM#*E>w%X5fM8}`u zsBi3N8=Y(c&QBVf0oV~Q3$OeLOYaj_J+80mW>^D`%9x8}V5v-DJ*hNk`swQge#DPi z0$nY(Nl!L36S7rh5?pkiV!#h%B5RfgfCPSG*_!tHbbem%joVfFPwTvkNyAx7th1#9 zF}x~@F^iD`T`%%Km0kk?3HCq7%c(k%Ee>gNyluRPV*WC$=G9Zo3yiv3orBVCTJTRr zka}>L*nVuG-g`&evp1q*_XVo8p-GhUy8BszN2YPa+BzCj-|87_G*g0 zR9=KvS)Ta*kA+|TfV3)|V_$VAu?Tj^YO2jKQc^={^C z&06zOFnoKcLvuT;qpacUGYBs?um27&-#Kik(z0yDlYCN-9fYQ7iI?V-SrZ0NBPW0jR}@#Hm?7JyU;Maw(xD$f#NdGL)+z^a=k-|!PxIA( zYf*RO_3Yykq%Tl{k{uc*ZZE{Hi)87WkPv>N;O6fZlayO1pNkHEa>O1S1W}kN<8|T) z)$GtptZX87dWjlsoxk7s=j^bg_tEd`?=d^r>ziGkdXvV~xtp*q@3Jw!$@NE^_4GdG z-7tQ7xoFzT+m+UU>2HL_tHos#sp69F00AL)CXEnLqL==j1CS)m5qv}LBQ z&?PK~G@S8{m##~T#p*@JAG^}Dgp@S0%MHpin)^#E1MPboN(nw<0lkYbG58rTGn-Q_ zLt=Z4=D$FG=B!B)Z+N}?Hk}XEZRz;dzF1=N?mRi;@wCyUuRS2Wo2u^EJs;VtAZ6ALY$7>pGmX^WVxPyMaxklXVxVPy|Q!>_U=3__3 zp=Mn*h!P#h$%LGzDP*(m@(rD<1&D{$cWY+6e^zi{-G|++;I6}-Y1vhy6*N&p`>v<~ zYZ?|l&=Uzd9cPNy&S!QHv$HDi5l&{Qq4aSHqzSQQKaM{|4LX44 zoLP`%U zcBnNj_0|uK!ux|zi%cdt&ff}#8@R7(G%cacTr(hTF&g__QfaUIMDNZVmDOEw!3oJe z1KAB;*!&Gp0RvNzQo6Tm?wz*d_OpH>ByjtzIm1L3`6~r{M`SABWQWw^Jf5F5@^$T}YWmXagIc&KSj3D!bg{-RQ-$PV4oJ z4d=7uFW#!@Aw616M{VvWv0lt}_t(5!>*x2l@@e?x>R+Kg%I@3BF`Q^=qW0F!JBbtH z-nbR%8u5>X-#3ZD6!gbjs!l}9`U+*Dd5b0c=%N_onl+&>M3KKz8b)iQkukg9sBgfI z_l=$OQ_FZ`H60og*z3>~cWMO{Nnp0afN zddv!cRR-$WBw9OA+hiEi!Cfd~*>kXoSJ|YgWB|ZjmQ9n2F(=Bz>rS*G#nqDY1TLtw zxtop|bD%joUQ_a?Tz!sJziSOa-`XayObZ5Xhfgn~mb&?`w42t3j_uCFF2U{t4tC27 zLE9vVV*Di|_AvpHqz%eXzGPyiu}2S5QtVbAQyXs%K^9vijIxPRob0p5enijO`^H01 zkJLREm9M(RcS4H?;H3MsMD<1mL79^Nt>B8mmFs54_cbPS&X%amErFR`*fC1pW{e@d zUT5dAIaz$p6d-(urZ zD>D5^4<=w2?-F-%z>Z-m`1hAv8VM_7&-Bo@&-vc4`lZK(;#7x}BudSv^2K6jcATHk zcE5PD2xG3`ITzsk3~bKa!&K*VUs_34@*C*NscDRhS_fNt$9!#`GuC@L^f-pOyhiG(l@NIvFi) z%rn_+))C6m-JC${zyDhl^>(DH(i+Hx?G7vJnLr2J5f>WT_?Kfc5<|_iQZOHUwwqX7fidD7AFi=J(+vV zKij=3yHOY*K!xe?qqU({UL5RI6=QzH9VYw>^$^-A3H7J%(||iW(CFzBZql8#AQ**U{Q5*{ByboGRCbCb*afA*m|R={r81%U(=xZ z+fqq+{`(Ih0UM41B+bn~HdVAvgVwt;8@6lFE*)Fw8+bK^ulxSE3S~4&mF8-B8RE`l zX{7VWK2rE%yvVn#d2tw{t@V!QW)H}s+Zd7nKl3?F3w#YT#ul-w%`w(wEL_U4A6}gN z;((s%ad~1C4zK2SaK8>9hSe8&YnT)T-ojjBi+FGnR^S~W zO~tWOM&%`prRjE~jZe^S0RfZamMIm0*-ihRGx$l$|L?jHUGS7^<6{@mT;oK<$HM71 zTWxlsNzlTjeI1y4e+c^YzRA|UK4gvDc$VB)(#_i@tYeysTG|xsuq{DQ1678uSxk(a zD|bw0q@N!`@}~~D`RF}lo*euSCe-Q?Ak6&v@3;8$w)oOM%isOa8fCPhA6*D{gS&|b@0NjE_yOlp8ux85QU1|x zwi^D)|2ZY$lQkuQ#3Ebe|qPd;k(RPDoB zs=*>Lt-(&r^$i4uB;So&cAsS9_Lj{%g{37zq89-1bd-S)t{I1Z;)+--!6K)l6y-P0 z6u3=N!Z34%_cQjV%@?}%+fR#gFx?a_t8i4&O$mEO52dF%Xg;Mk&jt-T4+vHB*9BaS z%mX_{4#NpA9&sG3agcMHI@U{sqpH@$lsh*7@3V{NKn?fksiQlGn<^Be74CEHT@qL; z+BryH4+zxmS0BsVOT0z~>P&&RBEm>HY%s=Vx@cshY;Y3HXw zUmC)NPZvFqaJieCjTi5tCpYzlQ-Zk8duCm|^R}y@F8-iqdEC?satWP>k-}Kp7{IfO zhaH9Kc^74%^weLFFqiJU+&>KSZqjt}br!@4Tu^4By)A21Q7XmPL0C5h_I^0!Tz?Z!pWsj|hU^C+`PFWn==@k{;{7&w*F zI&0TH;O^jf8S_q&ys9!=zWQ4)BAq$73X;TYkYjs)j!L_eGiUuO(#aPznOev*Ub9?^ zS*4cITsoS**|z8T0}Z~%((C$;u*LhkS~-(v@p1rK_R&1IU;IyJ_PgKU^)_|84K8%} z=%9#}2(u~A%_nqh^-W&$@^=`$Lezp+Oy#LAKDqRn#EEFF9I_%O`r$oI zA?F>V&+R4qEk~RCc9HB$*&P!sCb~!kG?|6A0~EVbM7A28oOE+n@tNSpZQOdq%aa4_ zP0Q$pXX$W0`TKQSu7oRHw6;r+CrmRUD+V)KXXw>IvIU6Qf5=R+(##zvBLxTHWuDn6 zOAc_~RNtrh9wD}&R&D}#jordK9g?e~PP{zU*9vPDV3Ow?iYbOdBW;RcmL=qUzfDb8 zRcA@lwok=qXju^hbW~3diz%jzt+3O$no!Smxct)CwEcd1Ib2}k&lavOMrEWZIPGbF zD{Ohkv%Gc6Os-UPVq8gN)40(^t}*pOWYf&$#b|NYc|niSrJ0OaJGLe0Y%%ltO$+G6 zg}>=9kJ5<5LWM07-29o1NB?zo1zN1(aCObdHz1qmo$#2%&4Vk^v^BPv@Miptu&=)f zO{-M%HFnURn?m4-$m^3hsqAA#CBdPdj<~LDzxvJm>jCPo-cS4}^*mZ;E}=V6cq(me z%r_PwY&XiPmC_8L)m=&X%Ckl{G9Zip$-MEjR ztgX>_|s8z!ezK^u8IXe9I;bc?z@&KQUqmR|(GMorsmtznsdpWtY( zhpXyWU8T0gyTB|qI5Kz!T6?(skAL(NJ0;|H#>soP1^<~fjsQ?K@ap_86+azJBmZO6 z>0k`52hK2!!YiRwBz%W4WFEK!Tsl1+C)i}pAsiq~oos^zx*!SbAzbGFC{1yMo)zS6 zrIh0w3e0yhK7*J7mTn?84W>F81gf@A%r&3vOt~UI0JiXsXkAM|MhhuIeD`8;l|T&n z?Tr_@_ce?DX9`W_-BD2oK{`-}B)co|wO7Lr;(%E11M|PG8>W;m{&#%ciBjcDp#!j3Y9*!jAQ{B?_MF}^X51zQYmR|yz| z2l=vhu7^5rm;T5C+ou_g{qwClVMf6hWKBUmPM*WmQc`M8T=*nacb6tY5O@8cT-+DE zjLZ!?i?1)HcNID$D_{UBsjw6b&6nP;jY9iwg|khB&@k1;ALwT}FzMo|U($GY-4ATl zC$^S|=O5Ar^HQ%Z)(n;I@vS}(1CKLS@pW1d9<3*EhRM2R=sWyup;z;^8GPz*^Ac3o zo=yp$)KlH8zPc6F_lQ~kaI(qW62^ZO_p%1Xp96+!;De<8{d)rRZ_g=bKK-))usQpY zO2ctoKJs@0w4U_2^$>cbM9ZmYHmPzq)VX0^O#y!jI6ip&N8l4!{x;8vOX((%5TcdN z7COaz8}c*8B&`OQJpzY8$D$6jpD*&HJ3@LrKmOM?c62yi#*E4HNb_?1d5slZc~+Tk z29nt5DuUK(Xxy|>X;67*2C=j`SQOARP_G8%3i9m<%oDD+*UA#iI}WW4M3F5uXgX`x z^H3RdJibm1CM^aMDN-OWKY|k3)(<`rw}Ortg8UQ@^$$c5IG%WC_C4InM`Zz$+5Jo~ zzB%a3E+vWc`0-h)Mrl$1BXpT!TzR{W9^Uj$5e}br5oKV*yC2xzTqHl5twO&Zvn3n+0-XLubjQcH42 zX7nj$<;QJe%BM={`#@Xr*cDO5QC1&-M-oieYmS0`Z>1A8Sj?fK(%-$Ot6mwwi# zHz|9D_mKeRa4l`)H_;lDAaXjVKhg`TgZ3JD?m(bhe`fJp=Gu@Lg8u{&;fjz)j5(69 z5{Rq+3d71xRooTV^}4pa>{m^R>i0n7 zf{9+9k}rx9sOba1`p7Smft}Cxvaen07;^aab13Hprs{lT2c}M%DN9IcRc77FjrQle z3+h;8gmYez(_UW{X&(?W+v;lHI_R*Waws za+(_AfR>4uNppGDPpyi6gwcMXtpXmET zkL8hyWRRap_@IyFkXCnZI?F%vkzymKf~TE&g$f00goSmZlERZ!t=T*rDmHq4DX*{H zp9wl%SG8yQ5m7HS!WBzXj{N$});=6nUaA`SPFc94F86HdJ@wKt*R8sex9}}2>Jn8T zeU|0r@aR3l{G8px61xuKvrI%XVhCW_1Nz4E7c(6sC#@!VVUv1=Y-KpEtVn?hPaf7-)zTaqKR%rBh=`}t{w4XRlsCd}+#Olua(&_CH*R>_qT8-JY z+M8mnxBNe%YN^Oa7A<~{ias^S zVS|*=tPWE);uU#oSRIfr%BS2}y^ST=pgje=`+QTuEcZ+NGI|YvO|K>{^a2U1eqOJo zNQqumJke`$jx_K|TFl3zuOLZZy>V=iBj73V`IG%DvE+eD6M-H>KBlsOERr;!trvtB zW{7eKoy@T3h|fM0pA!`M?eC$UT=D!o-(N>eui9PZmqsPDYNe7ST$c`_i-p%md3urt zga5f~l6b}1Gi5L3!Yx`ZnpOF6gtWd(L&NjqMFlAH<~%{0%JF!5beerB%BF^W{_bCA z;|w;cwI(y4!Eb(;tD$ z)?LB8(!%sb_ys$am@bmo%yEIasz7LNF3^RdoIl?cXB2E#O zIVB^9PDUfnJaM#e8fDFNf2=k4EUXN;;`_xCLNRvZe#d}$PKtNx>h;Krwlh_G@7J{= z*wYsC^83n4+eW^!bU$wxnsW^VhvFEWa7mb%=DQiaa&mKj_kbM+1Py-Rt>iQ5=Dwu# z*09yk-O!(3M8?j1p#P{K6=UP4zu-Qe&B#Yty}{xXT#ntuN4l_nSR<8IRgyl4UX}!f zD4DSkq4({LZNh$TuG-c4*X9%ZVzL<7}3XM&M z$Fp>^3Fm%ow^cf@?uT`g*dRufFKkKO%R#E4^zxp;s#bM zF?kEzoZ)1*nb74uu=-5y7dvY5i#BYjdG*1K;=M=7{%a02Zq_6YOt=*d;o#1qhCfQ# z$@K5r+k0kbSN~vZe^9CD9cUcTs4pis7(N{u?$Xw?Yq6g)g4EVj8~;M@KEgO&i}g!; zB^N3COcs-AIbL@n`T1y!96=LTd-cxnKaj){l#Rmwb>Z~n4s`u-`i%-$cZsF4Q_TSD zRORDN^2A|hlB*~gQZY>&*o!n{PkbGaqhKMrCV-YS{C=U};LOF#3VErwSekq4R?Xf- zD*RnYKSFy_Q(o-&13g2%;X3?-F*2A+23RuXNJ@gE=k(?A`5HNodk|MHqvT4Y6J!=9 zRVy#=uKPCaAz!3fg~B;7{0Cw!J@9eNCYUQD(xhNdGGzh3tdA+*14| zgBJJFlCw76tSb7x>2sLEfpK%wQ#KieBVKjqO}I^!``Zcv5c~YL=&DSev=eS#UWQsv z_uzBXHBG6Q%Eqipxv0T6Kb2bh9eYZ zH2*C{Vw*SO0hzsFj_HYXGr)##UNC~guidpDyqZJVX-AA=_J*-qGY{Ik(}|=<9h=Wu z9Y5z9(tH~;D5KqV9-D=R^rQo4DG6rWLX5Y;@bFi}MamA7>uF^V=HITJ&OpKGiZ6s0 z>d71$soSNJ#cQl^Hoh^Riuk0QhMCLur0TO<2@{K;y@LhptN^j#f1eWEXqxJGvbIuFUN7sAgo+6a1mGqf9qfhaBFIc}0ATv=E%l@)=yKYfls>?j8=6 zPg*hht3f)Zk}*BIWJ~5MD))`iR_?rIpG#w9oa{Tqj-6&gvB@g5J{iEcWEO=C6ldkJ z7TCMOuO0*IAlLa7iyU(OlUT|}uLIuThC~0}KlW~Ql?Kq^C?A7&u0RCiyY%*Cx!qzI zefYe(wW+o9JKle)R41tJQ;d#ArH*nkHqeFIhG--{OPFd_n6p*5ihjMZK6f4OdmQ*R zBZwzP<`#wBrcV!)goA!QPll$oFz*(wzlHMvd*dhT`a493&yM%iLSdEl4%vo({_tbsl77Z=D_VdSI*pB-dsEivbyugU-(d z!rs=KHr4e?R%rN(gZm@)7Tz@R9()P0qKMvN)LTKq$WHhgKd94Fg{Jp*_Z3C`V?R+k1G8s5Jw--+i;xv{Wp3-w}9SVJ8^!$xt33v$?#>zkVo$fX1iU z30Yh8uuSaUgDwnHWP&B&uCl!f|9{$hrXL{6$`uR>$C7_$n;MF#`q4&TYH+>~@pTEc zEB?eDFLT$|&uD%wvf`uBH=q&iq9!wWwu|t%`~j*D0lufXh&=CvSS2}$F5D(e`v1uqD#51>lTt+w^TE} z&V}XLj%>o~4sCBV+vs4~oyUyMq$Gvrx zzG28N|D(q+d(F(=<~G}Et6Q(qN(s-Pox zGzaS=92=4xX!;)+kx9%Noz0|%XjBxJjBkpi?-9;z#Z%KPv++t<6rWFc3AwyiZX1VQ znZ*+t#Fx7LU}UeD-4)l4Z)m>T?e1;g17urtx5Y1;{b?+SJ7~hrt%}sq>YxSAFSKhg77^0;cQ8UHrFs4wul$|@BG0JwMhql7vt&|FnC<1J{VqPIULhN9F1e-@SoT0x~ehJ$c_y z!uDAxstC?V8YgQ=<&j!3T~OU-xvo;r>6xi5&UOx%l$B!3&#(RG=VnD^JlaZxV? zuAT$ZpZALtpV@5{n}zlGquSSC{Cv}gQO9V zdR%ILe#u~@rs)zN2O)vXSr}0CU+laJ(V`qUCy z$F$gvs{%M!-NqOqTt&z>^fs9_fV**#(#W)pDlJ8wP|P{DLp$t3xtocKIxbb-dDB@J zx|e#_-%6;Y`7pD)gdFX4T(%C_E+Xjq*kE2@(_v*~p7S|O!nxQVlt-+;1&scV&`d-( zcfZ_2o!L|)H3flT-Z}J>Y4)9ur#F|=Ti`|Ss+EFOvDWgp9M zBeR_=>Tsfrutg{qKAafPHZCr2YOFtzx#M|+6Wyc8w7uC^G5|l@xoC~%YoG7OBnl>A zhz2*eia6N^a$(Yt4a3?2mO?@oxhLcsbPKn-wh^;Zk{48lpBXXesZ`FlWN`tFDth<{ zJ-b(b2_5}@u*{^IiA~V+ITGxkWrR!qi*hpa1kTXpr?d$ad{X|ZHZ}UnVA^BVCq*dh zGU)5LnltpL@5$Oj;?2EzRVydC{`PuaWd4K8FcUH(yike^JUufkMymmg)fvc&OXTbW zG+zpJ+T9MQ)Cs^r;E54v0`g6)ur|a}x&Q9D>|qBID*qyT@)jKx_kP>5b|}{4j!!=( zln`>{(sZM{DntW62;)-qzL9Ohd3 zy}2JQ;aWSgTnauhb5UpInCG#}n+^@UZ>M!51}VZFDB4=TF`=|nt9TvS*}>Gh(>P$c z8Z9CIRKN|T+=Eo$n6ZvYYwDQg#hcqrjuTj=Emdam3AG_iJ9Ui|=0m}cd(a4KPk49F z(e@p7P#v7MCgxgFci!Cj7?86YFxw}#qy^N&uN~2&a6adV+m-A`h_GsU!Uelo>scKn z3DZn>9i54XF#A*wKu)&YIRp@W%}P*Dq(}Ud;rHW7i|F<+d1c5601=S?8~W-?ASV1+MyJ4)Ne8DL{i8hlOR(|*J`MZJ z8nPlNTB@IF#|QN70JB6DG-KvDWBO#mK99E20~}Dhx#8c!a{T#$dTjHg6eaHGuTBy@ zHvF>vm-0XYtAE8K^{hmX+0;m|Cu;~Y*o)|`Ph*o8NDu3-1?G^SZqG@xS!D^W^hr(L z+1K=@z|JuU+a^peW@7n45I#JVu5>x&Cy79u<3j25-ehRUHwsZ}9fT;91dP)j{&>vt zOk@v>sS1wNdmzGE?nUJ&rXs8ai(Z^zNSiOtZXOVKnyL48yy2|y^pDNdZE;*Nut{Z$ zL{!o_D1Y+G{&-(X(om1m9022_dxHgZyJc_XT<6n-JA)?`WH!`i*$11e#{!=IY`Viu zQ&_!;kb5zp#Oho;-;O#Wj~|PmUuM(jCb_OY1|_PE;8HfKM9*t-tpA2o^A^r_wiuC# z(lYhi{csOFU@}H8`dAc+ACsU1SV2~wg?4F$fQyUzL-2Rr6|p8<@1Q6hHnh;4aW z;%Fkab6lR|Q6dpRV+mRz4>!w-mn@dpNU0KMJqF-#`iI|%!P}pXgC_321;|x=CL$JRUVjnj zSB0!_8;u5eyj32*J=M#5KT|oHo9I&yLXlS((Y`~JOSMEh8CgNNM_6F%P?cCvU&#G;UYVlugJlC-4|E&o-etxrfm0DBcJS(|4xA zDO#x~?%DY!cttl&PHtZJYfM%+viYS|A?45OStgL8%RWbB)daCXUo_-NT4B~-nTzAJ z@a`R%1=YRjR0FXpWDnX;?i!C#D>HU>K7Ue13nm zD&jiYS-Plr#v~uw^NQA%n4GNpMzQTuEb)yeQ^3lc%|IFU27ybuT&hiGRR}AC0kdJ9 z*&HK|Ie{HQvA4)rl+x{eWQ{!!K$q4$a;;VPSagE&Eq2mUf5LdlDy~elnDXX^)8ydP zn)}hcj|;@g2k4^{hUo&eq3TB>JJ=(y_X;&_Oow=pHz3j zU<>!dBeS%jA54W#{6>pM&L4G9gc|4F?=Qc)}|=1fRDdv-lJnw*@FC}l7;J$281s6Lgr*Ezf~?-Ej&b}4ye8|?G2 zHz8>c);o!$y`q>FMh%;+rVfp5^76RMj4KEy8~M%We%yItaDe3E%Rhgk#9qYV>SNgD z>hJK0CsfATT%FzaK(ucxo^nkQaE2 zb&Z6G(|$F2Jz7TCNsbogV$~9LF>|r99}bz}X1`(s!Q`az=K|`f{;dZMhwP_x&#-1* zUd~ymNXYOzS>eWY_OagaU4f9o%I|P&>pKkFov&p}ytO~2d7SIM7N&v)gQqfcCGBbE zURH-(G>Rnp&J|Z}b|Tv(9X^G%I`qMDnU>{O@1DFVaMw$g*OSwVMXhT<=+e)$%MLg$ zv{H?DtD|ZXYMVn)Q})vZx@`B>i*j?>w3vN;zV8)V{>%kNcfmj*CgV^7oL}Yk6k}o2 z{lg8m|8uI^{MEVK@Vb3OisiUNjoN&T+EC-wWMFS7p-0pI4>q-zD@e-|6V8%xy+Jp7 zD!*fx2Y=-J&sZy`x0hqYuOal-YJt#$2A*miYn{r?CYj`%b-Rx$y@VEN%GmVI4VK$d(5%2 zH%|#14re;+m~i^WWS2CDG9UMGz-w?`T=(si$q>!!3vl&VhTrp646aqXBeiwI#2=aKZ!U3 z7X9ug+6gZ>cm_O8H-`l@W}Rw`l<*+=U!}H*N&O+GzH!DhzRf@g(Ztl=j2!coDDJ&+ zd4d2yR90C+(OQnqZcaYO@>%lGGDJifgPlAuwex6wsB0(6Cw|nnM?zbZez=a>4BY&P za`B>bWZx%5|M=9fdCt`xYog{AS_#gN?L3)twRv?jEK;=S`9+&#(4|?#susO??$NWB z(8nCPH}g8}GR4lXywV;PFMQRDIR1W9MFHQC(?lo9GdB`W7T2U*|4VcFoSAX)Y^0+b z8!4Pxwd2WoQv^lr`*r0`K1=$a8FGU5)@jr5nCXVEM#@oqZ!<64=gA%eUDn~WSnS>^7p$71zY4zOyO5M%w$jZEtF=T>>=CYl6&@cWz# z@Y>e3wZ<7;VDX|G<$Oiul_`I=pAo2v4JFzA9Vb{8zf$n?aHl=qmAiBRsgC1Od2VsF z8N2LeiQ-GNzVZ9I@9ynHl{GQ0nsb*5*SpJ2;}%+OqFi#1N^Y)6vX%iBEQLeBmmh2a zZ8#NDjb3G+*^|7_=MXjZ^jP4kAS0RjKcpxIwCtZZ?(e+naT*nHwa%N!FV0lt;p(?~ zg2`^TP{AyV=%)^(YdD)U6aTFT)_y1$p;YH)tVc$!G2iSdYue74{}iDQld;@kkM;kk zw|%~N1=yFeS#ZnfH)e~KQG@U`_rHtlQ{YU%aC`bv4uwPEPltryAru0%H@xql=T^FQ z2Ucy5nt@q*73iIe&>)Dr{8X3uvEeowj+{QmF};Xf?GnDzheCX}_&r1KhdB4%F<3FQ zJQ@)(8p88{*4^%~S#|5aWHAJmS7N-1qA&W=&)+n(5yxZl0L(uGL1jtf+&}j7(}XIx zIOGd2NcfA;rM#<8w#B)_)mlXr1=M&>(3|Nj;l~JjR{K*Oy0SbYzb`TNKGE;s3aITQ z|BzqgJAZPR@gLg=|DRb4@{7n37kzwVFRmi}$X_NQwwtGyaDHGpNFCd=-)GS-^Kr|& z3-IT$ZSQ-haP=s{2#BKX9|Z=JqsyQntG}uJn0BdLW0Ye$e13Mj^h<~=ZjtX6v;#I^ zJ?MSujeAS1sS?7&l2V&7?e>Gqy!C7QbgU&R$tM(P7|PS{%^9v z>AzY_-4|`Ts2EAuQ7Jh?*!M3RXAHKnE3>%Ds>g#3+%@+eg4Vg|4hv0yDU$*Ie!vQ- zYnK2O$x@ia#-{iX3z%oW86W>8Vxq7|2UX`AaE4^CQO}sT3OUOnil^H|H3BTMy{GCM ze=3=GW1TDav?+bBPjM@NDG!4PGOz=gcG}*)`=R;M_3t<{%&M`-??u~dHzZz%Qddsy zG<-6WRMzo)fpZl{e_t5y#RHY`wEH#|`^u5Dx^4|8I`_j=%Hd(p%+?_PJfk*n$I!OzD~ZJEoJ!;m6~P`NaZ7y)g3>t<^5C0J+X9s2bhj( zvN(q+03_3!Cq1{iGbiEku1sb$<+$7x%A=1`+@(1E_cfCN;*$mqQF$35v_moehQE+8 zi0?p0R+3*q8gLcaeKL%FMGsBZh<@|yb+Mrx=;F0FE6%1nW7C$$?B&H9*GCQiV$OG} z7k^TG$E8=H_$+PEYyQTW-@RCv@H`l(1e~b^Evj2$((&~zyLcNpMgcpP`KDk^M6YOB zu4=jdL_KcejGqxJJx-7s?roGiH4;$aKVEq*84;%gV7Ws+^rhj;%OAMMxcD7nhKBF0 zu{*3F^B*chlBlUt^qJ{pB&WWPlpa~ca^>e#$E>v8Z{|tjhChQOW)`{YBU?qZsmfep z9iM|a*5sZO+C~qx3tANE-xDI-i13<2hK{?&*s0;1*JLIVbR4gAiPR^*VEPkccbFi-KN5!4?off_F{Hchq#yo_5O6w`riIGE|VqyEWd?7idgi${zY+( z)12O40cQd+KXv$`a7jDeiOHGD}3j{8TfyBBmn)t{|1o49dbg zl4|p1Jty+!i6@+p@h+uByrnA2%U~-buqCnd6WJycyAeiVwy{lB=7IZx!3o}lvkI5C z`Xzq$n&AU)?O!b6_z|H8xbE`Rl?BE3dQdDd>txm}Jkd1d{~_(Yq=^WK)Cfp#0z&8kY0{;aKw_Z?C?Fjvk=}b12oV91F1-^0sUg&akc1@f2G4WO zbKY|Adp~!7@&`NY%DN>W^K>vHvdhj*>M0LUtQT-^#yxpB_#(XMLI%6m#V!!w1 zn5?cfJ%Dj|pY=7lwEljY_fNv7nUI6c?Z>dLU|;fSLhdupbCnswmKG2G#1gAd)|K4O z)%xAou>9b&~>(mtFHL( z!r5M2>bZt{k7KPKJSYBS@V8g19Q0M+u4)A5m3Pa!UdlVGPpqd;m*vRM5_qTmq5m6& z4eC^fuJl-T>i_~b`*ijKbJ5zw?R(C9Hrr?gVB)IKh5s>eLI95iN-cckbJqiEb_J~; z2Z*wK4Cgw8G`tOfnTI8J{uAZTB-w4YpO@lz!2=4(IQ{Qg>46`GPV>51UPJzNehhsn zz+5GMf;*HC26}gT#V;nJXXeIrrH2P|eXFKDzrTMW)KCsQ6rW73Bo9bvSY_g`PnoIKZY5T_~=T8=UDIFAf+iAmh-hTUgqp-$rt^1652s_Ki+e!m@c9^;5=F=eNJqFr|BxxwAd(ihx4q0v2i5bZ1 zo>-}8txIBYT!9dUJAgFyO3Mes)4{&1#oA8O>^%OvbzFc zTm*w+$aZ1W8R}ME9XgUkKnFIhph3+tA~KA<3at#EZrABspLv`81N+4eL{=UtM5GP< z8LiED-gyTu@jAbaZ6Q?Vk5<@p)&1mv-ICni0ZlFVge;^b*R_|)VHxg2&~!kzedz^HvS`n^nUQ@<>; zZu_my*2HIC=kFrSya%QTT(S>d`~+6X8(!~*?p0i?o}1kqZnm6NBJ?c|Ey=q<9%)PbzHXHHez|mEe`XeL>OY=CTwvYD>-9=Y zEfHM0mq~c&?NE}@i=S7I3Cb#|XE(+Dn4;t0eP?Vu^V;Bj;(TshV|y$yXr9Za>N>|; zq;}@x)<=utUqLF-m8p&JgjMtuA5@j19VawQyHi<0oiUbc8tZ<`=JV%m+sjubR))l1 zinCoqj%>E$YbA%h#0GPrs!m9yOj!197cj-Did&&s)~>SmgXTMnK!e>anK1|W>H=^}lCe7*(`mzqb zWpUx&GtVZ_3*v>Hx2Z;@@chzFhf*s2;w~vK{C$Z5%^lzV*6i|C3^dA8uK<&NrccJBI;rO)a+otx_S zm4*IW>g}(jOOP9vDG?pf>-9qEId=Zjmai!L zz!jB}mvY&6mLi|XRkMUm^Yeb)s_9gD@N#f49;gS;ESV*Bg28&g>WS{{f4I)eObVT{ zymdn8A6A_`M>@`*p_E%zABgKT3kK_27=9F0Sh_Y8=zwX_yHvP9o$>eIVvFx_rGR^rLLEoUOvwtU!R)hMd3?(y%UYYSxPY94OGV9$$1e63;XqqXLDC%o! zlLGb`G8vLp(}aU9a^1=8D9BF`tO3or+fA4ff^BS&H_+Gd+Tag^u0KvDqK&dlo}rxY zn=KEZ;GNAzSKtT@Q5&^0=t!^jXQ+8<{d5`hTKo=*4W5@$%Rr?>jFmNNgrnf9>>hF~ z(|6Z(P3tjzw8osA_;e+AglJ+F%3=ihGm#0--CJq$et<;bN?@N*e(^m(@olcCWi!3e z^5Xls=J%1_UfAoO;c|1Op>EoWg3~o|ch|_rD@t_8n#NBB8cMSg5oX8Z(GpDhH2$Zf z103w_C*Sz01Iq2v#F2QJYbQa-TWO_O}y&yD*jxOo;0reQ&w<~l1KY#Lv(0>qh z>-5`Oxz~2c1kf?M!^;9lUv=~c9rrO3&?Rs^IOD&H-n2;yq7k7+4c%w{{u|TjL=kZy z`0%W^K1TQaT2D@iDrB&+r5v?j;qd_Jj~dRj8oIq73f~WADp4zJwasVw&D`=n z?rzPW!ig1ev1AI>jk)Tg(nJq;{7S;KdsUgbOL#;C5GOAq&y7&ui!kAOG;&dGXaAJs zbH$_fe{oEWmClO@rbjj;Oq}lp8E#88kXdY_s4P8hlG`F}HfbyQsTVNHG{M+xjnd3V z?V1zj!e*O}JJqK5bB$hnt*sZDhEx2x9eN+VD^>g{zGgP!5W{fP^rMd#Ixyqax2T+K z+ua7s7D+%7nsmzt4-NQoMM>4du zJ=ek6u`<|G@55pS2PJ<*K7NKdlaE1aZT@KSEf!v}k#EQj={^{tD0Jd9=BEW$bKs|- z<+{qgqeHjOx#%5i&Z}wygnD?92EhM8DHd7(8=CnAP%3b}R{f3N9K{E|y)MHpi@zmz z@t?zwld1L0WXTy^l%a(+_|m_=e0un07!}Br7`E`82|S3S?B+R<3eGj!cZI2w?fZ;P zB^JC${ra5Ul;Z$D6<;GtplxR)g88rGa&e>d@prQ`hJZe1tme@t;*=k;f3t)8zJ*_(9aGQSD zkUs@Em_YrPLJuujqi@Rd=M1JhjK?M)IKGKX7-2=-AK5!EeV<8F=dM|QWOr#-9`Ct9 z3Mb6HRn6GJ8#W}MoKn)iK2eJHcX$W zCaDwmBV$hM#Wyxf>`P<_ujxC-)%cf2Uin3j&W^e5Md*y8bcwZTBYU1~U}@L89aW+T zbz=QI&wb#K>tAXRuK3wdqj`SoBpM`ynf~DUap(BvrPBK;v+UQ-Iv9U2C;5nWa^|v5 z=s*2SQ5RV+8P$0^X68{RE-pBQBo%T_kRs;QGE0`yHn2PJz}QYH{dby~`MgD1rq83R{ha5+E);@3e@MmUBVXVTI5RiR;6N2`{JXq`!hd~# zj{-dy??B8F`p$Jkp?!`|H=-PzgdGbGCU#boYY(4b2bxma!^sUB65Lmu1{Mpt~AG+ zJ;;<6Ad#EqlIRzA`S<`KvJn1|KE%I8JC*gsVJ8+JC1R+4p{im^q6L?(Z(nm1D0pdP z=2>(f4lS=pm<<**m>lY+oEM~2-F-xuX?vc>6%^7bxlC0O7|kln4|yPcKDK zKp1gofheQcM0CS}Mb(2?5io40g%RZD=DVnqvbREgV-&cXY1Ucq+iOGZq$_sC-SJPc|_QIkCv5F83*A|Y{}6FJ!#VQOU)wE?N>W(?f?l?{Q8<~S7dH~S5! z&Abu6x*Xnh%4fDZ#bI^#;czbLvi4^#6KvGX_SY18xw$qz1hnh^p5=!BVK<{^ag5wg zfyrm5Uctl;pnja__|8BIo@@T6k(X_{N_2IUF(q*1BILGjjpsX&9<>wU)y`_VrO2zE zn1Uk9-+htSLM%navJJHQOCG))|C*v{AGj9puAx@_*yyENeXWo2wHcKx2W^$H-u#+F zlCWTULbH&6iZ=PS0zoZGm^ z5elalT!jywq*5J`NiIwyDrx#pvph=VHGV#U2+mxp-QytfpMOgnsJ&UFO&O}0>2w#l zx%?h4TkkU>lWbHfUhz~aU>WfzZqa&0n_>H_C-1YJ#u-QKp*r-h-hTM)GXb}B7FmCX zr9eBnd;6D9*vyF^Z7(OWL%QoBz4#a1^~wWPETjN-(FB=29*Nu;BAd5dd6c{Yl|DEk zekN-j65*hcK$#z^iOn%6dipH1dT5CTZ1)2`r|Sa*rBPJuav33cpR-w87xn7$QKv=% zKuHCgoCTP1s`Yh2l|)VWSYDFv^2yGDH~i8+dJZZYu50aiN*JFuTUvg{^0}5M$bSCS zyRc^QTxu9u&|=Bwu$9*pMnP1+tX;=+EsA>l`U1Er&~e3`ugT)-{c&SQTv^&+edfSe zhk1N(vCRF7B3(l;u9F|5eI z)~#aEjf+kckHV$h#z68aL^;_dQIM4K zw3qIB>Q_Lgn;zfClc|AUeRKMsm?He0>v1e3J9W%<8*ee!;WhR1B6mc@_)I$P$edggaT3-OgM+yQLQ5R_Ij6$p=i?k{5z^k|#llFVFcoh6I zQbB>kcHM(fS9;x4KO)jp>)0i-d$m&!hU%q#$mDdIghHK1LB;Qd@S_1sx!J>Mqh4X= zo3AA(IFmXE472mD_q!AOw3IKg51Z(^v5&vxx4%;(1@0%t!=%0Niy4gq?C|hA7t&$l zJhc)&BAvIOU!$J%y_=fp@X(&P>0T}@%w9uTKfC%c9;N0Zyz#ZGXbW3yt-Q>#MzvfHzz44amqbr2ots~tiZYY)hlaSRewHF;d;p{a`R_ij5k&%+s# z+jP&&xmzRQ1z5AwWgSx`^1?{>lV*QrQR?*)&#YpU)UwI_ZvX0%Zp)no_l1x5+iONg zV;nLHW)fF-rJw`&wY@8ozZxl=UD)+fa9*R;c2QToC$%`OU2iNeRTg{Z6WiDeu0vV7 z*#lSy>URB*It6%L&yFg}QaZbFlQd5ujoPHC6ZFqk05bTUqw81A!Lcavq|TR^w1gB+ z1>KXHg_y-B*x^NSZ1u;UOw1KxEDNLDwQ1qWhx!t;e#0$Y&HhGGhA^$k(L20L(qsjf zkcIVU=8qZIQilhtyh&>PGfryV&Lvd8n(i_LVuz?bgtsp^VvM7}X@ju6>f7-g%(a-! z;h(tQy8|g2uHPLVoaKE6`eSsjMNvJrYqeIGTTxly7i&aV0<=1kUp>q{CO2g=P$wR@ z^hf22w1W!Su1=(+&M>l?^Q9qE8dgBGu_{#_`7X+_0wB4Y6vsI2CAw)T4EV=4pAMOv zzQAKsy9qBPDFvmXi`F-+8dgjB5jl=(X2c$Epcvw$RY6W&=h>dAizzY@xoM?Axv5u4ixX#5L^b$9-4zY1)=t{UoLOYsP2FhB0``=_K2r;)G2i05|09Fg=G} zc32J14M1z9p{Cx83I^+C*|jqjF&ZomEdF$l?HIVP8CjuAjmEJ+Uf1JWkVSJrD+&*~ zODE!Yik9=dsg4L}4dtzjRh6t8K+T2^oGIN|gEQ#;@wkQggQ!DZ?T-@QD*?$)9!}+8o2b+l_14_25KTa{eC$fS`4|h`ZGK9TKQc^T+X$nm z_A(-uvNy)1Z1H&=>{Z=>nu-~UbBCA1i!^sA;XA3R}fal|gX) z|k66i$oxjm5(yd7Gc&wnVL^ChX_=&TRsj@I0!Q=SLb{A+R>V);j>Pcv7JAUDOhc>|P(~>0wK+y=-BW zsaGG!NI0Gab)1QlG+UnqKk9?E#Tw6;tMYH60w~gU=93ZRJc{M;fkPp2sLw3SX&>Gu z-AXBe6QOd6KSb#3{A^ZET@G}Wru^me0LS5>_%r7rV3@sbS2I|-(aMwD5V%BC(Q;2h zUMVS9CwkBYM2Lf!nDotvhQhaStuQaxqd&efDeYt?Ae4i78ZZbz@)_O)420(!qgk*eaEU#4PWC4KjI#Kzvl z1~;c!teWIyCgFXe-p4&scsiEEX*XE$d4X-V@9Yb?6Vo-%H}la5IqavNvAvM~${Rwd zkJwUjzr95B0|UJ5fk7ZlgjN#F7>2gv?`iz`z2x+Z=~2EXgxZmDjj1%#TSAEzJ~V0~ zSRAicRQH+vcYFq`1`c@%xA}*Nft8|~N#cwp8#SK$*4gcM3rm~W1kcZqvOKqK(DDe~ zF2+E@<11Fo*}}GSzb8#{x!7+wkr&4T7OY?j6*n`+mpsJH)UC^EZR5OIR;6(cs05Er ztG?I$2^TyV?3IWI}I3l*N(b51_9A8bE5Qw5sUI2OFnk5BH<8%v?K`b>D7+0E-6X5k+Ol$%I=P zg|bs39F|p=1AH#+T3fwtIA}^W!q*N4r;VXOzN;S~Zx{e(kY5HfN~PBL_t+CERC>{{2T-5G5Lyry)*;DQHRY-u zw`xf~)uyNOW!y(-$PaevWp>W9LxS;#sv#1eXIyZ$MM}c6{i$qN|3=xw%eCWsq54$Q z7jr4wl*EI@8^`D@j0H4lkJ5*Pkbz`;1nlIa*cE8j8pogW7t?F31*bs6*4KJ(Pg#lD zzh5b3O`%fg>0V-93qgP;|t z6^iHq-zIv}>6MM%f7S_%Mqa{>Gzjr=_~ z@CabN9@RSp(k^utYioQVk!kMZLkZ6+qb9q@MalT>?i%^$VlJ0qO2v!2%yqLwxdxtJ ze+SH3BsHzR8U@FkWs*M*yyCZpDm*DKWL?Ahg6+@lg5jxFf^ksh z>_a#;;E(1L^&sO*G8mZ;3#1}y^9qk4TYY}X70HU%VbvX)HW>*ep5 zwn%X)H^&$M28T|0Jg&++`Ka(>6 zI8zGGyT5)LcGya}5wKP04788Xkt6HIg6sd2rTIV2FN-oQ9ZqP51o)%*l{XYOk2D3l zgR|ep0n(5IC?ifBZvKFV+z-+|To5`#$H+{0hdHsp5c1&*T-AR*NJw;*JDpJQU%S`h z81PePoc5iIfV%=9hu&`(G@wbmSejn|M-fe(Q-4x$<5u1!EEJE`O%j_~gW&SGRBexs z`70A+X^&UrKB_(Hc=^T5%?w}-ulqT^qe}E!yt|KMN}srHHSW2+Hd7}Ang<>S3_LCj8o-Rnb)}eb z0HSsMYg%eYet|DoOm9+(`uDHC4hGf^h)X@}`*pA7B8k3S`hP>O(gABN!9O;=o6SE6 zu>J>9EgNAN zrMw96-sM%5CCu7k+n#B??`Q1)YW-UFDY|F{-AOxuQ;KMtiHuDJr5Bl8spEGh_fc90 z_6-Gg*N4cPQR(N4ct9q=dD-cGLfvLFqTNxPdawHtT$(uVXm*!2FbjXU3a56czTh>L za5d8@qQN#hMYU!AJfIClNR{9;Bk8H#{16gHKj@d*CUbxDUer<_v9oSu4IQvmEC8Zy zpxelWZD`b9)1R+fE$BKX1qn{-_RP7`Z%xsjn0q?*dFRF^eO$zNCE+pVktE_OlP-8L z-F;n#Mo&BVk?2}Ccm^2%3yBI13V8+DsvzW)OjQ(gx=4xe=J88C))g5lZdxc8KO|R0 zc4sl(ES!{J%iIL=m}20|#ha5S3aH6AI0YdTqCZh+01b_m3G+}oPF_PJWJ!3mjGMdc z+&T;VAR(scl7h76#LN?C$M0C*g?{7{EmJ^)q=IJm-_dq_`H}F)2tNW_nKjTk)?Pk{ zuR^^i*{?U&nsAc)vvoi7yL)k)CQ(Vjq)~RSzNL-5>7w&CUh!4P%pT zTt5v{%ux0gaAS*fC9Xmo!oE+9JQv~?Ytl99iLXSnL z4_e5@8H3=s?wK6#vYJ|XQ;k2*j${`~juHOGOqFJ(@Q<-xqwbejk3?~V_+y)!MQ7Lp zwH&ZzZFRIq(*Z9Iu#A<`ssR|GNQ{v)Y_+ZCy8u(GzN}wm86|&Cbt~BfVOXT&&$X5r1&(K7O8IW1?5yWE;!N3H6yICH zj7Zo>RM#fRD$pE0kEsbILS#UD(m@A%h5_~sH%s6(dmYij-$3L<$>2lMPhjdE1@SwD zia(@a*nuP`<)1Q5Y3}d%bVpF$$kE;xJ{?N95nX>CuQU($BF3jrXxB7x$YZ2L>0Kfo z#dPMp2~=61#x6-rspoC$U?d_#059UZ!X$Iy>MLKP>#l-B7W#L zn!fW_wm1pw3O_%90!MBZTshqAhFSs;+WL+i2g5HAR?(PN9MkIwYB_D)Ju11z7UQz* zo`f;2Fi%-=ubr+*;`qTuG6z!X!uOZ){ZyOZQOm@4$R8U!1E^RI(7*@kq8oQb3w0o- z;Y}9YnL%B7$~MoDp=vFjMnqdss=8^b=umy=Q%=;4UcGc){WhF2Svg`h3qG@Yd2D09 z?eY1Q%sc0QG`g2P(_y3RcEf4nCxBz%DPLp^ydGlLi{P~foU2@`kdlKnVujtqKj19C zE@)18lDRYdeHMj*=a94AOx7`RL?)zd7yQ}E3_=`XbRQ|6#^nZd){|Ynny{)`|`CSC`X-VUB2I@!l z#d^ERn2(UzU-7lp5>`fWS#~TV#j^zL;!dET>r_`#jgFr+?f1qMz0Yj(flAd{f;I}b zhaD4|eBPVf?K2A~${MD7e%2lD*i!rt_S=hm6#Olg@zORoZHFCA#;x=9K#YOW9$t2| zYKV#QV;UecqALL4a$9ecr+lF2)vc<0@>3a~w<$Nv!X7KX?dtC~v!DYY03a#h8R4qR_x$G0!~T44|43QK7>!8!T|lVr7OD2T zagwbKR=XORl3F-rHX*)-*!xy{D%-@7G_Za-#rfI`6vXk#-9Q7Rfrv3_pj7-?Qd(%! zfdMQcZdEgDlsZt3JRn@BW)-v#o`i-#EmLk z)@Wbwt!4P0veVoFAjqHm(8c$E$?l8#U9c<<^4}~U0L8mxk$*A#q#e0x{tSUQF@F`b0v@7!;5MpHqq_#|u>S<0 z|M#fERPA45h0gy0iYi0f2t@43vbhb z{uF3^>+OVQQ=PJ=Bh$hV94Sc}Gs*W~fsn4%D@NChmNf6ag_vE50Nr0v1$0Y5E3B`C z9~rZ!4qvc5_bEkcuS>f<`0a&>5ud298f?}0{+#-s%Cte19O0hzKfHh7vo60Di#*ZP zs8*e%SM<8YgbMKPQ>I#(8g~c48a^@M*1`uk7YeDJ4}Rm%@f_SZZ1`KlJicGzgKzgj zhphJvkzF~>h$-Q#5*hL7kyPX@6A(;nEk|P_PBNx%GhRcjO3HR%-@)--zrDFekMW|x zkXhH_b4*EX$AIj8!@Gd~KL}zWqzEq@(j3tAMP*uu?sfgDNj-LF{@f0o%CxbO4}Mc)|OlW}L2hV9+oB6Y?@? zt7RWkVmbn!j>7OIZROsBl<3ZM=%&o3RGdb??S4Z>({6tGj z1w}&W>Fw^0C{Vr67qExMl2jd}*#iK2WLrc;*#I=@N(H@KQL^+lU}k^270icMW(kU z_U`LuM2z*UY435kpMy=jTI$mNUOA;0I)O~P=Vn1FmvXfYcvbVZ_%h z3TL=v>#IX5-m}s{l(_`V?Xsy*>a!`qo2uC1k)CpR1I5-{hOo8h80d0H2_i<7R0+12 zXME##a&w<+B({CAyWgt3DdTsr9}$W|HbNIltuNG!dq$}Dcfr@TxT+%7Uy83jJhupr zmXCR~IeSiVLenp21{mMDrhh$f!c*1k|UHy@Rg3VmBIsV^f+nioz z-OI5XwUipFg$uD!49FqZm-I;J$HShOUO#RTL*fxI$r7~tGj!+ZOvaIYh;1sJfS{&QHVSlNtd+#j6F3yQZ zAmrbS|E`}*(o0z$4*4Y&1^4XTdU|brcQe@vL{_WT`HfAL5@x$>yTvsNM_6Ae4?t*b zUDe;NXDdv9D0)eGdCDZ4W3xIVAw6o~?kTY^v(L2dO=M3=Ctq)~Rq-E6&t<9c9u>xh z2|kax#o!nuC)V1a*{$z@y;A8hufjAmlM~*fZ+mm>yDY?qU4Hn+^!lt9yIO~h%5Jp| zM|ew3UK;#mgYxHLswg0fmMj%XJl@Po*znI_^{D1MEW`Ci`bE|qKgu*7mB3H76vd$x zAB*byD!fd}Q|7)iK}QFcR(&e>d{WEs6d*#WQ>ZFtS1baw2v*|cSoCilA1i`qm_uyskO>(Z;B`xS4i(kLNrre_k7Rbw zQ~B)KVpp>g@%5MIzAoVva?Vw-07=iUAxZ}O_+miy9~tvxl&s<)@ewun1}kBfaI9$c z^WMyEFt+ZB*1(4aF!(n#4C{@A>$g~Xub zDpWeuFG)QrVaef=(WQx{x4Qf&tQ+I;`sbP%^%)RTbp>M(SsuQN`mjkWG@Kw9xrCkI z{$cos5Wr?MvRqlYd4jIzMHq?4gFRpM%5m6>Q+dvAvfn(6HdDi&zw}sIQPB_6r1lrlxmqV9L1&<)8np>pV(iix$Dx{bw5@i-yy!C9y#m5HJBWwuQ#Xm1#B^H z8EIC5{eiLJ2y!&0;j_8DHf2`~XYc(5Fqf7M)tN(v&(U?;*pqmuL*Bq?2VE#t2Gp7! z`NeJ`*M-t8Q(~|5b@oEGIXF(IC4v9iA(9sR3w1aVI(VVv<-lVk9#p|bXp`ouxIWBB zpX%f@WflEXQmF>_h&!*BEA9Lg>w}r&tIgwRDC9lEOnG(3f(p5;wusX#^uV`O*qZ|! zd<^fM0O89E$HHnRz1w!PCiU*4UYSnJjr)_?+Q01@$dq1=cR%j8iF$R*#jAAhd0%UE zzj%rGU{xB!i7AL6O1^(jbV3psKf5w*H(9*?tB-zj|JAic!ybnnuQgjg^lpf#8JiYX zI&P>4TM*bRzv^2AXys|NzJ8l$NV;hL=O4ut8&oWDQY1NhnYG?Bo zeP24WXr1+5pRyZLfE;+yg=%y>%j+vZsyhSFDSkxg+%FJWst_jCdMk|6TXWi-s$Dh6 z7@huRLjy|k(mbnjik!vXXk^*qt?Xcy*`)2N(s+)IR=qwogsFF5Dy(}3%Sh$hzLIlZ z2GkpxQj@0(!`5H6M)&oPiTrNzVh6ur!G1vgpeK}0ZU$gIBy^!WyU!%d6rDsSlO3_^ zU7&2r$PWK`8P^)`NH5uxz5Ry@unC{vggnE@2hTrpVmziO{VXDHh}1bQ70202@E_~Uf1)BmqI#y8UdBG~nS3K54#yfmQw7DEAHdgaHQ;;F%7PV8*t z*@3+jkY#Jwq03Lo%aSk}F9OREf)KYV%4j4U_+WDUzbr$skHh4~v@+xxcsX}Zc6Q)b zRbZs5h+_n&A8UCI0e^on07ta*zx?_8)Cb3#_)|88hp4k?9N#vhho<8G#v z_LmT4&UWMC#7hMnuAE46J>SOi#S;g;RRkgcu)h|wwI|uZVp7mLGw-%Rv}+?0`HMn6 z$~SeN7q#kS>AK#+oC+R!7QEs7?FV424u^vJ*Uix2s&76Ip3|H%GgLv;HSuO@qiev( z{iR_by7r7Q?dh!=hVadawL-jPPyFDnBW<7HO53rkg8;D((81=*&Qa3lVS`n5iEu3S znQCHi69#cp#Tyvo$CIBAa??h3Oo)POr}Q1+R|8SHi`fJP{bFZ$QID|{7t!y!KPt`5 zG=db6!YE3ycI=q)JJfQLIDOOHPXmjo1VkztQ|J^|ELWNp#c01aROoa3xs1f`6^HN* zYMpXA4Ol9aDG7lv7O|wYR;sEO37TLbWNwR2I|Qhd*ls zdFI$9dVCgaoP`cMKAe_1Uqsw67Wo|hne}-|n%EuqBfdqKcdL|g)8aqd9lDNoclsY} z!K5(t*YHGcaqE$#$!+iS(C=<%WN=Z-fV0bj$q+bQ*Rm)7f^e4@7!N_?2;_y6D3SS5`Zx!(ia^y?V=Cs%Tj* zt)Z0_xlsowA=7{oG9-tpHzt}EuF9|0M{@JBTI>ds<-U1 zjpYKK0>GW_W{*Zu7D>VT&2b~o5NKC5=}P!30tJYWcwTfEWKh=o2dD0eZmvSb5qwg= z1}q=?8R92~qtqvz9<^^_6L(C)GEy(n3lYQkcjX65fLAZq6fmNB#~P)G&W(J=Jn=>H zII#jmMn9NFRB~E+2kC7DLK{5umTlWHaVo_{*&c_TXDIGZB6Ksrlf_iJ3 z=z4wdV{~0850j23N1_a4Zm(|e`Z(sI1>m7%GXnG_Gc?k3@4yR0Xx+$(g|&v;uOia9 z%@eB5+#zAmK$yd3?Z>+#*JF8BVmY2U6mzkaIOI5PN83OmS=)8}5}26Kfe}-+Ce&zNtYS@{RtH&tJVeS--H8r&ZVCzU?5b7`f&ayvx#BH<7rR$Ymb5!?h29c|J7dA3$JS~3)vI0hQ zL-F@x&<=4dOItx}RRf4Yl*%Fsm4NX;KmJ?n?ZG;sTFt$GbFurG0jc zx{|W?OwXc5Mr>&S3nbC+i?Znt<2cRC4!P+1< zuTadQlxwKIRQk0paF%WtJi9u{+_B&APRB@0>Dmec;u2XDO8qKbD$2{Vf)L=@uv;mD zry;<+GrA4%1bqL@u0n&qWLAPp!A#u|x@b+2dN}yz7ieqp@-bV0Q)h!w05t<)371oH z;Tw>EMMQMq_%U&^_V=8X0P0z8<^OWvEv<5Vn|_M!{{HVcNix3uzd7%ZVlNF(YExG1 zK-9&4*Z~AZD>s23kn4Kagy7!0+S7oEK_`%uvx@dc%?~y!S5uUp8HxagLouAE9|A!X z&@TV!MIh3*_yyOYauGvqjLEVvy?YwxEg*OCM7ud>U1Ca(ZFzfh2xd@8u<&2WeTfOl%c_I8$Cm z?JVAQNldRgNn)lKJv>-vwv?2Hg`q1{|vyn2(h1TzWoT)X|zQrr(c zgz6KXm;L%YWgZ>!2E7<>eC+c>} zh43|a{zf9sK0vF^)oxkAUvW@BhWZirhObd{MsrN2GE9E*!{uhOjgIrVpi{p7we$%9 zs=keL732ZI5wvjXIt1$O^_b~ssBeq~*lPW?!_~6NI>t;>y z=nwD)&GEYb)cXP~XN2u)7Ce`0unzIZM>s8hLWYsIHs54W+ritlLC&7=(%Yx^qPHqp zH~kl#c8yHA8nD{gK#csD&~rqIDf_$?1d6AUK{Ax9TrltY{?!Q;(pW1&*8#GRYtT!K zG37mJR-6qM8h0Ruyb|VnE@6v7ww8Z3>(i+l^iMesop~Z^FO@Rmcr=-JTMo}Ld|NYW zpc+|Q-#WlFPYp|dh{LI8i#%VyvJ|voyfPs=q8cuAkVUv)C4R3&v`Ai3pWBQ;yICuv z>TewRbTH7Vj@|%>9}~v8I!|j~>^ z(0!&*aoaUb8KgTpy6yAc_35;Z5Tuq~V5P}IVdJ>-iu?<*<_ld|g-pVC%AMZg3+3)8 z<1N3WHzl_PE$<(mwt77R#6hIcuV#JtwR|teJIdk)U{4T7gy>q6Rw&Eb)SV90LHBny zWWohtuCuB}N%Rly4-o!ugJ!^nIks{|&ZUiOHw}B_KUFVa-rbU?X9dp2In4BYt zzZQnF&W(JLsPR0EY*8LXc{Us(K4z%>AjpJ+1CwIhX}x||K0pLE69!va)a^d&Y@e23#T>KZOt)#9OVJ8$1y6O%^I1j9eS~s7x$%*GevN-}k6??AKja<%gNG z0$$30osx*xCO1nPlbCrv6S}(yA*)AXu=y}}@EQ;x7O5uc_f|GcZ6*+1#>Y^Uv)MHJ zVY0JQNVyADvU^XaXbsK9oi~%ii%wwbs&jrkUeVoPZf21qBQ`8>h10g_@v!;#cCtBe zvbhm4JjhSTc|+)b_WNU_cOpAM+pO$<`C$5u(lqMxm7QL9X;8z>6g$ghfJa$`3Fy)O z5X26E^yyhEK?jkfS&jEg%cx<^f}AmxU1fRbabXiMu^r*8dLBe$7}+`D7xE;*Tm}^H zFBP3>+L_D0dd~jm8bc9rxn}O@fChRGMB}}Z`wkp?Oii?^m2m*|eD{VVUPv~m;9g!t z9!u}gkxWzwrA`3q$9!RZ5kW@%p20)WRn0ded&AcY;qhd13e}(y5jRASt_yx8q9e*~ z<1O8E30yU$BT)M_?99=FKl`FcV->~u8@qZXKEM3{dN90QGzw~bw&pzylhub2hNLh) z&m9CjPdfSV4X03woUwLO?26{kznVM~1YOip(MmU$0@e5nHtP-Yp|8Mv#zd9y(Bno( z%No3&^CJK}96*_X*O^`exVxJTypRz-`So|}3MA6n#i^WCC+qF;FlE0qk1kOJb=CcH z1Fm1qY%*I3@aU%1wXU@nF`HhBt1A}JsQkPN8zRa7h)2aHsFZDB}&z%og?y$ zNYki0F>dNa1mG?J;@#VFC=?*NsX9SChFwJTC#x)|ggrBmX6Gik&pFg~=-Bv{X_P=k zuH@Y;FSByn8EPU<=BSH4T%wACnuqS%0!3Uw&L&Z>}3@y%mfbLFq~XG)!l~BA`Pn#s(b|7rt4f@FOB_S#;>hh^T8h)ldF}Xom1- zHE1EW?6w5HNq=JcnGrN3kcpn9wJv6MLuG+(y46=bphMp|DjDmJ0TWoS( zz;z&O_3%(yZXl!Hx3Z8zWriUTP{tFyiJ}b+L4@al_zct9PdG;O;rto$@^er`e!Baz zKa_Q4neNPBP&?miBip1SS`<|MDy(he^RjdbP8ZsM?-5sBP3@3rDjed+%FzLsd|0^Mn@YtH?kY}d0*iChyn+Ik9n!4g8Cq6*%$DosC>;fmG zH)BenUX2u8Ku% zrp3>-Agf%a94;nC?B2^?#n1n<0W%_+tI`~pq=&nFsvhV6kJ8>Vtf{u^7R6o=Q4tYo z7OFHA0jYUJK#GX;UX|XZgdP=XB1P#n(o2BQdx(O7fDn2W@(5BwfCveM1d^N;eBbx` z_IK@l&anu5m{YYjy7EF_D%jjvHp%z zG;>JuwE~w`jSSzcnhdo?JZQFJ@uDJrk|)KGIY^~I9>j4Ee2VnsWIPLmISb>qgAF@u2tjN=R0Tgsue>AvI zHMOodYEmV}-$JU#$k4->DU!c9Jb;!0NU934R<~UjEZpn!+_X;SN^(lm(XEFA{Q~YL z>C9D%fVgdlEU+;qCD`r&gH15fKT!C^IN7MGrf?OSGa;jbH3xO%c7=`nq4)9uQM-X! zC|hitOjQru*ct{%RTX&<`oCcZ%67CbEa6e=4TRDF#nIV}Bou0~F}rE)?|*Oa_j2e5iXw$2$|s8V8F^Wl zmuq*~&*JxbzcW>)0O!z$PE#Pq{oM(*APaQ9niT(PLeHH6#3{)RW3{Q1r#?}$@aEQ3 zD%3_hanJ%V7f7N$0=qmK($f`xwk1D)D7h7K*+AQ z1|}@{*%JC3EyrXe-w0s%++eF#l8|ERc#)TM*ZiDhtd8Zizi4!I=;KMG9-H6A!+)F- z0XC_mZuT)_-eKZN?4KC0{71kXd8n)TeB7j&dPF4tAL*TifBlP_(19sNw@|jZH~@vp zkbwL7Wl!@(+>g*ftp_gx02zwH_t3qOL-nD5L=h18E}OVe7~!L1@An(u?1toSNJBbO z0GR9*wO0-VaIw;VrkYl%w)A98m2Kku8!e}B<|oA>AM$^ z2@-E}h$ttsC*`*N!+ruxo-7h2w@0Em*OQp}6~^x6pPjl6pk*Nokr99{SKRjGX{?TA z^)+tte6E-1)?bkZ%EJ;S588H%rk%mnehwoRp@lK*Pv^gqbKBF589cF3-=*}E#T z@CvURqcO?un_OFBlX83q+*YOn-<*B~JN~H9(&(vP#tNuXJ zd8x@T+(($Bdiu7xoN!NO4$m~=Ly8h&XS?=5U9^IEQcqnx`4&%BsUUYa+~@b!*^s`; zd+Aw`4JPUNjskvHouW;bb1|E5>zIK&)EWa=H}y%BabyG>yq(U6I8krvM&)?i$vl=2 za8Ly3#P9Cl_Wm%cl^59~gMFSd)k{jT@`=VZPoML!th?pQACeNH64U=}#BAD?RHR-X zcx+RUjD_NY_a$RCq8_uJNg3H?nZ#EXu2|s5{K%6WeP{SGeKG}D(x%R-d(4d92WVc` z>R)Pz#;aA^ZIy6(eET6{gk?Ru1m-kqQGZ_6&-`#rG+TTB;r-;I>64te-`jy!-+SHfjfUs{x9{``qd7oMF1qXy&fY@_r~PRsAg|6*0QRquAjsEo{TL=?@62k(Rd zheTMS|wKQ--4rGO{#Q)w4-0yFoRNp3tQ zQhk5+=dOX{=mml5X#1Y8+RhuytuF>I^xu^ksF`u*{Os}4jKiGKt)Q?zZgS!L4WV4v zyas7}u`KG@(k-zZ?d+0Kg-3CXrlE^LWnVB4S=*I#ea#wwuDNrv;?Lt3W&HR8`>r zhPMB2!TtYW8KkFB>n-`#EEz^a4ZeRAM9lbHHVig*0RXSpD**yw={0mX!+n&MTy4*(#C1s}9IxTgSS^kKqtsf~MH>ejzn0Ltg_ zgP~Ya-u_4|8*t2D>C)ZtuxS`gO_sj?d~T)|U`t>tAP&1(JIMl}cg$iBDG48Bw(6;5 zf$qI23Yy@;XtUzWXLRdkPSLvirv}L;E-TsJN1Nx#jjR38S$Zx|XM&)rFR+1#n1SF| zy_Yv?IQ_~CCx=LkOy8C%u*Tvy`{2NFd#iS>$(;yO=M8p$^LxoE_l~Ga8735dEBkK! zGj4M}W~A-RQ#v;j2ySk47FCNj0KOe|NFjk8@Tjo>?L-24L;m+qO3gOVbIaK`)1>jD zq}yjiUb($X_i83iET{z!d)MA17TmYR%ZVw8gm zz(No1jJXhZ3NgE@-nuRjCU3hg?A_+jjY6YfOm+K#_qK3LAi@Y+kp%j!NH3{oy8*)D zYTW%j_5&Z|uCl_(gaa+{vY}UPnFdbUtXm}oX3Kr37$(2~f<4eYqDXL5($#M8+6BW$ zv8(7|0>B}ll#q=ym|u{=GzxN8`)&8{HOH&6pBTnOq`ruwW`SGdXZX%L=_MtlR7p8M_R-U;KY{*rQ8FV zO}cSNl?Bkvb%pZd-1L1kTeKdHxO_uq1ff36n9*kD*6a;t^loj;r;h}abUj2KQ-p&m z6ta7k` z7$UYoG>&qJA8BybW}I8+8(bBiifYTl0ZoT#`uRoHHF0`Y60k6(<{Nq$# zc%dH|xJab6tibF~S-+!%O&;6>E}?HyMrE~BZs&CtZ>ht5aY5Rko(1FQYmBF&%Xo12 zf%^3?+OKSAYpU2U532lOkDjoRRQrMGNBz^G9}@_z!ZB_rgal`YBc*jw8q)j&SO_~a6+NbR_w2uUY{=IMqUfe48jSE<+?;2P55)!-~e$g$`AZSr^|8w@p_Ev;ZZ>EnlTkwt+!3;RA^0g1{ zq*6n6MuTl5X1+3u&HX|N5LpQ85GiDo)swBCV4X~0{@>Fyx3%)gP*zRad)?(fuxxrf zkHuDWN^$6mOQ0VvP%!Cs5m|bWa$^|OS&q#!gcA{SL6yIhX;=I$QB`Na$T)AnW zG{!RH<95i(}m*`~7At6XF zK=#@~6{5EU|I>_rIB;rjO}Y$E_0`(X8Q>8-TI%*J7-eWwF=^ATqk!a&htPI`R?U8W zZD_r~hR6B?V&p-KO9;x0`1&QH`maQEU9D-TFmg$7(pRYsdKtd;s;p9F%U^Djd zmUB3G8mtofyuvN5S9{f^2-;r%MORN^(l&RxL?p*~)$eG7dP((04p?Y{{95{2`ga@oP>dA>=?a+oCJSX+H!|NGe9gTRl)Y#>YatpTlKs`h? zxVEWf3TryEC;=hN+h}$k6xC&QP#OZ;Qg%b~VU~~fL+5?Xi)p{5J%TYtkYAJ6oQc)B zn3JWp7jelz2{px?QUPHQ1_Z=^14_B8uTQjRhxaG~zaal#f=*fl6hib9q4=QlDvWdL z>7R=3XxeV8LMB_MIr0KJwdUFye*eokKTF`fvETsj2DRPiZJQ}LP|DDuL+ehcFL72} zJOOvLF&5?ZKEPWsb?xdQ0~_8*&7St2n9SIFIDa7HKSS(FM6C{~Oe$Y|?g<3${WIfd zoBek-XH$8$gnOVeO%+BC*Kxg^`;yH?3KQf4zL-%^`ny}%Q6SGH`>oh=;L25!Kq>GG z`dygihH=NaBWrXfYOoH;mTT=&fkU4`V zs{>8R#l_L7ORh(w+W`((z9n+i@GG`0tI4a32!xeFMimOj>RV^2@C(i}5l4%HC$EN` z!}9sEH*4smC?VPJ1k;@}x1AHzjCG*x(osku)%W~^{nUhh~9Cqb={vZjDXsSmkv(IwK!$5zyA4=InhSF>rsQ~>abKHu$z6@>hrN1S*|5O}q z^PIE|pWmY(#oEN|AEvEQ|Io@9I8cEYG#)okjM2sg@e#V`*5t(Z#>W?~E#7SKw2VVY z7|F=Ndm2x7$p5df7JrsJBqXGW%AxF*v1dyDfN6=NdtFTN0!D67OPgF`A0%#=#-K3nA3OR0^Fr?|Kh#U|>xHXFiQzd&{Sg zJLJ6`jXH(b32ALxdEpnZKF-?}E?VXxQ`Tb$Ky6;;Z?KowI{0YX@e1~-bC#hl6RDCm znWh-S!IH`AwS}<0!94+MgoqSFEpH8H>YD&qw3R)tI|?3fs<; zEI$lBUmy(yC2m`Qga&wmbexH5g;}NupsVz|r!dHuEdN53Kw>1P7PN|Gi=6CRszW*a zN)OvUu%>JG7cuCTCwpRXMww`F+XAsndLFofgpm-o6TXvVs@eM7CwxQVkeFdW>fiUK zj=D@Pe#X`Xn^!PS*u{|9q$D>=b9kUgA0ELo#)?M}dpVNQ#SpP!>k*Ct;W(;^gzI)4 zyWQUxfdv>24y)3X8cQ)n1#{O_)SVWP3$0?Qvqnogh&;9CENA-t3UV4bG#V^{Ewqsa zBXY7e7E5*UTOTN4N4)=fl)M^r3j=LJ)8#QUw?AO!4m%?iKVi_#62jJw_QiJE_RwNE zwsMEksK0}<AL3aS5i%DgyvQDgIYZ%DqUg=XN+fzOXq8UTJjL>vNDe`O~Z zS9L}M76PV!{h@#{NI|Q2v@5!+vKvI=ZxXI)IiY4Pllq>!oUs|j0!sf4HSv#QB>*G6 zg$a!-uR|()y4IR&(jr$$Cbj)JG`;#gdGm09uP{sMF44nc@*=I~b~k^_Xs^&rLj|&hY@Y3e=2MyFcSI%G4BNBZ2NeP`-TbIzXR9$0CamTbz
  • g0|_+Ak((J)znYH{zqSC)~PslaB?%d5-ah{)(Bc6$cCLvZs3=PSQdoocN{>y^h#A z1t-|D#|&1bb(rm9+s5naPM;$SmfGioPd#U|SRt ze{rtYm*TtX#BuMgC;Z3vJUtFqgw31d0j>73lhE^e9`(U62sH#*bi5Ffyt}_hG3Ej^ z79IU>wMaXQWyyL99$YKGY>$~H7`pfwFZAAvZrqztD?+J_bNKp5 zMS{uer%jhLRln2zl89iM@la0AQs!LGIMNhR@8@@2rTJRy*|kKc-WiFSW37BXMgO%VM0*y7oEQ+a&;uulKl!=yZz~vxY8v7MX&nY5ux7NpJlrt;*j%dEtR_HU>bw zwDy&GdaV~fX(W$>s%UQ&^ZO@E&xZu|uc{6qUx=Mry4~AKl^Auge_Q)P?^e@laAr&e zVXo-i->yq%&Xg_55%DC+&qK0o&?+@WgvG3RJYyN?VTX-fUBp=~8f(qt`k@g8Mkt5EtV+Dq zr91g<@Q{@?8i|LBK~o}m6kkkq{a7ADnk?P1kfXOhO@O296&IiIldj4VCxgWx_I!+0 zt>#^CKn^zX)L01E1Vf*@DlWNCbqpjA0qBX?2a z_=70vx7hN;K5rbXR)z4X!mcW@!d!A_G&L9|swfaQ*Vsvbt2 z+THU)RuQzy))CvKE(4t@Ix}z(I=*e8Ga&X(jMBeytZoVGSGJpkrMoo08vnV2YEJRj z&nk58)*P=NWaVF9tAK>M!>*S0GYR&*T;AsT!CVFu24#?48I)_2HV7|dKUD}>Ga0z> zH1_rkKZ&D%?Jjw;5K=p;cXHLL_oQ2O{h>jxb@JC?WbT;i&$Af!2i4hPGbw}7BDs%` zj#gy=e=P?`LVl05eE-7a0t7fJ8NAlvzV+ql&h?V)YoXo0aCwislAh>{^4{|Q8BbQO zt{JYap^~<l6-FQx=)G8hj=G4aWtr2-1nw~ z-pJ5lI71Tf{i4x_twjdc`>+Wl!Q-XqPts( zE0Patvej6jbHRP^ zietM`8OL4&a3xUtW6n^<+8`&T$M;X*(J|V4yujB2bXV<5$;A1@R$^8JaPSSwBLOYT zL$}*E!Z}o)+^isWJxZ-)Z1$3V@w5=Ix$d4Yb1!!O*k_&L1)fZX;8X-6A12!Xs~M0c z7xM?5jynFQnO?;XgoU=1bHkvG*KQQeM#F^LrX4BQGFGP%Y;$k6D~q!03Af2jU$HgM zFK;~AK~+W+?aGQ>1)AzV$qoWUm&|`j$1^)ec2L&_5uH@>N@_)BJwdzNDI$XXjUFE$ zA`7r!M!Q_haJx3mEeZ_h0bs?4WTQ-y#a}e~!mPcGUsKuF_2M*W2b~F0Z9;|ATdlJO ztrsMM1lAwoe-u?Ve#$;sDr=bgy&`2ZGj%oV@k!QELfwTkv)lv^p+6@UF|=`{3UYS! zIS)Z zp89g>y*7(8#`nK@XAkuP8g*#!??kt?J2?x@UfKK+3RoyEA}HT-@PWN6?ipXh zig|WnTrXsJe#oU!bZ);OW-_)(kM{vytJ9~87fNAV0&T&evS6>e*;@{--?ja!MON{* zp{TRF@0*!nII$16>S;gwCxPpVLEL-=>MbG)BU`^59h3(S%gBGZFc8|omcL<-mw-a< z&{z_FMEUSFF-qH=)73;J#KmnOdOOxP;X5UcCa)cs>s$g`sLfb-le@dUBS zg&KI*85^Y>cWmqoW`^I+5SyKtD>a_#zs)u63|Wsu&B>qU(%ULILRoCaZm3rr@LOC9 zcEi5%J#Sd`uf$|4r+n( zgK7&-e#DXsN?*>Jt~@Il7f#wX`=#Gl=b42x2BUwxc^34&Hy498MS z1Hk~Y`gdU+^4zDW_DL(+Q;R9lvzDSEoX+`vgRMSOAO3 z@KWRGoaIg+Qzu~79&vqcLCI*=&tbn9>s}|aqR?-Q3kx!`&~7yM7~x9gcJ^1)A{x4J zj3vZqrXJ-(&H_!T7&jYPf{w6*V~c|Bc&0eB>UhPi93JrLwFHMT7e`1_j-l_#X+%P^ z-@G%Xe$jabLsaNnv12N0saM7Z?>ZHW^qAgWaq!$1UQ+fsW`DE(+;E#|i`+4VY#fX-5L0Q<6HLLy+26*C0Ws0Ji#rN2372WB7eJ z#Onu&lFj|u^sv)qd}QYcRO@T(KHp;9?CXm&0bjqziLyQMr|Z{6Qo`Q@C!)YVXUMxY zP!)XlhCM*7?6i-(W){Z=5yWW}nr&tf#eZRV+g0JTeZsGJ&z$*D z@o>~tsv*Ksjj?uaiSKm`O+sLQ<*$AS#_Fg4B%qb-X*OOb=H{2YMn?`SKHgvcehZOS zuzzql9@ZmdvCE^)O_BGxw-;2OxBuuxE7hNsfxmx*psl<*9|MHWJF+hp4&5iuNpH4% zg|3K!!9>7r!+mrmazOl9B53_)`tx_pRx0q9x=!VVjnzBOt%=8c3`+P*&lRzQ!4@Q< zrO(T>th2^~K!D(&B$`lnQBVM^p>tjwPo5r?uHni)U=0{KQSIRiz9_w;ftz?bJL__9 z)-zjl66f?zH{`lSC^W~mI(y`zNKyiK(2S(WIJQ_Qrf^^t=F0<@F}fQj>rubRHIt*b zL?^eLSnIL7TF5E%q5${k%aJnlsfVdJQ0m}fg^tI{tKLnKZBZr_63$`cz=zXlOaAJ| zMJ73og;%(h&)5zG2_b8PORvn_M7;tAyM;=Z__K z2^^GlySLoieVbSmc1g}s3;B$?WkwloGVz_uHf_P>p9^ZtS^r2p?{-R>U&FWI38uSH zabk|5F+1I7wdyX_Q<)0eF`SuJ$N0NhXt91#a@jfWrae*B6ciZx!dI1KaXAiV=pj%D z(8h@mPp>rm^>hEaogpxmM^4xW8W~#LrF*5o1l_q{S%|+bSC*1C?x`3V0&=J;R@#>z zLzy)zWS`r!42THf(a`UMbEOu*B&-eNJr#~JlrsUjTZ@%bg>#xV%|3Z_h;9=4$R*40 zHMIh8rap;5ud~miEJfa*)we19#?HO*e_j##m4$4-!_Y< zx^nZcH@r?2O2|1waa*rfOdNTP5c6VJNFmR70{77(rs&AJ-v|5Vvh&xtR&K~_)P8__ z8R}1xE}Hi6C7~XX_V4`Omw_qRy<5o*o|l~&{qhNyJS6KehmO3$wUip~@&kL3!P?C@ z12~s*R)g@A4Ia*mqmXwLQH*A(yVz%0Yspuyxds7iW2rxMz<&yI{&FOD zoJ{iJK0#BuoV=hB1-Jh&K4EA<_1YgvN)WtgH82v$^h6oK%pc;SSsFZL3lx~cpq<^+ zj`j2ZcI%K$0ENaJ5>^>Bftmo;R#T%#d*9qEHZz)qe{l3U_v}qg;fM&HOo5peVuEm^9m3J#QyE;S`Qpj`zC+yul-?4I?KGH zVsz^NTJ(>5Ku(Rjq8fCr-9dtLeu!+uuHwp(U0eiF&+|}yOseWStlI8v7IOiN60U!F zoLXB_81p^1NWI19Jx*o|I~o8jRl%$gP%F-Xr^{gfRFF>Z@)&3(=q@seeS54gQk0); z388xsfG424e~eD6*uMitQXGIuDT%uK$J!Mbphfo*|A#|F{s*T?<_$F&U5D8c-yQq* zg1JIEd}98W6Z$lnu5!#GpU4gCJM!!>?-vl;z~Qoe`+M6U+p0st4nJO6`Q@~F@6XIT z)!&IZw2}JxMO$(2r@$#WMLJ`I!P*jV1e`(Z$`Wu00Whxl_QK|)e)`qurMf+hag;KU z4>@*`xc@gm>IBc`*hWyN&k@fr zu6=&VaQX0v`<{+=i^yXiRQHtUI>Gwh*yu?JJh>7 zz(K<7jC$u-dk^m z{(>%g@=`SCTiEL!rwFs$NzmPUULm#y`J+5O_M*|PSQu6i^5GL?7O=Mi z_A;RkS0nE^Lj*<_wbGr=+Xv^J!8;4$$b6sUj+UhKFPQ3J(&Cd2r z1-!_(@tSX)Q>}vMl7C>tqv=VHnrWXFh3^wSQGSU9QwKKY`i-Yl0j$%U&f>O7LW$rk zWrL_KJXhB0g_CN=*D8j`b8cXOwcKIqzDgO*4~Rv* zC^3sROdqL_yprn<6hW}$9Lx0Bqn$q>p1+4T5Zh!iii|@||0vz7MQA%X-cCZfeZ?C88 zbr%r)>kT-6g1G-!KP7>vE#~0P5TtB`nkK&41p!T4XQ89cy;6!5=5^$yr!3LCW;k9;H}mj{4E0@tY%B{56R%SLhX@-2>owGMGdsSnIC(edjl>H?i|TD>$|X$e*SOTN1+exA zOZNtP^~&z25N?s3i7P@}N~GZPq5+;VQk{CKP>EJ~-|<+J(mBSlej{j*o`tRl9MyQL zffI7{RD(b-eCGL(#hO|L#lUn!C@Yd$hxABZ)Oxm3Z0XVCt3RbLETE3_4&}si8O0L( zcjC$dU^4T$8>PusF4`+zM;OYP|A6&~9qr>d!)vubOZn$iTvT9<;JEzsH5zI9tieYU z!QBeck&tSV)){pp)j;{s#4~7<^3>;^25f|KEz>4txR`z@H)mLo^~=lcmf(5W!IiCr zfRZ~+oSCaB8`HwzySKQOS`(p{-Pw0Z6Wk7kSn(aBhMrB{WtIcw%=Z}Nhqf)DLVSDV>J-MeSN1rMFif2MW5Pnu zbtZUb5t%kxz~*I0Jn=u=Gq=d8I}vAWbw4P~t6%sUwe`F76ksSGB^tNhpj{sD33B{3 z_2So~x3GMGb8xg5HW5l&Y-OwYDjKB)s+4qs_|1BRhd^?&1!482S0CY7I&D*^AuIa; z(AWuNG>wq0a*L2%ImpgyT7D_kBh7~kjpV-fD_Sm|*2_$-&^Y)h;IZDajrU=*!7API zpsi~_sWG&x`2EGT_qn9#WEDSPppZ7{x*iQfxWn`*M6Tqi7mErZ3P_?hH%0FSkc64` zKXQaz-{d7I)>Y?^=TzH%^J1d55#*jTdR)48_ljSrMy|kT`JlV#4Aluuz$o2o>!1~a zpG878NQUI$e5Ab^2at8dg5B#I&cA2mIiP%c8L@2DqNuPx10pAmennG1yHR%0Qqd6n zms)3d;QKM^mle^N^#=62n!&DsT2oL_CjqWIxQ<3oXg6n|`zI?Iouo^%A@;nK-ffQK z4wSN#=W4XtV(N+4y*uKLHs^{Vv@JQvO;{`LEm!t(cq%Yfji()--IOm;SSb6^4T8Hi z7x24hXqP1M9p!E#uGZ??9jvctC~ z@)UMZuuGkxopG0@NhW>79_ssC$nk2a>ht84#Zx%KWc1w(w;#QR(gl_*VR0^mQ5R?0 zh5)*ue>E^)f4lFf)`=SU~;HIJ+M85HPj0`q605zjU@K84(sW{-G` zu?jP9oS(b?G^<9ME3)<5T!q$8SY@G+5=Abh2mAK+V>!T$BH1w&Hv`w`chra8NIXyRV0b=#uu#S%Jam|b!CNjv%U0F#_gg;`bD}L zz9xypCUGs*f%TK-cFlASgpwWrot|%f)ga5|NO4N?7}C&WWdO40|FxPg}f2D}t%`JT-Uo$l?8(g=n0USyWK6KM`KWm>OrEWTe^PhWkqcCiMw?bP?CZbHh} zhvJeQN%l%cc@tOcjA{YzU(TQVdQGx3A9gOCesfjgmrX~}J9^d|~?Ojb8~q zzss&Xo&b$Mos^o(IX~OmZ&FB2o^gs>%4VJqd3m zYIVHmCWX1yxz<5|Q}$ty`dN~Tj&SkL{&-Rm=|yN+4ODDx^XX>wHo}PFmhr| zYh&@HnF|IJR~wq@fZ=)gbtk={89c*wEm5A6Cm>r($T%V;W(@xtKQKu6=q;L}%d;O9agU;CC z&hwdSTYYDX5rfor%wf4;WQ56ItFIpelYaRxtfB)?k{bhtYe6P)Eq^m%AbF7E!`d`p zwz2TxGdf;v_hD`~T9O$K*+hFD)@BUWX8&))tzZ4=iZVPo`bXu;V14NmgdX332*>b8 zL(Px|44*yx$!Fd_Jv^XW_FuEr|1&51|No_^#911S#vGMvI=uGMz>xl#>MBo_E0wI@ F{67l|-0c7W literal 0 HcmV?d00001 From 1269c070cdb6c2090c73da02d73153d62e98e329 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 28 Jul 2017 20:47:14 -0400 Subject: [PATCH 345/680] Divide the introductory paragraph in the README This paragraph was too long and needed to be broken. --- README.markdown | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 2550331f..879d96d4 100644 --- a/README.markdown +++ b/README.markdown @@ -5,10 +5,12 @@ Introduction ------------ The NERDTree is a file system explorer for the Vim editor. Using this plugin, -you can visually browse complex directory hierarchies, quickly open files for -reading or editing, and perform basic file system operations. This plugin can -also be extended with custom mappings using a special API. The details of this -API and other NERDTree features is described in the included documentation. +users can visually browse complex directory hierarchies, quickly open files for +reading or editing, and perform basic file system operations. + +This plugin can also be extended with custom mappings using a special API. The +details of this API and of other NERDTree features are described in the +included documentation. ![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png) From 719d6785d48ca33ba1352febf27fa0ba5caec063 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 29 Jul 2017 08:37:25 -0400 Subject: [PATCH 346/680] Edit the commentary in "opener.vim" This commit doesn't change the content of any comments. It just changes their appearance (leading quotes are now followed by a space). --- lib/nerdtree/opener.vim | 99 ++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index d1bd05a5..a379d09e 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -1,15 +1,20 @@ -"CLASS: Opener -"============================================================ +" ============================================================================ +" CLASS: Opener +" +" The Opener class defines an API for "opening" operations. +" ============================================================================ + + let s:Opener = {} let g:NERDTreeOpener = s:Opener -"FUNCTION: s:Opener._bufInWindows(bnum){{{1 -"[[STOLEN FROM VTREEEXPLORER.VIM]] -"Determine the number of windows open to this buffer number. -"Care of Yegappan Lakshman. Thanks! +" FUNCTION: s:Opener._bufInWindows(bnum) {{{1 +" [[STOLEN FROM VTREEEXPLORER.VIM]] +" Determine the number of windows open to this buffer number. +" Care of Yegappan Lakshman. Thanks! " -"Args: -"bnum: the subject buffers buffer number +" Args: +" bnum: the subject buffers buffer number function! s:Opener._bufInWindows(bnum) let cnt = 0 let winnum = 1 @@ -26,14 +31,15 @@ function! s:Opener._bufInWindows(bnum) return cnt endfunction -"FUNCTION: Opener._checkToCloseTree(newtab) {{{1 -"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see -"if the tree should be closed now. + +" FUNCTION: Opener._checkToCloseTree(newtab) {{{1 +" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see +" if the tree should be closed now. " -"Args: -"a:newtab - boolean. If set, only close the tree now if we are opening the -"target in a new tab. This is needed because we have to close tree before we -"leave the tab +" Args: +" a:newtab - boolean. If set, only close the tree now if we are opening the +" target in a new tab. This is needed because we have to close tree before we +" leave the tab function! s:Opener._checkToCloseTree(newtab) if self._keepopen return @@ -44,9 +50,8 @@ function! s:Opener._checkToCloseTree(newtab) endif endfunction - -"FUNCTION: s:Opener._firstUsableWindow(){{{1 -"find the window number of the first normal window +" FUNCTION: s:Opener._firstUsableWindow() {{{1 +" find the window number of the first normal window function! s:Opener._firstUsableWindow() let i = 1 while i <= winnr("$") @@ -62,7 +67,7 @@ function! s:Opener._firstUsableWindow() return -1 endfunction -"FUNCTION: Opener._gotoTargetWin() {{{1 +" FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() if self._where == 'v' @@ -89,12 +94,12 @@ function! s:Opener._gotoTargetWin() endif endfunction -"FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1 -"Returns 0 if opening a file from the tree in the given window requires it to -"be split, 1 otherwise +" FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1 +" Returns 0 if opening a file from the tree in the given window requires it to +" be split, 1 otherwise " -"Args: -"winnumber: the number of the window in question +" Args: +" winnumber: the number of the window in question function! s:Opener._isWindowUsable(winnumber) "gotta split if theres only one window (i.e. the NERD tree) if winnr("$") ==# 1 @@ -120,21 +125,21 @@ function! s:Opener._isWindowUsable(winnumber) return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2 endfunction -"FUNCTION: Opener.New(path, opts) {{{1 -"Args: +" FUNCTION: Opener.New(path, opts) {{{1 +" Args: " -"a:path: The path object that is to be opened. +" a:path: The path object that is to be opened. " -"a:opts: +" a:opts: " -"A dictionary containing the following keys (all optional): -" 'where': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' or 'h' or 't' (for open in -" new tab) -" 'reuse': if a window is displaying the file then jump the cursor there. Can -" 'all', 'currenttab' or empty to not reuse. -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win +" A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' or 'h' or 't' (for open in +" new tab) +" 'reuse': if a window is displaying the file then jump the cursor there. Can +" 'all', 'currenttab' or empty to not reuse. +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win function! s:Opener.New(path, opts) let newObj = copy(self) @@ -155,7 +160,7 @@ function! s:Opener.New(path, opts) return newObj endfunction -"FUNCTION: Opener._newSplit() {{{1 +" FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() " Save the user's settings for splitbelow and splitright let savesplitbelow=&splitbelow @@ -215,7 +220,7 @@ function! s:Opener._newSplit() let &splitright=savesplitright endfunction -"FUNCTION: Opener._newVSplit() {{{1 +" FUNCTION: Opener._newVSplit() {{{1 function! s:Opener._newVSplit() let winwidth = winwidth(".") if winnr("$")==#1 @@ -233,7 +238,7 @@ function! s:Opener._newVSplit() exe currentWin . "wincmd w" endfunction -"FUNCTION: Opener.open(target) {{{1 +" FUNCTION: Opener.open(target) {{{1 function! s:Opener.open(target) if self._path.isDirectory call self._openDirectory(a:target) @@ -242,7 +247,7 @@ function! s:Opener.open(target) endif endfunction -"FUNCTION: Opener._openFile() {{{1 +" FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() if self._reuseWindow() return @@ -255,7 +260,7 @@ function! s:Opener._openFile() endif endfunction -"FUNCTION: Opener._openDirectory(node) {{{1 +" FUNCTION: Opener._openDirectory(node) {{{1 function! s:Opener._openDirectory(node) if self._nerdtree.isWinTree() call self._gotoTargetWin() @@ -276,7 +281,7 @@ function! s:Opener._openDirectory(node) endif endfunction -"FUNCTION: Opener._previousWindow() {{{1 +" FUNCTION: Opener._previousWindow() {{{1 function! s:Opener._previousWindow() if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1 call self._newSplit() @@ -296,16 +301,16 @@ function! s:Opener._previousWindow() endif endfunction -"FUNCTION: Opener._restoreCursorPos(){{{1 +" FUNCTION: Opener._restoreCursorPos() {{{1 function! s:Opener._restoreCursorPos() call nerdtree#exec('normal ' . self._tabnr . 'gt') call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') endfunction -"FUNCTION: Opener._reuseWindow(){{{1 -"put the cursor in the first window we find for this file +" FUNCTION: Opener._reuseWindow() {{{1 +" put the cursor in the first window we find for this file " -"return 1 if we were successful +" return 1 if we were successful function! s:Opener._reuseWindow() if empty(self._reuse) return 0 @@ -336,7 +341,7 @@ function! s:Opener._reuseWindow() return 0 endfunction -"FUNCTION: Opener._saveCursorPos(){{{1 +" FUNCTION: Opener._saveCursorPos() {{{1 function! s:Opener._saveCursorPos() let self._bufnr = bufnr("") let self._tabnr = tabpagenr() From 35724ee2064d73061e67fc9f2f4342a62249f39b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 29 Jul 2017 08:55:28 -0400 Subject: [PATCH 347/680] Refactor the internals of "_newVSplit()" The previous change to this function was simple. I figured that it would be a good time to improve the style of this function with some minor edits. The function is now cleaner and more readable. --- lib/nerdtree/opener.vim | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index a379d09e..fd32e643 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -222,20 +222,22 @@ endfunction " FUNCTION: Opener._newVSplit() {{{1 function! s:Opener._newVSplit() - let winwidth = winwidth(".") - if winnr("$")==#1 - let winwidth = g:NERDTreeWinSize + let l:winwidth = winwidth('.') + + if winnr('$') == 1 + let l:winwidth = g:NERDTreeWinSize endif - call nerdtree#exec("wincmd p") + call nerdtree#exec('wincmd p') vnew - let currentWin = winnr() + let l:currentWindowNumber = winnr() - "resize the nerd tree back to the original size + " Restore the NERDTree to its original width. call g:NERDTree.CursorToTreeWin() - exec("silent vertical resize ". winwidth) - exe currentWin . "wincmd w" + execute 'silent vertical resize ' . l:winwidth + + call nerdtree#exec(l:currentWindowNumber . 'wincmd w') endfunction " FUNCTION: Opener.open(target) {{{1 From d68c9abca81943b0e5c5028c9c745b04b1e09afb Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 29 Jul 2017 09:40:11 -0400 Subject: [PATCH 348/680] Improve three highlighting rules The highlighting rules "NERDTreeClosable" and "NERDTreeOpenable" did not recognize files beginning with a "~" character. This caused bad highlighting on systems that use "~" and "+" for the dir arrow symbols by default. Making these rules more specific solves this problem. The "~" characters in quickhelp section titles also would get confused with a custom mapping for "~". Adjusting the "NERDTreeHelpTitle" solved this problem. I also changed the quickhelp title in a minor way to reflect the proper spelling of "NERDTree". --- lib/nerdtree/ui.vim | 2 +- syntax/nerdtree.vim | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index e169dbbf..03f11b84 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -21,7 +21,7 @@ endfunction "prints out the quick help function! s:UI._dumpHelp() if self.getShowHelp() - let help = "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" + let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n" let help .= "\" ============================\n" let help .= "\" File node mappings~\n" let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index e93ca1df..7c80605c 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -8,7 +8,7 @@ execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" "quickhelp syntax elements syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 -syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1 +syn match NERDTreeHelpTitle #" .*\~$#ms=s+2,me=e-1 syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1 syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 @@ -22,8 +22,8 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir -exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' -exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' +exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' +exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' From a7d667b81bd381ff091e8ca0034a5b5e3660f1b2 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 08:07:23 -0400 Subject: [PATCH 349/680] Add spaces after comment leaders in "path.vim" Here, I applied the usual fix for the cramped comments I've found in our scripts. Use this command... :%s/^"\ze\S/" / to fix this problem elsewhere. --- lib/nerdtree/path.vim | 258 +++++++++++++++++++++--------------------- 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index b884ec60..4d608c74 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -1,13 +1,13 @@ -"we need to use this number many times for sorting... so we calculate it only -"once here +" we need to use this number many times for sorting... so we calculate it only +" once here let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') -"CLASS: Path -"============================================================ +" CLASS: Path +" ============================================================ let s:Path = {} let g:NERDTreePath = s:Path -"FUNCTION: Path.AbsolutePathFor(str) {{{1 +" FUNCTION: Path.AbsolutePathFor(str) {{{1 function! s:Path.AbsolutePathFor(str) let prependCWD = 0 if nerdtree#runningWindows() @@ -24,7 +24,7 @@ function! s:Path.AbsolutePathFor(str) return toReturn endfunction -"FUNCTION: Path.bookmarkNames() {{{1 +" FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() if !exists("self._bookmarkNames") call self.cacheDisplayString() @@ -32,7 +32,7 @@ function! s:Path.bookmarkNames() return self._bookmarkNames endfunction -"FUNCTION: Path.cacheDisplayString() {{{1 +" FUNCTION: Path.cacheDisplayString() {{{1 function! s:Path.cacheDisplayString() abort let self.cachedDisplayString = self.getLastPathComponent(1) @@ -59,7 +59,7 @@ function! s:Path.cacheDisplayString() abort endif endfunction -"FUNCTION: Path.changeToDir() {{{1 +" FUNCTION: Path.changeToDir() {{{1 function! s:Path.changeToDir() let dir = self.str({'format': 'Cd'}) if self.isDirectory ==# 0 @@ -74,16 +74,16 @@ function! s:Path.changeToDir() endtry endfunction -"FUNCTION: Path.compareTo() {{{1 +" FUNCTION: Path.compareTo() {{{1 " -"Compares this Path to the given path and returns 0 if they are equal, -1 if -"this Path is "less than" the given path, or 1 if it is "greater". +" Compares this Path to the given path and returns 0 if they are equal, -1 if +" this Path is "less than" the given path, or 1 if it is "greater". " -"Args: -"path: the path object to compare this to +" Args: +" path: the path object to compare this to " -"Return: -"1, -1 or 0 +" Return: +" 1, -1 or 0 function! s:Path.compareTo(path) let thisPath = self.getLastPathComponent(1) let thatPath = a:path.getLastPathComponent(1) @@ -118,16 +118,16 @@ function! s:Path.compareTo(path) endif endfunction -"FUNCTION: Path.Create(fullpath) {{{1 +" FUNCTION: Path.Create(fullpath) {{{1 " -"Factory method. +" Factory method. " -"Creates a path object with the given path. The path is also created on the -"filesystem. If the path already exists, a NERDTree.Path.Exists exception is -"thrown. If any other errors occur, a NERDTree.Path exception is thrown. +" Creates a path object with the given path. The path is also created on the +" filesystem. If the path already exists, a NERDTree.Path.Exists exception is +" thrown. If any other errors occur, a NERDTree.Path exception is thrown. " -"Args: -"fullpath: the full filesystem path to the file/dir to create +" Args: +" fullpath: the full filesystem path to the file/dir to create function! s:Path.Create(fullpath) "bail if the a:fullpath already exists if isdirectory(a:fullpath) || filereadable(a:fullpath) @@ -155,12 +155,12 @@ function! s:Path.Create(fullpath) return s:Path.New(a:fullpath) endfunction -"FUNCTION: Path.copy(dest) {{{1 +" FUNCTION: Path.copy(dest) {{{1 " -"Copies the file/dir represented by this Path to the given location +" Copies the file/dir represented by this Path to the given location " -"Args: -"dest: the location to copy this dir/file to +" Args: +" dest: the location to copy this dir/file to function! s:Path.copy(dest) if !s:Path.CopyingSupported() throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS" @@ -181,20 +181,20 @@ function! s:Path.copy(dest) endif endfunction -"FUNCTION: Path.CopyingSupported() {{{1 +" FUNCTION: Path.CopyingSupported() {{{1 " -"returns 1 if copying is supported for this OS +" returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd')) endfunction -"FUNCTION: Path.copyingWillOverwrite(dest) {{{1 +" FUNCTION: Path.copyingWillOverwrite(dest) {{{1 " -"returns 1 if copy this path to the given location will cause files to -"overwritten +" returns 1 if copy this path to the given location will cause files to +" overwritten " -"Args: -"dest: the location this path will be copied to +" Args: +" dest: the location this path will be copied to function! s:Path.copyingWillOverwrite(dest) if filereadable(a:dest) return 1 @@ -208,13 +208,13 @@ function! s:Path.copyingWillOverwrite(dest) endif endfunction -"FUNCTION: Path.createParentDirectories(path) {{{1 +" FUNCTION: Path.createParentDirectories(path) {{{1 " -"create parent directories for this path if needed -"without throwing any errors if those directories already exist +" create parent directories for this path if needed +" without throwing any errors if those directories already exist " -"Args: -"path: full path of the node whose parent directories may need to be created +" Args: +" path: full path of the node whose parent directories may need to be created function! s:Path.createParentDirectories(path) let dir_path = fnamemodify(a:path, ':h') if !isdirectory(dir_path) @@ -222,11 +222,11 @@ function! s:Path.createParentDirectories(path) endif endfunction -"FUNCTION: Path.delete() {{{1 +" FUNCTION: Path.delete() {{{1 " -"Deletes the file or directory represented by this path. +" Deletes the file or directory represented by this path. " -"Throws NERDTree.Path.Deletion exceptions +" Throws NERDTree.Path.Deletion exceptions function! s:Path.delete() if self.isDirectory @@ -250,10 +250,10 @@ function! s:Path.delete() endfor endfunction -"FUNCTION: Path.displayString() {{{1 +" FUNCTION: Path.displayString() {{{1 " -"Returns a string that specifies how the path should be represented as a -"string +" Returns a string that specifies how the path should be represented as a +" string function! s:Path.displayString() if self.cachedDisplayString ==# "" call self.cacheDisplayString() @@ -262,14 +262,14 @@ function! s:Path.displayString() return self.cachedDisplayString endfunction -"FUNCTION: Path.edit() {{{1 +" FUNCTION: Path.edit() {{{1 function! s:Path.edit() exec "edit " . self.str({'format': 'Edit'}) endfunction -"FUNCTION: Path.extractDriveLetter(fullpath) {{{1 +" FUNCTION: Path.extractDriveLetter(fullpath) {{{1 " -"If running windows, cache the drive letter for this path +" If running windows, cache the drive letter for this path function! s:Path.extractDriveLetter(fullpath) if nerdtree#runningWindows() if a:fullpath =~ '^\(\\\\\|\/\/\)' @@ -285,14 +285,14 @@ function! s:Path.extractDriveLetter(fullpath) endfunction -"FUNCTION: Path.exists() {{{1 -"return 1 if this path points to a location that is readable or is a directory +" FUNCTION: Path.exists() {{{1 +" return 1 if this path points to a location that is readable or is a directory function! s:Path.exists() let p = self.str() return filereadable(p) || isdirectory(p) endfunction -"FUNCTION: Path._escChars() {{{1 +" FUNCTION: Path._escChars() {{{1 function! s:Path._escChars() if nerdtree#runningWindows() return " `\|\"#%&,?()\*^<>$" @@ -301,12 +301,12 @@ function! s:Path._escChars() return " \\`\|\"#%&,?()\*^<>[]$" endfunction -"FUNCTION: Path.getDir() {{{1 +" FUNCTION: Path.getDir() {{{1 " -"Returns this path if it is a directory, else this paths parent. +" Returns this path if it is a directory, else this paths parent. " -"Return: -"a Path object +" Return: +" a Path object function! s:Path.getDir() if self.isDirectory return self @@ -315,12 +315,12 @@ function! s:Path.getDir() endif endfunction -"FUNCTION: Path.getParent() {{{1 +" FUNCTION: Path.getParent() {{{1 " -"Returns a new path object for this paths parent +" Returns a new path object for this paths parent " -"Return: -"a new Path object +" Return: +" a new Path object function! s:Path.getParent() if nerdtree#runningWindows() let path = self.drive . '\' . join(self.pathSegments[0:-2], '\') @@ -331,13 +331,13 @@ function! s:Path.getParent() return s:Path.New(path) endfunction -"FUNCTION: Path.getLastPathComponent(dirSlash) {{{1 +" FUNCTION: Path.getLastPathComponent(dirSlash) {{{1 " -"Gets the last part of this path. +" Gets the last part of this path. " -"Args: -"dirSlash: if 1 then a trailing slash will be added to the returned value for -"directory nodes. +" Args: +" dirSlash: if 1 then a trailing slash will be added to the returned value for +" directory nodes. function! s:Path.getLastPathComponent(dirSlash) if empty(self.pathSegments) return '' @@ -349,8 +349,8 @@ function! s:Path.getLastPathComponent(dirSlash) return toReturn endfunction -"FUNCTION: Path.getSortOrderIndex() {{{1 -"returns the index of the pattern in g:NERDTreeSortOrder that this path matches +" FUNCTION: Path.getSortOrderIndex() {{{1 +" returns the index of the pattern in g:NERDTreeSortOrder that this path matches function! s:Path.getSortOrderIndex() let i = 0 while i < len(g:NERDTreeSortOrder) @@ -362,8 +362,8 @@ function! s:Path.getSortOrderIndex() return s:NERDTreeSortStarIndex endfunction -"FUNCTION: Path._splitChunks(path) {{{1 -"returns a list of path chunks +" FUNCTION: Path._splitChunks(path) {{{1 +" returns a list of path chunks function! s:Path._splitChunks(path) let chunks = split(a:path, '\(\D\+\|\d\+\)\zs') let i = 0 @@ -377,8 +377,8 @@ function! s:Path._splitChunks(path) return chunks endfunction -"FUNCTION: Path.getSortKey() {{{1 -"returns a key used in compare function for sorting +" FUNCTION: Path.getSortKey() {{{1 +" returns a key used in compare function for sorting function! s:Path.getSortKey() if !exists("self._sortKey") let path = self.getLastPathComponent(1) @@ -399,14 +399,14 @@ function! s:Path.getSortKey() endfunction -"FUNCTION: Path.isUnixHiddenFile() {{{1 -"check for unix hidden files +" FUNCTION: Path.isUnixHiddenFile() {{{1 +" check for unix hidden files function! s:Path.isUnixHiddenFile() return self.getLastPathComponent(0) =~# '^\.' endfunction -"FUNCTION: Path.isUnixHiddenPath() {{{1 -"check for unix path with hidden components +" FUNCTION: Path.isUnixHiddenPath() {{{1 +" check for unix path with hidden components function! s:Path.isUnixHiddenPath() if self.getLastPathComponent(0) =~# '^\.' return 1 @@ -420,8 +420,8 @@ function! s:Path.isUnixHiddenPath() endif endfunction -"FUNCTION: Path.ignore(nerdtree) {{{1 -"returns true if this path should be ignored +" FUNCTION: Path.ignore(nerdtree) {{{1 +" returns true if this path should be ignored function! s:Path.ignore(nerdtree) "filter out the user specified paths to ignore if a:nerdtree.ui.isIgnoreFilterEnabled() @@ -450,8 +450,8 @@ function! s:Path.ignore(nerdtree) return 0 endfunction -"FUNCTION: Path._ignorePatternMatches(pattern) {{{1 -"returns true if this path matches the given ignore pattern +" FUNCTION: Path._ignorePatternMatches(pattern) {{{1 +" returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern if strpart(pat,len(pat)-7) == '[[dir]]' @@ -469,10 +469,10 @@ function! s:Path._ignorePatternMatches(pattern) return self.getLastPathComponent(0) =~# pat endfunction -"FUNCTION: Path.isAncestor(path) {{{1 -"return 1 if this path is somewhere above the given path in the filesystem. +" FUNCTION: Path.isAncestor(path) {{{1 +" return 1 if this path is somewhere above the given path in the filesystem. " -"a:path should be a dir +" a:path should be a dir function! s:Path.isAncestor(path) if !self.isDirectory return 0 @@ -483,8 +483,8 @@ function! s:Path.isAncestor(path) return stridx(that, this) == 0 endfunction -"FUNCTION: Path.isUnder(path) {{{1 -"return 1 if this path is somewhere under the given path in the filesystem. +" FUNCTION: Path.isUnder(path) {{{1 +" return 1 if this path is somewhere under the given path in the filesystem. function! s:Path.isUnder(path) if a:path.isDirectory == 0 return 0 @@ -495,7 +495,7 @@ function! s:Path.isUnder(path) return stridx(this, that . s:Path.Slash()) == 0 endfunction -"FUNCTION: Path.JoinPathStrings(...) {{{1 +" FUNCTION: Path.JoinPathStrings(...) {{{1 function! s:Path.JoinPathStrings(...) let components = [] for i in a:000 @@ -504,19 +504,19 @@ function! s:Path.JoinPathStrings(...) return '/' . join(components, '/') endfunction -"FUNCTION: Path.equals() {{{1 +" FUNCTION: Path.equals() {{{1 " -"Determines whether 2 path objects are "equal". -"They are equal if the paths they represent are the same +" Determines whether 2 path objects are "equal". +" They are equal if the paths they represent are the same " -"Args: -"path: the other path obj to compare this with +" Args: +" path: the other path obj to compare this with function! s:Path.equals(path) return self.str() ==# a:path.str() endfunction -"FUNCTION: Path.New() {{{1 -"The Constructor for the Path object +" FUNCTION: Path.New() {{{1 +" The Constructor for the Path object function! s:Path.New(path) let newPath = copy(self) @@ -528,26 +528,26 @@ function! s:Path.New(path) return newPath endfunction -"FUNCTION: Path.Slash() {{{1 -"return the slash to use for the current OS +" FUNCTION: Path.Slash() {{{1 +" return the slash to use for the current OS function! s:Path.Slash() return nerdtree#runningWindows() ? '\' : '/' endfunction -"FUNCTION: Path.Resolve() {{{1 -"Invoke the vim resolve() function and return the result -"This is necessary because in some versions of vim resolve() removes trailing -"slashes while in other versions it doesn't. This always removes the trailing -"slash +" FUNCTION: Path.Resolve() {{{1 +" Invoke the vim resolve() function and return the result +" This is necessary because in some versions of vim resolve() removes trailing +" slashes while in other versions it doesn't. This always removes the trailing +" slash function! s:Path.Resolve(path) let tmp = resolve(a:path) return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp endfunction -"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 +" FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 " " -"Throws NERDTree.Path.InvalidArguments exception. +" Throws NERDTree.Path.InvalidArguments exception. function! s:Path.readInfoFromDisk(fullpath) call self.extractDriveLetter(a:fullpath) @@ -598,22 +598,22 @@ function! s:Path.readInfoFromDisk(fullpath) endif endfunction -"FUNCTION: Path.refresh(nerdtree) {{{1 +" FUNCTION: Path.refresh(nerdtree) {{{1 function! s:Path.refresh(nerdtree) call self.readInfoFromDisk(self.str()) call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {}) call self.cacheDisplayString() endfunction -"FUNCTION: Path.refreshFlags(nerdtree) {{{1 +" FUNCTION: Path.refreshFlags(nerdtree) {{{1 function! s:Path.refreshFlags(nerdtree) call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {}) call self.cacheDisplayString() endfunction -"FUNCTION: Path.rename() {{{1 +" FUNCTION: Path.rename() {{{1 " -"Renames this node on the filesystem +" Renames this node on the filesystem function! s:Path.rename(newPath) if a:newPath ==# '' throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath @@ -632,28 +632,28 @@ function! s:Path.rename(newPath) call g:NERDTreeBookmark.Write() endfunction -"FUNCTION: Path.str() {{{1 +" FUNCTION: Path.str() {{{1 " -"Returns a string representation of this Path +" Returns a string representation of this Path " -"Takes an optional dictionary param to specify how the output should be -"formatted. +" Takes an optional dictionary param to specify how the output should be +" formatted. " -"The dict may have the following keys: +" The dict may have the following keys: " 'format' " 'escape' " 'truncateTo' " -"The 'format' key may have a value of: +" The 'format' key may have a value of: " 'Cd' - a string to be used with the :cd command " 'Edit' - a string to be used with :e :sp :new :tabedit etc " 'UI' - a string used in the NERD tree UI " -"The 'escape' key, if specified will cause the output to be escaped with -"shellescape() +" The 'escape' key, if specified will cause the output to be escaped with +" shellescape() " -"The 'truncateTo' key causes the resulting string to be truncated to the value -"'truncateTo' maps to. A '<' char will be prepended. +" The 'truncateTo' key causes the resulting string to be truncated to the value +" 'truncateTo' maps to. A '<' char will be prepended. function! s:Path.str(...) let options = a:0 ? a:1 : {} let toReturn = "" @@ -688,7 +688,7 @@ function! s:Path.str(...) return toReturn endfunction -"FUNCTION: Path._strForUI() {{{1 +" FUNCTION: Path._strForUI() {{{1 function! s:Path._strForUI() let toReturn = '/' . join(self.pathSegments, '/') if self.isDirectory && toReturn != '/' @@ -697,17 +697,17 @@ function! s:Path._strForUI() return toReturn endfunction -"FUNCTION: Path._strForCd() {{{1 +" FUNCTION: Path._strForCd() {{{1 " " returns a string that can be used with :cd function! s:Path._strForCd() return escape(self.str(), self._escChars()) endfunction -"FUNCTION: Path._strForEdit() {{{1 +" FUNCTION: Path._strForEdit() {{{1 " -"Return: the string for this path that is suitable to be used with the :edit -"command +" Return: the string for this path that is suitable to be used with the :edit +" command function! s:Path._strForEdit() let p = escape(self.str(), self._escChars()) @@ -727,7 +727,7 @@ function! s:Path._strForEdit() return p endfunction -"FUNCTION: Path._strForGlob() {{{1 +" FUNCTION: Path._strForGlob() {{{1 function! s:Path._strForGlob() let lead = s:Path.Slash() @@ -744,10 +744,10 @@ function! s:Path._strForGlob() return toReturn endfunction -"FUNCTION: Path._str() {{{1 +" FUNCTION: Path._str() {{{1 " -"Gets the string path for this path object that is appropriate for the OS. -"EG, in windows c:\foo\bar +" Gets the string path for this path object that is appropriate for the OS. +" EG, in windows c:\foo\bar " in *nix /foo/bar function! s:Path._str() let lead = s:Path.Slash() @@ -760,8 +760,8 @@ function! s:Path._str() return lead . join(self.pathSegments, s:Path.Slash()) endfunction -"FUNCTION: Path.strTrunk() {{{1 -"Gets the path without the last segment on the end. +" FUNCTION: Path.strTrunk() {{{1 +" Gets the path without the last segment on the end. function! s:Path.strTrunk() return self.drive . '/' . join(self.pathSegments[0:-2], '/') endfunction @@ -782,13 +782,13 @@ function! s:Path.tabnr() return 0 endfunction -"FUNCTION: Path.WinToUnixPath(pathstr){{{1 -"Takes in a windows path and returns the unix equiv +" FUNCTION: Path.WinToUnixPath(pathstr){{{1 +" Takes in a windows path and returns the unix equiv " -"A class level method +" A class level method " -"Args: -"pathstr: the windows path to convert +" Args: +" pathstr: the windows path to convert function! s:Path.WinToUnixPath(pathstr) if !nerdtree#runningWindows() return a:pathstr From 1a121337dd1e8d7ec6c44c068cb147f4e9b896ef Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 08:33:51 -0400 Subject: [PATCH 350/680] Clean up the script header in "path.vim" Some code was reorganized and comments were written/rewritten. --- lib/nerdtree/path.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 4d608c74..79dd483e 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -1,9 +1,16 @@ -" we need to use this number many times for sorting... so we calculate it only -" once here +" ============================================================================ +" CLASS: Path +" +" The Path class provides an abstracted representation of a file system +" pathname. Various operations on pathnames are provided and a number of +" representations of a given path name can be accessed here. +" ============================================================================ + + +" This constant is used throughout this script for sorting purposes. let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') +lockvar s:NERDTreeSortStarIndex -" CLASS: Path -" ============================================================ let s:Path = {} let g:NERDTreePath = s:Path From b5e54d255e8bc2369531e29b3eee46e4f9fb4f32 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 08:46:41 -0400 Subject: [PATCH 351/680] Rewrite the "Path._strForCd()" method This commit is the first in a series of commits that will rework some of the methods responsible for escaping pathnames. Some of these methods simply don't use the features that Vim has properly. The custom "Path._escChars()" method is far too rigid for our purposes, and better options have been available for some time. See ":h fnameescape()" for an especially helpful function in this effort. --- lib/nerdtree/path.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 79dd483e..9bd77931 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -705,10 +705,10 @@ function! s:Path._strForUI() endfunction " FUNCTION: Path._strForCd() {{{1 -" -" returns a string that can be used with :cd +" Return a string representation of this Path that is suitable for use as an +" argument to Vim's internal ":cd" command. function! s:Path._strForCd() - return escape(self.str(), self._escChars()) + return fnameescape(self.str()) endfunction " FUNCTION: Path._strForEdit() {{{1 From 72f9135d19cc4c4c4f9791176f93f76b0f182466 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 09:19:36 -0400 Subject: [PATCH 352/680] Clean up the commentary for two Path methods Especially note the improvements to the commentary on "Path.str()". This method does too much. However, it is used heavily, and changing its interface would be a major undertaking at this point. --- lib/nerdtree/path.vim | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 9bd77931..db40069f 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -640,27 +640,27 @@ function! s:Path.rename(newPath) endfunction " FUNCTION: Path.str() {{{1 +" Return a string representation of this Path object. " -" Returns a string representation of this Path -" -" Takes an optional dictionary param to specify how the output should be -" formatted. +" Args: +" This function takes a single dictionary (optional) with keys and values that +" specify how the returned pathname should be formatted. " -" The dict may have the following keys: +" The dictionary may have the following keys: " 'format' " 'escape' " 'truncateTo' " " The 'format' key may have a value of: -" 'Cd' - a string to be used with the :cd command -" 'Edit' - a string to be used with :e :sp :new :tabedit etc -" 'UI' - a string used in the NERD tree UI +" 'Cd' - a string to be used with ":cd" and similar commands +" 'Edit' - a string to be used with ":edit" and similar commands +" 'UI' - a string to be displayed in the NERDTree user interface " -" The 'escape' key, if specified will cause the output to be escaped with -" shellescape() +" The 'escape' key, if specified, will cause the output to be escaped with +" Vim's internal "shellescape()" function. " -" The 'truncateTo' key causes the resulting string to be truncated to the value -" 'truncateTo' maps to. A '<' char will be prepended. +" The 'truncateTo' key shortens the length of the path to that given by the +" value associated with 'truncateTo'. A '<' is prepended. function! s:Path.str(...) let options = a:0 ? a:1 : {} let toReturn = "" @@ -712,9 +712,8 @@ function! s:Path._strForCd() endfunction " FUNCTION: Path._strForEdit() {{{1 -" -" Return: the string for this path that is suitable to be used with the :edit -" command +" Return a string representation of this Path that is suitable for use as an +" argument to Vim's internal ":edit" command. function! s:Path._strForEdit() let p = escape(self.str(), self._escChars()) From 19b8dd7b60eb599d64e23c65f6aa6f9e50edbe18 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 09:32:01 -0400 Subject: [PATCH 353/680] Add a check for 'shellslash' in "Path.Slash()' Several issues (namely issue #733) report problems with using the NERDTree on Windows when 'shellslash' is set. This commit doesn't solve all of these problems, but it improves the NERDTree's recognition of this setting. --- lib/nerdtree/path.vim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index db40069f..1f33e656 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -536,9 +536,20 @@ function! s:Path.New(path) endfunction " FUNCTION: Path.Slash() {{{1 -" return the slash to use for the current OS +" Return the path separator used by the underlying file system. Special +" consideration is taken for the use of the 'shellslash' option on Windows +" systems. function! s:Path.Slash() - return nerdtree#runningWindows() ? '\' : '/' + + if nerdtree#runningWindows() + if exists('+shellslash') && &shellslash + return '/' + endif + + return '\' + endif + + return '/' endfunction " FUNCTION: Path.Resolve() {{{1 From 7a2fc6b6b94e8617a6f0ef14a5f1e789fc385213 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 09:43:57 -0400 Subject: [PATCH 354/680] Refactor the "Path._str()" method This method was using hardcoded values rather than provided abstractions to do its work. These improvements were necessary. --- lib/nerdtree/path.vim | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 1f33e656..2082eb58 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -762,19 +762,17 @@ function! s:Path._strForGlob() endfunction " FUNCTION: Path._str() {{{1 -" -" Gets the string path for this path object that is appropriate for the OS. -" EG, in windows c:\foo\bar -" in *nix /foo/bar +" Return the absolute pathname associated with this Path object. The pathname +" returned is appropriate for the underlying file system. function! s:Path._str() - let lead = s:Path.Slash() + let l:separator = s:Path.Slash() + let l:leader = l:separator - "if we are running windows then slap a drive letter on the front if nerdtree#runningWindows() - let lead = self.drive . '\' + let l:leader = self.drive . l:separator endif - return lead . join(self.pathSegments, s:Path.Slash()) + return l:leader . join(self.pathSegments, l:separator) endfunction " FUNCTION: Path.strTrunk() {{{1 From a32a55e8d98413459aa309176501b97b3f8a350e Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 10:09:18 -0400 Subject: [PATCH 355/680] Rewrite the "Path._strForEdit()" method This method used the brittle "Path._escChars()" method to do its work. This created problems when 'shellslash' was in use on Windows because excessive escape characters (i.e., backslashes!) are interpreted by Vim as additional path separators. The above problem made it impossible to edit files with weird names using the NERDTree on Windows with 'shellslash' set. For example, '+' should be escaped with ":edit", but '(' should not. So, when escaping '(', Vim on Windows correctly sees the start of a new directory in the path. This was reported in five issues which may be read for further details and commentary. Fixes #398, fixes #474, fixes #653, fixes #674, and fixes #733. --- lib/nerdtree/path.vim | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2082eb58..3e7c9133 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -726,22 +726,23 @@ endfunction " Return a string representation of this Path that is suitable for use as an " argument to Vim's internal ":edit" command. function! s:Path._strForEdit() - let p = escape(self.str(), self._escChars()) - "make it relative - let p = fnamemodify(p, ':.') + " Make the path relative to the current working directory, if possible. + let l:result = fnamemodify(self.str(), ':.') - "handle the edge case where the file begins with a + (vim interprets - "the +foo in `:e +foo` as an option to :edit) - if p[0] == "+" - let p = '\' . p + " On Windows, the drive letter may be removed by "fnamemodify()". Add it + " back, if necessary. + if nerdtree#runningWindows() && l:result[0] == s:Path.Slash() + let l:result = self.drive . l:result endif - if p ==# '' - let p = '.' + let l:result = fnameescape(l:result) + + if empty(l:result) + let l:result = '.' endif - return p + return l:result endfunction " FUNCTION: Path._strForGlob() {{{1 From d7cf9a2a9802f580c988f69f129ab7b187debb4c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 11 Aug 2017 10:13:12 -0400 Subject: [PATCH 356/680] Fix the drive check in "TreeDirNode._glob()" This check did not use the proper abstract method to check for a path separator. It now does. This fixes a problem with the 'u' macro that I noticed while working on the fix for using the NERDTree with 'shellslash'. --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 4a6d2137..62bcf882 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -243,7 +243,7 @@ function! s:TreeDirNode._glob(pattern, all) let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.') " On Windows, the drive letter may be removed by "fnamemodify()". - if nerdtree#runningWindows() && l:pathSpec[0] == '\' + if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() let l:pathSpec = self.path.drive . l:pathSpec endif endif From f4ff6dcf84bff73e6cc0e49410e28d0fb65ad73a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 19 Aug 2017 08:58:57 -0400 Subject: [PATCH 357/680] Fix a menu command that breaks under 'shellslash' The (l) menu command breaks on Windows systems when 'shellslash' is set. This is due to the fact that the menu item uses a hard coded shell command, thus relying on the use of the default Windows shell without the 'shellslash' setting. The pattern used for the fix is localized to the problem function. However, this technique could easily be abstracted into its own function to execute Windows shell commands with the default shell throughout the NERDTree codebase. --- nerdtree_plugin/fs_menu.vim | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e563a947..e42942c1 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -212,14 +212,40 @@ endfunction " FUNCTION: NERDTreeListNodeWin32() {{{1 function! NERDTreeListNodeWin32() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') - call nerdtree#echo(metadata[0]) - else - call nerdtree#echo("No information avaialable") + let l:node = g:NERDTreeFileNode.GetSelected() + + if !empty(l:node) + + let l:save_shell = &shell + set shell& + + if exists('+shellslash') + let l:save_shellslash = &shellslash + set noshellslash + endif + + let l:command = 'DIR /Q ' + \ . shellescape(l:node.path.str()) + \ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"' + + let l:metadata = systemlist(l:command) + + if v:shell_error == 0 + call nerdtree#echo(l:metadata[0]) + else + call nerdtree#echoError('shell command failed') + endif + + let &shell = l:save_shell + + if exists('+shellslash') + let &shellslash = l:save_shellslash + endif + + return endif + call nerdtree#echo('node not recognized') endfunction " FUNCTION: NERDTreeCopyNode() {{{1 From 876283b07cadba4f607ae34430b3e08db7a42365 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 19 Aug 2017 09:29:46 -0400 Subject: [PATCH 358/680] Improve display of shell output from menu command This small change reverts to the previous method of breaking shell output into lines. The reason for this is to avoid the printing of trailing carriage return characters on Windows. --- nerdtree_plugin/fs_menu.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e42942c1..bdb638ec 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -228,7 +228,7 @@ function! NERDTreeListNodeWin32() \ . shellescape(l:node.path.str()) \ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"' - let l:metadata = systemlist(l:command) + let l:metadata = split(system(l:command), "\n") if v:shell_error == 0 call nerdtree#echo(l:metadata[0]) @@ -238,7 +238,7 @@ function! NERDTreeListNodeWin32() let &shell = l:save_shell - if exists('+shellslash') + if exists('l:save_shellslash') let &shellslash = l:save_shellslash endif From 8a6ae7c6338378b6bb28ad0cf03e71ff0fd11a5a Mon Sep 17 00:00:00 2001 From: riyu ken Date: Thu, 28 Sep 2017 21:04:01 +0800 Subject: [PATCH 359/680] Use a better function to change directories When g:NERDTreeChDirMode is 2, changing the tree root will change the working directory as well. This change was silent because the wrong function was used to make the switch. This commit uses a better function that echoes a message. --- lib/nerdtree/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 1404cee0..ffbc9d3c 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -21,7 +21,7 @@ function! s:NERDTree.changeRoot(node) "change dir to the dir of the new root if instructed to if g:NERDTreeChDirMode ==# 2 - exec "cd " . self.root.path.str({'format': 'Edit'}) + call self.root.path.changeToDir() endif call self.render() From cb9f4db6ffc98f055954801cfced9399a1da829a Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Fri, 27 Oct 2017 10:06:51 +0300 Subject: [PATCH 360/680] fixed: directory navigation does not work on Cygwin Directory tree navigation is broken because of directory signs which is shown in UTF-8. Cygwin is a Windows application, so it uses ASCII codepages and so directory signs must be in ASCII, but if to modify "nerdtree#runningWindows" function there are many other functions break that convert paths, e.g. So, the quick and reliable solution is to add a separate function "nerdtree#runningCygwin" and use it in a specific place. --- autoload/nerdtree.vim | 5 +++++ plugin/NERD_tree.vim | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 1d2595b0..b138c21c 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -155,6 +155,11 @@ function! nerdtree#runningWindows() return has("win16") || has("win32") || has("win64") endfunction +"FUNCTION: nerdtree#runningCygwin(dir) {{{2 +function! nerdtree#runningCygwin() + return has("win32unix") +endfunction + " SECTION: View Functions {{{1 "============================================================ diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 7eeb682c..35b47c38 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -69,7 +69,7 @@ call s:initVariable("g:NERDTreeShowHidden", 0) call s:initVariable("g:NERDTreeShowLineNumbers", 0) call s:initVariable("g:NERDTreeSortDirs", 1) -if !nerdtree#runningWindows() +if !nerdtree#runningWindows() && !nerdtree#runningCygwin() call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") else From a8c6245057a0600a663a62ff3a53c90f332be8d9 Mon Sep 17 00:00:00 2001 From: Mohamed Boughaba Date: Thu, 2 Nov 2017 13:26:48 +0100 Subject: [PATCH 361/680] Merge pull request #756 from mboughaba/master Previously, deleting a file in the NERDTree with "md" would cause a new buffer to be created to fill the window(s) occupied by a buffer on the file. This pull request makes it so that a new buffer is not created. Instead, the next buffer in the buffer list fills the window. Fixes #755. --- nerdtree_plugin/fs_menu.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index bdb638ec..e48bd81e 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -55,7 +55,22 @@ function! s:promptToDelBuffer(bufnum, msg) " Is not it better to close single tabs with this file only ? let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif" + " Go to the next buffer in buffer list if at least one extra buffer is listed + " Otherwise open a new empty buffer + if v:version >= 800 + let l:listedBufferCount = len(getbufinfo({'buflisted':1})) + elseif v:version >= 702 + let l:listedBufferCount = len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) + else + " Ignore buffer count in this case to make sure we keep the old + " behavior + let l:listedBufferCount = 0 + endif + if l:listedBufferCount > 1 + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif" + else + exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif" + endif exec "tabnext " . s:originalTabNumber exec s:originalWindowNumber . "wincmd w" " 3. We don't need a previous buffer anymore From 97433edd43f3a4a95c84389bcaafbe7a047cf756 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 2 Nov 2017 08:36:07 -0400 Subject: [PATCH 362/680] Merge pull request #754 from branch comma-separated-file-size This change will display the file size (printed with the "ml" command) in an easy-to-read format, while still displaying its precise value. It uses the "stat" command (with the correct switches for Unix and OSX) to get the file size, "sed" to add the commas, and "sed" again to replace the original size with the modified number. --- nerdtree_plugin/fs_menu.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e48bd81e..3bb11dba 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -217,11 +217,21 @@ endfunction " FUNCTION: NERDTreeListNode() {{{1 function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} - let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n') + if !empty(treenode) + if has("osx") + let stat_cmd = 'stat -f "%z" ' + else + let stat_cmd = 'stat -c "%s" ' + endif + + let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' . + \ 'size_with_commas=$(echo $size | sed -e :a -e "s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta") && ' . + \ 'ls -ld ' . shellescape(treenode.path.str()) . ' | sed -e "s/ $size / $size_with_commas /"' + + let metadata = split(system(cmd),'\n') call nerdtree#echo(metadata[0]) else - call nerdtree#echo("No information avaialable") + call nerdtree#echo("No information available") endif endfunction From f0a97209f1d5a630f30506e4243d09a7254f71df Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 08:29:09 -0500 Subject: [PATCH 363/680] Clean up the NERDTreeOpener constructor This method needed some love. The internals were simplified and reformatted, and the comment was edited for additional readability. --- lib/nerdtree/opener.vim | 45 +++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index fd32e643..9956d740 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -126,38 +126,29 @@ function! s:Opener._isWindowUsable(winnumber) endfunction " FUNCTION: Opener.New(path, opts) {{{1 +" Instantiate a new NERDTreeOpener object. " Args: -" -" a:path: The path object that is to be opened. -" -" a:opts: -" -" A dictionary containing the following keys (all optional): -" 'where': Specifies whether the node should be opened in new split/tab or in -" the previous window. Can be either 'v' or 'h' or 't' (for open in -" new tab) -" 'reuse': if a window is displaying the file then jump the cursor there. Can -" 'all', 'currenttab' or empty to not reuse. -" 'keepopen': dont close the tree window -" 'stay': open the file, but keep the cursor in the tree win +" a:path: the path object that is to be opened +" a:opts: a dictionary containing the following optional keys... +" 'where': specifies whether the node should be opened in new split, in +" a new tab or, in the last window; takes values "v", "h", or "t" +" 'reuse': if file is already shown in a window, jump there; takes values +" "all", "currenttab", or empty +" 'keepopen': boolean (0 or 1); if true, the tree window will not be closed +" 'stay': boolean (0 or 1); if true, remain in tree window after opening function! s:Opener.New(path, opts) - let newObj = copy(self) + let l:newOpener = copy(self) - let newObj._path = a:path - let newObj._stay = nerdtree#has_opt(a:opts, 'stay') - - if has_key(a:opts, 'reuse') - let newObj._reuse = a:opts['reuse'] - else - let newObj._reuse = '' - endif + let l:newOpener._keepopen = nerdtree#has_opt(a:opts, 'keepopen') + let l:newOpener._nerdtree = b:NERDTree + let l:newOpener._path = a:path + let l:newOpener._reuse = has_key(a:opts, 'reuse') ? a:opts['reuse'] : '' + let l:newOpener._stay = nerdtree#has_opt(a:opts, 'stay') + let l:newOpener._where = has_key(a:opts, 'where') ? a:opts['where'] : '' - let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen') - let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : '' - let newObj._nerdtree = b:NERDTree - call newObj._saveCursorPos() + call l:newOpener._saveCursorPos() - return newObj + return l:newOpener endfunction " FUNCTION: Opener._newSplit() {{{1 From 26168324fcd1a4fd6ecf68ea1feb6cea1fa0b2e7 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 08:34:29 -0500 Subject: [PATCH 364/680] Remove an unnecessary "else" clause --- lib/nerdtree/opener.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 9956d740..8efdd7ab 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -233,11 +233,13 @@ endfunction " FUNCTION: Opener.open(target) {{{1 function! s:Opener.open(target) + if self._path.isDirectory call self._openDirectory(a:target) - else - call self._openFile() + return endif + + call self._openFile() endfunction " FUNCTION: Opener._openFile() {{{1 From 3cb90cb18d7589a630480d7ba0213397312e8873 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 08:45:34 -0500 Subject: [PATCH 365/680] Extract a common line to the top of a function --- lib/nerdtree/opener.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 8efdd7ab..ef8ab7fd 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -257,11 +257,11 @@ endfunction " FUNCTION: Opener._openDirectory(node) {{{1 function! s:Opener._openDirectory(node) + call self._gotoTargetWin() + if self._nerdtree.isWinTree() - call self._gotoTargetWin() call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) else - call self._gotoTargetWin() if empty(self._where) call b:NERDTree.changeRoot(a:node) elseif self._where == 't' From d9074c275370211bcb921edd83437877ece6dd5c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 08:53:47 -0500 Subject: [PATCH 366/680] Clean up the commentary in "creator.vim" --- lib/nerdtree/creator.vim | 60 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 92e1abeb..dae4c689 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -1,11 +1,17 @@ -"CLASS: Creator -"Creates tab/window/mirror nerdtree windows. Sets up all the window and -"buffer options and key mappings etc. -"============================================================ +" ============================================================================ +" CLASS: Creator +" +" This class is responsible for creating NERDTree instances. The new NERDTree +" may be a tab tree, a window tree, or a mirrored tree. In the process of +" creating a NERDTree, it sets up all of the window and buffer options and key +" mappings etc. +" ============================================================================ + + let s:Creator = {} let g:NERDTreeCreator = s:Creator -"FUNCTION: s:Creator._bindMappings() {{{1 +" FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() "make do the same as the activate node mapping nnoremap :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode) @@ -22,7 +28,7 @@ function! s:Creator._bindMappings() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() endfunction -"FUNCTION: s:Creator._broadcastInitEvent() {{{1 +" FUNCTION: s:Creator._broadcastInitEvent() {{{1 function! s:Creator._broadcastInitEvent() silent doautocmd User NERDTreeInit endfunction @@ -32,14 +38,14 @@ function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction -"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 +" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 function! s:Creator.CreateTabTree(name) let creator = s:Creator.New() call creator.createTabTree(a:name) endfunction -"FUNCTION: s:Creator.createTabTree(a:name) {{{1 -"name: the name of a bookmark or a directory +" FUNCTION: s:Creator.createTabTree(a:name) {{{1 +" name: the name of a bookmark or a directory function! s:Creator.createTabTree(name) let path = self._pathForString(a:name) @@ -74,13 +80,13 @@ function! s:Creator.createTabTree(name) call self._broadcastInitEvent() endfunction -"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1 +" FUNCTION: s:Creator.CreateWindowTree(dir) {{{1 function! s:Creator.CreateWindowTree(dir) let creator = s:Creator.New() call creator.createWindowTree(a:dir) endfunction -"FUNCTION: s:Creator.createWindowTree(dir) {{{1 +" FUNCTION: s:Creator.createWindowTree(dir) {{{1 function! s:Creator.createWindowTree(dir) try let path = g:NERDTreePath.New(a:dir) @@ -177,9 +183,9 @@ function! s:Creator.createMirror() endif endfunction -"FUNCTION: s:Creator._createTreeWin() {{{1 -"Inits the NERD tree window. ie. opens it, sizes it, sets all the local -"options etc +" FUNCTION: s:Creator._createTreeWin() {{{1 +" Inits the NERD tree window. ie. opens it, sizes it, sets all the local +" options etc function! s:Creator._createTreeWin() "create the nerd tree window let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " @@ -198,7 +204,7 @@ function! s:Creator._createTreeWin() call self._setCommonBufOptions() endfunction -"FUNCTION: s:Creator._isBufHidden(nr) {{{1 +" FUNCTION: s:Creator._isBufHidden(nr) {{{1 function! s:Creator._isBufHidden(nr) redir => bufs silent ls! @@ -207,7 +213,7 @@ function! s:Creator._isBufHidden(nr) return bufs =~ a:nr . '..h' endfunction -"FUNCTION: s:Creator.New() {{{1 +" FUNCTION: s:Creator.New() {{{1 function! s:Creator.New() let newCreator = copy(self) return newCreator @@ -232,8 +238,8 @@ function! s:Creator._nextBufferNumber() return s:Creator._NextBufNum endfunction -"FUNCTION: s:Creator._pathForString(str) {{{1 -"find a bookmark or adirectory for the given string +" FUNCTION: s:Creator._pathForString(str) {{{1 +" find a bookmark or adirectory for the given string function! s:Creator._pathForString(str) let path = {} if g:NERDTreeBookmark.BookmarkExistsFor(a:str) @@ -278,7 +284,7 @@ function! s:Creator._removeTreeBufForTab() unlet t:NERDTreeBufName endfunction -"FUNCTION: s:Creator._setCommonBufOptions() {{{1 +" FUNCTION: s:Creator._setCommonBufOptions() {{{1 function! s:Creator._setCommonBufOptions() "throwaway buffer options setlocal noswapfile @@ -310,7 +316,7 @@ function! s:Creator._setCommonBufOptions() setlocal filetype=nerdtree endfunction -"FUNCTION: s:Creator._setupStatusline() {{{1 +" FUNCTION: s:Creator._setupStatusline() {{{1 function! s:Creator._setupStatusline() if g:NERDTreeStatusline != -1 let &l:statusline = g:NERDTreeStatusline @@ -335,19 +341,19 @@ function! s:Creator._tabpagevar(tabnr, var) return v endfunction -"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1 +" FUNCTION: s:Creator.ToggleTabTree(dir) {{{1 function! s:Creator.ToggleTabTree(dir) let creator = s:Creator.New() call creator.toggleTabTree(a:dir) endfunction -"FUNCTION: s:Creator.toggleTabTree(dir) {{{1 -"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -"closed it is restored or initialized (if it doesnt exist) +" FUNCTION: s:Creator.toggleTabTree(dir) {{{1 +" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is +" closed it is restored or initialized (if it doesnt exist) " -"Args: -"dir: the full path for the root node (is only used if the NERD tree is being -"initialized. +" Args: +" dir: the full path for the root node (is only used if the NERD tree is being +" initialized. function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() From 870bedef21f6360ac0c1134505b2068c54577292 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 09:08:24 -0500 Subject: [PATCH 367/680] Clean up the Creator.createTabTree() function --- lib/nerdtree/creator.vim | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index dae4c689..da5d9802 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -47,33 +47,26 @@ endfunction " FUNCTION: s:Creator.createTabTree(a:name) {{{1 " name: the name of a bookmark or a directory function! s:Creator.createTabTree(name) - let path = self._pathForString(a:name) + let l:path = self._pathForString(a:name) - "abort if exception was thrown (bookmark/dir doesn't exist) - if empty(path) + " Abort if an exception was thrown (i.e., if the bookmark or directory + " does not exist). + if empty(l:path) return endif - if path == {} - return - endif - - "if instructed to, then change the vim CWD to the dir the NERDTree is - "inited in + " Obey the user's preferences for changing the working directory. if g:NERDTreeChDirMode != 0 - call path.changeToDir() + call l:path.changeToDir() endif if g:NERDTree.ExistsForTab() - if g:NERDTree.IsOpen() - call g:NERDTree.Close() - endif - + call g:NERDTree.Close() call self._removeTreeBufForTab() endif call self._createTreeWin() - call self._createNERDTree(path, "tab") + call self._createNERDTree(l:path, 'tab') call b:NERDTree.render() call b:NERDTree.root.putCursorHere(0, 0) From 0a0374b826dcdb3cdee4b40393205c16c744aa8c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 09:09:19 -0500 Subject: [PATCH 368/680] Remove an unnecessary assignment --- lib/nerdtree/creator.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index da5d9802..ec04140c 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -109,11 +109,6 @@ endfunction " FUNCTION: s:Creator._createNERDTree(path) {{{1 function! s:Creator._createNERDTree(path, type) let b:NERDTree = g:NERDTree.New(a:path, a:type) - "TODO: This is kept for compatability only since many things use - "b:NERDTreeRoot instead of the new NERDTree.root - "Remove this one day - let b:NERDTreeRoot = b:NERDTree.root - call b:NERDTree.root.open() endfunction From ae1c95bcbc458a4c4fe10cca3520ebf141eeda55 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 11:00:26 -0500 Subject: [PATCH 369/680] Explicitly call open() in "ui_glue.vim" callbacks This bug is subtle! Opening a directory node in a new tab (with the "t" or "T" mappings) would previously fail and require a refresh because it called the directory node's "activate()" method. In reviewing that method (i.e., "activate()"), I discovered that the directory node's NERDTree is rendered before the method returns, which overwrites the content of the tree in the new tab or window. To clarify, when "t" or "T" is used on a directory node, a new directory node and tree must be created to be rendered in a new tab. So, calling "self.getNerdtree().render()" at the bottom of "activate()" will render the NERDTree instance from which "t" or "T" was invoked, not the new NERDTree that is being displayed. This overwrites the new NERDTree text, and, thus, a refresh is required. Since a call to "render()" is almost always necessary at the bottom of "activate()" to keep everything in sync for other mappings, we avoid this problem entirely by using the "open()" method directly (works for files and directories) in the callbacks. Fixes #549. --- autoload/nerdtree/ui_glue.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2d94fd9a..a2921f99 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -68,10 +68,10 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) @@ -494,12 +494,12 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{1 function! s:openInNewTab(target) - call a:target.activate({'where': 't'}) + call a:target.open({'where': 't'}) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 function! s:openInNewTabSilent(target) - call a:target.activate({'where': 't', 'stay': 1}) + call a:target.open({'where': 't', 'stay': 1}) endfunction " FUNCTION: s:openNodeRecursively(node) {{{1 From c9f70140347ec9729e84eb783ec45e5fa7675f3e Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 12:10:08 -0500 Subject: [PATCH 370/680] Fix handlers for "t" and "T" on bookmarks The "t" and "T" mappings didn't work on bookmarks. This commit fixes this problem by making the callbacks more general. Fixes #565. --- autoload/nerdtree/ui_glue.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index a2921f99..f5b4726e 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -494,12 +494,14 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{1 function! s:openInNewTab(target) - call a:target.open({'where': 't'}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) + call l:opener.open(a:target) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 function! s:openInNewTabSilent(target) - call a:target.open({'where': 't', 'stay': 1}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) + call l:opener.open(a:target) endfunction " FUNCTION: s:openNodeRecursively(node) {{{1 From 31dbf1c139bf7fd6dee60e4b127da2a51cbef128 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 12:37:04 -0500 Subject: [PATCH 371/680] Silence messages when opening a file with "T" --- lib/nerdtree/opener.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index ef8ab7fd..974d99d3 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -244,15 +244,20 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() + if self._reuseWindow() return endif call self._gotoTargetWin() - call self._path.edit() + if self._stay + silent call self._path.edit() call self._restoreCursorPos() + return endif + + call self._path.edit() endfunction " FUNCTION: Opener._openDirectory(node) {{{1 From e27cd86a9b34bf9e055a8da35bd797fef2944eb6 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 13:09:42 -0500 Subject: [PATCH 372/680] Document "t" and "T" mappings in the quick help --- lib/nerdtree/ui.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 03f11b84..6ee8dab0 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -47,6 +47,8 @@ function! s:UI._dumpHelp() let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n" let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" let help .= "\" current node recursively\n" From 4c409a1640ab17a0fdcae98a7d82b7e1d5396106 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 11 Nov 2017 13:23:51 -0500 Subject: [PATCH 373/680] Add a note/warning to "TreeDirNode.activate()" This warning makes developers aware of the possibility of overwriting the NERDTree text in a new window when activate is used. --- lib/nerdtree/tree_dir_node.vim | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 62bcf882..03c3545b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -21,12 +21,19 @@ function! s:TreeDirNode.AbsoluteTreeRoot() endfunction " FUNCTION: TreeDirNode.activate([options]) {{{1 -unlet s:TreeDirNode.activate function! s:TreeDirNode.activate(...) - let opts = a:0 ? a:1 : {} - call self.toggleOpen(opts) - call self.getNerdtree().render() - call self.putCursorHere(0, 0) + let l:options = (a:0 > 0) ? a:1 : {} + + call self.toggleOpen(l:options) + + " Note that we only re-render the NERDTree for this node if we did NOT + " create a new node and render it in a new window or tab. In the latter + " case, rendering the NERDTree for this node could overwrite the text of + " the new NERDTree! + if !has_key(l:options, 'where') || empty(l:options['where']) + call self.getNerdtree().render() + call self.putCursorHere(0, 0) + endif endfunction " FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1 From 21c470c316f27721dc12eb507e8da05492aa53c2 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 14 Nov 2017 08:29:40 -0500 Subject: [PATCH 374/680] Have new tabs open as the last tab (with '$') --- lib/nerdtree/opener.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 974d99d3..82a03499 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -75,7 +75,7 @@ function! s:Opener._gotoTargetWin() elseif self._where == 'h' split elseif self._where == 't' - tabnew + $tabnew endif else call self._checkToCloseTree(1) @@ -85,7 +85,7 @@ function! s:Opener._gotoTargetWin() elseif self._where == 'h' call self._newSplit() elseif self._where == 't' - tabnew + $tabnew elseif self._where == 'p' call self._previousWindow() endif From e59d02575e35c268bae83df33131bd8539bc5111 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 14 Nov 2017 08:33:31 -0500 Subject: [PATCH 375/680] Update the CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 3d377ab2..6dac46dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Next + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759 - Update doc with already existing mapping variables (asnr) #699 - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696 - Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648 From 93356cd92ba914af24cf8c4db0ef2fa1deac3769 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 14 Nov 2017 18:36:09 -0500 Subject: [PATCH 376/680] Add back support for "b:NERDTreeRoot" (#765) --- lib/nerdtree/creator.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index ec04140c..047939fa 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -109,6 +109,12 @@ endfunction " FUNCTION: s:Creator._createNERDTree(path) {{{1 function! s:Creator._createNERDTree(path, type) let b:NERDTree = g:NERDTree.New(a:path, a:type) + + " TODO: This assignment is kept for compatibility reasons. Many other + " plugins use "b:NERDTreeRoot" instead of "b:NERDTree.root". Remove this + " assignment in the future. + let b:NERDTreeRoot = b:NERDTree.root + call b:NERDTree.root.open() endfunction From 70c8cb9bfa33add36680bafaef79e3474164dd11 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 18 Nov 2017 09:50:40 -0500 Subject: [PATCH 377/680] Revert change to tab opening method (#766) Previously the "t" and "T" mappings were altered to open new tabs at the end of the tab line. This commit reverts that change. --- lib/nerdtree/opener.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 82a03499..974d99d3 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -75,7 +75,7 @@ function! s:Opener._gotoTargetWin() elseif self._where == 'h' split elseif self._where == 't' - $tabnew + tabnew endif else call self._checkToCloseTree(1) @@ -85,7 +85,7 @@ function! s:Opener._gotoTargetWin() elseif self._where == 'h' call self._newSplit() elseif self._where == 't' - $tabnew + tabnew elseif self._where == 'p' call self._previousWindow() endif From f526c4e652c066807db1d8e99c0d23017c511328 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 18 Nov 2017 09:51:34 -0500 Subject: [PATCH 378/680] Clean up the handler for the "x" mapping (#767) Previously, pressing "x" on the tree root would result in unpredictable behavior. The user would either an receive an error message or the parent of the tree root (which is not visible) would be closed. This commit repairs this problem. In addition, some code duplication was removed. --- autoload/nerdtree/ui_glue.vim | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index f5b4726e..79292356 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -184,24 +184,28 @@ function! s:closeChildren(node) endfunction " FUNCTION: s:closeCurrentDir(node) {{{1 -" closes the parent dir of the current node +" Close the parent directory of the current node. function! s:closeCurrentDir(node) - let parent = a:node.parent - while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot() - let childNodes = parent.getVisibleChildren() - if len(childNodes) == 1 && childNodes[0].path.isDirectory - let parent = parent.parent - else - break - endif - endwhile - if parent ==# {} || parent.isRoot() - call nerdtree#echo("cannot close tree root") - else - call parent.close() - call b:NERDTree.render() - call parent.putCursorHere(0, 0) + + if a:node.isRoot() + call nerdtree#echo('cannot close parent of tree root') + return + endif + + let l:parent = a:node.parent + + if empty(l:parent) || l:parent.isRoot() + call nerdtree#echo('cannot close tree root') + return endif + + while l:parent.isCascadable() + let l:parent = l:parent.parent + endwhile + + call l:parent.close() + call b:NERDTree.render() + call l:parent.putCursorHere(0, 0) endfunction " FUNCTION: s:closeTreeWindow() {{{1 From e0e36c53855cb309d7a9af15bab69f8d3699966f Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 18 Nov 2017 10:55:43 -0500 Subject: [PATCH 379/680] Fix a problem with the "x" handler (#768) Pressing "x" on a cascade could close the root of the tree. This commit prevents that from happening. --- autoload/nerdtree/ui_glue.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 79292356..93ac5675 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -194,15 +194,15 @@ function! s:closeCurrentDir(node) let l:parent = a:node.parent - if empty(l:parent) || l:parent.isRoot() - call nerdtree#echo('cannot close tree root') - return - endif - while l:parent.isCascadable() let l:parent = l:parent.parent endwhile + if l:parent.isRoot() + call nerdtree#echo('cannot close tree root') + return + endif + call l:parent.close() call b:NERDTree.render() call l:parent.putCursorHere(0, 0) From ac94cd28c22b9f26f429390aa8871a36711dc31e Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 19 Nov 2017 16:37:54 -0500 Subject: [PATCH 380/680] Make the "o" mapping consistent with "x" The "o" mapping, which toggles directory nodes open/closed, allowed the user to close the tree root. This was not consistent with the "x" mapping which stops the user from doing this. This applies to a double-click on the root node as well. It should be noted that, if the root node is somehow closed, "o" and double click can still re-open the tree, even with this change. In other words, I was careful. --- autoload/nerdtree/ui_glue.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 93ac5675..689b7845 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -90,10 +90,15 @@ function! s:activateAll() endif endfunction -"FUNCTION: s:activateDirNode() {{{1 -"handle the user activating a tree node -function! s:activateDirNode(node) - call a:node.activate() +" FUNCTION: s:activateDirNode(directoryNode) {{{1 +function! s:activateDirNode(directoryNode) + + if a:directoryNode.isRoot() && a:directoryNode.isOpen + call nerdtree#echo('cannot close tree root') + return + endif + + call a:directoryNode.activate() endfunction "FUNCTION: s:activateFileNode() {{{1 From 3485b2a939324713db9c93210e288067e297833c Mon Sep 17 00:00:00 2001 From: SkyBlueEE Date: Mon, 27 Nov 2017 23:56:41 +0800 Subject: [PATCH 381/680] remove useless substitute when 'file =~# "/$"' --- lib/nerdtree/ui.vim | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6ee8dab0..28bf4457 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -166,12 +166,6 @@ function! s:UI.getPath(ln) "remove the tree parts and the leading space let curFile = self._stripMarkup(line, 0) - let wasdir = 0 - if curFile =~# '/$' - let wasdir = 1 - let curFile = substitute(curFile, '/\?$', '/', "") - endif - let dir = "" let lnum = a:ln while lnum > 0 @@ -390,14 +384,7 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces) "strip off any generic flags let line = substitute (line, '\[[^]]*\]', "","") - let wasdir = 0 - if line =~# '/$' - let wasdir = 1 - endif let line = substitute (line,' -> .*',"","") " remove link to - if wasdir ==# 1 - let line = substitute (line, '/\?$', '/', "") - endif if a:removeLeadingSpaces let line = substitute (line, '^ *', '', '') From ea01a691a29f639ee09e13db45120b167653a1f2 Mon Sep 17 00:00:00 2001 From: SkyBlueEE Date: Tue, 28 Nov 2017 00:04:03 +0800 Subject: [PATCH 382/680] remove useless removeLeadingSpaces in _stripMarkup --- lib/nerdtree/ui.vim | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6ee8dab0..f9d7c161 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -164,7 +164,7 @@ function! s:UI.getPath(ln) let indent = self._indentLevelFor(line) "remove the tree parts and the leading space - let curFile = self._stripMarkup(line, 0) + let curFile = self._stripMarkup(line) let wasdir = 0 if curFile =~# '/$' @@ -177,7 +177,7 @@ function! s:UI.getPath(ln) while lnum > 0 let lnum = lnum - 1 let curLine = getline(lnum) - let curLineStripped = self._stripMarkup(curLine, 1) + let curLineStripped = self._stripMarkup(curLine) "have we reached the top of the tree? if lnum == rootLine @@ -228,7 +228,7 @@ function! s:UI.getLineNum(file_node) let indent = self._indentLevelFor(curLine) if indent ==# curPathComponent - let curLine = self._stripMarkup(curLine, 1) + let curLine = self._stripMarkup(curLine) let curPath = join(pathcomponents, '/') . '/' . curLine if stridx(fullpath, curPath, 0) ==# 0 @@ -366,14 +366,12 @@ function! s:UI.setShowHidden(val) let self._showHidden = a:val endfunction -"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 +"FUNCTION: s:UI._stripMarkup(line){{{1 "returns the given line with all the tree parts stripped off " "Args: "line: the subject line -"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = -"any spaces before the actual text of the node) -function! s:UI._stripMarkup(line, removeLeadingSpaces) +function! s:UI._stripMarkup(line) let line = a:line "remove the tree parts and the leading space let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") @@ -399,10 +397,6 @@ function! s:UI._stripMarkup(line, removeLeadingSpaces) let line = substitute (line, '/\?$', '/', "") endif - if a:removeLeadingSpaces - let line = substitute (line, '^ *', '', '') - endif - return line endfunction From e48ae299f9ea4dbab8e636d23e1c83badd8c5058 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 1 Dec 2017 08:45:18 -0500 Subject: [PATCH 383/680] Update the delete bookmark map to use confirm() I contend that we should use confirm() whenever possible. It makes the code cleaner and uses a builtin feature rather than a custom one. Doing it the "Vim way" is always preferable in my mind. --- autoload/nerdtree/ui_glue.vim | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 689b7845..dbc34e5b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -227,24 +227,30 @@ function! s:closeTreeWindow() endif endfunction -" FUNCTION: s:deleteBookmark(bm) {{{1 -" if the cursor is on a bookmark, prompt to delete -function! s:deleteBookmark(bm) - echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" +" FUNCTION: s:deleteBookmark(bookmark) {{{1 +" Prompt the user to confirm the deletion of the selected bookmark. +function! s:deleteBookmark(bookmark) + let l:message = "Delete the bookmark \"" . a:bookmark.name + \ . "\" from the bookmark list?" - if nr2char(getchar()) ==# 'y' - try - call a:bm.delete() - call b:NERDTree.root.refresh() - call b:NERDTree.render() - redraw - catch /^NERDTree/ - call nerdtree#echoWarning("Could not remove bookmark") - endtry - else - call nerdtree#echo("delete aborted" ) + let l:choices = "&Yes\n&No" + + echo | redraw + let l:selection = confirm(l:message, l:choices, 1, 'Warning') + + if l:selection != 1 + call nerdtree#echo('bookmark not deleted') + return endif + try + call a:bookmark.delete() + silent call b:NERDTree.root.refresh() + call b:NERDTree.render() + echo | redraw + catch /^NERDTree/ + call nerdtree#echoWarning('could not remove bookmark') + endtry endfunction " FUNCTION: s:displayHelp() {{{1 From 12960b966f7c7b19c56936856ce30942f655d58f Mon Sep 17 00:00:00 2001 From: zhenyangze Date: Sat, 9 Dec 2017 16:58:18 +0800 Subject: [PATCH 384/680] change NERDTreeFind with args --- autoload/nerdtree/ui_glue.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index dbc34e5b..338f5e9e 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -262,9 +262,15 @@ function! s:displayHelp() endfunction " FUNCTION: s:findAndRevealPath() {{{1 -function! s:findAndRevealPath() +function! s:findAndRevealPath(userPath) + if len(a:userPath) == 0 + let s:userPath = expand("%:p") + else + let s:userPath = a:userPath + endif + try - let p = g:NERDTreePath.New(expand("%:p")) + let p = g:NERDTreePath.New(s:userPath) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echo("no file for the current buffer") return @@ -587,7 +593,7 @@ function! nerdtree#ui_glue#setupCommands() command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() - command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() + command! -n=? -complete=dir -bar NERDTreeFind call s:findAndRevealPath('') command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() endfunction From 21297404190e4a273d1afa318df121a49add580a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 9 Dec 2017 11:09:10 -0500 Subject: [PATCH 385/680] Add style improvements Function-local variables, instead of script-local variables, should be used here. In addition, "empty()" is a better choice for testing for the absence of an argument. Finally, the use of "else" is removed. The docstring is also updated to include the new argument. --- autoload/nerdtree/ui_glue.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 338f5e9e..60cc5dd3 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -261,16 +261,16 @@ function! s:displayHelp() call b:NERDTree.ui.centerView() endfunction -" FUNCTION: s:findAndRevealPath() {{{1 -function! s:findAndRevealPath(userPath) - if len(a:userPath) == 0 - let s:userPath = expand("%:p") - else - let s:userPath = a:userPath +" FUNCTION: s:findAndRevealPath(path) {{{1 +function! s:findAndRevealPath(path) + let l:path = a:path + + if empty(l:path) + let l:path = expand('%:p') endif try - let p = g:NERDTreePath.New(s:userPath) + let p = g:NERDTreePath.New(l:path) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echo("no file for the current buffer") return From b4b99c39fa4d22b355445034db44f4abfaf5cbe8 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Tue, 12 Dec 2017 08:22:07 -0500 Subject: [PATCH 386/680] Change the type of completion used by NERDTreeFind This command should complete file names, not directories. Fixes #780. --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 60cc5dd3..92795ca3 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -593,7 +593,7 @@ function! nerdtree#ui_glue#setupCommands() command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() - command! -n=? -complete=dir -bar NERDTreeFind call s:findAndRevealPath('') + command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('') command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() endfunction From 9f985514f0be074f3bc6430222c3e75192191b9c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 17 Dec 2017 08:42:49 -0500 Subject: [PATCH 387/680] Add modelines --- lib/nerdtree/flag_set.vim | 2 ++ lib/nerdtree/nerdtree.vim | 2 ++ lib/nerdtree/notifier.vim | 1 - lib/nerdtree/ui.vim | 2 ++ nerdtree_plugin/fs_menu.vim | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/flag_set.vim b/lib/nerdtree/flag_set.vim index 9d8d3359..bc6e8879 100644 --- a/lib/nerdtree/flag_set.vim +++ b/lib/nerdtree/flag_set.vim @@ -54,3 +54,5 @@ function! s:FlagSet.renderToString() return '[' . flagstring . ']' endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index ffbc9d3c..12e3ebbc 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -195,3 +195,5 @@ endfunction function! s:NERDTree.render() call self.ui.render() endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index 00041b85..d24fc8f8 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -32,4 +32,3 @@ function! s:Notifier.GetListenersForEvent(name) endfunction let g:NERDTreePathNotifier = deepcopy(s:Notifier) - diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ad7bd190..725b0c55 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -519,3 +519,5 @@ endfunction function! s:UI.UpDirLine() return '.. (up a dir)' endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 3bb11dba..928d8a2f 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -335,4 +335,5 @@ function! NERDTreeExecuteFile() call system("open '" . treenode.path.str() . "'") endif endfunction + " vim: set sw=4 sts=4 et fdm=marker: From fc14b4f5df9be4d1c1d67c99d841e634bd5472ea Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 19 Dec 2017 09:45:47 -0500 Subject: [PATCH 388/680] Add :Helptags to the pathogen instructions --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 879d96d4..6efeb0bd 100644 --- a/README.markdown +++ b/README.markdown @@ -21,7 +21,7 @@ Installation git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree -Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERDTree.txt`. +Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`, and check out `:help NERDTree.txt`. #### [apt-vim](https://github.com/egalpin/apt-vim) From 496d9a17d86185b6c41ea34877c7024d10837531 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 21 Dec 2017 08:28:28 -0500 Subject: [PATCH 389/680] Remove code duplication in "findAndRevealPath" --- autoload/nerdtree/ui_glue.vim | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 92795ca3..411c3128 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -270,13 +270,13 @@ function! s:findAndRevealPath(path) endif try - let p = g:NERDTreePath.New(l:path) + let l:p = g:NERDTreePath.New(l:path) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("no file for the current buffer") + call nerdtree#echo('no file for the current buffer') return endtry - if p.isUnixHiddenPath() + if l:p.isUnixHiddenPath() let showhidden=g:NERDTreeShowHidden let g:NERDTreeShowHidden = 1 endif @@ -285,36 +285,29 @@ function! s:findAndRevealPath(path) try let cwd = g:NERDTreePath.New(getcwd()) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("current directory does not exist.") - let cwd = p.getParent() + call nerdtree#echo('current directory does not exist.') + let cwd = l:p.getParent() endtry - if p.isUnder(cwd) + if l:p.isUnder(cwd) call g:NERDTreeCreator.CreateTabTree(cwd.str()) else - call g:NERDTreeCreator.CreateTabTree(p.getParent().str()) + call g:NERDTreeCreator.CreateTabTree(l:p.getParent().str()) endif else - if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) - if !g:NERDTree.IsOpen() - call g:NERDTreeCreator.ToggleTabTree('') - else - call g:NERDTree.CursorToTreeWin() - endif + NERDTreeFocus + + if !l:p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden) - call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree)) - else - if !g:NERDTree.IsOpen() - call g:NERDTreeCreator.ToggleTabTree("") - endif + call s:chRoot(g:NERDTreeDirNode.New(l:p.getParent(), b:NERDTree)) endif endif - call g:NERDTree.CursorToTreeWin() - let node = b:NERDTree.root.reveal(p) + + let node = b:NERDTree.root.reveal(l:p) call b:NERDTree.render() call node.putCursorHere(1,0) - if p.isUnixHiddenFile() + if l:p.isUnixHiddenFile() let g:NERDTreeShowHidden = showhidden endif endfunction From 5301dd24fb1478ebbdb5a026c8a84c1b8b03b2c5 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 21 Dec 2017 08:43:15 -0500 Subject: [PATCH 390/680] Improve variable naming in "findAndRevealPath" --- autoload/nerdtree/ui_glue.vim | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 411c3128..910ead30 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -270,45 +270,45 @@ function! s:findAndRevealPath(path) endif try - let l:p = g:NERDTreePath.New(l:path) + let l:pathObj = g:NERDTreePath.New(l:path) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echo('no file for the current buffer') return endtry - if l:p.isUnixHiddenPath() - let showhidden=g:NERDTreeShowHidden + if l:pathObj.isUnixHiddenPath() + let l:showHidden = g:NERDTreeShowHidden let g:NERDTreeShowHidden = 1 endif if !g:NERDTree.ExistsForTab() try - let cwd = g:NERDTreePath.New(getcwd()) + let l:cwd = g:NERDTreePath.New(getcwd()) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echo('current directory does not exist.') - let cwd = l:p.getParent() + let l:cwd = l:pathObj.getParent() endtry - if l:p.isUnder(cwd) - call g:NERDTreeCreator.CreateTabTree(cwd.str()) + if l:pathObj.isUnder(l:cwd) + call g:NERDTreeCreator.CreateTabTree(l:cwd.str()) else - call g:NERDTreeCreator.CreateTabTree(l:p.getParent().str()) + call g:NERDTreeCreator.CreateTabTree(l:pathObj.getParent().str()) endif else NERDTreeFocus - if !l:p.isUnder(g:NERDTreeFileNode.GetRootForTab().path) + if !l:pathObj.isUnder(g:NERDTreeFileNode.GetRootForTab().path) call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden) - call s:chRoot(g:NERDTreeDirNode.New(l:p.getParent(), b:NERDTree)) + call s:chRoot(g:NERDTreeDirNode.New(l:pathObj.getParent(), b:NERDTree)) endif endif - let node = b:NERDTree.root.reveal(l:p) + let l:node = b:NERDTree.root.reveal(l:pathObj) call b:NERDTree.render() - call node.putCursorHere(1,0) + call l:node.putCursorHere(1, 0) - if l:p.isUnixHiddenFile() - let g:NERDTreeShowHidden = showhidden + if l:pathObj.isUnixHiddenFile() + let g:NERDTreeShowHidden = l:showHidden endif endfunction From 90d08dc626f0638cd079895a68ee0cf7f7e03d9a Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 21 Dec 2017 09:26:26 -0500 Subject: [PATCH 391/680] Add a debugging message --- autoload/nerdtree/ui_glue.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 910ead30..894a88a4 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -304,6 +304,11 @@ function! s:findAndRevealPath(path) endif let l:node = b:NERDTree.root.reveal(l:pathObj) + + if empty(l:node) + echomsg 'l:node is totally empty...' + endif + call b:NERDTree.render() call l:node.putCursorHere(1, 0) From 344119439e417839d217f31c6195f996e91ce8a1 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 21 Dec 2017 10:26:07 -0500 Subject: [PATCH 392/680] Refresh children of directory nodes on "reveal()" The ":NERDTreeFind" command calls the "reveal()" method on the NERDTree root node. The "reveal()" method would, in turn, call the node's "open()" method. Since the "open()" method would only initialize the child nodes of the root (i.e., read them from disk) when the list of child nodes was empty, new paths would not be included in the list. This commit will result in the refreshing of the child node list whenever "reveal()" is called on a directory node (unless it is the first time the node is being opened... the most efficient option). The result is that ":NERDTreeFind" will discover newly created paths that exist on disk but are not cached in the NERDTree. A stray debugging message is also removed. Fixes issue #779. --- autoload/nerdtree/ui_glue.vim | 5 ----- lib/nerdtree/tree_dir_node.vim | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 894a88a4..910ead30 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -304,11 +304,6 @@ function! s:findAndRevealPath(path) endif let l:node = b:NERDTree.root.reveal(l:pathObj) - - if empty(l:node) - echomsg 'l:node is totally empty...' - endif - call b:NERDTree.render() call l:node.putCursorHere(1, 0) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 03c3545b..43285db4 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -568,6 +568,13 @@ function! s:TreeDirNode.reveal(path, ...) throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() endif + " Refresh "self.children" to avoid missing paths created after this node + " was last opened. If "self.children" is empty, the call to "open()" will + " initialize the children. + if !empty(self.children) + " Silence messages/errors. They were seen on the first open. + silent! call self._initChildren(1) + endif call self.open() if self.path.equals(a:path.getParent()) From 01b011d38e2af0e11f03d34d80d4cfae497732da Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 22 Dec 2017 08:45:57 -0500 Subject: [PATCH 393/680] Have "finAndRevealPath()" fail on no file If a file does not exist for the current buffer, this function should fail with a clear warning message. Here, I improved the messages that this function prints so that it fails gracefully when no path can be determined in the calling context. --- autoload/nerdtree/ui_glue.vim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 910ead30..e2dc96a2 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -261,18 +261,19 @@ function! s:displayHelp() call b:NERDTree.ui.centerView() endfunction -" FUNCTION: s:findAndRevealPath(path) {{{1 -function! s:findAndRevealPath(path) - let l:path = a:path +" FUNCTION: s:findAndRevealPath(pathStr) {{{1 +function! s:findAndRevealPath(pathStr) + let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') - if empty(l:path) - let l:path = expand('%:p') + if empty(l:pathStr) + call nerdtree#echoWarning('no file for the current buffer') + return endif - + try - let l:pathObj = g:NERDTreePath.New(l:path) + let l:pathObj = g:NERDTreePath.New(l:pathStr) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo('no file for the current buffer') + call nerdtree#echoWarning('invalid path') return endtry From f6dad4796e30cd1960dc2bed230e69c20f02313c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 22 Dec 2017 09:15:07 -0500 Subject: [PATCH 394/680] Update the documentation The docs for ":NERDTreeFind" are updated. Some additional formatting changes are made to other sections. --- doc/NERDTree.txt | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index f68880cd..38fbad9d 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -126,20 +126,20 @@ The following features and functionality are provided by the NERD tree: Changes made to one tree are reflected in both as they are actually the same buffer. - If only one other NERD tree exists, that tree is automatically mirrored. If - more than one exists, the script will ask which tree to mirror. + If only one other NERD tree exists, that tree is automatically mirrored. + If more than one exists, the script will ask which tree to mirror. :NERDTreeClose *:NERDTreeClose* Close the NERD tree in this tab. -:NERDTreeFind *:NERDTreeFind* - Find the current file in the tree. +:NERDTreeFind [] *:NERDTreeFind* + Without the optional argument, find and reveal the file for the active + buffer in the NERDTree window. With the argument, find and + reveal the specified path. - If no tree exists and the current file is under vim's CWD, then init a - tree at the CWD and reveal the file. Otherwise init a tree in the current - file's directory. - - In any case, the current file is revealed and the cursor is placed on it. + Focus will be shifted to the NERDTree window, and the cursor will be + placed on the tree node for the determined path. If a NERDTree for the + current tab does not exist, a new one will be initialized. :NERDTreeCWD *:NERDTreeCWD* Change tree root to current directory. If no NERD tree exists for this @@ -1128,13 +1128,12 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* Additionally, a "scope" argument may be supplied. This constrains the mapping so that it is only activated if the cursor is on a certain object. That object is then passed into the handling method. Possible values are: - "FileNode" - a file node - "DirNode" - a directory node - "Node" - a file or directory node - "Bookmark" - A bookmark - "all" - the keymap is not constrained to any scope (default). When - thei is used, the handling function is not passed any arguments. + "FileNode" .... a file node + "DirNode" ..... a directory node + "Node" ........ a file node OR a directory node + "Bookmark" .... a bookmark + "all" ......... global scope; handler receives no arguments (default) Example: > call NERDTreeAddKeyMap({ From 0ff697eb408c2045018796ad1ba13c1714a348a1 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 22 Dec 2017 10:28:31 -0500 Subject: [PATCH 395/680] Implement the "isHiddenUnder()" method for Path --- autoload/nerdtree/ui_glue.vim | 16 +++++----------- lib/nerdtree/path.vim | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index e2dc96a2..e1847039 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -277,11 +277,6 @@ function! s:findAndRevealPath(pathStr) return endtry - if l:pathObj.isUnixHiddenPath() - let l:showHidden = g:NERDTreeShowHidden - let g:NERDTreeShowHidden = 1 - endif - if !g:NERDTree.ExistsForTab() try let l:cwd = g:NERDTreePath.New(getcwd()) @@ -298,19 +293,18 @@ function! s:findAndRevealPath(pathStr) else NERDTreeFocus - if !l:pathObj.isUnder(g:NERDTreeFileNode.GetRootForTab().path) - call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden) + if !l:pathObj.isUnder(b:NERDTree.root.path) call s:chRoot(g:NERDTreeDirNode.New(l:pathObj.getParent(), b:NERDTree)) endif endif + if l:pathObj.isHiddenUnder(b:NERDTree.root.path) + call b:NERDTree.ui.setShowHidden(1) + endif + let l:node = b:NERDTree.root.reveal(l:pathObj) call b:NERDTree.render() call l:node.putCursorHere(1, 0) - - if l:pathObj.isUnixHiddenFile() - let g:NERDTreeShowHidden = l:showHidden - endif endfunction "FUNCTION: s:handleLeftClick() {{{1 diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 3e7c9133..b4916b46 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -405,6 +405,25 @@ function! s:Path.getSortKey() return self._sortKey endfunction +" FUNCTION: Path.isHiddenUnder(path) {{{1 +function! s:Path.isHiddenUnder(path) + + if !self.isUnder(a:path) + return 0 + endif + + let l:startIndex = len(a:path.pathSegments) + let l:segments = self.pathSegments[l:startIndex:] + + for l:segment in l:segments + + if l:segment =~# '^\.' + return 1 + endif + endfor + + return 0 +endfunction " FUNCTION: Path.isUnixHiddenFile() {{{1 " check for unix hidden files From d90b2af47431e95eb205366787ead57133d25a2c Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 22 Dec 2017 10:46:49 -0500 Subject: [PATCH 396/680] Add a space to help the parser --- lib/nerdtree/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index b4916b46..595d897e 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -413,7 +413,7 @@ function! s:Path.isHiddenUnder(path) endif let l:startIndex = len(a:path.pathSegments) - let l:segments = self.pathSegments[l:startIndex:] + let l:segments = self.pathSegments[l:startIndex : ] for l:segment in l:segments From af3ba1ef4eb2fd9023516bfb303b8f6f97924ecb Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Fri, 5 Jan 2018 08:23:03 -0500 Subject: [PATCH 397/680] Revert the bugfix from pull request #785 The small change here reverts an attempted bugfix from #785. That change resulted in the unintended side-effect of closing other children of the root whenever ":NERDTreeFind" was invoked. This was disruptive (as reported in #793), so a new method must be found to solve the problem of ":NERDTreeFind" not opening newly created files. Fixes #793. --- lib/nerdtree/tree_dir_node.vim | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 43285db4..03c3545b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -568,13 +568,6 @@ function! s:TreeDirNode.reveal(path, ...) throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() endif - " Refresh "self.children" to avoid missing paths created after this node - " was last opened. If "self.children" is empty, the call to "open()" will - " initialize the children. - if !empty(self.children) - " Silence messages/errors. They were seen on the first open. - silent! call self._initChildren(1) - endif call self.open() if self.path.equals(a:path.getParent()) From f4df03836662b0a32466861bd893db602c39f3aa Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 08:35:34 -0500 Subject: [PATCH 398/680] Refactor the "Path" constructor --- lib/nerdtree/path.vim | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 595d897e..3bb4f254 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -541,17 +541,16 @@ function! s:Path.equals(path) return self.str() ==# a:path.str() endfunction -" FUNCTION: Path.New() {{{1 -" The Constructor for the Path object -function! s:Path.New(path) - let newPath = copy(self) +" FUNCTION: Path.New(pathStr) {{{1 +function! s:Path.New(pathStr) + let l:newPath = copy(self) - call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path)) + call l:newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:pathStr)) - let newPath.cachedDisplayString = "" - let newPath.flagSet = g:NERDTreeFlagSet.New() + let l:newPath.cachedDisplayString = '' + let l:newPath.flagSet = g:NERDTreeFlagSet.New() - return newPath + return l:newPath endfunction " FUNCTION: Path.Slash() {{{1 From e6a116a9cd20bad7150de22f31311e492127224b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 08:41:55 -0500 Subject: [PATCH 399/680] Improve the code style in a "Path" method No functional changes here. Only style improvements were made. --- lib/nerdtree/path.vim | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 3bb4f254..65cd5ca8 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -14,21 +14,23 @@ lockvar s:NERDTreeSortStarIndex let s:Path = {} let g:NERDTreePath = s:Path -" FUNCTION: Path.AbsolutePathFor(str) {{{1 -function! s:Path.AbsolutePathFor(str) - let prependCWD = 0 +" FUNCTION: Path.AbsolutePathFor(pathStr) {{{1 +function! s:Path.AbsolutePathFor(pathStr) + let l:prependWorkingDir = 0 + if nerdtree#runningWindows() - let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)' + let l:prependWorkingDir = a:pathStr !~# '^.:\(\\\|\/\)' && a:pathStr !~# '^\(\\\\\|\/\/\)' else - let prependCWD = a:str !~# '^/' + let l:prependWorkingDir = a:pathStr !~# '^/' endif - let toReturn = a:str - if prependCWD - let toReturn = getcwd() . s:Path.Slash() . a:str + let l:result = a:pathStr + + if l:prependWorkingDir + let l:result = getcwd() . s:Path.Slash() . a:pathStr endif - return toReturn + return l:result endfunction " FUNCTION: Path.bookmarkNames() {{{1 From d745e11b42201e4cdec2b98ca51011ffcaf1236b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 08:54:28 -0500 Subject: [PATCH 400/680] Format the commentary in "tree_file_node.vim" --- lib/nerdtree/tree_file_node.vim | 187 ++++++++++++++++---------------- 1 file changed, 95 insertions(+), 92 deletions(-) diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index adb0e96b..c7e48956 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -1,22 +1,25 @@ -"CLASS: TreeFileNode -"This class is the parent of the TreeDirNode class and is the -"'Component' part of the composite design pattern between the treenode -"classes. -"============================================================ +" ============================================================================ +" CLASS: TreeFileNode +" +" This class is the parent of the "TreeDirNode" class and is the "Component" +" part of the composite design pattern between the NERDTree node classes. +" ============================================================================ + + let s:TreeFileNode = {} let g:NERDTreeFileNode = s:TreeFileNode -"FUNCTION: TreeFileNode.activate(...) {{{1 +" FUNCTION: TreeFileNode.activate(...) {{{1 function! s:TreeFileNode.activate(...) call self.open(a:0 ? a:1 : {}) endfunction -"FUNCTION: TreeFileNode.bookmark(name) {{{1 -"bookmark this node with a:name +" FUNCTION: TreeFileNode.bookmark(name) {{{1 +" bookmark this node with a:name function! s:TreeFileNode.bookmark(name) - "if a bookmark exists with the same name and the node is cached then save - "it so we can update its display string + " if a bookmark exists with the same name and the node is cached then save + " it so we can update its display string let oldMarkedNode = {} try let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree()) @@ -33,8 +36,8 @@ function! s:TreeFileNode.bookmark(name) endif endfunction -"FUNCTION: TreeFileNode.cacheParent() {{{1 -"initializes self.parent if it isnt already +" FUNCTION: TreeFileNode.cacheParent() {{{1 +" initializes self.parent if it isnt already function! s:TreeFileNode.cacheParent() if empty(self.parent) let parentPath = self.path.getParent() @@ -45,7 +48,7 @@ function! s:TreeFileNode.cacheParent() endif endfunction -"FUNCTION: TreeFileNode.clearBookmarks() {{{1 +" FUNCTION: TreeFileNode.clearBookmarks() {{{1 function! s:TreeFileNode.clearBookmarks() for i in g:NERDTreeBookmark.Bookmarks() if i.path.equals(self.path) @@ -55,7 +58,7 @@ function! s:TreeFileNode.clearBookmarks() call self.path.cacheDisplayString() endfunction -"FUNCTION: TreeFileNode.copy(dest) {{{1 +" FUNCTION: TreeFileNode.copy(dest) {{{1 function! s:TreeFileNode.copy(dest) call self.path.copy(a:dest) let newPath = g:NERDTreePath.New(a:dest) @@ -68,44 +71,44 @@ function! s:TreeFileNode.copy(dest) endif endfunction -"FUNCTION: TreeFileNode.delete {{{1 -"Removes this node from the tree and calls the Delete method for its path obj +" FUNCTION: TreeFileNode.delete {{{1 +" Removes this node from the tree and calls the Delete method for its path obj function! s:TreeFileNode.delete() call self.path.delete() call self.parent.removeChild(self) endfunction -"FUNCTION: TreeFileNode.displayString() {{{1 +" FUNCTION: TreeFileNode.displayString() {{{1 " -"Returns a string that specifies how the node should be represented as a -"string +" Returns a string that specifies how the node should be represented as a +" string " -"Return: -"a string that can be used in the view to represent this node +" Return: +" a string that can be used in the view to represent this node function! s:TreeFileNode.displayString() return self.path.flagSet.renderToString() . self.path.displayString() endfunction -"FUNCTION: TreeFileNode.equals(treenode) {{{1 +" FUNCTION: TreeFileNode.equals(treenode) {{{1 " -"Compares this treenode to the input treenode and returns 1 if they are the -"same node. +" Compares this treenode to the input treenode and returns 1 if they are the +" same node. " -"Use this method instead of == because sometimes when the treenodes contain -"many children, vim seg faults when doing == +" Use this method instead of == because sometimes when the treenodes contain +" many children, vim seg faults when doing == " -"Args: -"treenode: the other treenode to compare to +" Args: +" treenode: the other treenode to compare to function! s:TreeFileNode.equals(treenode) return self.path.str() ==# a:treenode.path.str() endfunction -"FUNCTION: TreeFileNode.findNode(path) {{{1 -"Returns self if this node.path.Equals the given path. -"Returns {} if not equal. +" FUNCTION: TreeFileNode.findNode(path) {{{1 +" Returns self if this node.path.Equals the given path. +" Returns {} if not equal. " -"Args: -"path: the path object to compare against +" Args: +" path: the path object to compare against function! s:TreeFileNode.findNode(path) if a:path.equals(self.path) return self @@ -113,18 +116,18 @@ function! s:TreeFileNode.findNode(path) return {} endfunction -"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1 +" FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1 " -"Finds the next sibling for this node in the indicated direction. This sibling -"must be a directory and may/may not have children as specified. +" Finds the next sibling for this node in the indicated direction. This sibling +" must be a directory and may/may not have children as specified. " -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" Args: +" direction: 0 if you want to find the previous sibling, 1 for the next sibling " -"Return: -"a treenode object or {} if no appropriate sibling could be found +" Return: +" a treenode object or {} if no appropriate sibling could be found function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) - "if we have no parent then we can have no siblings + " if we have no parent then we can have no siblings if self.parent != {} let nextSibling = self.findSibling(a:direction) @@ -139,37 +142,37 @@ function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) return {} endfunction -"FUNCTION: TreeFileNode.findSibling(direction) {{{1 +" FUNCTION: TreeFileNode.findSibling(direction) {{{1 " -"Finds the next sibling for this node in the indicated direction +" Finds the next sibling for this node in the indicated direction " -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling +" Args: +" direction: 0 if you want to find the previous sibling, 1 for the next sibling " -"Return: -"a treenode object or {} if no sibling could be found +" Return: +" a treenode object or {} if no sibling could be found function! s:TreeFileNode.findSibling(direction) - "if we have no parent then we can have no siblings + " if we have no parent then we can have no siblings if self.parent != {} - "get the index of this node in its parents children + " get the index of this node in its parents children let siblingIndx = self.parent.getChildIndex(self.path) if siblingIndx != -1 - "move a long to the next potential sibling node + " move a long to the next potential sibling node let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - "keep moving along to the next sibling till we find one that is valid + " keep moving along to the next sibling till we find one that is valid let numSiblings = self.parent.getChildCount() while siblingIndx >= 0 && siblingIndx < numSiblings - "if the next node is not an ignored node (i.e. wont show up in the - "view) then return it + " if the next node is not an ignored node (i.e. wont show up in the + " view) then return it if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0 return self.parent.children[siblingIndx] endif - "go to next node + " go to next node let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 endwhile endif @@ -178,13 +181,13 @@ function! s:TreeFileNode.findSibling(direction) return {} endfunction -"FUNCTION: TreeFileNode.getNerdtree(){{{1 +" FUNCTION: TreeFileNode.getNerdtree(){{{1 function! s:TreeFileNode.getNerdtree() return self._nerdtree endfunction -"FUNCTION: TreeFileNode.GetRootForTab(){{{1 -"get the root node for this tab +" FUNCTION: TreeFileNode.GetRootForTab(){{{1 +" get the root node for this tab function! s:TreeFileNode.GetRootForTab() if g:NERDTree.ExistsForTab() return getbufvar(t:NERDTreeBufName, 'NERDTree').root @@ -192,8 +195,8 @@ function! s:TreeFileNode.GetRootForTab() return {} endfunction -"FUNCTION: TreeFileNode.GetSelected() {{{1 -"gets the treenode that the cursor is currently over +" FUNCTION: TreeFileNode.GetSelected() {{{1 +" gets the treenode that the cursor is currently over function! s:TreeFileNode.GetSelected() try let path = b:NERDTree.ui.getPath(line(".")) @@ -206,14 +209,14 @@ function! s:TreeFileNode.GetSelected() endtry endfunction -"FUNCTION: TreeFileNode.isVisible() {{{1 -"returns 1 if this node should be visible according to the tree filters and -"hidden file filters (and their on/off status) +" FUNCTION: TreeFileNode.isVisible() {{{1 +" returns 1 if this node should be visible according to the tree filters and +" hidden file filters (and their on/off status) function! s:TreeFileNode.isVisible() return !self.path.ignore(self.getNerdtree()) endfunction -"FUNCTION: TreeFileNode.isRoot() {{{1 +" FUNCTION: TreeFileNode.isRoot() {{{1 function! s:TreeFileNode.isRoot() if !g:NERDTree.ExistsForBuf() throw "NERDTree.NoTreeError: No tree exists for the current buffer" @@ -222,12 +225,12 @@ function! s:TreeFileNode.isRoot() return self.equals(self.getNerdtree().root) endfunction -"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1 -"Returns a new TreeNode object with the given path and parent +" FUNCTION: TreeFileNode.New(path, nerdtree) {{{1 +" Returns a new TreeNode object with the given path and parent " -"Args: -"path: file/dir that the node represents -"nerdtree: the tree the node belongs to +" Args: +" path: file/dir that the node represents +" nerdtree: the tree the node belongs to function! s:TreeFileNode.New(path, nerdtree) if a:path.isDirectory return g:NERDTreeDirNode.New(a:path, a:nerdtree) @@ -240,40 +243,40 @@ function! s:TreeFileNode.New(path, nerdtree) endif endfunction -"FUNCTION: TreeFileNode.open() {{{1 +" FUNCTION: TreeFileNode.open() {{{1 function! s:TreeFileNode.open(...) let opts = a:0 ? a:1 : {} let opener = g:NERDTreeOpener.New(self.path, opts) call opener.open(self) endfunction -"FUNCTION: TreeFileNode.openSplit() {{{1 -"Open this node in a new window +" FUNCTION: TreeFileNode.openSplit() {{{1 +" Open this node in a new window function! s:TreeFileNode.openSplit() call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') call self.open({'where': 'h'}) endfunction -"FUNCTION: TreeFileNode.openVSplit() {{{1 -"Open this node in a new vertical window +" FUNCTION: TreeFileNode.openVSplit() {{{1 +" Open this node in a new vertical window function! s:TreeFileNode.openVSplit() call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') call self.open({'where': 'v'}) endfunction -"FUNCTION: TreeFileNode.openInNewTab(options) {{{1 +" FUNCTION: TreeFileNode.openInNewTab(options) {{{1 function! s:TreeFileNode.openInNewTab(options) echomsg 'TreeFileNode.openInNewTab is deprecated' call self.open(extend({'where': 't'}, a:options)) endfunction -"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 -"Places the cursor on the line number this node is rendered on +" FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 +" Places the cursor on the line number this node is rendered on " -"Args: -"isJump: 1 if this cursor movement should be counted as a jump by vim -"recurseUpward: try to put the cursor on the parent if the this node isnt -"visible +" Args: +" isJump: 1 if this cursor movement should be counted as a jump by vim +" recurseUpward: try to put the cursor on the parent if the this node isnt +" visible function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) let ln = self.getNerdtree().ui.getLineNum(self) if ln != -1 @@ -294,18 +297,18 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) endif endfunction -"FUNCTION: TreeFileNode.refresh() {{{1 +" FUNCTION: TreeFileNode.refresh() {{{1 function! s:TreeFileNode.refresh() call self.path.refresh(self.getNerdtree()) endfunction -"FUNCTION: TreeFileNode.refreshFlags() {{{1 +" FUNCTION: TreeFileNode.refreshFlags() {{{1 function! s:TreeFileNode.refreshFlags() call self.path.refreshFlags(self.getNerdtree()) endfunction -"FUNCTION: TreeFileNode.rename() {{{1 -"Calls the rename method for this nodes path obj +" FUNCTION: TreeFileNode.rename() {{{1 +" Calls the rename method for this nodes path obj function! s:TreeFileNode.rename(newName) let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') call self.path.rename(newName) @@ -320,17 +323,17 @@ function! s:TreeFileNode.rename(newName) endif endfunction -"FUNCTION: TreeFileNode.renderToString {{{1 -"returns a string representation for this tree to be rendered in the view +" FUNCTION: TreeFileNode.renderToString {{{1 +" returns a string representation for this tree to be rendered in the view function! s:TreeFileNode.renderToString() return self._renderToString(0, 0) endfunction -"Args: -"depth: the current depth in the tree for this call -"drawText: 1 if we should actually draw the line for this node (if 0 then the -"child nodes are rendered only) -"for each depth in the tree +" Args: +" depth: the current depth in the tree for this call +" drawText: 1 if we should actually draw the line for this node (if 0 then the +" child nodes are rendered only) +" for each depth in the tree function! s:TreeFileNode._renderToString(depth, drawText) let output = "" if a:drawText ==# 1 @@ -346,7 +349,7 @@ function! s:TreeFileNode._renderToString(depth, drawText) let output = output . line . "\n" endif - "if the node is an open dir, draw its children + " if the node is an open dir, draw its children if self.path.isDirectory ==# 1 && self.isOpen ==# 1 let childNodesToDraw = self.getVisibleChildren() From c6a68d4b962e747a58450ae03f7f443deb0afddf Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 09:02:10 -0500 Subject: [PATCH 401/680] Improve the style in a "TreeFileNode" method No functional changes here. --- lib/nerdtree/tree_file_node.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index c7e48956..3ad9fcb6 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -196,14 +196,18 @@ function! s:TreeFileNode.GetRootForTab() endfunction " FUNCTION: TreeFileNode.GetSelected() {{{1 -" gets the treenode that the cursor is currently over +" If the cursor is currently positioned on a tree node, return the node. +" Otherwise, return the empty dictionary. function! s:TreeFileNode.GetSelected() + try - let path = b:NERDTree.ui.getPath(line(".")) - if path ==# {} + let l:path = b:NERDTree.ui.getPath(line('.')) + + if empty(l:path) return {} endif - return b:NERDTree.root.findNode(path) + + return b:NERDTree.root.findNode(l:path) catch /^NERDTree/ return {} endtry From 1e93f6840a4cbbbf1130ae56357d92fc90055036 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 09:10:10 -0500 Subject: [PATCH 402/680] Format the commentary in "ui.vim" --- lib/nerdtree/ui.vim | 149 ++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 725b0c55..f52534ef 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -1,11 +1,14 @@ -"CLASS: UI -"============================================================ +" ============================================================================ +" CLASS: UI +" ============================================================================ + + let s:UI = {} let g:NERDTreeUI = s:UI -"FUNCTION: s:UI.centerView() {{{2 -"centers the nerd tree window around the cursor (provided the nerd tree -"options permit) +" FUNCTION: s:UI.centerView() {{{2 +" centers the nerd tree window around the cursor (provided the nerd tree +" options permit) function! s:UI.centerView() if g:NERDTreeAutoCenter let current_line = winline() @@ -17,8 +20,8 @@ function! s:UI.centerView() endif endfunction -"FUNCTION: s:UI._dumpHelp {{{1 -"prints out the quick help +" FUNCTION: s:UI._dumpHelp {{{1 +" prints out the quick help function! s:UI._dumpHelp() if self.getShowHelp() let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n" @@ -93,7 +96,7 @@ function! s:UI._dumpHelp() let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" - "add quickhelp entries for each custom key map + " add quickhelp entries for each custom key map let help .= "\"\n\" ----------------------------\n" let help .= "\" Custom mappings~\n" for i in g:NERDTreeKeyMap.All() @@ -124,7 +127,7 @@ function! s:UI._dumpHelp() endfunction -"FUNCTION: s:UI.new(nerdtree) {{{1 +" FUNCTION: s:UI.new(nerdtree) {{{1 function! s:UI.New(nerdtree) let newObj = copy(self) let newObj.nerdtree = a:nerdtree @@ -137,22 +140,22 @@ function! s:UI.New(nerdtree) return newObj endfunction -"FUNCTION: s:UI.getPath(ln) {{{1 -"Gets the full path to the node that is rendered on the given line number +" FUNCTION: s:UI.getPath(ln) {{{1 +" Gets the full path to the node that is rendered on the given line number " -"Args: -"ln: the line number to get the path for +" Args: +" ln: the line number to get the path for " -"Return: -"A path if a node was selected, {} if nothing is selected. -"If the 'up a dir' line was selected then the path to the parent of the -"current root is returned +" Return: +" A path if a node was selected, {} if nothing is selected. +" If the 'up a dir' line was selected then the path to the parent of the +" current root is returned function! s:UI.getPath(ln) let line = getline(a:ln) let rootLine = self.getRootLineNum() - "check to see if we have the root node + " check to see if we have the root node if a:ln == rootLine return self.nerdtree.root.path endif @@ -163,7 +166,7 @@ function! s:UI.getPath(ln) let indent = self._indentLevelFor(line) - "remove the tree parts and the leading space + " remove the tree parts and the leading space let curFile = self._stripMarkup(line) let dir = "" @@ -173,7 +176,7 @@ function! s:UI.getPath(ln) let curLine = getline(lnum) let curLineStripped = self._stripMarkup(curLine) - "have we reached the top of the tree? + " have we reached the top of the tree? if lnum == rootLine let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir break @@ -193,19 +196,19 @@ function! s:UI.getPath(ln) return toReturn endfunction -"FUNCTION: s:UI.getLineNum(file_node){{{1 -"returns the line number this node is rendered on, or -1 if it isnt rendered +" FUNCTION: s:UI.getLineNum(file_node){{{1 +" returns the line number this node is rendered on, or -1 if it isnt rendered function! s:UI.getLineNum(file_node) - "if the node is the root then return the root line no. + " if the node is the root then return the root line no. if a:file_node.isRoot() return self.getRootLineNum() endif let totalLines = line("$") - "the path components we have matched so far + " the path components we have matched so far let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')] - "the index of the component we are searching for + " the index of the component we are searching for let curPathComponent = 1 let fullpath = a:file_node.path.str({'format': 'UI'}) @@ -213,7 +216,7 @@ function! s:UI.getLineNum(file_node) let lnum = self.getRootLineNum() while lnum > 0 let lnum = lnum + 1 - "have we reached the bottom of the tree? + " have we reached the bottom of the tree? if lnum ==# totalLines+1 return -1 endif @@ -241,8 +244,8 @@ function! s:UI.getLineNum(file_node) return -1 endfunction -"FUNCTION: s:UI.getRootLineNum(){{{1 -"gets the line number of the root node +" FUNCTION: s:UI.getRootLineNum(){{{1 +" gets the line number of the root node function! s:UI.getRootLineNum() let rootLine = 1 while getline(rootLine) !~# '^\(/\|<\)' @@ -251,29 +254,29 @@ function! s:UI.getRootLineNum() return rootLine endfunction -"FUNCTION: s:UI.getShowBookmarks() {{{1 +" FUNCTION: s:UI.getShowBookmarks() {{{1 function! s:UI.getShowBookmarks() return self._showBookmarks endfunction -"FUNCTION: s:UI.getShowFiles() {{{1 +" FUNCTION: s:UI.getShowFiles() {{{1 function! s:UI.getShowFiles() return self._showFiles endfunction -"FUNCTION: s:UI.getShowHelp() {{{1 +" FUNCTION: s:UI.getShowHelp() {{{1 function! s:UI.getShowHelp() return self._showHelp endfunction -"FUNCTION: s:UI.getShowHidden() {{{1 +" FUNCTION: s:UI.getShowHidden() {{{1 function! s:UI.getShowHidden() return self._showHidden endfunction -"FUNCTION: s:UI._indentLevelFor(line) {{{1 +" FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - "have to do this work around because match() returns bytes, not chars + " have to do this work around because match() returns bytes, not chars let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) @@ -281,27 +284,27 @@ function! s:UI._indentLevelFor(line) return leadChars / s:UI.IndentWid() endfunction -"FUNCTION: s:UI.IndentWid() {{{1 +" FUNCTION: s:UI.IndentWid() {{{1 function! s:UI.IndentWid() return 2 endfunction -"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 +" FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 function! s:UI.isIgnoreFilterEnabled() return self._ignoreEnabled == 1 endfunction -"FUNCTION: s:UI.isMinimal() {{{1 +" FUNCTION: s:UI.isMinimal() {{{1 function! s:UI.isMinimal() return g:NERDTreeMinimalUI endfunction -"FUNCTION: s:UI.MarkupReg() {{{1 +" FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' endfunction -"FUNCTION: s:UI._renderBookmarks {{{1 +" FUNCTION: s:UI._renderBookmarks {{{1 function! s:UI._renderBookmarks() if !self.isMinimal() @@ -322,12 +325,12 @@ function! s:UI._renderBookmarks() call cursor(line(".")+1, col(".")) endfunction -"FUNCTION: s:UI.restoreScreenState() {{{1 +" FUNCTION: s:UI.restoreScreenState() {{{1 " -"Sets the screen state back to what it was when nerdtree#saveScreenState was last -"called. +" Sets the screen state back to what it was when nerdtree#saveScreenState was last +" called. " -"Assumes the cursor is in the NERDTree window +" Assumes the cursor is in the NERDTree window function! s:UI.restoreScreenState() if !has_key(self, '_screenState') return @@ -342,9 +345,9 @@ function! s:UI.restoreScreenState() let &scrolloff=old_scrolloff endfunction -"FUNCTION: s:UI.saveScreenState() {{{1 -"Saves the current cursor position in the current buffer and the window -"scroll position +" FUNCTION: s:UI.saveScreenState() {{{1 +" Saves the current cursor position in the current buffer and the window +" scroll position function! s:UI.saveScreenState() let win = winnr() call g:NERDTree.CursorToTreeWin() @@ -355,31 +358,31 @@ function! s:UI.saveScreenState() call nerdtree#exec(win . "wincmd w") endfunction -"FUNCTION: s:UI.setShowHidden(val) {{{1 +" FUNCTION: s:UI.setShowHidden(val) {{{1 function! s:UI.setShowHidden(val) let self._showHidden = a:val endfunction -"FUNCTION: s:UI._stripMarkup(line){{{1 -"returns the given line with all the tree parts stripped off +" FUNCTION: s:UI._stripMarkup(line){{{1 +" returns the given line with all the tree parts stripped off " -"Args: -"line: the subject line +" Args: +" line: the subject line function! s:UI._stripMarkup(line) let line = a:line - "remove the tree parts and the leading space + " remove the tree parts and the leading space let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") - "strip off any read only flag + " strip off any read only flag let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","") - "strip off any bookmark flags + " strip off any bookmark flags let line = substitute (line, ' {[^}]*}', "","") - "strip off any executable flags + " strip off any executable flags let line = substitute (line, '*\ze\($\| \)', "","") - "strip off any generic flags + " strip off any generic flags let line = substitute (line, '\[[^]]*\]', "","") let line = substitute (line,' -> .*',"","") " remove link to @@ -387,22 +390,22 @@ function! s:UI._stripMarkup(line) return line endfunction -"FUNCTION: s:UI.render() {{{1 +" FUNCTION: s:UI.render() {{{1 function! s:UI.render() setlocal modifiable - "remember the top line of the buffer and the current line so we can - "restore the view exactly how it was + " remember the top line of the buffer and the current line so we can + " restore the view exactly how it was let curLine = line(".") let curCol = col(".") let topLine = line("w0") - "delete all lines in the buffer (being careful not to clobber a register) + " delete all lines in the buffer (being careful not to clobber a register) silent 1,$delete _ call self._dumpHelp() - "delete the blank line before the help and add one after it + " delete the blank line before the help and add one after it if !self.isMinimal() call setline(line(".")+1, "") call cursor(line(".")+1, col(".")) @@ -412,24 +415,24 @@ function! s:UI.render() call self._renderBookmarks() endif - "add the 'up a dir' line + " add the 'up a dir' line if !self.isMinimal() call setline(line(".")+1, s:UI.UpDirLine()) call cursor(line(".")+1, col(".")) endif - "draw the header line + " draw the header line let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) call setline(line(".")+1, header) call cursor(line(".")+1, col(".")) - "draw the tree + " draw the tree silent put =self.nerdtree.root.renderToString() - "delete the blank line at the top of the buffer + " delete the blank line at the top of the buffer silent 1,1delete _ - "restore the view + " restore the view let old_scrolloff=&scrolloff let &scrolloff=0 call cursor(topLine, 1) @@ -441,14 +444,14 @@ function! s:UI.render() endfunction -"FUNCTION: UI.renderViewSavingPosition {{{1 -"Renders the tree and ensures the cursor stays on the current node or the -"current nodes parent if it is no longer available upon re-rendering +" FUNCTION: UI.renderViewSavingPosition {{{1 +" Renders the tree and ensures the cursor stays on the current node or the +" current nodes parent if it is no longer available upon re-rendering function! s:UI.renderViewSavingPosition() let currentNode = g:NERDTreeFileNode.GetSelected() - "go up the tree till we find a node that will be visible or till we run - "out of nodes + " go up the tree till we find a node that will be visible or till we run + " out of nodes while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() let currentNode = currentNode.parent endwhile @@ -460,7 +463,7 @@ function! s:UI.renderViewSavingPosition() endif endfunction -"FUNCTION: s:UI.toggleHelp() {{{1 +" FUNCTION: s:UI.toggleHelp() {{{1 function! s:UI.toggleHelp() let self._showHelp = !self._showHelp endfunction @@ -515,7 +518,7 @@ function! s:UI.toggleZoom() endif endfunction -"FUNCTION: s:UI.UpDirLine() {{{1 +" FUNCTION: s:UI.UpDirLine() {{{1 function! s:UI.UpDirLine() return '.. (up a dir)' endfunction From 8f052c5b47dce01ec04bed580226fd18da32def4 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 09:23:27 -0500 Subject: [PATCH 403/680] Simplify the commentary for the "getPath()" method --- lib/nerdtree/ui.vim | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index f52534ef..5f946ba6 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -141,15 +141,10 @@ function! s:UI.New(nerdtree) endfunction " FUNCTION: s:UI.getPath(ln) {{{1 -" Gets the full path to the node that is rendered on the given line number -" -" Args: -" ln: the line number to get the path for -" -" Return: -" A path if a node was selected, {} if nothing is selected. -" If the 'up a dir' line was selected then the path to the parent of the -" current root is returned +" Return the "Path" object for the node that is rendered on the given line +" number. If the "up a dir" line is selected, return the "Path" object for +" the parent of the root. Return the empty dictionary if the given line +" does not reference a tree node. function! s:UI.getPath(ln) let line = getline(a:ln) From 1d14961285a6ce61a037391a527508f46164d33f Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 09:28:15 -0500 Subject: [PATCH 404/680] Remove a noise comment --- lib/nerdtree/ui.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5f946ba6..1e746575 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -150,7 +150,6 @@ function! s:UI.getPath(ln) let rootLine = self.getRootLineNum() - " check to see if we have the root node if a:ln == rootLine return self.nerdtree.root.path endif From a019486dc842d5c639be34965cec3cc13805afa9 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 09:46:40 -0500 Subject: [PATCH 405/680] Fix unstable behavior in "NERDTreeUI.getPath()" This commit prevents "NERDTreeUI.getPath()" from returning a "Path" object even when no tree node was selected. Previously, positioning your cursor on one of the blank lines above the tree and running... :echo g:NERDTreeFileNode.GetSelected() ... could potentially return the path for the current working directory (your working directory needs to be under the tree root). This is because the constructor for "Path" objects returns a "Path" for the current working directory when passed an empty string. So, we need to short circuit the "getPath()" function for lines that cannot possibly be tree nodes. This solves the problem for "GetSelected()" because that method uses the "getPath()" method from the "UI" class to do its work. Note that this bug only presented for me on *nix systems. --- lib/nerdtree/ui.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 1e746575..196d745e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -158,6 +158,10 @@ function! s:UI.getPath(ln) return self.nerdtree.root.path.getParent() endif + if a:ln < rootLine + return {} + endif + let indent = self._indentLevelFor(line) " remove the tree parts and the leading space From 6e26222a303f8cb5bec0773dbd33e3d476bcd90b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 6 Jan 2018 10:44:50 -0500 Subject: [PATCH 406/680] Update the docs for "NERDTreeStatusline" --- doc/NERDTree.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 38fbad9d..828032cc 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -996,17 +996,16 @@ Other examples: > ------------------------------------------------------------------------------ *'NERDTreeStatusline'* -Values: Any valid statusline setting. -Default: %{b:NERDTree.root.path.strForOS(0)} +Values: Any valid |'statusline'| setting. +Default: %{exists('b:NERDTree')?b:NERDTree.root.path.str():''} -Tells the script what to use as the |'statusline'| setting for NERD tree -windows. +Defines the value for the |'statusline'| setting in NERDTree windows. -Note that the statusline is set using |:let-&| not |:set| so escaping spaces -isn't necessary. +Note: The setting is actually applied using |:let-&|, not |:set|, so +escaping spaces is not necessary. Setting this option to -1 will will deactivate it so that your global -statusline setting is used instead. +|'statusline'| setting is used. ------------------------------------------------------------------------------ *'NERDTreeWinPos'* From a0f3bf3ed6405453be39906ad026cd5aee6ca0e3 Mon Sep 17 00:00:00 2001 From: Martin Rubli Date: Fri, 2 Feb 2018 20:10:34 +0800 Subject: [PATCH 407/680] Focus previous window when closing NERDTree Previously closing NERDTree while two windows were showing the same buffer would focus the first window, which was not necessarily the previously active one. Instead of obtaining the buffer ID of the previous buffer and mapping that to the window ID (which is a 1:n mapping) we obtain the unique window ID and focus the right window after closing NERDTree. win_getid() and win_gotoid() are available from VIM 7.4.1557 but the old behavior is used as a fallback if the two functions are not available. --- lib/nerdtree/nerdtree.vim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 12e3ebbc..fcabcb9e 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -38,17 +38,26 @@ function! s:NERDTree.Close() endif if winnr("$") != 1 + " Use the window ID to identify the currently active window or fall + " back on the buffer ID if win_getid/win_gotoid are not available, in + " which case we'll focus an arbitrary window showing the buffer. + let l:useWinId = exists('*win_getid') && exists('*win_gotoid') + if winnr() == s:NERDTree.GetWinNum() call nerdtree#exec("wincmd p") - let bufnr = bufnr("") + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") call nerdtree#exec("wincmd p") else - let bufnr = bufnr("") + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") endif call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w") close - call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") + if l:useWinId + call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")") + else + call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w") + endif else close endif From dc349a072ae4abc4747b23d7ab4085c5a1afe589 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 6 Mar 2018 08:41:06 -0500 Subject: [PATCH 408/680] Use a better check for existence of the NERDTree buffer. If the user wipes out or deletes (:bw or :bd) the NERDTree buffer, there is still a tab variable that hangs onto the name of that now-missing buffer. Checking only that variable is not enough to decide whether to create a new NERDTree or use the existing one. Fortunately, there already is a function with a more complete check: ExistsForTab() --- lib/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 047939fa..fb5adfd0 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -185,7 +185,7 @@ function! s:Creator._createTreeWin() let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " let splitSize = g:NERDTreeWinSize - if !exists('t:NERDTreeBufName') + if !g:NERDTree.ExistsForTab() let t:NERDTreeBufName = self._nextBufferName() silent! exec splitLocation . 'vertical ' . splitSize . ' new' silent! exec "edit " . t:NERDTreeBufName From d6fe203dece8bef77bca24c117adca3d612b66c1 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 6 Mar 2018 09:23:11 -0500 Subject: [PATCH 409/680] Update issue template, making it a little cleaner. --- .github/ISSUE_TEMPLATE.md | 47 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 69aa7d9b..998330d1 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,37 +1,30 @@ -_To assist in resolving your issue, provide as much information as possible, in place of the ellipses (`…`) below._ + ---- -**Environment:** _Describe your Vim/NERDTree setup._ +### Environment + ->* Operating System: … ->* Vim version `:version`: … ->* NERDTree version `git rev-parse --short HEAD`: … ->* NERDTree settings applied in your vimrc, if any: -> -> ``` -> … -> ``` +* Operating System: +* Vim version `:version`: +* NERDTree version `git rev-parse --short HEAD`: +* NERDTree settings applied in your vimrc, if any: + ```vim + ``` -**Process:** _List the steps that will recreate the issue._ +### Process + ->1. … +1. -**Current Result:** _Describe what you you currently experience from this process._ +### Current Result + ->… +### Expected Result + -**Expected Result:** _Describe what you would expect to have resulted from this process._ +## Optional ->… +### Screenshot(s) ---- -**Optional** - -**Screenshot(s):** - ->… - -**Possible Fix:** _(Have you poked around in the code?)_ - ->… +### Possible Fix + From ed446e5cbe0733a8f98befc88d33e42edebb67d2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 6 Mar 2018 11:31:19 -0500 Subject: [PATCH 410/680] Update issue template again. "Optional" isn't needed. --- .github/ISSUE_TEMPLATE.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 998330d1..c3ca5eff 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -21,8 +21,6 @@ ### Expected Result -## Optional - ### Screenshot(s) ### Possible Fix From 9afa6b38286d6e3e86fbe4616812f8e7a128b2c1 Mon Sep 17 00:00:00 2001 From: Kutsan Kaplan Date: Tue, 13 Mar 2018 06:14:39 +0300 Subject: [PATCH 411/680] Add new variable g:NERDTreeRemoveFileCmd --- doc/NERDTree.txt | 6 ++++++ lib/nerdtree/path.vim | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 828032cc..c35c52f7 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -694,6 +694,12 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the NERDTree window. +|'NERDTreeRemoveFileCmd'| Specify a custom shell command that will used + when deleting files with delete action. Note + that, it should be one space character at the + end of the command and it applies only for files. + See |g:NERDTreeRemoveDirCmd| for directories. + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 65cd5ca8..7fc726ed 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -246,7 +246,13 @@ function! s:Path.delete() throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" endif else - let success = delete(self.str()) + if exists('g:NERDTreeRemoveFileCmd') + let cmd = g:NERDTreeRemoveFileCmd . self.str({'escape': 1}) + let success = system(cmd) + else + let success = delete(self.str()) + endif + if success != 0 throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" endif @@ -409,7 +415,7 @@ endfunction " FUNCTION: Path.isHiddenUnder(path) {{{1 function! s:Path.isHiddenUnder(path) - + if !self.isUnder(a:path) return 0 endif @@ -418,7 +424,7 @@ function! s:Path.isHiddenUnder(path) let l:segments = self.pathSegments[l:startIndex : ] for l:segment in l:segments - + if l:segment =~# '^\.' return 1 endif From a172d7cfcb4fe9b927dcc24184204fc89d826301 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 13 Mar 2018 08:51:33 -0400 Subject: [PATCH 412/680] Add documentation for the NERDTreeRemoveDirCmd option. --- doc/NERDTree.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index c35c52f7..a83c4e15 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -694,11 +694,15 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the NERDTree window. -|'NERDTreeRemoveFileCmd'| Specify a custom shell command that will used - when deleting files with delete action. Note - that, it should be one space character at the - end of the command and it applies only for files. - See |g:NERDTreeRemoveDirCmd| for directories. +|'NERDTreeRemoveFileCmd'| Specify a custom shell command to be used when + deleting files. Note that it should include + one space character at the end of the command + and it applies only to files. + +|'NERDTreeRemoveDirCmd'| Specify a custom shell command to be used when + deleting directories. Note that it should + include one space character at the end of the + command and it applies only to directories. ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* From b37495fa985794b1a8d1b4bee6232fc42c7ca8d8 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 2 Apr 2018 09:26:34 -0400 Subject: [PATCH 413/680] If node isn't open, count children on disk before deleting. Fixes #821. If a node isn't opened in NERDTree, it's children aren't known yet, so when deleting the node (with `m`, `d`), the user isn't properly asked to confirm the delete. It was going to the less strict `Y`/`n` confirmation, instead of the `yes` confirmation for non-empty directories. This change checks to see if the node is opened already. If it is, the existing getChildCount() function is used; otherwise, the disk is read to get the number of children there. --- nerdtree_plugin/fs_menu.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 928d8a2f..c91624d7 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -175,7 +175,8 @@ function! NERDTreeDeleteNode() let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 - if currentNode.path.isDirectory && currentNode.getChildCount() > 0 + if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || + \ (len(currentNode._glob('*', 1)) > 0)) let choice =input("Delete the current node\n" . \ "==========================================================\n" . \ "STOP! Directory is not empty! To delete, type 'yes'\n" . From 435861ee69becb4f6c780bf7daedb18fdf160815 Mon Sep 17 00:00:00 2001 From: Hieu Nguyen Date: Mon, 9 Apr 2018 19:08:09 +0200 Subject: [PATCH 414/680] Support revealing file and executing file with xdg-open for Linux --- nerdtree_plugin/fs_menu.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index c91624d7..e963a5ff 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -29,6 +29,11 @@ if has("gui_mac") || has("gui_macvim") || has("mac") call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) endif +if executable("xdg-open") + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif @@ -337,4 +342,22 @@ function! NERDTreeExecuteFile() endif endfunction +" FUNCTION: NERDTreeRevealFileLinux() {{{1 +function! NERDTreeRevealFileLinux() + let treenode = g:NERDTreeFileNode.GetSelected() + let parentnode = treenode.parent + if parentnode != {} + call system("xdg-open '" . parentnode.path.str() . "' &") + endif +endfunction + +" FUNCTION: NERDTreeExecuteFileLinux() {{{1 +function! NERDTreeExecuteFileLinux() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + call system("xdg-open '" . treenode.path.str() . "' &") + endif +endfunction + " vim: set sw=4 sts=4 et fdm=marker: + From 1792b6a75b337d739dbc6cd16c3091e9f38923cd Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:19:13 -0400 Subject: [PATCH 415/680] Clear output when the NERDTree menu is aborted Previously, exiting the NERDTree menu with "Ctrl-C" or "Esc" would leave the last line of the menu visible. We can avoid this by redrawing the screen when the menu is aborted in this manner. --- lib/nerdtree/menu_controller.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index ae0ee848..b28ca4d3 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -33,6 +33,11 @@ function! s:MenuController.showMenu() endwhile finally call self._restoreOptions() + + " Redraw when "Ctrl-C" or "Esc" is received. + if !l:done || self.selection == -1 + redraw! + endif endtry if self.selection != -1 From 38d4d2288a83f08b8b2ba24f36259e3f140da9d6 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:21:16 -0400 Subject: [PATCH 416/680] Clean up a function comment --- lib/nerdtree/menu_controller.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index b28ca4d3..f24e222e 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -15,9 +15,9 @@ function! s:MenuController.New(menuItems) return newMenuController endfunction -"FUNCTION: MenuController.showMenu() {{{1 -"start the main loop of the menu and get the user to choose/execute a menu -"item +" FUNCTION: MenuController.showMenu() {{{1 +" Enter the main loop of the NERDTree menu, prompting the user to select +" a menu item. function! s:MenuController.showMenu() call self._saveOptions() From 164131762f1d37f7e7dc19e0ebe177c80c3f74ea Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:23:16 -0400 Subject: [PATCH 417/680] Refine the internals of the "showMenu()" function --- lib/nerdtree/menu_controller.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index f24e222e..68e4d304 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -23,13 +23,14 @@ function! s:MenuController.showMenu() try let self.selection = 0 + let l:done = 0 - let done = 0 - while !done + while !l:done redraw! call self._echoPrompt() - let key = nr2char(getchar()) - let done = self._handleKeypress(key) + + let l:key = nr2char(getchar()) + let l:done = self._handleKeypress(l:key) endwhile finally call self._restoreOptions() @@ -41,8 +42,8 @@ function! s:MenuController.showMenu() endtry if self.selection != -1 - let m = self._current() - call m.execute() + let l:m = self._current() + call l:m.execute() endif endfunction From 6aff1b6cd3f5306a6828e20375cc0fc11cabe590 Mon Sep 17 00:00:00 2001 From: bravestarr Date: Sun, 22 Apr 2018 21:18:46 +0800 Subject: [PATCH 418/680] Display a path with multi-byte characters correctly when it is truncated When a path is rendered in the Bookmarks area or as the header line of the tree, it is truncated if there is no enough space for it. But if a path contains multi-byte characters, it should be truncated by characters, not bytes, otherwise the path may be truncated between the bytes of a multi-byte character. To deal with multi-byte characters, use strdisplaywidth() instead of len() to get the number of display cells, and use strcharpart() instead of strpart() to truncate a path. --- lib/nerdtree/bookmark.vim | 9 ++++++--- lib/nerdtree/path.vim | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 45f9950e..307211ba 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -280,14 +280,17 @@ endfunction " FUNCTION: Bookmark.str() {{{1 " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() - let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name) + let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - strdisplaywidth(self.name) if &nu let pathStrMaxLen = pathStrMaxLen - &numberwidth endif let pathStr = self.path.str({'format': 'UI'}) - if len(pathStr) > pathStrMaxLen - let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) + if strdisplaywidth(pathStr) > pathStrMaxLen + while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 + let pathStr = strcharpart(pathStr, 1) + endwhile + let pathStr = '<' . pathStr endif return '>' . self.name . ' ' . pathStr endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 7fc726ed..f436d362 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -719,8 +719,10 @@ function! s:Path.str(...) if has_key(options, 'truncateTo') let limit = options['truncateTo'] - if len(toReturn) > limit-1 - let toReturn = toReturn[(len(toReturn)-limit+1):] + if strdisplaywidth(toReturn) > limit-1 + while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 + let toReturn = strcharpart(toReturn, 1) + endwhile if len(split(toReturn, '/')) > 1 let toReturn = ' Date: Wed, 25 Apr 2018 03:04:18 +0300 Subject: [PATCH 419/680] Fixed bug 'unknown function strcharpart' for older versions of Vim --- lib/nerdtree/bookmark.vim | 12 ++++++++---- lib/nerdtree/path.vim | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 307211ba..482afa2c 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -287,10 +287,14 @@ function! s:Bookmark.str() let pathStr = self.path.str({'format': 'UI'}) if strdisplaywidth(pathStr) > pathStrMaxLen - while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 - let pathStr = strcharpart(pathStr, 1) - endwhile - let pathStr = '<' . pathStr + if exists("*strcharpart") + while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 + let pathStr = strcharpart(pathStr, 1) + endwhile + let pathStr = '<' . pathStr + else + let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) + endif endif return '>' . self.name . ' ' . pathStr endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index f436d362..f51310ad 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -720,9 +720,13 @@ function! s:Path.str(...) if has_key(options, 'truncateTo') let limit = options['truncateTo'] if strdisplaywidth(toReturn) > limit-1 - while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 - let toReturn = strcharpart(toReturn, 1) - endwhile + if exists("*strcharpart") + while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 + let toReturn = strcharpart(toReturn, 1) + endwhile + else + let toReturn = toReturn[(len(toReturn)-limit+1):] + endif if len(split(toReturn, '/')) > 1 let toReturn = ' Date: Thu, 26 Apr 2018 17:13:06 +0800 Subject: [PATCH 420/680] Replace strcharpart() with substitute() for backward compatibility --- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/path.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 307211ba..32bf4344 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -288,7 +288,7 @@ function! s:Bookmark.str() let pathStr = self.path.str({'format': 'UI'}) if strdisplaywidth(pathStr) > pathStrMaxLen while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 - let pathStr = strcharpart(pathStr, 1) + let pathStr = substitute(pathStr, '.\{1}', '', '') endwhile let pathStr = '<' . pathStr endif diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index f436d362..59c8c699 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -721,7 +721,7 @@ function! s:Path.str(...) let limit = options['truncateTo'] if strdisplaywidth(toReturn) > limit-1 while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 - let toReturn = strcharpart(toReturn, 1) + let toReturn = substitute(toReturn, '.\{1}', '', '') endwhile if len(split(toReturn, '/')) > 1 let toReturn = ' Date: Sat, 28 Apr 2018 09:17:29 -0400 Subject: [PATCH 421/680] Remove unsupported bookmark table mappings The definitions for certain bookmark mappings reference callbacks that don't actually support operation on bookmarks. Furthermore, the mappings that are defined are not documented anywhere. Removing them seems reasonable since they serve no real purpose. --- autoload/nerdtree/ui_glue.vim | 7 ------- 1 file changed, 7 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index e1847039..0cc3362a 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -23,17 +23,10 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) From 2c38519733006e29444bf909072b22db6dbd55fd Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sun, 6 May 2018 11:34:24 -0400 Subject: [PATCH 422/680] Make the NERDTree buffer writable when rendering it. --- lib/nerdtree/ui.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 196d745e..68a72b68 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -390,7 +390,7 @@ endfunction " FUNCTION: s:UI.render() {{{1 function! s:UI.render() - setlocal modifiable + setlocal noreadonly modifiable " remember the top line of the buffer and the current line so we can " restore the view exactly how it was @@ -438,7 +438,7 @@ function! s:UI.render() call cursor(curLine, curCol) let &scrolloff = old_scrolloff - setlocal nomodifiable + setlocal readonly nomodifiable endfunction From f9e83ad8bda884b3fa8a6e5f615dc6ffffa06379 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 6 May 2018 12:19:19 -0400 Subject: [PATCH 423/680] Fix a bug with the 'u' mapping This commit refactors the "nerdtree#ui_glue#UpDir()" function to fix a bug in the behavior of the 'u' mapping. To reproduce the bug: 1. Open a bookmarked directory with 'o' 2. Press 'u' twice, observing normal behavior 3. Open the same bookmark again with 'o' 4. Press 'u' again, observe the new root is closed The reason for this bug is that the parent node already existed and was closed by the second 'u' press in step two above. This commit fixes this bug by being careful to always open the new root and transplant the child node properly. Also, the internals of the function in question were refactored to make use of valuable NERDTree functions that ultimately help to reduce the amount of code needed for this operation. --- autoload/nerdtree/ui_glue.vim | 55 +++++++++++++++-------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 0cc3362a..6ba9ee64 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -29,9 +29,9 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': 'all', 'callback': s . 'upDirCurrentRootClosed' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': 'all', 'callback': s . 'upDirCurrentRootOpen' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': 'Node', 'callback': s . 'chRoot' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) @@ -619,40 +619,33 @@ function! s:toggleZoom() call b:NERDTree.ui.toggleZoom() endfunction -"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1 -"moves the tree up a level +" FUNCTION: nerdtree#ui_glue#upDir(preserveState) {{{1 +" Move the NERDTree up one level. " -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! nerdtree#ui_glue#upDir(keepState) - let cwd = b:NERDTree.root.path.str({'format': 'UI'}) - if cwd ==# "/" || cwd =~# '^[^/]..$' - call nerdtree#echo("already at top dir") - else - if !a:keepState - call b:NERDTree.root.close() - endif +" Args: +" preserveState: if 1, the current root is left open when the new tree is +" rendered; if 0, the current root node is closed +function! nerdtree#ui_glue#upDir(preserveState) - let oldRoot = b:NERDTree.root + try + call b:NERDTree.root.cacheParent() + catch /^NERDTree.CannotCacheParentError/ + call nerdtree#echo('already at root directory') + return + endtry - if empty(b:NERDTree.root.parent) - let path = b:NERDTree.root.path.getParent() - let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree) - call newRoot.open() - call newRoot.transplantChild(b:NERDTree.root) - let b:NERDTree.root = newRoot - else - let b:NERDTree.root = b:NERDTree.root.parent - endif + let l:oldRoot = b:NERDTree.root + let l:newRoot = b:NERDTree.root.parent - if g:NERDTreeChDirMode ==# 2 - call b:NERDTree.root.path.changeToDir() - endif + call l:newRoot.open() + call l:newRoot.transplantChild(l:oldRoot) - call b:NERDTree.render() - call oldRoot.putCursorHere(0, 0) + if !a:preserveState + call l:oldRoot.close() endif + + call b:NERDTree.changeRoot(l:newRoot) + call l:oldRoot.putCursorHere(0, 0) endfunction " FUNCTION: s:upDirCurrentRootOpen() {{{1 From c4f8a0f370f31e90b1dc20868db6150cb80c1b30 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 16 May 2018 13:09:20 -0400 Subject: [PATCH 424/680] Like m-c did before, create parent directories if needed on m-m. --- lib/nerdtree/path.vim | 2 ++ nerdtree_plugin/fs_menu.vim | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 80607c55..2d8de23c 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -663,6 +663,8 @@ function! s:Path.rename(newPath) throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath endif + call s:Path.createParentDirectories(a:newPath) + let success = rename(self.str(), a:newPath) if success != 0 throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e963a5ff..ecca9cd3 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -158,6 +158,7 @@ function! NERDTreeMoveNode() let bufnum = bufnr("^".curNode.path.str()."$") call curNode.rename(newNodePath) + call b:NERDTree.root.refresh() call NERDTreeRender() "if the node is open in a buffer, ask the user if they want to From 80ee0897ff4d4f0583c0c4985d352162d8166d6e Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 26 May 2018 08:43:27 -0400 Subject: [PATCH 425/680] Add a call to ":clearjumps" to "_createTreeWin()" Using the ":clearjumps" command wipes out the jump list for the current window. This means that the user can't inadvertently jump out of the NERDTree buffer while using the NERDTree window (i.e., by using ""). --- lib/nerdtree/creator.vim | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index fb5adfd0..625914ec 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -178,24 +178,28 @@ function! s:Creator.createMirror() endfunction " FUNCTION: s:Creator._createTreeWin() {{{1 -" Inits the NERD tree window. ie. opens it, sizes it, sets all the local -" options etc +" Initialize the NERDTree window. Open the window, size it properly, set all +" local options, etc. function! s:Creator._createTreeWin() - "create the nerd tree window - let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " - let splitSize = g:NERDTreeWinSize + let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright ' + let l:splitSize = g:NERDTreeWinSize if !g:NERDTree.ExistsForTab() let t:NERDTreeBufName = self._nextBufferName() - silent! exec splitLocation . 'vertical ' . splitSize . ' new' - silent! exec "edit " . t:NERDTreeBufName + silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' + silent! execute 'edit ' . t:NERDTreeBufName else - silent! exec splitLocation . 'vertical ' . splitSize . ' split' - silent! exec "buffer " . t:NERDTreeBufName + silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' + silent! execute 'buffer ' . t:NERDTreeBufName endif - setlocal winfixwidth call self._setCommonBufOptions() + + if has('patch-7.4.1925') + clearjumps + endif + + setlocal winfixwidth endfunction " FUNCTION: s:Creator._isBufHidden(nr) {{{1 From 57c825a169cfe7b77c247fd0e9eb8812cdbb5f76 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Wed, 6 Jun 2018 09:02:25 -0400 Subject: [PATCH 426/680] Add code to sort mappings in quickhelp --- lib/nerdtree/key_map.vim | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 2411406e..b7d0c448 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -5,12 +5,30 @@ let g:NERDTreeKeyMap = s:KeyMap "FUNCTION: KeyMap.All() {{{1 function! s:KeyMap.All() - if !exists("s:keyMaps") + + if !exists('s:keyMaps') let s:keyMaps = [] endif + + call sort(s:keyMaps, s:KeyMap.Compare, s:KeyMap) + return s:keyMaps endfunction +"FUNCTION: KeyMap.Compare(keyMap1, keyMap2) {{{1 +function! s:KeyMap.Compare(keyMap1, keyMap2) + + if a:keyMap1.key >? a:keyMap2.key + return 1 + endif + + if a:keyMap1.key Date: Sun, 10 Jun 2018 23:36:56 -0700 Subject: [PATCH 427/680] Decrease startup-time by avoiding iteration over maps This commit makes adding, removing and finding key maps an O(1) operation instead of O(n), where n is the number of pre-existing maps. In my testing, averaged over 100 iterations, this reduces the time spent initializing NERDTree at Vim startup from ~73ms to ~9.7ms. That's with only the default included key maps. --- lib/nerdtree/key_map.vim | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index b7d0c448..6e984595 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -3,18 +3,23 @@ let s:KeyMap = {} let g:NERDTreeKeyMap = s:KeyMap -"FUNCTION: KeyMap.All() {{{1 -function! s:KeyMap.All() - - if !exists('s:keyMaps') - let s:keyMaps = [] +"FUNCTION: KeyMap.all() {{{1 +function! s:KeyMap.all() + if !exists("s:keyMaps") + let s:keyMaps = {} endif - call sort(s:keyMaps, s:KeyMap.Compare, s:KeyMap) - return s:keyMaps endfunction +"FUNCTION: KeyMap.All() {{{1 +function! s:KeyMap.All() + let sortedKeyMaps = values(s:KeyMap.all()) + call sort(sortedKeyMaps, s:KeyMap.Compare, s:KeyMap) + + return sortedKeyMaps +endfunction + "FUNCTION: KeyMap.Compare(keyMap1, keyMap2) {{{1 function! s:KeyMap.Compare(keyMap1, keyMap2) @@ -31,17 +36,12 @@ endfunction "FUNCTION: KeyMap.FindFor(key, scope) {{{1 function! s:KeyMap.FindFor(key, scope) - for i in s:KeyMap.All() - if i.key ==# a:key && i.scope ==# a:scope - return i - endif - endfor - return {} + return get(s:KeyMap.all(), a:key . a:scope, {}) endfunction "FUNCTION: KeyMap.BindAll() {{{1 function! s:KeyMap.BindAll() - for i in s:KeyMap.All() + for i in values(s:KeyMap.all()) call i.bind() endfor endfunction @@ -67,12 +67,7 @@ endfunction "FUNCTION: KeyMap.Remove(key, scope) {{{1 function! s:KeyMap.Remove(key, scope) - let maps = s:KeyMap.All() - for i in range(len(maps)) - if maps[i].key ==# a:key && maps[i].scope ==# a:scope - return remove(maps, i) - endif - endfor + return remove(s:keyMaps, a:key . a:scope) endfunction "FUNCTION: KeyMap.invoke() {{{1 @@ -170,8 +165,7 @@ endfunction "FUNCTION: KeyMap.Add(keymap) {{{1 function! s:KeyMap.Add(keymap) - call s:KeyMap.Remove(a:keymap.key, a:keymap.scope) - call add(s:KeyMap.All(), a:keymap) + let s:keyMaps[a:keymap.key . a:keymap.scope] = a:keymap endfunction " vim: set sw=4 sts=4 et fdm=marker: From 657be6b24d44477a3da7ad8dc0838fc9c9063cf5 Mon Sep 17 00:00:00 2001 From: mnussbaum Date: Tue, 12 Jun 2018 08:28:04 -0700 Subject: [PATCH 428/680] Mark private function with leading underscore --- lib/nerdtree/key_map.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 6e984595..b583e8ee 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -3,8 +3,8 @@ let s:KeyMap = {} let g:NERDTreeKeyMap = s:KeyMap -"FUNCTION: KeyMap.all() {{{1 -function! s:KeyMap.all() +"FUNCTION: KeyMap._all() {{{1 +function! s:KeyMap._all() if !exists("s:keyMaps") let s:keyMaps = {} endif @@ -14,7 +14,7 @@ endfunction "FUNCTION: KeyMap.All() {{{1 function! s:KeyMap.All() - let sortedKeyMaps = values(s:KeyMap.all()) + let sortedKeyMaps = values(s:KeyMap._all()) call sort(sortedKeyMaps, s:KeyMap.Compare, s:KeyMap) return sortedKeyMaps @@ -36,12 +36,12 @@ endfunction "FUNCTION: KeyMap.FindFor(key, scope) {{{1 function! s:KeyMap.FindFor(key, scope) - return get(s:KeyMap.all(), a:key . a:scope, {}) + return get(s:KeyMap._all(), a:key . a:scope, {}) endfunction "FUNCTION: KeyMap.BindAll() {{{1 function! s:KeyMap.BindAll() - for i in values(s:KeyMap.all()) + for i in values(s:KeyMap._all()) call i.bind() endfor endfunction From eb048a3070241c8340f9b4bfe62c736ed5023b50 Mon Sep 17 00:00:00 2001 From: mnussbaum Date: Tue, 12 Jun 2018 12:43:25 -0700 Subject: [PATCH 429/680] Bugfix - ensure keymaps dictionary exists before using it The s:KeyMap._all function isn't necessary if we initialize the s:keyMaps dictionary at file load time. --- lib/nerdtree/key_map.vim | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index b583e8ee..1ca478dd 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -2,19 +2,11 @@ "============================================================ let s:KeyMap = {} let g:NERDTreeKeyMap = s:KeyMap - -"FUNCTION: KeyMap._all() {{{1 -function! s:KeyMap._all() - if !exists("s:keyMaps") - let s:keyMaps = {} - endif - - return s:keyMaps -endfunction +let s:keyMaps = {} "FUNCTION: KeyMap.All() {{{1 function! s:KeyMap.All() - let sortedKeyMaps = values(s:KeyMap._all()) + let sortedKeyMaps = values(s:keyMaps) call sort(sortedKeyMaps, s:KeyMap.Compare, s:KeyMap) return sortedKeyMaps @@ -36,12 +28,12 @@ endfunction "FUNCTION: KeyMap.FindFor(key, scope) {{{1 function! s:KeyMap.FindFor(key, scope) - return get(s:KeyMap._all(), a:key . a:scope, {}) + return get(s:keyMaps, a:key . a:scope, {}) endfunction "FUNCTION: KeyMap.BindAll() {{{1 function! s:KeyMap.BindAll() - for i in values(s:KeyMap._all()) + for i in values(s:keyMaps) call i.bind() endfor endfunction From c0d87db309d2ba74230c9f1a2e64be1aa2c51c58 Mon Sep 17 00:00:00 2001 From: Bubba Date: Fri, 15 Jun 2018 10:43:20 -0400 Subject: [PATCH 430/680] Better OSX detection --- nerdtree_plugin/fs_menu.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index ecca9cd3..997c0633 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -225,10 +225,12 @@ endfunction function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if !empty(treenode) - if has("osx") - let stat_cmd = 'stat -f "%z" ' - else - let stat_cmd = 'stat -c "%s" ' + if has("unix") + let s:uname = system("uname") + let stat_cmd = 'stat -c "%s" ' + if s:uname == "Darwin\n" + let stat_cmd = 'stat -f "%z" ' + endif endif let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' . From a053179d6afe9c9272eb44f3d9ed9f2fe21703aa Mon Sep 17 00:00:00 2001 From: Bubba Date: Fri, 15 Jun 2018 11:29:09 -0400 Subject: [PATCH 431/680] Use the case-insensitive regex --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 997c0633..553b7609 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -228,7 +228,7 @@ function! NERDTreeListNode() if has("unix") let s:uname = system("uname") let stat_cmd = 'stat -c "%s" ' - if s:uname == "Darwin\n" + if s:uname =~? "Darwin" let stat_cmd = 'stat -f "%z" ' endif endif From 08db3a0eea7f7f28984ed029cb06db7ecc32c842 Mon Sep 17 00:00:00 2001 From: Bubba Date: Fri, 15 Jun 2018 12:02:58 -0400 Subject: [PATCH 432/680] Do not need to check for unix os here. --- nerdtree_plugin/fs_menu.vim | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 553b7609..36e2eae0 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -225,12 +225,11 @@ endfunction function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if !empty(treenode) - if has("unix") - let s:uname = system("uname") - let stat_cmd = 'stat -c "%s" ' - if s:uname =~? "Darwin" - let stat_cmd = 'stat -f "%z" ' - endif + let s:uname = system("uname") + let stat_cmd = 'stat -c "%s" ' + + if s:uname =~? "Darwin" + let stat_cmd = 'stat -f "%z" ' endif let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' . From 703e1ef4fe8350afbc61ce8271f72cef2d5c363a Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sun, 1 Jul 2018 19:55:26 -0400 Subject: [PATCH 433/680] Correctly check the type of the sort key's value. Fixes #842. --- autoload/nerdtree.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index b138c21c..bdf3deb7 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -61,7 +61,6 @@ endfunction function! nerdtree#compareNodesBySortKey(n1, n2) let sortKey1 = a:n1.path.getSortKey() let sortKey2 = a:n2.path.getSortKey() - let i = 0 while i < min([len(sortKey1), len(sortKey2)]) " Compare chunks upto common length. @@ -73,9 +72,9 @@ function! nerdtree#compareNodesBySortKey(n1, n2) elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif sortKey1[i] == type(0) + elseif type(sortKey1[i]) == v:t_number return -1 - elseif sortKey2[i] == type(0) + elseif type(sortKey2[i]) == v:t_number return 1 endif let i = i + 1 From a053925279b2b7a060a7714a7d98a8c5576878bf Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sun, 1 Jul 2018 19:57:02 -0400 Subject: [PATCH 434/680] Recalculate the node's sortkey every time. The cached _sortkey wasn't being recalculated after changing the NERDTreeSortOrder, resulting in incorrect sort orders. --- lib/nerdtree/path.vim | 9 ++------- lib/nerdtree/tree_dir_node.vim | 1 + plugin/NERD_tree.vim | 14 ++++++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2d8de23c..2af280fa 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -7,10 +7,6 @@ " ============================================================================ -" This constant is used throughout this script for sorting purposes. -let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') -lockvar s:NERDTreeSortStarIndex - let s:Path = {} let g:NERDTreePath = s:Path @@ -374,7 +370,8 @@ function! s:Path.getSortOrderIndex() endif let i = i + 1 endwhile - return s:NERDTreeSortStarIndex + + return index(g:NERDTreeSortOrder, '*') endfunction " FUNCTION: Path._splitChunks(path) {{{1 @@ -395,7 +392,6 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - if !exists("self._sortKey") let path = self.getLastPathComponent(1) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') @@ -408,7 +404,6 @@ function! s:Path.getSortKey() else let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) endif - endif return self._sortKey endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 03c3545b..17d9c7f4 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -607,6 +607,7 @@ endfunction " FUNCTION: TreeDirNode.sortChildren() {{{1 " Sort "self.children" by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() + call AddDefaultGroupToSortOrder() let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 35b47c38..eb02eaab 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -24,6 +24,15 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpo set cpo&vim +"Function: AddDefaultGroupToSortOrder() function {{{2 +"This function adds the default grouping '*' to the sort sequence if it's not +"already in the list. +function! AddDefaultGroupToSortOrder() + if count(g:NERDTreeSortOrder, '*') < 1 + call add(g:NERDTreeSortOrder, '*') + endif +endfunction + "Function: s:initVariable() function {{{2 "This function is used to initialise a given variable to a given value. The "variable is only initialised if it does not exist prior @@ -82,10 +91,7 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] else - "if there isnt a * in the sort sequence then add one - if count(g:NERDTreeSortOrder, '*') < 1 - call add(g:NERDTreeSortOrder, '*') - endif + call AddDefaultGroupToSortOrder() endif call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") From 6ef3213cd008d260b8c6b24f6ed26e95493d8ab2 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 2 Jul 2018 08:55:32 -0400 Subject: [PATCH 435/680] Fix indentation. --- lib/nerdtree/path.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2af280fa..71be5f5d 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -392,18 +392,18 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - let path = self.getLastPathComponent(1) - if !g:NERDTreeSortHiddenFirst - let path = substitute(path, '^[._]', '', '') - endif - if !g:NERDTreeCaseSensitiveSort - let path = tolower(path) - endif - if !g:NERDTreeNaturalSort - let self._sortKey = [self.getSortOrderIndex(), path] - else - let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) - endif + let path = self.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + if !g:NERDTreeNaturalSort + let self._sortKey = [self.getSortOrderIndex(), path] + else + let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + endif return self._sortKey endfunction From 1e2b7ef98d87955f7b9e6d1cfcad49df7e47cd5b Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 2 Jul 2018 09:06:09 -0400 Subject: [PATCH 436/680] Remove AddDefaultGroupToSortOrder check from startup. The call to AddDefaultGroupToSortOrder in NERD_tree.vim is redundant because it's also done every time sortChildren is called. And since the check is done only once, there's no need for a function either. sortChildren now just contains the needed if statement. --- lib/nerdtree/tree_dir_node.vim | 4 +++- plugin/NERD_tree.vim | 11 ----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 17d9c7f4..2f62ec31 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -607,7 +607,9 @@ endfunction " FUNCTION: TreeDirNode.sortChildren() {{{1 " Sort "self.children" by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() - call AddDefaultGroupToSortOrder() + if count(g:NERDTreeSortOrder, '*') < 1 + call add(g:NERDTreeSortOrder, '*') + endif let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index eb02eaab..a8af089a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -24,15 +24,6 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpo set cpo&vim -"Function: AddDefaultGroupToSortOrder() function {{{2 -"This function adds the default grouping '*' to the sort sequence if it's not -"already in the list. -function! AddDefaultGroupToSortOrder() - if count(g:NERDTreeSortOrder, '*') < 1 - call add(g:NERDTreeSortOrder, '*') - endif -endfunction - "Function: s:initVariable() function {{{2 "This function is used to initialise a given variable to a given value. The "variable is only initialised if it does not exist prior @@ -90,8 +81,6 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -else - call AddDefaultGroupToSortOrder() endif call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") From e99a7a03139314997b1a83bea181bb6b36639514 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Fri, 27 Jul 2018 08:46:50 -0400 Subject: [PATCH 437/680] Restore the cached _sortKey for faster processing. Also add a new global variable to track when the g:NERDTreeSortOrder changes. If it has been changed, or when the cached _sortKey value is uninitialized, then calculate the sort key. This improves processing speed over the previous commit, and allows on-the-fly changes to the sort order, (without required vim to be restarted.) --- lib/nerdtree/path.vim | 24 +++++++++++++----------- lib/nerdtree/tree_dir_node.vim | 1 + plugin/NERD_tree.vim | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 71be5f5d..0aa592e2 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -392,17 +392,19 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - let path = self.getLastPathComponent(1) - if !g:NERDTreeSortHiddenFirst - let path = substitute(path, '^[._]', '', '') - endif - if !g:NERDTreeCaseSensitiveSort - let path = tolower(path) - endif - if !g:NERDTreeNaturalSort - let self._sortKey = [self.getSortOrderIndex(), path] - else - let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + let path = self.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + if !g:NERDTreeNaturalSort + let self._sortKey = [self.getSortOrderIndex(), path] + else + let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + endif endif return self._sortKey diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 2f62ec31..30db853f 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -612,6 +612,7 @@ function! s:TreeDirNode.sortChildren() endif let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction " FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a8af089a..71d719aa 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -82,6 +82,7 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] endif +let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") From 456367ab07cd9d866b503a25e52aaa5a9fd8ad1f Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 2 Aug 2018 09:17:18 -0400 Subject: [PATCH 438/680] Put cursor on root when closing bookmark table If the cursor is not already positioned on a node when the bookmark table is closed, then the resulting position of the cursor is not determined. Here, we default to positioning the cursor on the root when the bookmark table is closed. --- lib/nerdtree/ui.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 68a72b68..07373107 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -475,15 +475,23 @@ function! s:UI.toggleIgnoreFilter() endfunction " FUNCTION: s:UI.toggleShowBookmarks() {{{1 -" toggles the display of bookmarks +" Toggle the visibility of the Bookmark table. function! s:UI.toggleShowBookmarks() let self._showBookmarks = !self._showBookmarks + if self.getShowBookmarks() call self.nerdtree.render() call g:NERDTree.CursorToBookmarkTable() else + + if empty(g:NERDTreeFileNode.GetSelected()) + call b:NERDTree.root.putCursorHere(0, 0) + normal! 0 + endif + call self.renderViewSavingPosition() endif + call self.centerView() endfunction From 9e9d16a38a20533ef39bd040a05224b86fc6561a Mon Sep 17 00:00:00 2001 From: Andrew Flockhart Date: Sat, 4 Aug 2018 01:16:46 -0400 Subject: [PATCH 439/680] Reword renamed-buffer prompt to be more clear --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 36e2eae0..c9897cee 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -164,7 +164,7 @@ function! NERDTreeMoveNode() "if the node is open in a buffer, ask the user if they want to "close that buffer if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)" + let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with the new file? (yN)" call s:promptToRenameBuffer(bufnum, prompt, newNodePath) endif From 192b07ce1fb9a7a273232639cd2514f41e8a79af Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 7 Aug 2018 09:00:39 -0400 Subject: [PATCH 440/680] If the NERDTree is zoomed when 'o'pening a file, unzoom it. 'go' does not trigger this new behavior, because focus remains in the NERDTree. --- lib/nerdtree/opener.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 974d99d3..9de36d69 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -244,6 +244,9 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() + if !self._stay && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + call b:NERDTree.ui.toggleZoom() + endif if self._reuseWindow() return From b6978ecd7091c5a9f32176e4b020c83acc61b648 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 7 Aug 2018 10:01:09 -0400 Subject: [PATCH 441/680] Unzoom only when user want NERDTree to stay open. --- lib/nerdtree/opener.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 9de36d69..1ea6e221 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -244,7 +244,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + if !self._stay && !g:NERDTreeQuitOnOpen && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif From 7d9a3f0e8b1546c81e9a3591c416313f0dffd936 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 7 Aug 2018 18:13:40 -0400 Subject: [PATCH 442/680] Make sure the path to the bookmarks file exists before writing it. --- lib/nerdtree/bookmark.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index dd69ad05..55abc8c0 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -343,6 +343,12 @@ function! s:Bookmark.Write() for j in s:Bookmark.InvalidBookmarks() call add(bookmarkStrings, j) endfor + + let path = fnamemodify(g:NERDTreeBookmarksFile, ':h') + if !isdirectory(path) + call mkdir(path, 'p') + endif + call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) endfunction From 026bfaf35ef7ee11fd77c805500d5c746c71440d Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 15 Aug 2018 13:22:06 +0000 Subject: [PATCH 443/680] Do a case sensitive comparison of new/existing buffers. When NERTDtree opens a file, it compares this new file to all open buffers to see if it's already open. If the user has 'ignorecase' turned on then the comparison of "file" and "File" says they're the same, and NERDTree won't reopen the file. This commit forces a case sensitive comparison by using the ==# operator. --- lib/nerdtree/path.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 0aa592e2..912c5372 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -817,7 +817,7 @@ function! s:Path.tabnr() let str = self.str() for t in range(tabpagenr('$')) for b in tabpagebuflist(t+1) - if str == expand('#' . b . ':p') + if str ==# expand('#' . b . ':p') return t+1 endif endfor From 39a89f5e50467eca9d131ee995a2eb97a979c151 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 22 Aug 2018 09:16:33 -0400 Subject: [PATCH 444/680] Use tabnext instead of gt to allow users to remap gt. --- lib/nerdtree/opener.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 974d99d3..56701cfe 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -233,7 +233,6 @@ endfunction " FUNCTION: Opener.open(target) {{{1 function! s:Opener.open(target) - if self._path.isDirectory call self._openDirectory(a:target) return @@ -303,7 +302,7 @@ endfunction " FUNCTION: Opener._restoreCursorPos() {{{1 function! s:Opener._restoreCursorPos() - call nerdtree#exec('normal ' . self._tabnr . 'gt') + call nerdtree#exec(self._tabnr . 'tabnext') call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') endfunction @@ -332,7 +331,7 @@ function! s:Opener._reuseWindow() let tabnr = self._path.tabnr() if tabnr call self._checkToCloseTree(1) - call nerdtree#exec('normal! ' . tabnr . 'gt') + call nerdtree#exec(tabnr . 'tabnext') let winnr = bufwinnr('^' . self._path.str() . '$') call nerdtree#exec(winnr . "wincmd w") return 1 From 18071f599955f6720170d9daa6835a663a6bbaf0 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 22 Aug 2018 17:01:08 -0400 Subject: [PATCH 445/680] NERDTreeCWD: reset CWD if changed by NERDTreeFocus When the user has `'autochdir'` turned on, opening a new NERDTree will cause the current working directory to change. To prevent this happening, remember the CWD and reset it if NERDTreeFocus caused it to change. --- plugin/NERD_tree.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 71d719aa..f8700d56 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -202,7 +202,11 @@ function! NERDTreeFocus() endfunction function! NERDTreeCWD() + let l:cwd = getcwd() call NERDTreeFocus() + if l:cwd != getcwd() + exec 'cd '.l:cwd + endif call nerdtree#ui_glue#chRootCwd() endfunction From 808f5b225b090bb4a94a2c47bb08d1bc1f7f8a4e Mon Sep 17 00:00:00 2001 From: "Phil Runninger (home)" Date: Mon, 13 Aug 2018 23:01:02 -0400 Subject: [PATCH 446/680] Escape commas in the globpath() function's path argument. If not escaped, commas will cause globpath() to search in multiple directories, none of which really exist. --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 30db853f..9d4edee8 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -247,7 +247,7 @@ function! s:TreeDirNode._glob(pattern, all) if self.path.str() == getcwd() let l:pathSpec = ',' else - let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.') + let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') " On Windows, the drive letter may be removed by "fnamemodify()". if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() From f78cf63627dbed66f01c4eaba37c2e5e86315d41 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sun, 9 Sep 2018 21:29:20 -0400 Subject: [PATCH 447/680] Instead of creating the bookmark file path, show error message. This change puts the burden on the user to make sure g:NERDTreeBookmarksFile is correctly set and the path it contains is present and has the proper permissions. If this is not the case, an error message is displayed. This is a better solution than to blindly create the path, when it may actually be impossible to do so. --- lib/nerdtree/bookmark.vim | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 55abc8c0..2e0aab02 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -344,12 +344,11 @@ function! s:Bookmark.Write() call add(bookmarkStrings, j) endfor - let path = fnamemodify(g:NERDTreeBookmarksFile, ':h') - if !isdirectory(path) - call mkdir(path, 'p') - endif - - call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) + try + call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) + catch + call nerdtree#echoError("Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.") + endtry endfunction " vim: set sw=4 sts=4 et fdm=marker: From c726ec7318f1cbb756744333c05445d751804e80 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 10 Sep 2018 06:57:39 -0400 Subject: [PATCH 448/680] Implement PR review comments. --- doc/NERDTree.txt | 4 ++-- plugin/NERD_tree.vim | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index a83c4e15..1cb9856e 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -142,8 +142,8 @@ The following features and functionality are provided by the NERD tree: current tab does not exist, a new one will be initialized. :NERDTreeCWD *:NERDTreeCWD* - Change tree root to current directory. If no NERD tree exists for this - tab, a new tree will be opened. + Change the NERDTree root to the current working directory. If no NERDTree + exists for this tab, a new one is opened. ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index f8700d56..93d299eb 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -202,12 +202,15 @@ function! NERDTreeFocus() endfunction function! NERDTreeCWD() - let l:cwd = getcwd() + let l:cwdPath = g:NERDTreePath.New(getcwd()) call NERDTreeFocus() - if l:cwd != getcwd() - exec 'cd '.l:cwd + + if b:NERDTree.root.path.equals(l:cwdPath) + return endif - call nerdtree#ui_glue#chRootCwd() + + let l:newRoot = g:NERDTreeFileNode.New(l:cwdPath, b:NERDTree) + call b:NERDTree.changeRoot(l:newRoot) endfunction function! NERDTreeAddPathFilter(callback) From 7c8c811f00f9e8f792a88a271f7f79ab0bdd7e85 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 10 Sep 2018 08:33:10 -0400 Subject: [PATCH 449/680] Edit the help file --- doc/NERDTree.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 1cb9856e..278eb6c8 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -142,8 +142,8 @@ The following features and functionality are provided by the NERD tree: current tab does not exist, a new one will be initialized. :NERDTreeCWD *:NERDTreeCWD* - Change the NERDTree root to the current working directory. If no NERDTree - exists for this tab, a new one is opened. + Change the NERDTree root to the current working directory. If no + NERDTree exists for this tab, a new one is opened. ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* @@ -522,7 +522,7 @@ Default key: cd Map option: NERDTreeMapChdir Applies to: files and directories. -Change vims current working directory to that of the selected node. +Change Vim's current working directory to that of the selected node. ------------------------------------------------------------------------------ *NERDTree-CD* @@ -530,7 +530,7 @@ Default key: CD Map option: NERDTreeMapCWD Applies to: no restrictions. -Change tree root to vims current working directory. +Change the NERDTree root to Vim's current working directory. ------------------------------------------------------------------------------ *NERDTree-I* From 7e00a9971e16ccf88362ecf0d52fcd31c31582f2 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 10 Sep 2018 08:46:42 -0400 Subject: [PATCH 450/680] Check for error; remove code duplication --- autoload/nerdtree/ui_glue.vim | 13 ++----------- plugin/NERD_tree.vim | 9 ++++++++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 6ba9ee64..36e71ecb 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -142,18 +142,9 @@ function! s:chRoot(node) endfunction " FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 -" changes the current root to CWD +" Change the NERDTree root to match the current working directory. function! nerdtree#ui_glue#chRootCwd() - try - let cwd = g:NERDTreePath.New(getcwd()) - catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("current directory does not exist.") - return - endtry - if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str() - return - endif - call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree)) + NERDTreeCWD endfunction " FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 93d299eb..b29a3063 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -202,7 +202,14 @@ function! NERDTreeFocus() endfunction function! NERDTreeCWD() - let l:cwdPath = g:NERDTreePath.New(getcwd()) + + try + let l:cwdPath = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echoWarning('current directory does not exist') + return + endtry + call NERDTreeFocus() if b:NERDTree.root.path.equals(l:cwdPath) From 5442d5e04ad3c43d05f4d74b34d8ec2b9eb47fb8 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 10 Sep 2018 08:52:43 -0400 Subject: [PATCH 451/680] Put cursor in first column --- plugin/NERD_tree.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index b29a3063..74ca60d2 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -218,6 +218,7 @@ function! NERDTreeCWD() let l:newRoot = g:NERDTreeFileNode.New(l:cwdPath, b:NERDTree) call b:NERDTree.changeRoot(l:newRoot) + normal! ^ endfunction function! NERDTreeAddPathFilter(callback) From 2cd4331b7837a16daa12858a32cf85fc49366683 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 10 Sep 2018 09:00:05 -0400 Subject: [PATCH 452/680] Check for unknown current working directory --- plugin/NERD_tree.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 74ca60d2..2abd248a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -203,6 +203,11 @@ endfunction function! NERDTreeCWD() + if empty(getcwd()) + call nerdtree#echoWarning('current directory does not exist') + return + endif + try let l:cwdPath = g:NERDTreePath.New(getcwd()) catch /^NERDTree.InvalidArgumentsError/ From e9d3f72d9c955d12630278a823614af49fbe9c5b Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 13 Sep 2018 08:39:09 -0400 Subject: [PATCH 453/680] Function "s:UI.getLineNum()" doesn't always work on cascades. (#882) This PR is a rewrite of the "s:UI.getLineNum()" function. This change improves the logic and clarity of this function, and it fixes the function's ability to work with cascades. Fixes #529. --- lib/nerdtree/ui.vim | 71 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 07373107..5ea13334 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -194,51 +194,52 @@ function! s:UI.getPath(ln) return toReturn endfunction -" FUNCTION: s:UI.getLineNum(file_node){{{1 -" returns the line number this node is rendered on, or -1 if it isnt rendered -function! s:UI.getLineNum(file_node) - " if the node is the root then return the root line no. - if a:file_node.isRoot() +" FUNCTION: s:UI.getLineNum(node) {{{1 +" Return the line number where the given node is rendered. Return -1 if the +" given node is not visible. +function! s:UI.getLineNum(node) + + if a:node.isRoot() return self.getRootLineNum() endif - let totalLines = line("$") + let l:pathComponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/\s*$', '', '')] + let l:currentPathComponent = 1 - " the path components we have matched so far - let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')] - " the index of the component we are searching for - let curPathComponent = 1 + let l:fullPath = a:node.path.str({'format': 'UI'}) - let fullpath = a:file_node.path.str({'format': 'UI'}) + for l:lineNumber in range(self.getRootLineNum() + 1, line('$')) + let l:currentLine = getline(l:lineNumber) + let l:indentLevel = self._indentLevelFor(l:currentLine) - let lnum = self.getRootLineNum() - while lnum > 0 - let lnum = lnum + 1 - " have we reached the bottom of the tree? - if lnum ==# totalLines+1 - return -1 + if l:indentLevel != l:currentPathComponent + continue endif - let curLine = getline(lnum) + let l:currentLine = self._stripMarkup(l:currentLine) + let l:currentPath = join(l:pathComponents, '/') . '/' . l:currentLine - let indent = self._indentLevelFor(curLine) - if indent ==# curPathComponent - let curLine = self._stripMarkup(curLine) - - let curPath = join(pathcomponents, '/') . '/' . curLine - if stridx(fullpath, curPath, 0) ==# 0 - if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' - let curLine = substitute(curLine, '/ *$', '', '') - call add(pathcomponents, curLine) - let curPathComponent = curPathComponent + 1 - - if fullpath ==# curPath - return lnum - endif - endif - endif + " Directories: If the current path "starts with" the full path, then + " either the paths are equal or the line is a cascade containing the + " full path. + if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 + return l:lineNumber endif - endwhile + + " Files: The paths must exactly match. + if l:fullPath ==# l:currentPath + return l:lineNumber + endif + + " Otherwise: If the full path starts with the current path and the + " current path is a directory, we add a new path component. + if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/' + let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') + call add(l:pathComponents, l:currentLine) + let l:currentPathComponent += 1 + endif + endfor + return -1 endfunction From cd1f2c803ec485074af070a2fe942a029775e5bd Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sat, 15 Sep 2018 10:18:09 -0400 Subject: [PATCH 454/680] Fix the , , J, and K default mappings (#886) These mappings currently fail on cascades. This pull request fixes this problem. --- autoload/nerdtree/ui_glue.vim | 106 ++++++++++++++------------------ lib/nerdtree/tree_dir_node.vim | 26 ++++++++ lib/nerdtree/tree_file_node.vim | 70 +++++++-------------- 3 files changed, 94 insertions(+), 108 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 36e71ecb..24c63585 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -348,35 +348,6 @@ function! s:handleMiddleMouse() endif endfunction -" FUNCTION: s:jumpToChild(direction) {{{2 -" Args: -" direction: 0 if going to first child, 1 if going to last -function! s:jumpToChild(currentNode, direction) - if a:currentNode.isRoot() - return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - end - let dirNode = a:currentNode.parent - let childNodes = dirNode.getVisibleChildren() - - let targetNode = childNodes[0] - if a:direction - let targetNode = childNodes[len(childNodes) - 1] - endif - - if targetNode.equals(a:currentNode) - let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) - if siblingDir != {} - let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 - let targetNode = siblingDir.getChildByIndex(indx, 1) - endif - endif - - call targetNode.putCursorHere(1, 0) - - call b:NERDTree.ui.centerView() -endfunction - - " FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 "this is needed since I cant figure out how to invoke dict functions from a "key map @@ -384,41 +355,55 @@ function! nerdtree#ui_glue#invokeKeyMap(key) call g:NERDTreeKeyMap.Invoke(a:key) endfunction -" FUNCTION: s:jumpToFirstChild() {{{1 -" wrapper for the jump to child method +" FUNCTION: s:jumpToFirstChild(node) {{{1 function! s:jumpToFirstChild(node) call s:jumpToChild(a:node, 0) endfunction -" FUNCTION: s:jumpToLastChild() {{{1 -" wrapper for the jump to child method +" FUNCTION: s:jumpToLastChild(node) {{{1 function! s:jumpToLastChild(node) call s:jumpToChild(a:node, 1) endfunction +" FUNCTION: s:jumpToChild(node, last) {{{2 +" Jump to the first or last child node at the same file system level. +" +" Args: +" node: the node on which the cursor currently sits +" last: 1 (true) if jumping to last child, 0 (false) if jumping to first +function! s:jumpToChild(node, last) + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node + + if l:node.isRoot() + return + endif + + let l:parent = l:node.parent + let l:children = l:parent.getVisibleChildren() + + let l:target = a:last ? l:children[len(l:children) - 1] : l:children[0] + + call l:target.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + " FUNCTION: s:jumpToParent(node) {{{1 -" Move the cursor to the parent of the specified node. For a cascade, move to -" the parent of the cascade's highest node. At the root, do nothing. +" Move the cursor to the parent of the specified node. For a cascade, move to +" the parent of the cascade's first node. At the root node, do nothing. function! s:jumpToParent(node) - let l:parent = a:node.parent + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node - " If "a:node" represents a directory, back out of its cascade. - if a:node.path.isDirectory - while !empty(l:parent) && !l:parent.isRoot() - if index(l:parent.getCascade(), a:node) >= 0 - let l:parent = l:parent.parent - else - break - endif - endwhile + if l:node.isRoot() + return endif - if !empty(l:parent) - call l:parent.putCursorHere(1, 0) - call b:NERDTree.ui.centerView() - else + if empty(l:node.parent) call nerdtree#echo('could not jump to parent node') + return endif + + call l:node.parent.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:jumpToRoot() {{{1 @@ -438,19 +423,22 @@ function! s:jumpToPrevSibling(node) call s:jumpToSibling(a:node, 0) endfunction -" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2 -" moves the cursor to the sibling of the current node in the given direction +" FUNCTION: s:jumpToSibling(node, forward) {{{2 +" Move the cursor to the next or previous node at the same file system level. " " Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! s:jumpToSibling(currentNode, forward) - let sibling = a:currentNode.findSibling(a:forward) - - if !empty(sibling) - call sibling.putCursorHere(1, 0) - call b:NERDTree.ui.centerView() +" node: the node on which the cursor currently sits +" forward: 0 to jump to previous sibling, 1 to jump to next sibling +function! s:jumpToSibling(node, forward) + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node + let l:sibling = l:node.findSibling(a:forward) + + if empty(l:sibling) + return endif + + call l:sibling.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 9d4edee8..04c598b4 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -153,6 +153,32 @@ function! s:TreeDirNode.getCascade() return [self] + visChild.getCascade() endfunction +" FUNCTION: TreeDirNode.getCascadeRoot() {{{1 +" Return the first directory node in the cascade in which this directory node +" is rendered. +function! s:TreeDirNode.getCascadeRoot() + + " Don't search above the current NERDTree root node. + if self.isRoot() + return self + endif + + let l:cascadeRoot = self + let l:parent = self.parent + + while !empty(l:parent) && !l:parent.isRoot() + + if index(l:parent.getCascade(), self) == -1 + break + endif + + let l:cascadeRoot = l:parent + let l:parent = l:parent.parent + endwhile + + return l:cascadeRoot +endfunction + " FUNCTION: TreeDirNode.getChildCount() {{{1 " Returns the number of children this node has function! s:TreeDirNode.getChildCount() diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 3ad9fcb6..86aa7a64 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -116,67 +116,39 @@ function! s:TreeFileNode.findNode(path) return {} endfunction -" FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1 -" -" Finds the next sibling for this node in the indicated direction. This sibling -" must be a directory and may/may not have children as specified. -" -" Args: -" direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -" Return: -" a treenode object or {} if no appropriate sibling could be found -function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) - " if we have no parent then we can have no siblings - if self.parent != {} - let nextSibling = self.findSibling(a:direction) - - while nextSibling != {} - if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen - return nextSibling - endif - let nextSibling = nextSibling.findSibling(a:direction) - endwhile - endif - - return {} -endfunction - " FUNCTION: TreeFileNode.findSibling(direction) {{{1 -" -" Finds the next sibling for this node in the indicated direction +" Find the next or previous sibling of this node. " " Args: -" direction: 0 if you want to find the previous sibling, 1 for the next sibling +" direction: 0 for previous, 1 for next " " Return: -" a treenode object or {} if no sibling could be found +" The next/previous TreeFileNode object or an empty dictionary if not found. function! s:TreeFileNode.findSibling(direction) - " if we have no parent then we can have no siblings - if self.parent != {} - " get the index of this node in its parents children - let siblingIndx = self.parent.getChildIndex(self.path) + " There can be no siblings if there is no parent. + if empty(self.parent) + return {} + endif + + let l:nodeIndex = self.parent.getChildIndex(self.path) - if siblingIndx != -1 - " move a long to the next potential sibling node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 + if l:nodeIndex == -1 + return {} + endif - " keep moving along to the next sibling till we find one that is valid - let numSiblings = self.parent.getChildCount() - while siblingIndx >= 0 && siblingIndx < numSiblings + " Get the next index to begin the search. + let l:nodeIndex += a:direction ? 1 : -1 - " if the next node is not an ignored node (i.e. wont show up in the - " view) then return it - if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0 - return self.parent.children[siblingIndx] - endif + while 0 <= l:nodeIndex && l:nodeIndex < self.parent.getChildCount() - " go to next node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - endwhile + " Return the next node if it is not ignored. + if !self.parent.children[l:nodeIndex].path.ignore(self.getNerdtree()) + return self.parent.children[l:nodeIndex] endif - endif + + let l:nodeIndex += a:direction ? 1 : -1 + endwhile return {} endfunction From 599238ad99642e8767c4be6adda75bd84afdfd42 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Mon, 17 Sep 2018 08:13:07 -0400 Subject: [PATCH 455/680] Make NERDTreeCreator set the 'nolist' option (#889) --- lib/nerdtree/creator.vim | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 625914ec..78dfd9eb 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -284,16 +284,21 @@ endfunction " FUNCTION: s:Creator._setCommonBufOptions() {{{1 function! s:Creator._setCommonBufOptions() - "throwaway buffer options - setlocal noswapfile - setlocal buftype=nofile + + " Options for a non-file/control buffer. setlocal bufhidden=hide - setlocal nowrap + setlocal buftype=nofile + setlocal noswapfile + + " Options for controlling buffer/window appearance. setlocal foldcolumn=0 setlocal foldmethod=manual - setlocal nofoldenable setlocal nobuflisted + setlocal nofoldenable + setlocal nolist setlocal nospell + setlocal nowrap + if g:NERDTreeShowLineNumbers setlocal nu else @@ -311,6 +316,7 @@ function! s:Creator._setCommonBufOptions() call self._setupStatusline() call self._bindMappings() + setlocal filetype=nerdtree endfunction From bba4b0087b8cc6f869316398eaf4e74dd6c6246e Mon Sep 17 00:00:00 2001 From: Laurent Voisin Date: Mon, 8 Oct 2018 13:17:33 +0200 Subject: [PATCH 456/680] Fix typo in help file Remove duplicated word. --- doc/NERDTree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 278eb6c8..31f8c571 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1014,7 +1014,7 @@ Defines the value for the |'statusline'| setting in NERDTree windows. Note: The setting is actually applied using |:let-&|, not |:set|, so escaping spaces is not necessary. -Setting this option to -1 will will deactivate it so that your global +Setting this option to -1 will deactivate it so that your global |'statusline'| setting is used. ------------------------------------------------------------------------------ From 6b6cadf86ccce077212292b0585ab17e7884c81e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 10 Oct 2018 22:19:18 -0400 Subject: [PATCH 457/680] Use a better arg for FINDSTR when using the m,l command in Windows. (#887) * Use a better arg for FINDSTR when using the m,l command in Windows. * Remove trailing spaces. * Use vim getf...() functions in place of DOS commands. * Remove unnecessary variable. * Put labels in the text of the file/dir listing. --- nerdtree_plugin/fs_menu.vim | 40 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index c9897cee..f6249f93 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -226,9 +226,9 @@ function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if !empty(treenode) let s:uname = system("uname") - let stat_cmd = 'stat -c "%s" ' - - if s:uname =~? "Darwin" + let stat_cmd = 'stat -c "%s" ' + + if s:uname =~? "Darwin" let stat_cmd = 'stat -f "%z" ' endif @@ -248,33 +248,13 @@ function! NERDTreeListNodeWin32() let l:node = g:NERDTreeFileNode.GetSelected() if !empty(l:node) - - let l:save_shell = &shell - set shell& - - if exists('+shellslash') - let l:save_shellslash = &shellslash - set noshellslash - endif - - let l:command = 'DIR /Q ' - \ . shellescape(l:node.path.str()) - \ . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"' - - let l:metadata = split(system(l:command), "\n") - - if v:shell_error == 0 - call nerdtree#echo(l:metadata[0]) - else - call nerdtree#echoError('shell command failed') - endif - - let &shell = l:save_shell - - if exists('l:save_shellslash') - let &shellslash = l:save_shellslash - endif - + let l:path = l:node.path.str() + call nerdtree#echo(printf("%s:%s MOD:%s BYTES:%d PERMISSIONS:%s", + \ toupper(getftype(l:path)), + \ fnamemodify(l:path, ':t'), + \ strftime("%c", getftime(l:path)), + \ getfsize(l:path), + \ getfperm(l:path))) return endif From 5381197747c8ead163071542c77fe76379aaf84e Mon Sep 17 00:00:00 2001 From: Werner Hofstra Date: Tue, 16 Oct 2018 17:08:23 +0200 Subject: [PATCH 458/680] Add NERDTreeRefreshRoot command (#897) * Add NERDTreeRefreshRoot command * Document NERDTreeRefreshRoot --- autoload/nerdtree/ui_glue.vim | 8 ++++++++ doc/NERDTree.txt | 3 +++ 2 files changed, 11 insertions(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 24c63585..507b5086 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -524,10 +524,17 @@ endfunction " Reloads the current root. All nodes below this will be lost and the root dir " will be reloaded. function! s:refreshRoot() + if !g:NERDTree.IsOpen() + return + endif call nerdtree#echo("Refreshing the root node. This could take a while...") + + let l:curWin = winnr() + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call b:NERDTree.root.refresh() call b:NERDTree.render() redraw + call nerdtree#exec(l:curWin . "wincmd w") call nerdtree#echo("Refreshing the root node. This could take a while... DONE") endfunction @@ -554,6 +561,7 @@ function! nerdtree#ui_glue#setupCommands() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('') + command! -n=0 -bar NERDTreeRefreshRoot call s:refreshRoot() command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() endfunction diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 31f8c571..8f214cb6 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -145,6 +145,9 @@ The following features and functionality are provided by the NERD tree: Change the NERDTree root to the current working directory. If no NERDTree exists for this tab, a new one is opened. +:NERDTreeRefreshRoot *:NERDTreeRefreshRoot* + Refreshes the NERD tree root node. + ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* From 820955e77308d2c3d324bde152c0dca9d69c735f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 18 Oct 2018 11:35:00 -0400 Subject: [PATCH 459/680] Catch all errors, not just NERDTree errors. (#894) When middle-clicking, the s:TreeFileNode.GetSelected() function is called along the way. If this is done outside of the NERDTree window, there is not "b:NERDTree" variable, and the "E121: Undefined variable" exception is thrown. This function was trying to catch only the NERDTree specific errors; thus, it let the Undefined variable exception slip by. This commit causes the function to catch all errors. --- lib/nerdtree/tree_file_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 86aa7a64..52b61930 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -180,7 +180,7 @@ function! s:TreeFileNode.GetSelected() endif return b:NERDTree.root.findNode(l:path) - catch /^NERDTree/ + catch return {} endtry endfunction From f98078d3ae6d356fcc58a4fc8840eb55b1ea522e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 18 Oct 2018 16:13:15 -0400 Subject: [PATCH 460/680] Force sort to recalculate the cached sortKey. (#898) * Force sort to recalculate the cached sortKey. The problem in issue #880 was caused by the sort using the old sortKey. For example, given nodes A, B, and C, if B were renamed to D, the sort was still using B as its sortKey, thus not moving it. It's a bit of a hack, but if we set g:NERDTreeOldSortOrder to an empty list, the cached sortKey will be recalculated. I did the same thing for both the Copy and Add functions as well. * Add a comment to explain the let ... = [] statement. --- nerdtree_plugin/fs_menu.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index f6249f93..ef378e26 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -128,6 +128,9 @@ function! NERDTreeAddNode() let parentNode = b:NERDTree.root.findNode(newPath.getParent()) let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] if empty(parentNode) call b:NERDTree.root.refresh() call b:NERDTree.render() @@ -158,6 +161,9 @@ function! NERDTreeMoveNode() let bufnum = bufnr("^".curNode.path.str()."$") call curNode.rename(newNodePath) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] call b:NERDTree.root.refresh() call NERDTreeRender() @@ -283,6 +289,9 @@ function! NERDTreeCopyNode() if confirmed try let newNode = currentNode.copy(newNodePath) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] if empty(newNode) call b:NERDTree.root.refresh() call b:NERDTree.render() From 52151fb30741dfd3665d3e4e5493c6cc822992fc Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Oct 2018 22:13:42 -0400 Subject: [PATCH 461/680] Call Resolve on the file's path when calling :NERDTreeFind. (#896) When :NERDTreeFind creates a tree, it resolves the file's path, and makes that its root. See :h resolve() for more info; it basically tracks down links to their ultimate source. Then :NERDTreeFind tries to find the file under that root, so it can be revealed. The problem is that it compares the file's unresolved path against the resolved path in the root. Here is the scenario: /tmp/ is a link to /private/tmp/ :e /tmp/foo will open the file as expected :NERDTreeFind will first create a tree with a root of /private/tmp/ Then it tries to find /tmp/foo, but it can't, because the path names don't match. This commit resolves /tmp/foo to the actual location of /private/tmp/foo; thus, it is able to find the file in the tree. --- autoload/nerdtree/ui_glue.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 507b5086..12dd9ae1 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -255,6 +255,7 @@ function! s:findAndRevealPath(pathStr) endif try + let l:pathStr = g:NERDTreePath.Resolve(l:pathStr) let l:pathObj = g:NERDTreePath.New(l:pathStr) catch /^NERDTree.InvalidArgumentsError/ call nerdtree#echoWarning('invalid path') From 92a20c0736f39aac0498db7bbf98b886dfa1ef70 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Oct 2018 22:14:18 -0400 Subject: [PATCH 462/680] Bug fix: Parse . and .. from path string with trailing slash. (#899) --- lib/nerdtree/tree_dir_node.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 04c598b4..a36bdf81 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -304,9 +304,11 @@ function! s:TreeDirNode._glob(pattern, all) for l:file in l:globList let l:tail = fnamemodify(l:file, ':t') - " Double the modifier if only a separator was stripped. + " If l:file has a trailing slash, then its :tail will be ''. Use + " :h to drop the slash and the empty string after it; then use :t + " to get the directory name. if l:tail == '' - let l:tail = fnamemodify(l:file, ':t:t') + let l:tail = fnamemodify(l:file, ':h:t') endif if l:tail == '.' || l:tail == '..' From 388623e702ce7df7d642e4e69d4d0328667751f2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Oct 2018 22:18:18 -0400 Subject: [PATCH 463/680] Support sorting files and directories by modification time. (#901) * Introduce a flag to to sort by the node's modification time. This flag is part of the NERDTreeSortOrder list. '[[timestamp]]' sorts oldest to newest, while '[[-timestamp]]' sorts newest to oldest. Its position in the array determines whether it is the primary sort (first position) or secondary sort (any other position). The remaining elements in the array describe the other sort level following all prior rules. If needed, a tertiary sort is done alphabetically on the filename. Examples: ['[[timestamp]]'] - oldest to newest ['\/$','*','[[-timestamp]]'] - dirs, then files, each newest first. When using this flag, performance is slowed a little because the sortKey is always recalculated with every sort. Why? Because if a file is saved (either in vim or by an outside program), NERDTree needs to go back out to the shell to get the new modification time. * Update NERDTreeSortOrder documentation. The new `[[timestamp]]' and '[[-timestamp]]' flags are added to support sorting by modification time. * Fix the inequality. Must be >= to force recalculation of _sortKey. * Move `let path=` closer to where it's used. --- doc/NERDTree.txt | 16 ++++++++++++++++ lib/nerdtree/path.vim | 20 +++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 8f214cb6..42c31cca 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -995,17 +995,33 @@ appended to the array. The regex '\/$' should be used to match directory nodes. +A special flag can be used to sort by the modification timestamps of files and +directories. It is either '[[timestamp]]' for ascending, or '[[-timestamp]]' +for descending. If placed at the beginning of the list, files and directories +are sorted by timestamp, and then by the remaining items in the sort order +list. If this flag is in any other position of the list, timestamp sorting is +done secondarily. See examples 4, 5, and 6 below. + After this sorting is done, the files in each group are sorted alphabetically. Other examples: > (1) ['*', '\/$'] (2) [] (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] + (4) ['[[timestamp]]'] + (5) ['\/$', '*', '[[-timestamp]]'] + (6) ['\.md$', '\.c$', '[[-timestamp]]', '*'] < 1. Directories will appear last, everything else will appear above. 2. Everything will simply appear in alphabetical order. 3. Dirs will appear first, then ruby and php. Swap files, bak files and vim backup files will appear last with everything else preceding them. +4. All files and directories are sorted by timestamp, oldest first. If any + files have identical timestamps, they are sorted alphabetically. +5. Directories are first, newest to oldest, then everything else, newest to + oldest. +6. Markdown files first, followed by C source files, then everything else. + Each group is shown newest to oldest. ------------------------------------------------------------------------------ *'NERDTreeStatusline'* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 912c5372..32c9cdb3 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -392,7 +392,17 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + let l:ascending = index(g:NERDTreeSortOrder,'[[timestamp]]') + let l:descending = index(g:NERDTreeSortOrder,'[[-timestamp]]') + if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder || l:ascending >= 0 || l:descending >= 0 + let self._sortKey = [self.getSortOrderIndex()] + + if l:descending >= 0 + call insert(self._sortKey, -getftime(self.str()), l:descending == 0 ? 0 : len(self._sortKey)) + elseif l:ascending >= 0 + call insert(self._sortKey, getftime(self.str()), l:ascending == 0 ? 0 : len(self._sortKey)) + endif + let path = self.getLastPathComponent(1) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') @@ -400,13 +410,9 @@ function! s:Path.getSortKey() if !g:NERDTreeCaseSensitiveSort let path = tolower(path) endif - if !g:NERDTreeNaturalSort - let self._sortKey = [self.getSortOrderIndex(), path] - else - let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) - endif - endif + call extend(self._sortKey, (g:NERDTreeNaturalSort ? self._splitChunks(path) : [path])) + endif return self._sortKey endfunction From c372911c4a49c1747061425cb2685ca3f317c743 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Oct 2018 22:20:59 -0400 Subject: [PATCH 464/680] Refresh buffers after `m`, `m` operation on a folder (#888) * WIP: Wow! That's an ugly diff. I'm not done yet, though. * Fix the ugliness of the previous commit, and finish the work. If the node being renamed is a directory, get a list of all open buffers whose file lives in the old directory. If that list is not empty, ask the user if he wants to replace the old buffers with the new files. The logic to handle renaming a file node stays the same, although the code has been refactored a bit. --- nerdtree_plugin/fs_menu.vim | 70 ++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index ef378e26..ef261ca9 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -83,31 +83,32 @@ function! s:promptToDelBuffer(bufnum, msg) endif endfunction -"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is replaced with a new one +"FUNCTION: s:renameBuffer(bufNum, newNodeName, isDirectory){{{1 +"The buffer with the given bufNum is replaced with a new one " "Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:promptToRenameBuffer(bufnum, msg, newFileName) - echo a:msg - if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' - let quotedFileName = fnameescape(a:newFileName) - " 1. ensure that a new buffer is loaded - exec "badd " . quotedFileName - " 2. ensure that all windows which display the just deleted filename - " display a buffer for a new filename. - let s:originalTabNumber = tabpagenr() - let s:originalWindowNumber = winnr() - let editStr = g:NERDTreePath.New(a:newFileName).str({'format': 'Edit'}) - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . editStr . "' | endif" - exec "tabnext " . s:originalTabNumber - exec s:originalWindowNumber . "wincmd w" - " 3. We don't need a previous buffer anymore - exec "bwipeout! " . a:bufnum +"bufNum: the buffer that may be deleted +"newNodeName: the name given to the renamed node +"isDirectory: determines how to do the create the new filenames +function! s:renameBuffer(bufNum, newNodeName, isDirectory) + if a:isDirectory + let quotedFileName = fnameescape(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')) + let editStr = g:NERDTreePath.New(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')).str({'format': 'Edit'}) + else + let quotedFileName = fnameescape(a:newNodeName) + let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif + " 1. ensure that a new buffer is loaded + exec "badd " . quotedFileName + " 2. ensure that all windows which display the just deleted filename + " display a buffer for a new filename. + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif" + exec "tabnext " . s:originalTabNumber + exec s:originalWindowNumber . "wincmd w" + " 3. We don't need a previous buffer anymore + exec "bwipeout! " . a:bufNum endfunction "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() @@ -158,7 +159,11 @@ function! NERDTreeMoveNode() endif try - let bufnum = bufnr("^".curNode.path.str()."$") + if curNode.path.isDirectory + let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + else + let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') + endif call curNode.rename(newNodePath) " Emptying g:NERDTreeOldSortOrder forces the sort to @@ -167,11 +172,20 @@ function! NERDTreeMoveNode() call b:NERDTree.root.refresh() call NERDTreeRender() - "if the node is open in a buffer, ask the user if they want to - "close that buffer - if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with the new file? (yN)" - call s:promptToRenameBuffer(bufnum, prompt, newNodePath) + " If the file node is open, or files under the directory node are + " open, ask the user if they want to replace the file(s) with the + " renamed files. + if !empty(l:openBuffers) + if curNode.path.isDirectory + echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . ". Replace these buffers with the new files? (yN)" + else + echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . ". Replace this buffer with the new file? (yN)" + endif + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + for bufNum in l:openBuffers + call s:renameBuffer(bufNum, newNodePath, curNode.path.isDirectory) + endfor + endif endif call curNode.putCursorHere(1, 0) From 91e0f2253fbecefa7e14f095950341584877ef19 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Oct 2018 22:41:13 -0400 Subject: [PATCH 465/680] Support unusual characters in file and directory names (#868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use a delimiter in node to separate file/dir name from the rest. * Switch warning message to use nerdtree#deprecated function. * Compress the space between the tree symbols and the node. * Include the delimiter when calculating indent or getting filename. * Don't need to strip leading delimiter. It will already be gone. * Simplify the way the delimiter is being used. I don't know what I was thinking. The delimiter doesn't need to be used to separate every indicator on the node's text, ie. Bad: Tree|GenericFlags|Filename|ExecutableFlag|Link|ReadonlyFlag Better: Tree GenericFlags|Filename|ExecutableFlag Link ReadonlyFlag This was unnecessary, given that we're only interested in the filename. So, just one pair of delimiters is all we need. That greatly simplifies the _stripMarkup function, and restores a bunch of other statements to what they already are in the master branch. * Add syntax highlighting to conceal the delimiter * Put a if has("conceal") check around the syntax statement using it. * Make concealment work correctly for LinkFile and readonly files. * Use highlight Ignore if conceal isn't available. This is probably the best we can do, especially if some other character must be used in place of nbsp. * Make the regex better match the original, but more compact. It was allowing 2+ spaces, instead of only 1+. * Fix the syntax highlighing of delimiters around NERDTreeExecFile. * Bug fix: Parse . and .. from path string with trailing slash. * Fix unresponsive cascaded directories. Using ':' as a more visible delimiter, when directories are cascaded, the line appears in NERDTree like so: ▾ :lib/::nerdtree/: Before this commit, the s:UI._stripMarkup function was leaving the internal delimiters in place (lib/::nerdtree/). Now they are removed, resulting in a valid path (lib/nerdtree/). * Use .= to shorten statement. Use clearer substitutes to get node name. * Remove node delimiters that terminate the line. * If flags are needed after the node name, then put another delimiter before them. * When joining directory nodes for cascaded display, strip off the delimiter from the child node(s). * Remove the unnecessary substitution of doubled intermediate delimiters, since they're not in there anymore. * DRY up the addition of the 2nd delimiter, and use only 1 for all tags. --- lib/nerdtree/path.vim | 19 ++++++++++++++----- lib/nerdtree/tree_dir_node.vim | 3 ++- lib/nerdtree/tree_file_node.vim | 2 +- lib/nerdtree/ui.vim | 25 ++++--------------------- plugin/NERD_tree.vim | 3 +++ syntax/nerdtree.vim | 9 +++++++++ 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 32c9cdb3..d997c312 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -39,10 +39,10 @@ endfunction " FUNCTION: Path.cacheDisplayString() {{{1 function! s:Path.cacheDisplayString() abort - let self.cachedDisplayString = self.getLastPathComponent(1) + let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . '*' + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . '*' endif let self._bookmarkNames = [] @@ -52,15 +52,24 @@ function! s:Path.cacheDisplayString() abort endif endfor if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 - let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' endif if self.isSymLink - let self.cachedDisplayString .= ' -> ' . self.symLinkDest + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest endif if self.isReadOnly - let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']' + endif +endfunction + +" FUNCTION: Path.addDelimiter() {{{1 +function! s:Path.addDelimiter(line) + if a:line =~# '\(.*' . g:NERDTreeNodeDelimiter . '\)\{2}' + return a:line + else + return a:line . g:NERDTreeNodeDelimiter endif endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a36bdf81..016a5dcb 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -99,7 +99,8 @@ function! s:TreeDirNode.displayString() let l:label = '' let l:cascade = self.getCascade() for l:dirNode in l:cascade - let l:label .= l:dirNode.path.displayString() + let l:next = l:dirNode.path.displayString() + let l:label .= l:label == '' ? l:next : strcharpart(l:next,1) endfor " Select the appropriate open/closed status indicator symbol. diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 52b61930..d4c060fc 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -242,7 +242,7 @@ endfunction " FUNCTION: TreeFileNode.openInNewTab(options) {{{1 function! s:TreeFileNode.openInNewTab(options) - echomsg 'TreeFileNode.openInNewTab is deprecated' + call nerdtree#deprecated('TreeFileNode.openinNewTab', 'is deprecated, use .open() instead.') call self.open(extend({'where': 't'}, a:options)) endfunction diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5ea13334..32d96d9b 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -300,7 +300,7 @@ endfunction " FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() - return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' + return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']\? ' endfunction " FUNCTION: s:UI._renderBookmarks {{{1 @@ -363,30 +363,13 @@ function! s:UI.setShowHidden(val) endfunction " FUNCTION: s:UI._stripMarkup(line){{{1 -" returns the given line with all the tree parts stripped off +" find the filename in the given line, and return it. " " Args: " line: the subject line function! s:UI._stripMarkup(line) - let line = a:line - " remove the tree parts and the leading space - let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") - - " strip off any read only flag - let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","") - - " strip off any bookmark flags - let line = substitute (line, ' {[^}]*}', "","") - - " strip off any executable flags - let line = substitute (line, '*\ze\($\| \)', "","") - - " strip off any generic flags - let line = substitute (line, '\[[^]]*\]', "","") - - let line = substitute (line,' -> .*',"","") " remove link to - - return line + let l:line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '') + return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '') endfunction " FUNCTION: s:UI.render() {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 2abd248a..62506e53 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -86,6 +86,9 @@ let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") +" ASCII 160: non-breaking space used to delimit items in the tree's nodes. +call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") + if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7c80605c..dddce6d3 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -36,6 +36,15 @@ exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir +"highlighing to conceal the delimiter around the file/dir name +if has("conceal") + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' + setlocal conceallevel=2 concealcursor=nvic +else + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' + hi! link NERDTreeNodeDelimiters Ignore +endif + syn match NERDTreeCWD #^[ Date: Wed, 31 Oct 2018 08:45:43 -0400 Subject: [PATCH 466/680] Use substitute() for backward compatibility. Change conceallevel to 3. --- lib/nerdtree/tree_dir_node.vim | 2 +- syntax/nerdtree.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 016a5dcb..b7b7d8f9 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -100,7 +100,7 @@ function! s:TreeDirNode.displayString() let l:cascade = self.getCascade() for l:dirNode in l:cascade let l:next = l:dirNode.path.displayString() - let l:label .= l:label == '' ? l:next : strcharpart(l:next,1) + let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','') endfor " Select the appropriate open/closed status indicator symbol. diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index dddce6d3..172806b8 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -39,7 +39,7 @@ syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir "highlighing to conceal the delimiter around the file/dir name if has("conceal") exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' - setlocal conceallevel=2 concealcursor=nvic + setlocal conceallevel=3 concealcursor=nvic else exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' hi! link NERDTreeNodeDelimiters Ignore From 6fe967b3b357c50c74ca25a3840a66b705593bce Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Mon, 5 Nov 2018 16:12:07 +0100 Subject: [PATCH 467/680] Allow highlighting more than one flag. (#908) --- syntax/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 172806b8..64c0f3fa 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -33,8 +33,8 @@ exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# cont "highlighting for readonly files exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' -syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile -syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir +syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExecFile +syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir "highlighing to conceal the delimiter around the file/dir name if has("conceal") From 64c3a6aed3e54d48a85e42aad6db3c6baac44f3c Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 12 Nov 2018 11:17:20 -0500 Subject: [PATCH 468/680] Change the containedin to ALL to conceal delmiter after filename. --- syntax/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 172806b8..68ca3843 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -38,10 +38,10 @@ syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir "highlighing to conceal the delimiter around the file/dir name if has("conceal") - exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=ALL' setlocal conceallevel=3 concealcursor=nvic else - exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore endif From 370eb5bcb44d7df6cd4512e05d4511fd479497d7 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 20 Nov 2018 13:33:23 -0500 Subject: [PATCH 469/680] Add two more disqualifications for isCascadable(). (#914) * Add two more disqualifications for isCascadable(). A directory that is bookmarked or that is a symlink to another location has trailing text indicating so. This extra text causes problem when cascading with a directory underneath it, so disable it in this case. * Add comments to explain the new exclusions for bookmarks and symlinks. --- lib/nerdtree/tree_dir_node.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index b7b7d8f9..dd818a56 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -370,12 +370,26 @@ function! s:TreeDirNode.hasVisibleChildren() endfunction " FUNCTION: TreeDirNode.isCascadable() {{{1 -" true if this dir has only one visible child - which is also a dir +" true if this dir has only one visible child that is also a dir +" false if this dir is bookmarked or symlinked. Why? Two reasons: +" 1. If cascaded, we don't know which dir is bookmarked or is a symlink. +" 2. If the parent is a symlink or is bookmarked, you end up with unparsable +" text, and NERDTree cannot get the path of any child node. function! s:TreeDirNode.isCascadable() if g:NERDTreeCascadeSingleChildDir == 0 return 0 endif + if self.path.isSymLink + return 0 + endif + + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self.path) + return 0 + endif + endfor + let c = self.getVisibleChildren() return len(c) == 1 && c[0].path.isDirectory endfunction From c905a5d7b87051e574c2e72fae57e56c456ba2f4 Mon Sep 17 00:00:00 2001 From: Arvid Gerstmann Date: Thu, 29 Nov 2018 15:17:39 +0100 Subject: [PATCH 470/680] Allow modification of menu keybindings (#923) --- doc/NERDTree.txt | 16 ++++++++++++++++ lib/nerdtree/menu_controller.vim | 6 +++--- plugin/NERD_tree.vim | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 42c31cca..562d9d5c 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -605,6 +605,22 @@ menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| +------------------------------------------------------------------------------ + *NERDTreeMenu-j* +Default key: j +Map option: NERDTreeMenuDown +Applies to: The NERD tree menu. + +Moves the cursor down. + +------------------------------------------------------------------------------ + *NERDTreeMenu-k* +Default key: k +Map option: NERDTreeMenuUp +Applies to: The NERD tree menu. + +Moves the cursor up. + ============================================================================== 3. Customisation *NERDTreeOptions* diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 68e4d304..84bdb26b 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -49,7 +49,7 @@ endfunction "FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() - echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" + echo "NERDTree Menu. Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter and the shortcuts indicated" echo "==========================================================" for i in range(0, len(self.menuItems)-1) @@ -71,9 +71,9 @@ endfunction "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) - if a:key == 'j' + if a:key == g:NERDTreeMenuDown call self._cursorDown() - elseif a:key == 'k' + elseif a:key == g:NERDTreeMenuUp call self._cursorUp() elseif a:key == nr2char(27) "escape let self.selection = -1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 62506e53..57a65a1b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -148,6 +148,8 @@ call s:initVariable("g:NERDTreeMapToggleZoom", "A") call s:initVariable("g:NERDTreeMapUpdir", "u") call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") call s:initVariable("g:NERDTreeMapCWD", "CD") +call s:initVariable("g:NERDTreeMenuDown", "j") +call s:initVariable("g:NERDTreeMenuUp", "k") "SECTION: Load class files{{{2 call nerdtree#loadClassFiles() From ffa8be8aa7b3048d767635e0fadc37d4391ff9cc Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 6 Dec 2018 01:08:16 -0500 Subject: [PATCH 471/680] Document NERDTreeNodeDelimiter #912 (#926) * Change the default node delimiter to the BELL character, \x07. * Syntax match by ASCII code, vs. string concatenation. * Document the NERDTreeNodeDelimiter setting. * Clean up the documentation markup. * Remove apostrophes, since the NERDTree settings aren't vim options. * Use backticks to hot-link the referenced vim options. * Add a modeline. * Update the title and the About section of the documentation. * Fix typo, and clarify branches of code in Github. * Fix wrapping to 78, and remove colorcolumn setting from modeline. * Change the ASCI Art title, and give credit for it. * Change the word option to setting, and redo the word wrapping. I want to reserve the word 'option' to mean only Vim options that are changed with the `:set` command. Since we need to use `:let` to establish the values for the NERDTree variables, I choose to call them settings instead. * Realign hot-links with concealed markup tags taken into account. * Text alignment, typo fixes, and wordsmithing the About section. --- doc/NERDTree.txt | 688 +++++++++++++++++++++++-------------------- plugin/NERD_tree.vim | 4 +- syntax/nerdtree.vim | 4 +- 3 files changed, 367 insertions(+), 329 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 562d9d5c..0a3ae60c 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1,23 +1,23 @@ -*NERDTree.txt* A tree explorer plugin that owns your momma! +*NERDTree.txt* A tree explorer plugin to rule the Vim world. Bwahahaha!! - omg its ... ~ + Are you ready for this? It's the... - ________ ________ _ ____________ ____ __________ ____________~ - /_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~ - / / / /_/ / __/ / |/ / __/ / /_/ / / / / / / / /_/ / __/ / __/ ~ - / / / __ / /___ / /| / /___/ _, _/ /_/ / / / / _, _/ /___/ /___ ~ - /_/ /_/ /_/_____/ /_/ |_/_____/_/ |_/_____/ /_/ /_/ |_/_____/_____/ ~ - Reference Manual~ - + Y88b Y88 888'Y88 888 88e 888 88e 88P'888'Y88 ~ + Y88b Y8 888 ,'Y 888 888D 888 888b P' 888 'Y 888,8, ,e e, ,e e, ~ + b Y88b Y 888C8 888 88" 888 8888D 888 888 " d88 88b d88 88b ~ + 8b Y88b 888 ",d 888 b, 888 888P 888 888 888 , 888 , ~ + 88b Y88b 888,d88 888 88b, 888 88" 888 888 "YeeP" "YeeP" ~ + ~ + Reference Manual ~ ============================================================================== -CONTENTS *NERDTree-contents* +CONTENTS *NERDTree-contents* 1.Intro...................................|NERDTree| 2.Functionality provided..................|NERDTreeFunctionality| @@ -28,9 +28,9 @@ CONTENTS *NERDTree-contents* 2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks| 2.3.NERD tree mappings................|NERDTreeMappings| 2.4.The NERD tree menu................|NERDTreeMenu| - 3.Options.................................|NERDTreeOptions| - 3.1.Option summary....................|NERDTreeOptionSummary| - 3.2.Option details....................|NERDTreeOptionDetails| + 3.Settings................................|NERDTreeSettings| + 3.1.Settings summary..................|NERDTreeSettingsSummary| + 3.2.Settings details..................|NERDTreeSettingsDetails| 4.The NERD tree API.......................|NERDTreeAPI| 4.1.Key map API.......................|NERDTreeKeymapAPI| 4.2.Menu API..........................|NERDTreeMenuAPI| @@ -40,7 +40,7 @@ CONTENTS *NERDTree-contents* 6.License.................................|NERDTreeLicense| ============================================================================== -1. Intro *NERDTree* +1. Intro *NERDTree* What is this "NERD tree"?? @@ -94,12 +94,12 @@ The following features and functionality are provided by the NERD tree: ============================================================================== -2. Functionality provided *NERDTreeFunctionality* +2. Functionality provided *NERDTreeFunctionality* ------------------------------------------------------------------------------ -2.1. Global Commands *NERDTreeGlobalCommands* +2.1. Global Commands *NERDTreeGlobalCommands* -:NERDTree [ | ] *:NERDTree* +:NERDTree [ | ] *:NERDTree* Opens a fresh NERD tree. The root of the tree depends on the argument given. There are 3 cases: If no argument is given, the current directory will be used. If a directory is given, that will be used. If a bookmark @@ -107,21 +107,21 @@ The following features and functionality are provided by the NERD tree: :NERDTree /home/marty/vim7/src :NERDTree foo (foo is the name of a bookmark) < -:NERDTreeFromBookmark *:NERDTreeFromBookmark* +:NERDTreeFromBookmark *:NERDTreeFromBookmark* Opens a fresh NERD tree with the root initialized to the dir for . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). -:NERDTreeToggle [ | ] *:NERDTreeToggle* +:NERDTreeToggle [ | ] *:NERDTreeToggle* If a NERD tree already exists for this tab, it is reopened and rendered again. If no NERD tree exists for this tab then this command acts the same as the |:NERDTree| command. -:NERDTreeFocus *:NERDTreeFocus* +:NERDTreeFocus *:NERDTreeFocus* Opens (or reopens) the NERD Tree if it is not currently visible; otherwise, the cursor is moved to the already-open NERD Tree. -:NERDTreeMirror *:NERDTreeMirror* +:NERDTreeMirror *:NERDTreeMirror* Shares an existing NERD tree, from another tab, in the current tab. Changes made to one tree are reflected in both as they are actually the same buffer. @@ -129,10 +129,10 @@ The following features and functionality are provided by the NERD tree: If only one other NERD tree exists, that tree is automatically mirrored. If more than one exists, the script will ask which tree to mirror. -:NERDTreeClose *:NERDTreeClose* +:NERDTreeClose *:NERDTreeClose* Close the NERD tree in this tab. -:NERDTreeFind [] *:NERDTreeFind* +:NERDTreeFind [] *:NERDTreeFind* Without the optional argument, find and reveal the file for the active buffer in the NERDTree window. With the argument, find and reveal the specified path. @@ -141,29 +141,29 @@ The following features and functionality are provided by the NERD tree: placed on the tree node for the determined path. If a NERDTree for the current tab does not exist, a new one will be initialized. -:NERDTreeCWD *:NERDTreeCWD* +:NERDTreeCWD *:NERDTreeCWD* Change the NERDTree root to the current working directory. If no NERDTree exists for this tab, a new one is opened. -:NERDTreeRefreshRoot *:NERDTreeRefreshRoot* +:NERDTreeRefreshRoot *:NERDTreeRefreshRoot* Refreshes the NERD tree root node. ------------------------------------------------------------------------------ -2.2. Bookmarks *NERDTreeBookmarks* +2.2. Bookmarks *NERDTreeBookmarks* Bookmarks in the NERD tree are a way to tag files or directories of interest. For example, you could use bookmarks to tag all of your project directories. ------------------------------------------------------------------------------ -2.2.1. The Bookmark Table *NERDTreeBookmarkTable* +2.2.1. The Bookmark Table *NERDTreeBookmarkTable* If the bookmark table is active (see |NERDTree-B| and -|'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double +|NERDTreeShowBookmarks|), it will be rendered above the tree. You can double click bookmarks or use the |NERDTree-o| mapping to activate them. See also, |NERDTree-t| and |NERDTree-T| ------------------------------------------------------------------------------ -2.2.2. Bookmark commands *NERDTreeBookmarkCommands* +2.2.2. Bookmark commands *NERDTreeBookmarkCommands* Note: The following commands are only available within the NERDTree buffer. @@ -199,18 +199,18 @@ Note: The following commands are only available within the NERDTree buffer. Remove all bookmarks. :ReadBookmarks - Re-read the bookmarks in the |'NERDTreeBookmarksFile'|. + Re-read the bookmarks in the |NERDTreeBookmarksFile|. See also |:NERDTree| and |:NERDTreeFromBookmark|. ------------------------------------------------------------------------------ -2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks* +2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks* If invalid bookmarks are detected, the script will issue an error message and the invalid bookmarks will become unavailable for use. These bookmarks will still be stored in the bookmarks file (see -|'NERDTreeBookmarksFile'|), down the bottom. There will always be a blank line +|NERDTreeBookmarksFile|), down the bottom. There will always be a blank line after the valid bookmarks but before the invalid ones. Each line in the bookmarks file represents one bookmark. The proper format is: @@ -220,60 +220,59 @@ After you have corrected any invalid bookmarks, either restart vim, or go :ReadBookmarks from the NERD tree window. ------------------------------------------------------------------------------ -2.3. NERD tree Mappings *NERDTreeMappings* - -Default Description~ help-tag~ -Key~ - -o.......Open files, directories and bookmarks....................|NERDTree-o| -go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go| -t.......Open selected node/bookmark in a new tab.................|NERDTree-t| -T.......Same as 't' but keep the focus on the current tab........|NERDTree-T| -i.......Open selected file in a split window.....................|NERDTree-i| -gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi| -s.......Open selected file in a new vsplit.......................|NERDTree-s| -gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs| -O.......Recursively open the selected directory..................|NERDTree-O| -x.......Close the current nodes parent...........................|NERDTree-x| -X.......Recursively close all children of the current node.......|NERDTree-X| -e.......Edit the current dir.....................................|NERDTree-e| - -...............same as |NERDTree-o|. -double-click.......same as the |NERDTree-o| map. -middle-click.......same as |NERDTree-i| for files, same as - |NERDTree-e| for dirs. - -D.......Delete the current bookmark .............................|NERDTree-D| - -P.......Jump to the root node....................................|NERDTree-P| -p.......Jump to current nodes parent.............................|NERDTree-p| -K.......Jump up inside directories at the current tree depth.....|NERDTree-K| -J.......Jump down inside directories at the current tree depth...|NERDTree-J| -...Jump down to the next sibling of the current directory...|NERDTree-C-J| -...Jump up to the previous sibling of the current directory.|NERDTree-C-K| - -C.......Change the tree root to the selected dir.................|NERDTree-C| -u.......Move the tree root up one directory......................|NERDTree-u| -U.......Same as 'u' except the old root node is left open........|NERDTree-U| -r.......Recursively refresh the current directory................|NERDTree-r| -R.......Recursively refresh the current root.....................|NERDTree-R| -m.......Display the NERD tree menu...............................|NERDTree-m| -cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| -CD......Change tree root to the CWD..............................|NERDTree-CD| - -I.......Toggle whether hidden files displayed....................|NERDTree-I| -f.......Toggle whether the file filters are used.................|NERDTree-f| -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-?| - ------------------------------------------------------------------------------- - *NERDTree-o* +2.3. NERD tree Mappings *NERDTreeMappings* + +Default~ +Key Description help-tag~ + +o........Open files, directories and bookmarks......................|NERDTree-o| +go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| +t........Open selected node/bookmark in a new tab...................|NERDTree-t| +T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| +i........Open selected file in a split window.......................|NERDTree-i| +gi.......Same as i, but leave the cursor on the NERDTree...........|NERDTree-gi| +s........Open selected file in a new vsplit.........................|NERDTree-s| +gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| +O........Recursively open the selected directory....................|NERDTree-O| +x........Close the current nodes parent.............................|NERDTree-x| +X........Recursively close all children of the current node.........|NERDTree-X| +e........Edit the current dir.......................................|NERDTree-e| + +............same as |NERDTree-o|. +double-click....same as |NERDTree-o|. +middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. + +D........Delete the current bookmark ...............................|NERDTree-D| + +P........Jump to the root node......................................|NERDTree-P| +p........Jump to current nodes parent...............................|NERDTree-p| +K........Jump up inside directories at the current tree depth.......|NERDTree-K| +J........Jump down inside directories at the current tree depth.....|NERDTree-J| +....Jump down to next sibling of the current directory.......|NERDTree-C-J| +....Jump up to previous sibling of the current directory.....|NERDTree-C-K| + +C........Change the tree root to the selected dir...................|NERDTree-C| +u........Move the tree root up one directory........................|NERDTree-u| +U........Same as 'u' except the old root node is left open..........|NERDTree-U| +r........Recursively refresh the current directory..................|NERDTree-r| +R........Recursively refresh the current root.......................|NERDTree-R| +m........Display the NERD tree menu.................................|NERDTree-m| +cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| +CD.......Change tree root to the CWD...............................|NERDTree-CD| + +I........Toggle whether hidden files displayed......................|NERDTree-I| +f........Toggle whether the file filters are used...................|NERDTree-f| +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-?| + +------------------------------------------------------------------------------ + *NERDTree-o* Default key: o -Map option: NERDTreeMapActivateNode +Map setting: NERDTreeMapActivateNode Applies to: files and directories. If a file node is selected, it is opened in the previous window. @@ -288,9 +287,9 @@ If a bookmark that links to a file is selected then that file is opened in the previous window. ------------------------------------------------------------------------------ - *NERDTree-go* + *NERDTree-go* Default key: go -Map option: NERDTreeMapPreview +Map setting: NERDTreeMapPreview Applies to: files. If a file node is selected, it is opened in the previous window, but the @@ -300,9 +299,9 @@ The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). ------------------------------------------------------------------------------ - *NERDTree-t* + *NERDTree-t* Default key: t -Map option: NERDTreeMapOpenInTab +Map setting: NERDTreeMapOpenInTab Applies to: files and directories. Opens the selected file in a new tab. If a directory is selected, a fresh @@ -313,26 +312,26 @@ that directory in a new tab. If the bookmark points to a file, open that file in a new tab. ------------------------------------------------------------------------------ - *NERDTree-T* + *NERDTree-T* Default key: T -Map option: NERDTreeMapOpenInTabSilent +Map setting: NERDTreeMapOpenInTabSilent Applies to: files and directories. The same as |NERDTree-t| except that the focus is kept in the current tab. ------------------------------------------------------------------------------ - *NERDTree-i* + *NERDTree-i* Default key: i -Map option: NERDTreeMapOpenSplit +Map setting: NERDTreeMapOpenSplit Applies to: files. Opens the selected file in a new split window and puts the cursor in the new window. ------------------------------------------------------------------------------ - *NERDTree-gi* + *NERDTree-gi* Default key: gi -Map option: NERDTreeMapPreviewSplit +Map setting: NERDTreeMapPreviewSplit Applies to: files. The same as |NERDTree-i| except that the cursor is not moved. @@ -341,18 +340,18 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see |NERDTree-i|). ------------------------------------------------------------------------------ - *NERDTree-s* + *NERDTree-s* Default key: s -Map option: NERDTreeMapOpenVSplit +Map setting: NERDTreeMapOpenVSplit Applies to: files. -Opens the selected file in a new vertically split window and puts the cursor in -the new window. +Opens the selected file in a new vertically split window and puts the cursor +in the new window. ------------------------------------------------------------------------------ - *NERDTree-gs* + *NERDTree-gs* Default key: gs -Map option: NERDTreeMapPreviewVSplit +Map setting: NERDTreeMapPreviewVSplit Applies to: files. The same as |NERDTree-s| except that the cursor is not moved. @@ -361,30 +360,30 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenVSplit (see |NERDTree-s|). ------------------------------------------------------------------------------ - *NERDTree-O* + *NERDTree-O* Default key: O -Map option: NERDTreeMapOpenRecursively +Map setting: NERDTreeMapOpenRecursively Applies to: directories. Recursively opens the selected directory. All files and directories are cached, but if a directory would not be -displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the -hidden file filter (see |'NERDTreeShowHidden'|) then its contents are not +displayed due to file filters (see |NERDTreeIgnore| |NERDTree-f|) or the +hidden file filter (see |NERDTreeShowHidden|) then its contents are not cached. This is handy, especially if you have .svn directories. ------------------------------------------------------------------------------ - *NERDTree-x* + *NERDTree-x* Default key: x -Map option: NERDTreeMapCloseDir +Map setting: NERDTreeMapCloseDir Applies to: files and directories. Closes the parent of the selected node. ------------------------------------------------------------------------------ - *NERDTree-X* + *NERDTree-X* Default key: X -Map option: NERDTreeMapCloseChildren +Map setting: NERDTreeMapCloseChildren Applies to: directories. Recursively closes all children of the selected directory. @@ -392,43 +391,43 @@ Recursively closes all children of the selected directory. Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. ------------------------------------------------------------------------------ - *NERDTree-e* + *NERDTree-e* Default key: e -Map option: NERDTreeMapOpenExpl +Map setting: NERDTreeMapOpenExpl Applies to: files and directories. |:edit|s the selected directory, or the selected file's directory. This could result in a NERD tree or a netrw being opened, depending on -|'NERDTreeHijackNetrw'|. +|NERDTreeHijackNetrw|. ------------------------------------------------------------------------------ - *NERDTree-D* + *NERDTree-D* Default key: D -Map option: NERDTreeMapDeleteBookmark +Map setting: NERDTreeMapDeleteBookmark Applies to: lines in the bookmarks table Deletes the currently selected bookmark. ------------------------------------------------------------------------------ - *NERDTree-P* + *NERDTree-P* Default key: P -Map option: NERDTreeMapJumpRoot +Map setting: NERDTreeMapJumpRoot Applies to: no restrictions. Jump to the tree root. ------------------------------------------------------------------------------ - *NERDTree-p* + *NERDTree-p* Default key: p -Map option: NERDTreeMapJumpParent +Map setting: NERDTreeMapJumpParent Applies to: files and directories. Jump to the parent node of the selected node. ------------------------------------------------------------------------------ - *NERDTree-K* + *NERDTree-K* Default key: K -Map option: NERDTreeMapJumpFirstChild +Map setting: NERDTreeMapJumpFirstChild Applies to: files and directories. Jump to the first child of the current nodes parent. @@ -439,9 +438,9 @@ If the cursor is already on the first node then do the following: * go to the first child of that node ------------------------------------------------------------------------------ - *NERDTree-J* + *NERDTree-J* Default key: J -Map option: NERDTreeMapJumpLastChild +Map setting: NERDTreeMapJumpLastChild Applies to: files and directories. Jump to the last child of the current nodes parent. @@ -452,50 +451,50 @@ If the cursor is already on the last node then do the following: * go to the last child of that node ------------------------------------------------------------------------------ - *NERDTree-C-J* + *NERDTree-C-J* Default key: -Map option: NERDTreeMapJumpNextSibling +Map setting: NERDTreeMapJumpNextSibling Applies to: files and directories. Jump to the next sibling of the selected node. ------------------------------------------------------------------------------ - *NERDTree-C-K* + *NERDTree-C-K* Default key: -Map option: NERDTreeMapJumpPrevSibling +Map setting: NERDTreeMapJumpPrevSibling Applies to: files and directories. Jump to the previous sibling of the selected node. ------------------------------------------------------------------------------ - *NERDTree-C* + *NERDTree-C* Default key: C -Map option: NERDTreeMapChangeRoot +Map setting: NERDTreeMapChangeRoot Applies to: files and directories. Make the selected directory node the new tree root. If a file is selected, its parent is used. ------------------------------------------------------------------------------ - *NERDTree-u* + *NERDTree-u* Default key: u -Map option: NERDTreeMapUpdir +Map setting: NERDTreeMapUpdir Applies to: no restrictions. Move the tree root up a dir (like doing a "cd .."). ------------------------------------------------------------------------------ - *NERDTree-U* + *NERDTree-U* Default key: U -Map option: NERDTreeMapUpdirKeepOpen +Map setting: NERDTreeMapUpdirKeepOpen Applies to: no restrictions. Like |NERDTree-u| except that the old tree root is kept open. ------------------------------------------------------------------------------ - *NERDTree-r* + *NERDTree-r* Default key: r -Map option: NERDTreeMapRefresh +Map setting: NERDTreeMapRefresh Applies to: files and directories. If a dir is selected, recursively refresh that dir, i.e. scan the filesystem @@ -504,95 +503,95 @@ for changes and represent them in the tree. If a file node is selected then the above is done on it's parent. ------------------------------------------------------------------------------ - *NERDTree-R* + *NERDTree-R* Default key: R -Map option: NERDTreeMapRefreshRoot +Map setting: NERDTreeMapRefreshRoot Applies to: no restrictions. Recursively refresh the tree root. ------------------------------------------------------------------------------ - *NERDTree-m* + *NERDTree-m* Default key: m -Map option: NERDTreeMapMenu +Map setting: NERDTreeMapMenu Applies to: files and directories. Display the NERD tree menu. See |NERDTreeMenu| for details. ------------------------------------------------------------------------------ - *NERDTree-cd* + *NERDTree-cd* Default key: cd -Map option: NERDTreeMapChdir +Map setting: NERDTreeMapChdir Applies to: files and directories. Change Vim's current working directory to that of the selected node. ------------------------------------------------------------------------------ - *NERDTree-CD* + *NERDTree-CD* Default key: CD -Map option: NERDTreeMapCWD +Map setting: NERDTreeMapCWD Applies to: no restrictions. Change the NERDTree root to Vim's current working directory. ------------------------------------------------------------------------------ - *NERDTree-I* + *NERDTree-I* Default key: I -Map option: NERDTreeMapToggleHidden +Map setting: NERDTreeMapToggleHidden Applies to: no restrictions. Toggles whether hidden files (i.e. "dot files") are displayed. ------------------------------------------------------------------------------ - *NERDTree-f* + *NERDTree-f* Default key: f -Map option: NERDTreeMapToggleFilters +Map setting: NERDTreeMapToggleFilters Applies to: no restrictions. -Toggles whether file filters are used. See |'NERDTreeIgnore'| for details. +Toggles whether file filters are used. See |NERDTreeIgnore| for details. ------------------------------------------------------------------------------ - *NERDTree-F* + *NERDTree-F* Default key: F -Map option: NERDTreeMapToggleFiles +Map setting: NERDTreeMapToggleFiles Applies to: no restrictions. Toggles whether file nodes are displayed. ------------------------------------------------------------------------------ - *NERDTree-B* + *NERDTree-B* Default key: B -Map option: NERDTreeMapToggleBookmarks +Map setting: NERDTreeMapToggleBookmarks Applies to: no restrictions. Toggles whether the bookmarks table is displayed. ------------------------------------------------------------------------------ - *NERDTree-q* + *NERDTree-q* Default key: q -Map option: NERDTreeMapQuit +Map setting: NERDTreeMapQuit Applies to: no restrictions. Closes the NERDtree window. ------------------------------------------------------------------------------ - *NERDTree-A* + *NERDTree-A* Default key: A -Map option: NERDTreeMapToggleZoom +Map setting: NERDTreeMapToggleZoom Applies to: no restrictions. Maximize (zoom) and minimize the NERDtree window. ------------------------------------------------------------------------------ - *NERDTree-?* + *NERDTree-?* Default key: ? -Map option: NERDTreeMapHelp +Map setting: NERDTreeMapHelp Applies to: no restrictions. Toggles whether the quickhelp is displayed. ------------------------------------------------------------------------------ -2.3. The NERD tree menu *NERDTreeMenu* +2.3. The NERD tree menu *NERDTreeMenu* The NERD tree has a menu that can be programmed via the an API (see |NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most @@ -622,126 +621,131 @@ Applies to: The NERD tree menu. Moves the cursor up. ============================================================================== -3. Customisation *NERDTreeOptions* +3. Customisation *NERDTreeSettings* ------------------------------------------------------------------------------ -3.1. Customisation summary *NERDTreeOptionSummary* +3.1. Customisation summary *NERDTreeSettingsSummary* + +The plugin provides the following settings that can customise the behaviour +the NERD tree. These settings should be set in your vimrc, using `:let`. -The script provides the following options that can customise the behaviour the -NERD tree. These options should be set in your vimrc. +|loaded_nerd_tree| Turns off the script. -|'loaded_nerd_tree'| Turns off the script. +|NERDTreeAutoCenter| Controls whether the NERD tree window centers + when the cursor moves within a specified + distance to the top/bottom of the window. -|'NERDTreeAutoCenter'| Controls whether the NERD tree window centers - when the cursor moves within a specified - distance to the top/bottom of the window. +|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. -|'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering. +|NERDTreeCaseSensitiveSort| Tells the NERD tree whether to be case + sensitive or not when sorting nodes. -|'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case - sensitive or not when sorting nodes. +|NERDTreeNaturalSort| Tells the NERD tree whether to use natural sort + order or not when sorting nodes. -|'NERDTreeNaturalSort'| Tells the NERD tree whether to use - natural sort order or not when sorting nodes. +|NERDTreeSortHiddenFirst| Tells the NERD tree whether to take the dot at + the beginning of the hidden file names into + account when sorting nodes. -|'NERDTreeSortHiddenFirst'| Tells the NERD tree whether to take the dot - at the beginning of the hidden file names - into account when sorting nodes. +|NERDTreeChDirMode| Tells the NERD tree if/when it should change + vim's current working directory. -|'NERDTreeChDirMode'| Tells the NERD tree if/when it should change - vim's current working directory. +|NERDTreeHighlightCursorline| Tell the NERD tree whether to highlight the + current cursor line. -|'NERDTreeHighlightCursorline'| Tell the NERD tree whether to highlight the - current cursor line. +|NERDTreeHijackNetrw| Tell the NERD tree whether to replace the netrw + autocommands for exploring local directories. -|'NERDTreeHijackNetrw'| Tell the NERD tree whether to replace the netrw - autocommands for exploring local directories. +|NERDTreeIgnore| Tells the NERD tree which files to ignore. -|'NERDTreeIgnore'| Tells the NERD tree which files to ignore. +|NERDTreeRespectWildIgnore| Tells the NERD tree to respect `'wildignore'`. -|'NERDTreeRespectWildIgnore'| Tells the NERD tree to respect |'wildignore'|. +|NERDTreeBookmarksFile| Where the bookmarks are stored. -|'NERDTreeBookmarksFile'| Where the bookmarks are stored. +|NERDTreeBookmarksSort| Control how the Bookmark table is sorted. -|'NERDTreeBookmarksSort'| Control how the Bookmark table is sorted. +|NERDTreeMarkBookmarks| Render bookmarked nodes with markers. -|'NERDTreeMarkBookmarks'| Render bookmarked nodes with markers. +|NERDTreeMouseMode| Manage the interpretation of mouse clicks. -|'NERDTreeMouseMode'| Manage the interpretation of mouse clicks. +|NERDTreeQuitOnOpen| Closes the tree window after opening a file. -|'NERDTreeQuitOnOpen'| Closes the tree window after opening a file. +|NERDTreeShowBookmarks| Tells the NERD tree whether to display the + bookmarks table on startup. -|'NERDTreeShowBookmarks'| Tells the NERD tree whether to display the - bookmarks table on startup. +|NERDTreeShowFiles| Tells the NERD tree whether to display files in + the tree on startup. -|'NERDTreeShowFiles'| Tells the NERD tree whether to display files - in the tree on startup. +|NERDTreeShowHidden| Tells the NERD tree whether to display hidden + files on startup. -|'NERDTreeShowHidden'| Tells the NERD tree whether to display hidden - files on startup. +|NERDTreeShowLineNumbers| Tells the NERD tree whether to display line + numbers in the tree window. -|'NERDTreeShowLineNumbers'| Tells the NERD tree whether to display line - numbers in the tree window. +|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in the + tree. -|'NERDTreeSortOrder'| Tell the NERD tree how to sort the nodes in - the tree. +|NERDTreeStatusline| Set a statusline for NERD tree windows. -|'NERDTreeStatusline'| Set a statusline for NERD tree windows. +|NERDTreeWinPos| Tells the script where to put the NERD tree + window. -|'NERDTreeWinPos'| Tells the script where to put the NERD tree - window. +|NERDTreeWinSize| Sets the window size when the NERD tree is + opened. -|'NERDTreeWinSize'| Sets the window size when the NERD tree is - opened. +|NERDTreeMinimalUI| Disables display of the 'Bookmarks' label and + 'Press ? for help' text. -|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and - 'Press ? for help' text. +|NERDTreeCascadeSingleChildDir| + Collapses on the same line directories that have + only one child directory. -|'NERDTreeCascadeSingleChildDir'| - Collapses on the same line directories that - have only one child directory. +|NERDTreeCascadeOpenSingleChildDir| + Cascade open while selected directory has only + one child that also is a directory. -|'NERDTreeCascadeOpenSingleChildDir'| - Cascade open while selected directory has only - one child that also is a directory. +|NERDTreeAutoDeleteBuffer| Tells the NERD tree to automatically remove a + buffer when a file is being deleted or renamed + via a context menu command. -|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove - a buffer when a file is being deleted or renamed - via a context menu command. +|NERDTreeCreatePrefix| Specify a prefix to be used when creating the + NERDTree window. -|'NERDTreeCreatePrefix'| Specify a prefix to be used when creating the - NERDTree window. +|NERDTreeRemoveFileCmd| Specify a custom shell command to be used when + deleting files. Note that it should include one + space character at the end of the command and it + applies only to files. -|'NERDTreeRemoveFileCmd'| Specify a custom shell command to be used when - deleting files. Note that it should include - one space character at the end of the command - and it applies only to files. +|NERDTreeRemoveDirCmd| Specify a custom shell command to be used when + deleting directories. Note that it should + include one space character at the end of the + command and it applies only to directories. -|'NERDTreeRemoveDirCmd'| Specify a custom shell command to be used when - deleting directories. Note that it should - include one space character at the end of the - command and it applies only to directories. +|NERDTreeNodeDelimiter| A single character that is used to separate the + file or directory name from the rest of the + characters on the line of text. ------------------------------------------------------------------------------ -3.2. Customisation details *NERDTreeOptionDetails* +3.2. Customisation details *NERDTreeSettingsDetails* -To enable any of the below options you should put the given line in your -~/.vimrc +To enable any of the below settings you should put an appropriate > + let = + let loaded_nerd_tree=1 < ------------------------------------------------------------------------------ - *'NERDTreeAutoCenter'* + *NERDTreeAutoCenter* Values: 0 or 1. Default: 1 If set to 1, the NERD tree window will center around the cursor if it moves to -within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window. +within |NERDTreeAutoCenterThreshold| lines of the top/bottom of the window. This is ONLY done in response to tree navigation mappings, i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p| @@ -750,15 +754,15 @@ i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p| The centering is done with a |zz| operation. ------------------------------------------------------------------------------ - *'NERDTreeAutoCenterThreshold'* + *NERDTreeAutoCenterThreshold* Values: Any natural number. Default: 3 -This option controls the "sensitivity" of the NERD tree auto centering. See -|'NERDTreeAutoCenter'| for details. +This setting controls the "sensitivity" of the NERD tree auto centering. See +|NERDTreeAutoCenter| for details. ------------------------------------------------------------------------------ - *'NERDTreeCaseSensitiveSort'* + *NERDTreeCaseSensitiveSort* Values: 0 or 1. Default: 0. @@ -770,8 +774,8 @@ could appear like this: > boner.c Foo.c < -But, if you set this option to 1 then the case of the nodes will be taken into -account. The above nodes would then be sorted like this: > +But, if you set this setting to 1 then the case of the nodes will be taken +into account. The above nodes would then be sorted like this: > Baz.c Foo.c bar.c @@ -779,7 +783,7 @@ account. The above nodes would then be sorted like this: > boner.c < ------------------------------------------------------------------------------ - *'NERDTreeNaturalSort'* + *NERDTreeNaturalSort* Values: 0 or 1. Default: 0. @@ -794,7 +798,7 @@ could appear like this: > z20.txt z3.txt < -But if you set this option to 1 then the natural sort order will be used. The +But if you set this setting to 1 then the natural sort order will be used. The above nodes would then be sorted like this: > z1.txt z2.txt @@ -806,12 +810,12 @@ above nodes would then be sorted like this: > z110.txt < ------------------------------------------------------------------------------ - *'NERDTreeChDirMode'* + *NERDTreeChDirMode* Values: 0, 1 or 2. Default: 0. -Use this option to tell the script when (if at all) to change the current +Use this setting to tell the script when (if at all) to change the current working directory (CWD) for vim. If it is set to 0 then the CWD is never changed by the NERD tree. @@ -823,21 +827,21 @@ directory it is initialized in. For example, if you start the NERD tree with > then the CWD will be changed to /home/marty/foobar and will not be changed again unless you init another NERD tree with a similar command. -If the option is set to 2 then it behaves the same as if set to 1 except that +If the setting is set to 2 then it behaves the same as if set to 1 except that the CWD is changed whenever the tree root is changed. For example, if the CWD is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new root then the CWD will become /home/marty/foobar/baz. ------------------------------------------------------------------------------ - *'NERDTreeHighlightCursorline'* + *NERDTreeHighlightCursorline* Values: 0 or 1. Default: 1. If set to 1, the current cursor line in the NERD tree buffer will be -highlighted. This is done using the |'cursorline'| option. +highlighted. This is done using the `'cursorline'` Vim option. ------------------------------------------------------------------------------ - *'NERDTreeHijackNetrw'* + *NERDTreeHijackNetrw* Values: 0 or 1. Default: 1. @@ -853,13 +857,13 @@ following respects: 2. you can have one tree per window - instead of per tab. ------------------------------------------------------------------------------ - *'NERDTreeIgnore'* + *NERDTreeIgnore* Values: a list of regular expressions. Default: ['\~$']. -This option is used to specify which files the NERD tree should ignore. It +This setting is used to specify which files the NERD tree should ignore. It must be a list of regular expressions. When the NERD tree is rendered, any -files/dirs that match any of the regex's in 'NERDTreeIgnore' wont be +files/dirs that match any of the regex's in NERDTreeIgnore won't be displayed. For example if you put the following line in your vimrc: > @@ -884,25 +888,25 @@ The file filters can be turned on and off dynamically with the |NERDTree-f| mapping. ------------------------------------------------------------------------------ - *'NERDTreeRespectWildIgnore'* + *NERDTreeRespectWildIgnore* Values: 0 or 1. Default: 0. -If set to 1, the |'wildignore'| setting is respected. +If set to 1, the `'wildignore'` setting is respected. ------------------------------------------------------------------------------ - *'NERDTreeBookmarksFile'* + *NERDTreeBookmarksFile* Values: a path Default: $HOME/.NERDTreeBookmarks This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. ------------------------------------------------------------------------------ - *'NERDTreeBookmarksSort'* + *NERDTreeBookmarksSort* Values: 0, 1, or 2 Default: 1 -This option controls the method by which the list of user bookmarks is +This setting controls the method by which the list of user bookmarks is sorted. When sorted, bookmarks will render in alphabetical order by name. If set to 0, the bookmarks list is not sorted. @@ -910,16 +914,16 @@ If set to 1, the bookmarks list is sorted in a case-insensitive manner. If set to 2, the bookmarks list is sorted in a case-sensitive manner. ------------------------------------------------------------------------------ - *'NERDTreeMarkBookmarks'* + *NERDTreeMarkBookmarks* Values: 0 or 1 Default: 1 If set to 1, Bookmarks will be specially marked whenever the NERDTree is -rendered. Users of the |'NERDTreeMinimalUI'| setting may prefer to disable +rendered. Users of the |NERDTreeMinimalUI| setting may prefer to disable this setting for even less visual clutter. ------------------------------------------------------------------------------ - *'NERDTreeMouseMode'* + *NERDTreeMouseMode* Values: 1, 2 or 3. Default: 1. @@ -937,7 +941,7 @@ then (to single click activate it) you must click somewhere in 'application.rb'. ------------------------------------------------------------------------------ - *'NERDTreeQuitOnOpen'* + *NERDTreeQuitOnOpen* Values: 0 or 1. Default: 0 @@ -946,67 +950,67 @@ If set to 1, the NERD tree window will close after opening a file with the |NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings. ------------------------------------------------------------------------------ - *'NERDTreeShowBookmarks'* + *NERDTreeShowBookmarks* Values: 0 or 1. Default: 0. -If this option is set to 1 then the bookmarks table will be displayed. +If this setting is set to 1 then the bookmarks table will be displayed. -This option can be toggled dynamically, per tree, with the |NERDTree-B| +This setting can be toggled dynamically, per tree, with the |NERDTree-B| mapping. ------------------------------------------------------------------------------ - *'NERDTreeShowFiles'* + *NERDTreeShowFiles* Values: 0 or 1. Default: 1. -If this option is set to 1 then files are displayed in the NERD tree. If it is -set to 0 then only directories are displayed. +If this setting is set to 1 then files are displayed in the NERD tree. If it +is set to 0 then only directories are displayed. -This option can be toggled dynamically, per tree, with the |NERDTree-F| +This setting can be toggled dynamically, per tree, with the |NERDTree-F| mapping and is useful for drastically shrinking the tree when you are navigating to a different part of the tree. ------------------------------------------------------------------------------ - *'NERDTreeShowHidden'* + *NERDTreeShowHidden* Values: 0 or 1. Default: 0. -This option tells vim whether to display hidden files by default. This option -can be dynamically toggled, per tree, with the |NERDTree-I| mapping. Use one -of the follow lines to set this option: > +This setting tells vim whether to display hidden files by default. This +setting can be dynamically toggled, per tree, with the |NERDTree-I| mapping. +Use one of the follow lines for this setting: > let NERDTreeShowHidden=0 let NERDTreeShowHidden=1 < ------------------------------------------------------------------------------ - *'NERDTreeShowLineNumbers'* + *NERDTreeShowLineNumbers* Values: 0 or 1. Default: 0. -This option tells vim whether to display line numbers for the NERD tree -window. Use one of the follow lines to set this option: > +This setting tells vim whether to display line numbers for the NERD tree +window. Use one of the follow lines for this setting: > let NERDTreeShowLineNumbers=0 let NERDTreeShowLineNumbers=1 < ------------------------------------------------------------------------------ - *'NERDTreeSortOrder'* + *NERDTreeSortOrder* Values: a list of regular expressions. Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -This option is set to a list of regular expressions which are used to -specify the order of nodes under their parent. +This setting is a list of regular expressions which are used to specify the +order of nodes under their parent. -For example, if the option is set to: > +For example, if the setting is: > ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] < then all .vim files will be placed at the top, followed by all .c files then all .h files. All files containing the string 'foobar' will be placed at the end. The star is a special flag: it tells the script that every node that -doesnt match any of the other regexps should be placed here. +doesn't match any of the other regexps should be placed here. -If no star is present in 'NERDTreeSortOrder' then one is automatically +If no star is present in NERDTreeSortOrder then one is automatically appended to the array. The regex '\/$' should be used to match directory nodes. @@ -1020,7 +1024,7 @@ done secondarily. See examples 4, 5, and 6 below. After this sorting is done, the files in each group are sorted alphabetically. -Other examples: > +Examples: > (1) ['*', '\/$'] (2) [] (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] @@ -1040,100 +1044,123 @@ Other examples: > Each group is shown newest to oldest. ------------------------------------------------------------------------------ - *'NERDTreeStatusline'* -Values: Any valid |'statusline'| setting. + *NERDTreeStatusline* +Values: Any valid `'statusline'` setting. Default: %{exists('b:NERDTree')?b:NERDTree.root.path.str():''} -Defines the value for the |'statusline'| setting in NERDTree windows. +Defines the value for the `'statusline'` setting in NERDTree windows. Note: The setting is actually applied using |:let-&|, not |:set|, so escaping spaces is not necessary. -Setting this option to -1 will deactivate it so that your global -|'statusline'| setting is used. +Setting this to -1 will deactivate it so that your global `'statusline'` +setting is used. ------------------------------------------------------------------------------ - *'NERDTreeWinPos'* + *NERDTreeWinPos* Values: "left" or "right" Default: "left". -This option is used to determine where NERD tree window is placed on the +This setting is used to determine where NERD tree window is placed on the screen. -This option makes it possible to use two different explorer plugins +This setting makes it possible to use two different explorer plugins simultaneously. For example, you could have the taglist plugin on the left of the window and the NERD tree on the right. ------------------------------------------------------------------------------ - *'NERDTreeWinSize'* + *NERDTreeWinSize* Values: a positive integer. Default: 31. -This option is used to change the size of the NERD tree when it is loaded. +This setting is used to change the size of the NERD tree when it is loaded. ------------------------------------------------------------------------------ - *'NERDTreeMinimalUI'* + *NERDTreeMinimalUI* Values: 0 or 1 Default: 0 -This options disables the 'Bookmarks' label 'Press ? for help' text. Use one -of the following lines to set this option: > +This setting disables the 'Bookmarks' label 'Press ? for help' text. Use one +of the following lines for this setting: > let NERDTreeMinimalUI=0 let NERDTreeMinimalUI=1 < ------------------------------------------------------------------------------ - *'NERDTreeCascadeSingleChildDir'* + *NERDTreeCascadeSingleChildDir* Values: 0 or 1 Default: 1. -When displaying dir nodes, this option tells NERDTree to collapse dirs that -have only one child. Use one of the follow lines to set this option: > +When displaying dir nodes, this setting tells NERDTree to collapse dirs that +have only one child. Use one of the following lines for this setting: > let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=1 < ------------------------------------------------------------------------------ - *'NERDTreeCascadeOpenSingleChildDir'* + *NERDTreeCascadeOpenSingleChildDir* Values: 0 or 1 Default: 1. -When opening dir nodes, this option tells NERDTree to recursively open dirs +When opening dir nodes, this setting tells NERDTree to recursively open dirs that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. This option also causes -the |NERDTree-x| mapping to close dirs in the same manner. This option may be -useful for Java projects. Use one of the follow lines to set this option: > +a dir that contains anything but another single dir. This setting also causes +the |NERDTree-x| mapping to close dirs in the same manner. This setting may be +useful for Java projects. Use one of the following lines for this setting: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < ------------------------------------------------------------------------------ - *'NERDTreeAutoDeleteBuffer'* + *NERDTreeAutoDeleteBuffer* Values: 0 or 1 Default: 0. -When using a context menu to delete or rename a file you may also want to delete -the buffer which is no more valid. If the option is not set you will see a -confirmation if you really want to delete an old buffer. If you always press 'y' -then it worths to set this option to 1. Use one of the follow lines to set this -option: > +When using a context menu to delete or rename a file you may also want to +delete the buffer which is no more valid. If the setting is not set you will +see a confirmation if you really want to delete an old buffer. If you always +press 'y' then it's worth it to set this setting to 1. Use one of the +following lines for this setting: > let NERDTreeAutoDeleteBuffer=0 let NERDTreeAutoDeleteBuffer=1 < ------------------------------------------------------------------------------ - *'NERDTreeCreatePrefix'* + *NERDTreeCreatePrefix* Values: Any valid command prefix. Default: "silent". Internally, NERDTree uses the |:edit| command to create a buffer in which to display its tree view. You can augment this behavior by specifying a prefix string such as "keepalt" or similar. For example, to have NERDTree create its -tree window using `silent keepalt keepjumps edit`: +tree window using `silent keepalt keepjumps edit`: > let NERDTreeCreatePrefix='silent keepalt keepjumps' < +------------------------------------------------------------------------------ + *NERDTreeNodeDelimiter* +Values: Any single character. +Default: "\x07" - the non-printable character BELL. + +This character is used to separate the file or directory name from the rest of +the characters in the line of text. It allows filenames to contain special +characters that are otherwise used in the NERDTree, such as square brackets, +braces, trailing asterisk, and leading space. For more details, see the +resoponsible pull request: https://github.com/scrooloose/nerdtree/pull/868. + +The default should work in nearly every situation, but this setting exists for +those very rare cases where it doesn't. "\x07" was chosen because it's +non-printable, and very unlikely to be used purposefully in a filename or as a +flag by other NERDTree plugins. If you need to change the delimiter, be sure +to choose a character that won't appear in your filenames or any of the flags +set by your installed NERDTree plugins. The suggestions below are but a few of +the many possibilities. Remember to use double quotes when specifying by hex +or Unicode. > + let NERDTreeNodeDelimiter='😀' + let NERDTreeNodeDelimiter="\u00a0" + let NERDTreeNodeDelimiter="\xFF" +< ============================================================================== -4. The NERD tree API *NERDTreeAPI* +4. The NERD tree API *NERDTreeAPI* The NERD tree script allows you to add custom key mappings and menu items via a set of API calls. Any scripts that use this API should be placed in @@ -1156,9 +1183,9 @@ See this blog post for more details: http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html ------------------------------------------------------------------------------ -4.1. Key map API *NERDTreeKeymapAPI* +4.1. Key map API *NERDTreeKeymapAPI* -NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* +NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* Adds a new keymapping for all NERD tree buffers. {options} must be a dictionary, and must contain the following keys: "key" - the trigger key for the new mapping @@ -1198,7 +1225,7 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* ------------------------------------------------------------------------------ 4.2. Menu API *NERDTreeMenuAPI* -NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* +NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* Creates and returns a new submenu. {options} must be a dictionary and must contain the following keys: @@ -1207,15 +1234,15 @@ NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* The following keys are optional: "isActiveCallback" - a function that will be called to determine whether - this submenu item will be displayed or not. The callback function must return - 0 or 1. + this submenu item will be displayed or not. The callback function must + return 0 or 1. "parent" - the parent submenu of the new submenu (returned from a previous invocation of NERDTreeAddSubmenu()). If this key is left out then the new submenu will sit under the top level menu. See below for an example. -NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* +NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|). {options} must be a dictionary and must contain the @@ -1235,7 +1262,7 @@ NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* See below for an example. -NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()* +NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()* Adds a menu separator (a row of dashes). {options} is an optional dictionary that may contain the following keys: @@ -1278,7 +1305,7 @@ When any of the 3 concrete menu items are selected the function "SomeFunction" will be called. ------------------------------------------------------------------------------ -4.3 NERDTreeAddPathFilter(callback) *NERDTreeAddPathFilter()* +4.3 NERDTreeAddPathFilter(callback) *NERDTreeAddPathFilter()* Path filters are essentially a more powerful version of |NERDTreeIgnore|. If the simple regex matching in |NERDTreeIgnore| is not enough then use @@ -1295,7 +1322,7 @@ checked against when the decision to ignore them is made. Example > endfunction < ------------------------------------------------------------------------------ -4.4 Path Listener API *NERDTreePathListenerAPI* +4.4 Path Listener API *NERDTreePathListenerAPI* Use this API if you want to run a callback for events on Path objects. E.G > @@ -1307,7 +1334,7 @@ Use this API if you want to run a callback for events on Path objects. E.G > "This function will be called whenever a Path object is created. "a:event is an object that contains a bunch of relevant info - - "including the path in question. See lib/nerdtree/event.vim for details. + "including the affected path. See lib/nerdtree/event.vim for details. endfunction < Current events supported: @@ -1316,29 +1343,40 @@ Current events supported: refreshFlags ~ ------------------------------------------------------------------------------ -NERDTreeRender() *NERDTreeRender()* +NERDTreeRender() *NERDTreeRender()* Re-renders the NERD tree buffer. Useful if you change the state of the tree and you want to it to be reflected in the UI. ============================================================================== -5. About *NERDTreeAbout* +5. About *NERDTreeAbout* The author of the NERD tree is a terrible terrible monster called Martyzilla who gobbles up small children with milk and sugar for breakfast. He can be reached at martin.grenfell at gmail dot com. He would love to hear from you, so feel free to send him suggestions and/or comments about this -plugin. Don't be shy --- the worst he can do is slaughter you and stuff you in -the fridge for later ;) +plugin. Don't be shy --- the worst he can do is slaughter you and stuff you +in the fridge for later ;) + +Martyzilla recruited two other unwitting accomplices to become his minions in +his quest to conquer the Vim plugin world. While he may still love to receive +your emails, the best way to send suggestions, bug reports, and questions is +to submit an issue at http://github.com/scrooloose/nerdtree/issues. -The latest stable versions can be found at - http://www.vim.org/scripts/script.php?script_id=1658 +The latest stable and development versions are on Github. + Stable: http://github.com/scrooloose/nerdtree (master branch) + Development: http://github.com/scrooloose/nerdtree/branches -The latest dev versions are on github - http://github.com/scrooloose/nerdtree +Title Credit: + Patrick Gillespie's Text ASCII Art Generator + http://patorjk.com/software/taag + http://patorjk.com/software/taag/#p=display&f=Rozzo&t=NERDTree ============================================================================== -6. License *NERDTreeLicense* +6. License *NERDTreeLicense* The NERD tree is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. + +------------------------------------------------------------------------------ + vim:tw=78:ts=8:ft=help:noet diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 57a65a1b..c3de3f21 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -86,8 +86,8 @@ let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") -" ASCII 160: non-breaking space used to delimit items in the tree's nodes. -call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") +" ASCII 7: bell non-printing character used to delimit items in the tree's nodes. +call s:initVariable("g:NERDTreeNodeDelimiter", "\x07") if !exists('g:NERDTreeStatusline') diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 24e78dbf..99773bf1 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -38,10 +38,10 @@ syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir "highlighing to conceal the delimiter around the file/dir name if has("conceal") - exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=ALL' + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' setlocal conceallevel=3 concealcursor=nvic else - exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=ALL' + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore endif From 743b849dcf7e0571831edbaaa73b5ef1b5cb11ac Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 6 Dec 2018 15:07:13 -0500 Subject: [PATCH 472/680] Add a happy little tree to the "cover" of the help document. --- doc/NERDTree.txt | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 0a3ae60c..74e18277 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1,20 +1,22 @@ *NERDTree.txt* A tree explorer plugin to rule the Vim world. Bwahahaha!! - Are you ready for this? It's the... - - - Y88b Y88 888'Y88 888 88e 888 88e 88P'888'Y88 ~ - Y88b Y8 888 ,'Y 888 888D 888 888b P' 888 'Y 888,8, ,e e, ,e e, ~ - b Y88b Y 888C8 888 88" 888 8888D 888 888 " d88 88b d88 88b ~ - 8b Y88b 888 ",d 888 b, 888 888P 888 888 888 , 888 , ~ - 88b Y88b 888,d88 888 88b, 888 88" 888 888 "YeeP" "YeeP" ~ - ~ - Reference Manual ~ - - + # #### #### Y88b Y88 888'Y88 888 88e 888 88e ~ + ### \/#|### |/#### Y88b Y8 888 ,'Y 888 888D 888 888b ~ + ##\/#/ \||/##/_/##/_# b Y88b Y 888C8 888 88" 888 8888D 888 ~ + ### \/###|/ \/ # ### 8b Y88b 888 ",d 888 b, 888 888P ~ + ##_\_#\_\## | #/###_/_#### 88b Y88b 888,d88 888 88b, 888 88" ~ + ## #### # \ #| / #### ##/## ~ + __#_--###` |{,###---###-~ 88P'888'Y88 ~ + \ }{ P' 888 'Y 888,8, ,e e, ,e e, ~ + }}{ 888 888 " d88 88b d88 88b ~ + }}{ 888 888 888 , 888 , ~ + ejm {{} 888 888 "YeeP" "YeeP" ~ + , -=-~{ .-^- _ ~ + `} Reference Manual ~ + { ~ ============================================================================== CONTENTS *NERDTree-contents* @@ -1368,7 +1370,9 @@ The latest stable and development versions are on Github. Development: http://github.com/scrooloose/nerdtree/branches Title Credit: - Patrick Gillespie's Text ASCII Art Generator + * http://ascii.co.uk/art/tree + + * Patrick Gillespie's Text ASCII Art Generator http://patorjk.com/software/taag http://patorjk.com/software/taag/#p=display&f=Rozzo&t=NERDTree @@ -1379,4 +1383,4 @@ The NERD tree is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. ------------------------------------------------------------------------------ - vim:tw=78:ts=8:ft=help:noet + vim:tw=78:ts=8:ft=help:noet:nospell From c1876da09c38315d7fdea33d9082d1868b5fbd2b Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 6 Dec 2018 19:29:25 -0500 Subject: [PATCH 473/680] Change things up with the artwork on the "cover" of the help doc. --- doc/NERDTree.txt | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 74e18277..48b56b41 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1,23 +1,21 @@ *NERDTree.txt* A tree explorer plugin to rule the Vim world. Bwahahaha!! - - Are you ready for this? It's the... - - # #### #### Y88b Y88 888'Y88 888 88e 888 88e ~ - ### \/#|### |/#### Y88b Y8 888 ,'Y 888 888D 888 888b ~ - ##\/#/ \||/##/_/##/_# b Y88b Y 888C8 888 88" 888 8888D 888 ~ - ### \/###|/ \/ # ### 8b Y88b 888 ",d 888 b, 888 888P ~ - ##_\_#\_\## | #/###_/_#### 88b Y88b 888,d88 888 88b, 888 88" ~ - ## #### # \ #| / #### ##/## ~ - __#_--###` |{,###---###-~ 88P'888'Y88 ~ - \ }{ P' 888 'Y 888,8, ,e e, ,e e, ~ - }}{ 888 888 " d88 88b d88 88b ~ - }}{ 888 888 888 , 888 , ~ - ejm {{} 888 888 "YeeP" "YeeP" ~ - , -=-~{ .-^- _ ~ - `} Reference Manual ~ - { ~ - + # #### #### ~ + ### \/#|### |/#### ~ + d8 888 ##\/#/ \||/##/_/##/_# ~ + d88 888 ee ,e e, ### \/###|/ \/ # ### ~ + d88888 888 88b d88 88b ##_\_#\_\## | #/###_/_#### ~ + 888 888 888 888 , ## #### # \ #| / #### ##/## ~ + 888 888 888 "YeeP" __#_--###`. |{,###---###-~ ~ + \ % @% ~ + Y88b Y88 888'Y88 888 88e 888 88e \%@% 88P'888'Y88 ~ + Y88b Y8 888 ,'Y 888 888D 888 888b %o% P' 888 'Y 888,8, ,e e, ,e e, ~ + b Y88b Y 888C8 888 88" 888 8888D %@% 888 888 " d88 88b d88 88b ~ + 8b Y88b 888 ",d 888 b, 888 888P %@% 888 888 888 , 888 , ~ + 88b Y88b 888,d88 888 88b, 888 88" %@% 888 888 "YeeP" "YeeP" ~ + , -=-%{@%-^- _ ~ + ejm `} Reference Manual ~ + { ~ ============================================================================== CONTENTS *NERDTree-contents* @@ -574,7 +572,7 @@ Default key: q Map setting: NERDTreeMapQuit Applies to: no restrictions. -Closes the NERDtree window. +Closes the NERDTree window. ------------------------------------------------------------------------------ *NERDTree-A* @@ -582,7 +580,7 @@ Default key: A Map setting: NERDTreeMapToggleZoom Applies to: no restrictions. -Maximize (zoom) and minimize the NERDtree window. +Maximize (zoom) and minimize the NERDTree window. ------------------------------------------------------------------------------ *NERDTree-?* @@ -1374,7 +1372,7 @@ Title Credit: * Patrick Gillespie's Text ASCII Art Generator http://patorjk.com/software/taag - http://patorjk.com/software/taag/#p=display&f=Rozzo&t=NERDTree + http://patorjk.com/software/taag/#p=display&f=Rozzo&t=the%20NERD%20Tree ============================================================================== 6. License *NERDTreeLicense* From a4dd4e1dce1645a018f07d1bc30ee7d38303fb20 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 11 Dec 2018 22:44:55 -0500 Subject: [PATCH 474/680] Restore getDirChildren for use in nerdtree-project-plugin. (#929) This function was added to support a separate plugin: https://github.com/scrooloose/nerdtree-project-plugin.git. It was subsequently removed without recognizing its contribution to the external plugin. This commit restores that function so NERDTree projects will work. --- lib/nerdtree/tree_dir_node.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index dd818a56..658ff09e 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -254,6 +254,13 @@ function! s:TreeDirNode.getChildIndex(path) return -1 endfunction +" FUNCTION: TreeDirNode.getDirChildren() {{{1 +" Return a list of all child nodes from "self.children" that are of type +" TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. +function! s:TreeDirNode.getDirChildren() + return filter(copy(self.children), 'v:val.path.isDirectory == 1') +endfunction + " FUNCTION: TreeDirNode._glob(pattern, all) {{{1 " Return a list of strings naming the descendants of the directory in this " TreeDirNode object that match the specified glob pattern. From 72c3656799289d4635520c28e17f737066ce19d6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 12 Dec 2018 13:30:13 -0500 Subject: [PATCH 475/680] Add new command to open NERDTree in the root of a VCS repository. (#872) * Add new command to open NERDTree in the root of a VCS repository. * Add another example to the help file. * Refactor and make NERDTreeVCS work on Windows. * Don't crash when NERDTreeVCS is given a nonexistent folder. * Move VCS code to a plugin script. * Add some documentation to the top of vcs.vim. --- doc/NERDTree.txt | 8 ++++++++ lib/nerdtree/creator.vim | 2 +- nerdtree_plugin/vcs.vim | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 nerdtree_plugin/vcs.vim diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 48b56b41..b86cdf11 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -107,6 +107,14 @@ The following features and functionality are provided by the NERD tree: :NERDTree /home/marty/vim7/src :NERDTree foo (foo is the name of a bookmark) < +:NERDTreeVCS [ | ] *:NERDTreeVCS* + Like |:NERDTree|, but searches up the directory tree to find the top of + the version control system repository, and roots the NERD tree there. It + works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A + couple of examples: > + :NERDTreeVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) + :NERDTreeVCS (opens root of repository containing CWD) +< :NERDTreeFromBookmark *:NERDTreeFromBookmark* Opens a fresh NERD tree with the root initialized to the dir for . The only reason to use this command over :NERDTree is for diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 78dfd9eb..1afd0564 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -33,7 +33,7 @@ function! s:Creator._broadcastInitEvent() silent doautocmd User NERDTreeInit endfunction -" FUNCTION: s:Creator.BufNamePrefix() {{{2 +" FUNCTION: s:Creator.BufNamePrefix() {{{1 function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim new file mode 100644 index 00000000..c30579ae --- /dev/null +++ b/nerdtree_plugin/vcs.vim @@ -0,0 +1,38 @@ +" ============================================================================ +" File: vcs.vim +" Description: NERDTree plugin that provides a command to open on the root of +" a version control system repository. +" Maintainer: Phil Runninger +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ +command! -n=? -complete=dir -bar NERDTreeVCS :call CreateTabTreeVCS('') + +" FUNCTION: s:CreateTabTreeVCS(a:name) {{{1 +function! s:CreateTabTreeVCS(name) + let l:path = g:NERDTreeCreator._pathForString(a:name) + let l:path = s:FindParentVCSRoot(l:path) + call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str()) +endfunction + +" FUNCTION: s:FindParentVCSRoot(a:path) {{{1 +" Finds the root version control system folder of the given path. If a:path is +" not part of a repository, return the original path. +function! s:FindParentVCSRoot(path) + let l:path = a:path + while !empty(l:path) && + \ l:path._str() !~ '^\(\a:\\\|\/\)$' && + \ !isdirectory(l:path._str() . '/.git') && + \ !isdirectory(l:path._str() . '/.svn') && + \ !isdirectory(l:path._str() . '/.hg') && + \ !isdirectory(l:path._str() . '/.bzr') && + \ !isdirectory(l:path._str() . '/_darcs') + let l:path = l:path.getParent() + endwhile + return (empty(l:path) || l:path._str() =~ '^\(\a:\\\|\/\)$') ? a:path : l:path +endfunction + From 8cc154d4b0cf28f73815050b9782e6ac5a4d733d Mon Sep 17 00:00:00 2001 From: zcodes Date: Fri, 1 Feb 2019 20:50:55 +0800 Subject: [PATCH 476/680] fixed root path error for windows (#935) * fixed root path error for windows * simplify condition check --- lib/nerdtree/path.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index d997c312..b92eb6f7 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -15,7 +15,7 @@ function! s:Path.AbsolutePathFor(pathStr) let l:prependWorkingDir = 0 if nerdtree#runningWindows() - let l:prependWorkingDir = a:pathStr !~# '^.:\(\\\|\/\)' && a:pathStr !~# '^\(\\\\\|\/\/\)' + let l:prependWorkingDir = a:pathStr !~# '^.:\(\\\|\/\)\?' && a:pathStr !~# '^\(\\\\\|\/\/\)' else let l:prependWorkingDir = a:pathStr !~# '^/' endif @@ -23,7 +23,13 @@ function! s:Path.AbsolutePathFor(pathStr) let l:result = a:pathStr if l:prependWorkingDir - let l:result = getcwd() . s:Path.Slash() . a:pathStr + let l:result = getcwd() + + if l:result[-1:] == s:Path.Slash() + let l:result = l:result . a:pathStr + else + let l:result = l:result . s:Path.Slash() . a:pathStr + endif endif return l:result From 74be22deb7690d847146bd8e52853362b56c82e2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 14 Feb 2019 15:28:30 -0500 Subject: [PATCH 477/680] Escape a backslash so it can be used in a key mapping. (#948) --- lib/nerdtree/key_map.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 1ca478dd..584da1f1 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -51,6 +51,7 @@ function! s:KeyMap.bind() else let keymapInvokeString = self.key endif + let keymapInvokeString = escape(keymapInvokeString, '\') let premap = self.key == "" ? " " : " " From 5e8aa9e721235daf49e79b341afc2f8eeff091a4 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 14 Feb 2019 17:44:31 -0500 Subject: [PATCH 478/680] Confirm the wipeout of a unsaved buffer whose file has been renamed. (#949) --- nerdtree_plugin/fs_menu.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index ef261ca9..5dee6809 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -108,7 +108,11 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) exec "tabnext " . s:originalTabNumber exec s:originalWindowNumber . "wincmd w" " 3. We don't need a previous buffer anymore - exec "bwipeout! " . a:bufNum + try + exec "confirm bwipeout " . a:bufNum + catch + " This happens when answering Cancel if confirmation is needed. Do nothing. + endtry endfunction "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() From c05615fd80141c3ab04459e75a42d2ed6f030e18 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 15 Feb 2019 03:10:28 -0500 Subject: [PATCH 479/680] Set a maximum window size when zooming. (#950) --- doc/NERDTree.txt | 3 +++ lib/nerdtree/ui.vim | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index b86cdf11..174b7f78 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -702,6 +702,9 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. |NERDTreeWinSize| Sets the window size when the NERD tree is opened. +|NERDTreeWinSizeMax| Sets the maximum window size when the NERD tree + is zoomed. + |NERDTreeMinimalUI| Disables display of the 'Bookmarks' label and 'Press ? for help' text. diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 32d96d9b..5e3fcf1d 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -503,7 +503,7 @@ function! s:UI.toggleZoom() exec "silent vertical resize ". size let b:NERDTreeZoomed = 0 else - exec "vertical resize" + exec "vertical resize ". get(g:, 'NERDTreeWinSizeMax', '') let b:NERDTreeZoomed = 1 endif endfunction From cce52fb9c5b957f5fadd1bc5c74b8aea32fd4bcb Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 17 Feb 2019 18:30:10 -0500 Subject: [PATCH 480/680] Before copying, turn off &shellslash. Restore after copy is finished. (#952) --- nerdtree_plugin/fs_menu.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 5dee6809..a638bd70 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -287,6 +287,8 @@ endfunction " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() + let l:shellslash = &shellslash + let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() let newNodePath = input("Copy the current node\n" . \ "==========================================================\n" . @@ -324,6 +326,7 @@ function! NERDTreeCopyNode() else call nerdtree#echo("Copy aborted.") endif + let &shellslash = l:shellslash redraw endfunction From 842f5cabaab4738ac53247ee474b210c69c4695d Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 17 Feb 2019 22:03:49 -0500 Subject: [PATCH 481/680] Before deleting, turn off &shellslash. Restore after delete is done. --- nerdtree_plugin/fs_menu.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index a638bd70..e0911e49 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -202,6 +202,8 @@ endfunction " FUNCTION: NERDTreeDeleteNode() {{{1 function! NERDTreeDeleteNode() + let l:shellslash = &shellslash + let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 @@ -242,7 +244,7 @@ function! NERDTreeDeleteNode() else call nerdtree#echo("delete aborted") endif - + let &shellslash = l:shellslash endfunction " FUNCTION: NERDTreeListNode() {{{1 From 4ef9967e299177a0c3aa30539296bdea8953d1ac Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 18 Feb 2019 15:52:23 -0500 Subject: [PATCH 482/680] Update the documentation to better explain the delimiter character. --- doc/NERDTree.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 174b7f78..5b2ef68f 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1165,10 +1165,17 @@ to choose a character that won't appear in your filenames or any of the flags set by your installed NERDTree plugins. The suggestions below are but a few of the many possibilities. Remember to use double quotes when specifying by hex or Unicode. > - let NERDTreeNodeDelimiter='😀' - let NERDTreeNodeDelimiter="\u00a0" - let NERDTreeNodeDelimiter="\xFF" + let NERDTreeNodeDelimiter="\u00a0" "non-breaking space + let NERDTreeNodeDelimiter="\u00b7" "middle dot < +The delimiter character is hidden by setting 'conceallevel' to 3. If you use +autocommands, make sure none of them change that setting in the NERDTree_* +windows. + +If your vim was not compiled with the +conceal feature, NERDTree will use the +Ignore highlight group, which doesn't hide the BELL character. In this +situation, you will need to override the delimiter character as described +above. ============================================================================== 4. The NERD tree API *NERDTreeAPI* From 2e0b101d571a170c9919f180eae20100bcd6b62e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 20 Feb 2019 23:57:51 -0500 Subject: [PATCH 483/680] Add an :EditBookmarks command to edit the bookmarks file (#954) * Add a new NERDTree buffer command to edit the bookmarks file. * Update the mini-help panel with missing bookmark commands. * Update the help file with the new :EditBookmarks command. --- doc/NERDTree.txt | 9 +++++++-- lib/nerdtree/bookmark.vim | 7 +++++++ lib/nerdtree/creator.vim | 1 + lib/nerdtree/ui.vim | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 5b2ef68f..907ad4a0 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -206,6 +206,10 @@ Note: The following commands are only available within the NERDTree buffer. :ClearAllBookmarks Remove all bookmarks. +:EditBookmarks + Opens the bookmarks file for manual editing, e.g. for removing invalid + bookmarks. + :ReadBookmarks Re-read the bookmarks in the |NERDTreeBookmarksFile|. @@ -218,13 +222,14 @@ If invalid bookmarks are detected, the script will issue an error message and the invalid bookmarks will become unavailable for use. These bookmarks will still be stored in the bookmarks file (see -|NERDTreeBookmarksFile|), down the bottom. There will always be a blank line +|NERDTreeBookmarksFile|), down at the bottom. There will always be a blank line after the valid bookmarks but before the invalid ones. Each line in the bookmarks file represents one bookmark. The proper format is: -After you have corrected any invalid bookmarks, either restart vim, or go +You can use the :EditBookmarks command to open the bookmarks file for editing. +After you have corrected any invalid bookmarks, either restart vim, or run :ReadBookmarks from the NERD tree window. ------------------------------------------------------------------------------ diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 2e0aab02..c256aaf0 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -156,6 +156,13 @@ function! s:Bookmark.delete() call s:Bookmark.Write() endfunction +" FUNCTION: s:Edit() {{{1 +" opens the NERDTreeBookmarks file for manual editing +function! s:Bookmark.Edit() + execute "wincmd w" + execute "edit ".g:NERDTreeBookmarksFile +endfunction + " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " Returns the tree node object associated with this Bookmark. " Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 1afd0564..980cf805 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -26,6 +26,7 @@ function! s:Creator._bindMappings() command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() + command! -buffer -nargs=0 EditBookmarks call g:NERDTreeBookmark.Edit() endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5e3fcf1d..c289f904 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -119,6 +119,9 @@ function! s:UI._dumpHelp() let help .= "\" :OpenBookmark \n" let help .= "\" :ClearBookmarks []\n" let help .= "\" :ClearAllBookmarks\n" + let help .= "\" :ReadBookmarks\n" + let help .= "\" :WriteBookmarks\n" + let help .= "\" :EditBookmarks\n" silent! put =help elseif !self.isMinimal() let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" From 9eda9ce6a11307f5441ff12b9fa0a99bae53da21 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 21 Feb 2019 07:47:15 -0500 Subject: [PATCH 484/680] Add new value to NERDTreeQuitOnOpen to close bookmark table (#955) * Update documentation for new NERDTreeQuitOnOpen values. * Modify use of NERDTreeQuitOnOpen, keeping current behavior. * If applicable, close the bookmarks table before opening the target. --- doc/NERDTree.txt | 17 +++++++++++++---- lib/nerdtree/bookmark.vim | 4 ++++ lib/nerdtree/nerdtree.vim | 2 +- lib/nerdtree/opener.vim | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 907ad4a0..29dc9cde 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -682,7 +682,8 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. |NERDTreeMouseMode| Manage the interpretation of mouse clicks. -|NERDTreeQuitOnOpen| Closes the tree window after opening a file. +|NERDTreeQuitOnOpen| Closes the tree window or bookmark table after + opening a file. |NERDTreeShowBookmarks| Tells the NERD tree whether to display the bookmarks table on startup. @@ -959,11 +960,19 @@ then (to single click activate it) you must click somewhere in ------------------------------------------------------------------------------ *NERDTreeQuitOnOpen* -Values: 0 or 1. +Values: 0,1,2 or 3. Default: 0 -If set to 1, the NERD tree window will close after opening a file with the -|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings. +This setting governs whether the NERDTree window or the bookmarks table closes +after opening a file with the |NERDTree-o|, |NERDTree-i|, |NERDTree-t| and +|NERDTree-T| mappings. + + Value | NERDTree Window Behavior + -------+------------------------------------------------------- + 0 | No change + 1 | Closes after opening a file + 2 | Closes the bookmark table after opening a bookmark + 3(1+2) | Same as both 1 and 2 ------------------------------------------------------------------------------ *NERDTreeShowBookmarks* diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index c256aaf0..dad3dc8c 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -256,6 +256,10 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} + if and(g:NERDTreeQuitOnOpen,2) + call a:nerdtree.ui.toggleShowBookmarks() + endif + if self.path.isDirectory && !has_key(opts, 'where') call self.toRoot(a:nerdtree) else diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index fcabcb9e..5a4ebc50 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -66,7 +66,7 @@ endfunction "FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 "Closes the NERD tree window if the close on open option is set function! s:NERDTree.CloseIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen() + if and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() call s:NERDTree.Close() endif endfunction diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index ef357ef4..f4bd6e06 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -243,7 +243,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !g:NERDTreeQuitOnOpen && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif From b6cde142ddbec3ea47bdf23b0e5365f4d87bdd7c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 22 Feb 2019 08:21:20 -0500 Subject: [PATCH 485/680] Preview bookmarks (#956) * Add function to preview bookmarks. File bookmarks are previewed like regular file nodes. Directory bookmarks are located with NERDTreeFind in the current tree. * Update help doc to include the new bookmark preview functionality. --- autoload/nerdtree/ui_glue.vim | 12 +++++++++++- doc/NERDTree.txt | 9 +++++++-- lib/nerdtree/ui.vim | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 12dd9ae1..d519d8bd 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -18,6 +18,7 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewBookmark" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) @@ -100,7 +101,7 @@ function! s:activateFileNode(node) call a:node.activate({'reuse': 'all', 'where': 'p'}) endfunction -"FUNCTION: s:activateBookmark() {{{1 +"FUNCTION: s:activateBookmark(bookmark) {{{1 "handle the user activating a bookmark function! s:activateBookmark(bm) call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) @@ -495,6 +496,15 @@ function! s:openNodeRecursively(node) call nerdtree#echo("Recursively opening node. Please wait... DONE") endfunction +" FUNCTION: s:previewBookmark(bookmark) {{{1 +function! s:previewBookmark(bookmark) + if a:bookmark.path.isDirectory + execute 'NERDTreeFind '.a:bookmark.path.str() + else + call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1}) + endif +endfunction + "FUNCTION: s:previewNodeCurrent(node) {{{1 function! s:previewNodeCurrent(node) call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 29dc9cde..0034a93c 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -240,6 +240,7 @@ Key Description help-tag~ o........Open files, directories and bookmarks......................|NERDTree-o| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| + Open selected bookmark dir in current NERDTree t........Open selected node/bookmark in a new tab...................|NERDTree-t| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| i........Open selected file in a split window.......................|NERDTree-i| @@ -305,8 +306,12 @@ Default key: go Map setting: NERDTreeMapPreview Applies to: files. -If a file node is selected, it is opened in the previous window, but the -cursor does not move. +If a file node or a bookmark that links to a file is selected, it is opened in +the previous window, but the cursor does not move. + +If a bookmark that links to a directory is selected, that directory is found +in the current NERDTree. If the directory couldn't be found, a new NERDTree is +created. The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index c289f904..9ae643bb 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -62,6 +62,8 @@ function! s:UI._dumpHelp() let help .= "\" Bookmark table mappings~\n" let help .= "\" double-click,\n" let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n" + let help .= "\" ". g:NERDTreeMapPreview .": preview file\n" + let help .= "\" ". g:NERDTreeMapPreview .": find dir in tree\n" let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" From 84737f2ebe533ffac9ebc21da8d1f57216962641 Mon Sep 17 00:00:00 2001 From: Chris Patuzzo Date: Sun, 24 Feb 2019 23:01:12 +0000 Subject: [PATCH 486/680] Add a NERDTreeMinimalMenu feature (#938) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Extract the menu action prompts to a function * Add a NERDTreeMinimalMenu configuration option If this option is set, Vim’s command line displays a single-line version of the menu: Which action? (a*/m/d/r/o/q/c/l): Pressing ‘a’ will call the ‘add child node’ menu item as that is its shortcut. The * denotes the position of the currently selected menu item which can be changed with NERDTreeMenuDown and Up in the usual way. The user may wish to set these to , or h, l if they prefer. * Minimise the text once a menu item is chosen If NERDTreeMinimalMenu is set, then echo a single line prompt after the menu item is chosen. This reduces noise for users who are already familiar with how the menu works and prevents Vim scrolling down to accommodate the menu text. If the directory is non-empty we display ‘Delete directory?’ instead of ‘Delete?’ and the user must still type ‘yes’ to confirm, rather than just pressing ‘y’. * Document the new NERDTreeMinimalMenu feature * Tweak the format for the minimal menu prompt As per @PhilRunninger’s suggestions: - The menu now shows the ‘j/k/enter’ help text - The first word of the selected item is shown* - Use commas between menu items so that it’s visually distinct from the ‘j/k/enter’ text * I tried displaying the full menuItem text, but this can be quite long, e.g. > (o)pen the current node with system editor This causes the menu to jump around a lot. We could add another minimal versions of these, but I think the first word seems ok for now. --- doc/NERDTree.txt | 23 +++++++++ lib/nerdtree/menu_controller.vim | 40 ++++++++++++---- nerdtree_plugin/fs_menu.vim | 82 ++++++++++++++++++++++---------- plugin/NERD_tree.vim | 1 + 4 files changed, 111 insertions(+), 35 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 0034a93c..5bf169cd 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -719,6 +719,9 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. |NERDTreeMinimalUI| Disables display of the 'Bookmarks' label and 'Press ? for help' text. +|NERDTreeMinimalMenu| Use a compact menu that fits on a single line + for adding, copying, deleting, etc + |NERDTreeCascadeSingleChildDir| Collapses on the same line directories that have only one child directory. @@ -1116,6 +1119,26 @@ of the following lines for this setting: > let NERDTreeMinimalUI=1 < +------------------------------------------------------------------------------ + *NERDTreeMinimalMenu* +Values: 0 or 1 +Default: 0 + +This setting makes NERD tree use a smaller, more compact menu for adding, +copying, deleting nodes. This menu fits on a single line so Vim doesn't need to +scroll down to present it. This setting is recommended for users already +familiar with the menu items. It will look similar to this: + + Menu: [ (a)dd ,m,d,r,o,q,c,l] (Use j/k/enter or shortcut): + +An action can be selected with its shortcut key or with the NERDTreeMenuUp and +NERDTreeMenuDown keys, then pressing enter. + +Use one of the following lines for this setting: > + let NERDTreeMinimalMenu=0 + let NERDTreeMinimalMenu=1 + + ------------------------------------------------------------------------------ *NERDTreeCascadeSingleChildDir* Values: 0 or 1 diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 84bdb26b..26dbd296 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -15,6 +15,11 @@ function! s:MenuController.New(menuItems) return newMenuController endfunction +" FUNCTION: s:MenuController.isMinimal() {{{1 +function! s:MenuController.isMinimal() + return g:NERDTreeMinimalMenu +endfunction + " FUNCTION: MenuController.showMenu() {{{1 " Enter the main loop of the NERDTree menu, prompting the user to select " a menu item. @@ -49,16 +54,27 @@ endfunction "FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() - echo "NERDTree Menu. Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter and the shortcuts indicated" - echo "==========================================================" + let navHelp = "Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter" - for i in range(0, len(self.menuItems)-1) - if self.selection == i - echo "> " . self.menuItems[i].text - else - echo " " . self.menuItems[i].text - endif - endfor + if self.isMinimal() + let selection = self.menuItems[self.selection].text + + let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") + let shortcuts[self.selection] = " " . split(selection)[0] . " " + + echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " + else + echo "NERDTree Menu. " . navHelp . " . or the shortcuts indicated" + echo "=========================================================" + + for i in range(0, len(self.menuItems)-1) + if self.selection == i + echo "> " . self.menuItems[i].text + else + echo " " . self.menuItems[i].text + endif + endfor + endif endfunction "FUNCTION: MenuController._current(key) {{{1 @@ -129,7 +145,11 @@ endfunction "FUNCTION: MenuController._setCmdheight() {{{1 "sets &cmdheight to whatever is needed to display the menu function! s:MenuController._setCmdheight() - let &cmdheight = len(self.menuItems) + 3 + if self.isMinimal() + let &cmdheight = 1 + else + let &cmdheight = len(self.menuItems) + 3 + endif endfunction "FUNCTION: MenuController._saveOptions() {{{1 diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index e0911e49..3eef5176 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -44,6 +44,47 @@ else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif +"FUNCTION: s:inputPrompt(action){{{1 +"returns the string that should be prompted to the user for the given action +" +"Args: +"action: the action that is being performed, e.g. 'delete' +function! s:inputPrompt(action) + if a:action == "add" + let title = "Add a childnode" + let info = "Enter the dir/file name to be created. Dirs end with a '/'" + let minimal = "Add node:" + + elseif a:action == "copy" + let title = "Copy the current node" + let info = "Enter the new path to copy the node to:" + let minimal = "Copy to:" + + elseif a:action == "delete" + let title = "Delete the current node" + let info = "Are you sure you wish to delete the node:" + let minimal = "Delete?" + + elseif a:action == "deleteNonEmpty" + let title = "Delete the current node" + let info = "STOP! Directory is not empty! To delete, type 'yes'" + let minimal = "Delete directory?" + + elseif a:action == "move" + let title = "Rename the current node" + let info = "Enter the new path for the node:" + let minimal = "Move to:" + endif + + if g:NERDTreeMenuController.isMinimal() + redraw! " Clear the menu + return minimal . " " + else + let divider = "==========================================================" + return title . "\n" . divider . "\n" . info . "\n" + end +endfunction + "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 "prints out the given msg and, if the user responds by pushing 'y' then the "buffer with the given bufnum is deleted @@ -114,14 +155,12 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) " This happens when answering Cancel if confirmation is needed. Do nothing. endtry endfunction + "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() - - let newNodeName = input("Add a childnode\n". - \ "==========================================================\n". - \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . - \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file") + let prompt = s:inputPrompt("add") + let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), "file") if newNodeName ==# '' call nerdtree#echo("Node Creation Aborted.") @@ -144,6 +183,8 @@ function! NERDTreeAddNode() call NERDTreeRender() call newTreeNode.putCursorHere(1, 0) endif + + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Node Not Created.") endtry @@ -152,10 +193,8 @@ endfunction "FUNCTION: NERDTreeMoveNode(){{{1 function! NERDTreeMoveNode() let curNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Rename the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path for the node: \n" . - \ "", curNode.path.str(), "file") + let prompt = s:inputPrompt("move") + let newNodePath = input(prompt, curNode.path.str(), "file") if newNodePath ==# '' call nerdtree#echo("Node Renaming Aborted.") @@ -194,7 +233,7 @@ function! NERDTreeMoveNode() call curNode.putCursorHere(1, 0) - redraw + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Node Not Renamed.") endtry @@ -209,21 +248,16 @@ function! NERDTreeDeleteNode() if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || \ (len(currentNode._glob('*', 1)) > 0)) - let choice =input("Delete the current node\n" . - \ "==========================================================\n" . - \ "STOP! Directory is not empty! To delete, type 'yes'\n" . - \ "" . currentNode.path.str() . ": ") + let prompt = s:inputPrompt("deleteNonEmpty") . currentNode.path.str() . ": " + let choice = input(prompt) let confirmed = choice ==# 'yes' else - echo "Delete the current node\n" . - \ "==========================================================\n". - \ "Are you sure you wish to delete the node:\n" . - \ "" . currentNode.path.str() . " (yN):" + let prompt = s:inputPrompt("delete") . currentNode.path.str() . " (yN): " + echo prompt let choice = nr2char(getchar()) let confirmed = choice ==# 'y' endif - if confirmed try call currentNode.delete() @@ -237,7 +271,7 @@ function! NERDTreeDeleteNode() call s:promptToDelBuffer(bufnum, prompt) endif - redraw + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Could not remove node") endtry @@ -292,10 +326,8 @@ function! NERDTreeCopyNode() let l:shellslash = &shellslash let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Copy the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path to copy the node to: \n" . - \ "", currentNode.path.str(), "file") + let prompt = s:inputPrompt("copy") + let newNodePath = input(prompt, currentNode.path.str(), "file") if newNodePath != "" "strip trailing slash @@ -329,7 +361,7 @@ function! NERDTreeCopyNode() call nerdtree#echo("Copy aborted.") endif let &shellslash = l:shellslash - redraw + redraw! endfunction " FUNCTION: NERDTreeQuickLook() {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c3de3f21..5a04fc37 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -51,6 +51,7 @@ call s:initVariable("g:NERDTreeSortHiddenFirst", 1) call s:initVariable("g:NERDTreeChDirMode", 0) call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeMinimalUI", 0) +call s:initVariable("g:NERDTreeMinimalMenu", 0) if !exists("g:NERDTreeIgnore") let g:NERDTreeIgnore = ['\~$'] endif From e1916d6fe71f5ff84b74dbca881a598fcda877c4 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 5 Mar 2019 09:25:49 -0700 Subject: [PATCH 487/680] Update directory .vimdc readme example (#961) * set pwd for new window * adding 'cd '.argv()[0] explination * spacing * exe * [0] --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 6efeb0bd..75b311a6 100644 --- a/README.markdown +++ b/README.markdown @@ -64,10 +64,12 @@ Note: Now start vim with plain `vim`, not `vim .` > How can I open NERDTree automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. +Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` + --- > How can I map a specific key or shortcut to open NERDTree? From 288669db1fa888947deaf715d7469233f476909f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 7 Mar 2019 08:24:17 -0500 Subject: [PATCH 488/680] Smarter delimiter default (#963) * Better default node delimiter, based on presence of +conceal feature. * Update documentation for node delimiter. * Fix IF logic, and remove debug statements. * Rewrite the NERDTreeNodeDelimiter help text to reflect new behavior. * Change "NERD tree" to "NERDTree" and fix spacing in doc file. --- doc/NERDTree.txt | 242 +++++++++++++++++++++++-------------------- plugin/NERD_tree.vim | 9 +- 2 files changed, 135 insertions(+), 116 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 5bf169cd..93635bd0 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -26,12 +26,12 @@ CONTENTS *NERDTree-contents* 2.2.1.The bookmark table..........|NERDTreeBookmarkTable| 2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands| 2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks| - 2.3.NERD tree mappings................|NERDTreeMappings| - 2.4.The NERD tree menu................|NERDTreeMenu| + 2.3.NERDTree mappings.................|NERDTreeMappings| + 2.4.The NERDTree menu.................|NERDTreeMenu| 3.Settings................................|NERDTreeSettings| 3.1.Settings summary..................|NERDTreeSettingsSummary| 3.2.Settings details..................|NERDTreeSettingsDetails| - 4.The NERD tree API.......................|NERDTreeAPI| + 4.The NERDTree API........................|NERDTreeAPI| 4.1.Key map API.......................|NERDTreeKeymapAPI| 4.2.Menu API..........................|NERDTreeMenuAPI| 4.3.Menu API..........................|NERDTreeAddPathFilter()| @@ -42,14 +42,14 @@ CONTENTS *NERDTree-contents* ============================================================================== 1. Intro *NERDTree* -What is this "NERD tree"?? +What is this "NERDTree"?? -The NERD tree allows you to explore your filesystem and to open files and +The NERDTree allows you to explore your filesystem and to open files and directories. It presents the filesystem to you in the form of a tree which you manipulate with the keyboard and/or mouse. It also allows you to perform simple filesystem operations. -The following features and functionality are provided by the NERD tree: +The following features and functionality are provided by the NERDTree: * Files and directories are displayed in a hierarchical tree structure * Different highlighting is provided for the following types of nodes: * files @@ -65,12 +65,12 @@ The following features and functionality are provided by the NERD tree: * Mappings to navigate around the tree * ... * Directories and files can be bookmarked. - * Most NERD tree navigation can also be done with the mouse + * Most NERDTree navigation can also be done with the mouse * Filtering of tree content (can be toggled at runtime) * custom file filters to prevent e.g. vim backup files being displayed * optional displaying of hidden files (. files) * files can be "turned off" so that only directories are displayed - * The position and size of the NERD tree window can be customised + * The position and size of the NERDTree window can be customised * The order in which the nodes in the tree are listed can be customised. * A model of your filesystem is created/maintained as you explore it. This has several advantages: @@ -79,12 +79,12 @@ The following features and functionality are provided by the NERD tree: session, the directory nodes will be opened/closed as you left them * The script remembers the cursor position and window position in the NERD tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear exactly + reopen it (with NERDTreeToggle) the NERDTree window will appear exactly as you left it - * You can have a separate NERD tree for each tab, share trees across tabs, + * You can have a separate NERDTree for each tab, share trees across tabs, or a mix of both. * By default the script overrides the default file browser (netrw), so if - you :edit a directory a (slightly modified) NERD tree will appear in the + you :edit a directory a (slightly modified) NERDTree will appear in the current window * A programmable menu system is provided (simulates right clicking on a node) @@ -100,7 +100,7 @@ The following features and functionality are provided by the NERD tree: 2.1. Global Commands *NERDTreeGlobalCommands* :NERDTree [ | ] *:NERDTree* - Opens a fresh NERD tree. The root of the tree depends on the argument + Opens a fresh NERDTree. The root of the tree depends on the argument given. There are 3 cases: If no argument is given, the current directory will be used. If a directory is given, that will be used. If a bookmark name is given, the corresponding directory will be used. For example: > @@ -109,36 +109,36 @@ The following features and functionality are provided by the NERD tree: < :NERDTreeVCS [ | ] *:NERDTreeVCS* Like |:NERDTree|, but searches up the directory tree to find the top of - the version control system repository, and roots the NERD tree there. It + the version control system repository, and roots the NERDTree there. It works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A couple of examples: > :NERDTreeVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) :NERDTreeVCS (opens root of repository containing CWD) < :NERDTreeFromBookmark *:NERDTreeFromBookmark* - Opens a fresh NERD tree with the root initialized to the dir for + Opens a fresh NERDTree with the root initialized to the dir for . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). :NERDTreeToggle [ | ] *:NERDTreeToggle* - If a NERD tree already exists for this tab, it is reopened and rendered - again. If no NERD tree exists for this tab then this command acts the + If a NERDTree already exists for this tab, it is reopened and rendered + again. If no NERDTree exists for this tab then this command acts the same as the |:NERDTree| command. :NERDTreeFocus *:NERDTreeFocus* - Opens (or reopens) the NERD Tree if it is not currently visible; - otherwise, the cursor is moved to the already-open NERD Tree. + Opens (or reopens) the NERDTree if it is not currently visible; + otherwise, the cursor is moved to the already-open NERDTree. :NERDTreeMirror *:NERDTreeMirror* - Shares an existing NERD tree, from another tab, in the current tab. + Shares an existing NERDTree, from another tab, in the current tab. Changes made to one tree are reflected in both as they are actually the same buffer. - If only one other NERD tree exists, that tree is automatically mirrored. + If only one other NERDTree exists, that tree is automatically mirrored. If more than one exists, the script will ask which tree to mirror. :NERDTreeClose *:NERDTreeClose* - Close the NERD tree in this tab. + Close the NERDTree in this tab. :NERDTreeFind [] *:NERDTreeFind* Without the optional argument, find and reveal the file for the active @@ -154,12 +154,12 @@ The following features and functionality are provided by the NERD tree: NERDTree exists for this tab, a new one is opened. :NERDTreeRefreshRoot *:NERDTreeRefreshRoot* - Refreshes the NERD tree root node. + Refreshes the NERDTree root node. ------------------------------------------------------------------------------ 2.2. Bookmarks *NERDTreeBookmarks* -Bookmarks in the NERD tree are a way to tag files or directories of interest. +Bookmarks in the NERDTree are a way to tag files or directories of interest. For example, you could use bookmarks to tag all of your project directories. ------------------------------------------------------------------------------ @@ -230,10 +230,10 @@ Each line in the bookmarks file represents one bookmark. The proper format is: You can use the :EditBookmarks command to open the bookmarks file for editing. After you have corrected any invalid bookmarks, either restart vim, or run -:ReadBookmarks from the NERD tree window. +:ReadBookmarks from the NERDTree window. ------------------------------------------------------------------------------ -2.3. NERD tree Mappings *NERDTreeMappings* +2.3. NERDTree Mappings *NERDTreeMappings* Default~ Key Description help-tag~ @@ -270,7 +270,7 @@ u........Move the tree root up one directory........................|NERDTree-u| U........Same as 'u' except the old root node is left open..........|NERDTree-U| r........Recursively refresh the current directory..................|NERDTree-r| R........Recursively refresh the current root.......................|NERDTree-R| -m........Display the NERD tree menu.................................|NERDTree-m| +m........Display the NERDTree menu..................................|NERDTree-m| cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| CD.......Change tree root to the CWD...............................|NERDTree-CD| @@ -323,9 +323,9 @@ Map setting: NERDTreeMapOpenInTab Applies to: files and directories. Opens the selected file in a new tab. If a directory is selected, a fresh -NERD Tree for that directory is opened in a new tab. +NERDTree for that directory is opened in a new tab. -If a bookmark which points to a directory is selected, open a NERD tree for +If a bookmark which points to a directory is selected, open a NERDTree for that directory in a new tab. If the bookmark points to a file, open that file in a new tab. @@ -415,7 +415,7 @@ Map setting: NERDTreeMapOpenExpl Applies to: files and directories. |:edit|s the selected directory, or the selected file's directory. This could -result in a NERD tree or a netrw being opened, depending on +result in a NERDTree or a netrw being opened, depending on |NERDTreeHijackNetrw|. ------------------------------------------------------------------------------ @@ -534,7 +534,7 @@ Default key: m Map setting: NERDTreeMapMenu Applies to: files and directories. -Display the NERD tree menu. See |NERDTreeMenu| for details. +Display the NERDTree menu. See |NERDTreeMenu| for details. ------------------------------------------------------------------------------ *NERDTree-cd* @@ -609,9 +609,9 @@ Applies to: no restrictions. Toggles whether the quickhelp is displayed. ------------------------------------------------------------------------------ -2.3. The NERD tree menu *NERDTreeMenu* + 2.3. The NERDTree menu *NERDTreeMenu* -The NERD tree has a menu that can be programmed via the an API (see +The NERDTree has a menu that can be programmed via the an API (see |NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most file explorers have. @@ -623,18 +623,18 @@ menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| ------------------------------------------------------------------------------ - *NERDTreeMenu-j* + *NERDTreeMenu-j* Default key: j Map option: NERDTreeMenuDown -Applies to: The NERD tree menu. +Applies to: The NERDTree menu. Moves the cursor down. ------------------------------------------------------------------------------ - *NERDTreeMenu-k* + *NERDTreeMenu-k* Default key: k Map option: NERDTreeMenuUp -Applies to: The NERD tree menu. +Applies to: The NERDTree menu. Moves the cursor up. @@ -646,38 +646,38 @@ Moves the cursor up. 3.1. Customisation summary *NERDTreeSettingsSummary* The plugin provides the following settings that can customise the behaviour -the NERD tree. These settings should be set in your vimrc, using `:let`. +the NERDTree. These settings should be set in your vimrc, using `:let`. |loaded_nerd_tree| Turns off the script. -|NERDTreeAutoCenter| Controls whether the NERD tree window centers +|NERDTreeAutoCenter| Controls whether the NERDTree window centers when the cursor moves within a specified distance to the top/bottom of the window. |NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. -|NERDTreeCaseSensitiveSort| Tells the NERD tree whether to be case +|NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case sensitive or not when sorting nodes. -|NERDTreeNaturalSort| Tells the NERD tree whether to use natural sort +|NERDTreeNaturalSort| Tells the NERDTree whether to use natural sort order or not when sorting nodes. -|NERDTreeSortHiddenFirst| Tells the NERD tree whether to take the dot at +|NERDTreeSortHiddenFirst| Tells the NERDTree whether to take the dot at the beginning of the hidden file names into account when sorting nodes. -|NERDTreeChDirMode| Tells the NERD tree if/when it should change +|NERDTreeChDirMode| Tells the NERDTree if/when it should change vim's current working directory. -|NERDTreeHighlightCursorline| Tell the NERD tree whether to highlight the +|NERDTreeHighlightCursorline| Tell the NERDTree whether to highlight the current cursor line. -|NERDTreeHijackNetrw| Tell the NERD tree whether to replace the netrw +|NERDTreeHijackNetrw| Tell the NERDTree whether to replace the netrw autocommands for exploring local directories. -|NERDTreeIgnore| Tells the NERD tree which files to ignore. +|NERDTreeIgnore| Tells the NERDTree which files to ignore. -|NERDTreeRespectWildIgnore| Tells the NERD tree to respect `'wildignore'`. +|NERDTreeRespectWildIgnore| Tells the NERDTree to respect `'wildignore'`. |NERDTreeBookmarksFile| Where the bookmarks are stored. @@ -690,30 +690,30 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. |NERDTreeQuitOnOpen| Closes the tree window or bookmark table after opening a file. -|NERDTreeShowBookmarks| Tells the NERD tree whether to display the +|NERDTreeShowBookmarks| Tells the NERDTree whether to display the bookmarks table on startup. -|NERDTreeShowFiles| Tells the NERD tree whether to display files in +|NERDTreeShowFiles| Tells the NERDTree whether to display files in the tree on startup. -|NERDTreeShowHidden| Tells the NERD tree whether to display hidden +|NERDTreeShowHidden| Tells the NERDTree whether to display hidden files on startup. -|NERDTreeShowLineNumbers| Tells the NERD tree whether to display line +|NERDTreeShowLineNumbers| Tells the NERDTree whether to display line numbers in the tree window. -|NERDTreeSortOrder| Tell the NERD tree how to sort the nodes in the +|NERDTreeSortOrder| Tell the NERDTree how to sort the nodes in the tree. -|NERDTreeStatusline| Set a statusline for NERD tree windows. +|NERDTreeStatusline| Set a statusline for NERDTree windows. -|NERDTreeWinPos| Tells the script where to put the NERD tree +|NERDTreeWinPos| Tells the script where to put the NERDTree window. -|NERDTreeWinSize| Sets the window size when the NERD tree is +|NERDTreeWinSize| Sets the window size when the NERDTree is opened. -|NERDTreeWinSizeMax| Sets the maximum window size when the NERD tree +|NERDTreeWinSizeMax| Sets the maximum window size when the NERDTree is zoomed. |NERDTreeMinimalUI| Disables display of the 'Bookmarks' label and @@ -730,7 +730,7 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. Cascade open while selected directory has only one child that also is a directory. -|NERDTreeAutoDeleteBuffer| Tells the NERD tree to automatically remove a +|NERDTreeAutoDeleteBuffer| Tells the NERDTree to automatically remove a buffer when a file is being deleted or renamed via a context menu command. @@ -747,6 +747,9 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. include one space character at the end of the command and it applies only to directories. +|NERDTreeDirArrowCollapsible| These characters indicate when a directory is +|NERDTreeDirArrowExpandable| either collapsible or expandable. + |NERDTreeNodeDelimiter| A single character that is used to separate the file or directory name from the rest of the characters on the line of text. @@ -763,13 +766,12 @@ If this plugin is making you feel homicidal, it may be a good idea to turn it off with this line in your vimrc: > let loaded_nerd_tree=1 < - ------------------------------------------------------------------------------ *NERDTreeAutoCenter* Values: 0 or 1. Default: 1 -If set to 1, the NERD tree window will center around the cursor if it moves to +If set to 1, the NERDTree window will center around the cursor if it moves to within |NERDTreeAutoCenterThreshold| lines of the top/bottom of the window. This is ONLY done in response to tree navigation mappings, @@ -783,7 +785,7 @@ The centering is done with a |zz| operation. Values: Any natural number. Default: 3 -This setting controls the "sensitivity" of the NERD tree auto centering. See +This setting controls the "sensitivity" of the NERDTree auto centering. See |NERDTreeAutoCenter| for details. ------------------------------------------------------------------------------ @@ -791,7 +793,7 @@ This setting controls the "sensitivity" of the NERD tree auto centering. See Values: 0 or 1. Default: 0. -By default the NERD tree does not sort nodes case sensitively, i.e. nodes +By default the NERDTree does not sort nodes case sensitively, i.e. nodes could appear like this: > bar.c Baz.c @@ -812,7 +814,7 @@ into account. The above nodes would then be sorted like this: > Values: 0 or 1. Default: 0. -By default the NERD tree does not sort nodes in natural sort order, i.e. nodes +By default the NERDTree does not sort nodes in natural sort order, i.e. nodes could appear like this: > z1.txt z10.txt @@ -843,14 +845,14 @@ Default: 0. Use this setting to tell the script when (if at all) to change the current working directory (CWD) for vim. -If it is set to 0 then the CWD is never changed by the NERD tree. +If it is set to 0 then the CWD is never changed by the NERDTree. -If set to 1 then the CWD is changed when the NERD tree is first loaded to the -directory it is initialized in. For example, if you start the NERD tree with > +If set to 1 then the CWD is changed when the NERDTree is first loaded to the +directory it is initialized in. For example, if you start the NERDTree with > :NERDTree /home/marty/foobar < then the CWD will be changed to /home/marty/foobar and will not be changed -again unless you init another NERD tree with a similar command. +again unless you init another NERDTree with a similar command. If the setting is set to 2 then it behaves the same as if set to 1 except that the CWD is changed whenever the tree root is changed. For example, if the CWD @@ -862,7 +864,7 @@ root then the CWD will become /home/marty/foobar/baz. Values: 0 or 1. Default: 1. -If set to 1, the current cursor line in the NERD tree buffer will be +If set to 1, the current cursor line in the NERDTree buffer will be highlighted. This is done using the `'cursorline'` Vim option. ------------------------------------------------------------------------------ @@ -873,7 +875,7 @@ Default: 1. If set to 1, doing a > :edit < -will open up a window level NERD tree instead of a netrw in the target window. +will open up a window level NERDTree instead of a netrw in the target window. Window level trees behaves slightly different from a regular trees in the following respects: @@ -886,8 +888,8 @@ following respects: Values: a list of regular expressions. Default: ['\~$']. -This setting is used to specify which files the NERD tree should ignore. It -must be a list of regular expressions. When the NERD tree is rendered, any +This setting is used to specify which files the NERDTree should ignore. It +must be a list of regular expressions. When the NERDTree is rendered, any files/dirs that match any of the regex's in NERDTreeIgnore won't be displayed. @@ -904,11 +906,10 @@ These flags are "[[dir]]" and "[[file]]". Example: > This will cause all dirs ending in ".d" to be ignored and all files ending in ".o" to be ignored. -Note: to tell the NERD tree not to ignore any files you must use the following +Note: to tell the NERDTree not to ignore any files you must use the following line: > let NERDTreeIgnore=[] < - The file filters can be turned on and off dynamically with the |NERDTree-f| mapping. @@ -997,7 +998,7 @@ mapping. Values: 0 or 1. Default: 1. -If this setting is set to 1 then files are displayed in the NERD tree. If it +If this setting is set to 1 then files are displayed in the NERDTree. If it is set to 0 then only directories are displayed. This setting can be toggled dynamically, per tree, with the |NERDTree-F| @@ -1015,18 +1016,16 @@ Use one of the follow lines for this setting: > let NERDTreeShowHidden=0 let NERDTreeShowHidden=1 < - ------------------------------------------------------------------------------ *NERDTreeShowLineNumbers* Values: 0 or 1. Default: 0. -This setting tells vim whether to display line numbers for the NERD tree +This setting tells vim whether to display line numbers for the NERDTree window. Use one of the follow lines for this setting: > let NERDTreeShowLineNumbers=0 let NERDTreeShowLineNumbers=1 < - ------------------------------------------------------------------------------ *NERDTreeSortOrder* Values: a list of regular expressions. @@ -1094,19 +1093,19 @@ setting is used. Values: "left" or "right" Default: "left". -This setting is used to determine where NERD tree window is placed on the +This setting is used to determine where NERDTree window is placed on the screen. This setting makes it possible to use two different explorer plugins simultaneously. For example, you could have the taglist plugin on the left of -the window and the NERD tree on the right. +the window and the NERDTree on the right. ------------------------------------------------------------------------------ *NERDTreeWinSize* Values: a positive integer. Default: 31. -This setting is used to change the size of the NERD tree when it is loaded. +This setting is used to change the size of the NERDTree when it is loaded. ------------------------------------------------------------------------------ *NERDTreeMinimalUI* @@ -1118,13 +1117,12 @@ of the following lines for this setting: > let NERDTreeMinimalUI=0 let NERDTreeMinimalUI=1 < - ------------------------------------------------------------------------------ - *NERDTreeMinimalMenu* + *NERDTreeMinimalMenu* Values: 0 or 1 Default: 0 -This setting makes NERD tree use a smaller, more compact menu for adding, +This setting makes NERDTree use a smaller, more compact menu for adding, copying, deleting nodes. This menu fits on a single line so Vim doesn't need to scroll down to present it. This setting is recommended for users already familiar with the menu items. It will look similar to this: @@ -1137,8 +1135,7 @@ NERDTreeMenuDown keys, then pressing enter. Use one of the following lines for this setting: > let NERDTreeMinimalMenu=0 let NERDTreeMinimalMenu=1 - - +< ------------------------------------------------------------------------------ *NERDTreeCascadeSingleChildDir* Values: 0 or 1 @@ -1149,7 +1146,6 @@ have only one child. Use one of the following lines for this setting: > let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=1 < - ------------------------------------------------------------------------------ *NERDTreeCascadeOpenSingleChildDir* Values: 0 or 1 @@ -1163,7 +1159,6 @@ useful for Java projects. Use one of the following lines for this setting: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < - ------------------------------------------------------------------------------ *NERDTreeAutoDeleteBuffer* Values: 0 or 1 @@ -1188,41 +1183,60 @@ string such as "keepalt" or similar. For example, to have NERDTree create its tree window using `silent keepalt keepjumps edit`: > let NERDTreeCreatePrefix='silent keepalt keepjumps' < +------------------------------------------------------------------------------ + *NERDTreeDirArrowCollapsible* *NERDTreeDirArrowExpandable* +Values: Any single character. +Defaults: Windows: ~ and + Others: ▾ and ▸ + +These characters indicate whether a directory is collapsible or expandable. + +They can be set to "\u00a0" to hide the arrows, but if you do this you may +need to change the node delimiter. See |NERDTreeNodeDelimiter|. You cannot use +the same character for both the arrows and the delimiter. Example: > + let NERDTreeDirArrowExpandable=">" + let NERDTreeDirArrowCollapsible="v" +< ------------------------------------------------------------------------------ *NERDTreeNodeDelimiter* Values: Any single character. -Default: "\x07" - the non-printable character BELL. +Default: varies (see below) This character is used to separate the file or directory name from the rest of the characters in the line of text. It allows filenames to contain special characters that are otherwise used in the NERDTree, such as square brackets, braces, trailing asterisk, and leading space. For more details, see the -resoponsible pull request: https://github.com/scrooloose/nerdtree/pull/868. - -The default should work in nearly every situation, but this setting exists for -those very rare cases where it doesn't. "\x07" was chosen because it's -non-printable, and very unlikely to be used purposefully in a filename or as a -flag by other NERDTree plugins. If you need to change the delimiter, be sure -to choose a character that won't appear in your filenames or any of the flags -set by your installed NERDTree plugins. The suggestions below are but a few of -the many possibilities. Remember to use double quotes when specifying by hex -or Unicode. > - let NERDTreeNodeDelimiter="\u00a0" "non-breaking space +responsible pull request: https://github.com/scrooloose/nerdtree/pull/868. + +The default value of this variable depends on the features compiled into your +vim and the values of |NERDTreeDirArrowCollapsible| and +|NERDTreeDirArrowExpandable|. + * If your vim is compiled with the +conceal feature, it is the "\x07" (BELL) + character, and it is hidden by setting 'conceallevel' to 3. If you use + autocommands, make sure none of them change that setting in the NERDTree_* + buffers. + * If your vim does NOT have the +conceal feature and you're using "\u00a0" + (non-breaking space) to hide the directory arrows, "\u00b7" (middle dot) + is used as the default delimiter. + * If neither condition above applies, NERDTree uses "\u00a0" (non-breaking + space) as the default delimiter. + +In the 2nd and 3rd cases, NERDTree will use the Ignore highlight group to +"hide" the delimiter. It should appear as an empty space. + +Other plugins can interfere with these defaults, so if you need to change the +delimiter, be sure to choose a character that won't appear in your filenames +or any of the flags set by your installed NERDTree plugins. The suggestions +below are but a few of the many possibilities. Remember to use double quotes +when specifying by hex or Unicode. > + let NERDTreeNodeDelimiter="\x07" "bell let NERDTreeNodeDelimiter="\u00b7" "middle dot + let NERDTreeNodeDelimiter="\u00a0" "non-breaking space + let NERDTreeNodeDelimiter="😀" "smiley face < -The delimiter character is hidden by setting 'conceallevel' to 3. If you use -autocommands, make sure none of them change that setting in the NERDTree_* -windows. - -If your vim was not compiled with the +conceal feature, NERDTree will use the -Ignore highlight group, which doesn't hide the BELL character. In this -situation, you will need to override the delimiter character as described -above. - ============================================================================== -4. The NERD tree API *NERDTreeAPI* +4. The NERDTree API *NERDTreeAPI* -The NERD tree script allows you to add custom key mappings and menu items via +The NERDTree script allows you to add custom key mappings and menu items via a set of API calls. Any scripts that use this API should be placed in ~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows). @@ -1246,7 +1260,7 @@ See this blog post for more details: 4.1. Key map API *NERDTreeKeymapAPI* NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* - Adds a new keymapping for all NERD tree buffers. + Adds a new keymapping for all NERDTree buffers. {options} must be a dictionary, and must contain the following keys: "key" - the trigger key for the new mapping "callback" - the function the new mapping will be bound to @@ -1283,7 +1297,7 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* on a directory node. ------------------------------------------------------------------------------ -4.2. Menu API *NERDTreeMenuAPI* +4.2. Menu API *NERDTreeMenuAPI* NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* Creates and returns a new submenu. @@ -1303,7 +1317,7 @@ NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* See below for an example. NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* - Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|). + Adds a new menu item to the NERDTree menu (see |NERDTreeMenu|). {options} must be a dictionary and must contain the following keys: @@ -1404,13 +1418,13 @@ Current events supported: ------------------------------------------------------------------------------ NERDTreeRender() *NERDTreeRender()* - Re-renders the NERD tree buffer. Useful if you change the state of the + Re-renders the NERDTree buffer. Useful if you change the state of the tree and you want to it to be reflected in the UI. ============================================================================== 5. About *NERDTreeAbout* -The author of the NERD tree is a terrible terrible monster called Martyzilla +The author of the NERDTree is a terrible terrible monster called Martyzilla who gobbles up small children with milk and sugar for breakfast. He can be reached at martin.grenfell at gmail dot com. He would love to hear @@ -1437,7 +1451,7 @@ Title Credit: ============================================================================== 6. License *NERDTreeLicense* -The NERD tree is released under the wtfpl. +The NERDTree is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. ------------------------------------------------------------------------------ diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 5a04fc37..a18082eb 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -87,8 +87,13 @@ let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") -" ASCII 7: bell non-printing character used to delimit items in the tree's nodes. -call s:initVariable("g:NERDTreeNodeDelimiter", "\x07") +if has("conceal") + call s:initVariable("g:NERDTreeNodeDelimiter", "\x07") +elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") + call s:initVariable("g:NERDTreeNodeDelimiter", "\u00b7") +else + call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") +endif if !exists('g:NERDTreeStatusline') From 0efbdfbc5a1a312d3877c46be6afb7bee55ba2f6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 25 Mar 2019 22:29:21 -0400 Subject: [PATCH 489/680] Remove the "Please wait... DONE" messages. (#966) --- autoload/nerdtree/ui_glue.vim | 9 +++------ lib/nerdtree/tree_dir_node.vim | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index d519d8bd..8da3640a 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -492,8 +492,7 @@ function! s:openNodeRecursively(node) call nerdtree#echo("Recursively opening node. Please wait...") call a:node.openRecursively() call b:NERDTree.render() - redraw - call nerdtree#echo("Recursively opening node. Please wait... DONE") + redraw! endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 @@ -544,9 +543,8 @@ function! s:refreshRoot() call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call b:NERDTree.root.refresh() call b:NERDTree.render() - redraw + redraw! call nerdtree#exec(l:curWin . "wincmd w") - call nerdtree#echo("Refreshing the root node. This could take a while... DONE") endfunction " FUNCTION: s:refreshCurrent(node) {{{1 @@ -560,8 +558,7 @@ function! s:refreshCurrent(node) call nerdtree#echo("Refreshing node. This could take a while...") call node.refresh() call b:NERDTree.render() - redraw - call nerdtree#echo("Refreshing node. This could take a while... DONE") + redraw! endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 658ff09e..995b3572 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -405,17 +405,15 @@ endfunction " Removes all childen from this node and re-reads them " " Args: -" silent: 1 if the function should not echo any "please wait" messages for -" large directories " " Return: the number of child nodes read -function! s:TreeDirNode._initChildren(silent) +function! s:TreeDirNode._initChildren() "remove all the current child nodes let self.children = [] let files = self._glob('*', 1) + self._glob('.*', 0) - if !a:silent && len(files) > g:NERDTreeNotificationThreshold + if len(files) > g:NERDTreeNotificationThreshold call nerdtree#echo("Please wait, caching a large dir ...") endif @@ -432,9 +430,7 @@ function! s:TreeDirNode._initChildren(silent) call self.sortChildren() - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call nerdtree#echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).") - endif + redraw! if invalidFilesFound call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") @@ -494,7 +490,7 @@ function! s:TreeDirNode.open(...) let l:numChildrenCached = 0 if empty(self.children) - let l:numChildrenCached = self._initChildren(0) + let l:numChildrenCached = self._initChildren endif return l:numChildrenCached From e3e600608a73af516ed8a1fd375d20191a65b35a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 25 Mar 2019 22:32:07 -0400 Subject: [PATCH 490/680] On Windows, do a case-insensitive comparison of paths. (#967) --- lib/nerdtree/path.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index b92eb6f7..c3af1952 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -564,7 +564,11 @@ endfunction " Args: " path: the other path obj to compare this with function! s:Path.equals(path) - return self.str() ==# a:path.str() + if nerdtree#runningWindows() + return self.str() ==? a:path.str() + else + return self.str() ==# a:path.str() + endif endfunction " FUNCTION: Path.New(pathStr) {{{1 From 839cddc750e6bb2a21a36c057fbfef114b0d8cec Mon Sep 17 00:00:00 2001 From: Terry Ding Date: Tue, 26 Mar 2019 14:03:12 +0800 Subject: [PATCH 491/680] fix _initChildren function value set to numChildrenCached error (#969) --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 995b3572..f45a5b0b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -490,7 +490,7 @@ function! s:TreeDirNode.open(...) let l:numChildrenCached = 0 if empty(self.children) - let l:numChildrenCached = self._initChildren + let l:numChildrenCached = self._initChildren() endif return l:numChildrenCached From 7513f256aa1d59b6a749cefe5ac505375b1b8a6a Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 26 Mar 2019 11:57:21 -0400 Subject: [PATCH 492/680] Fixes #970. Restore silent parameter to _initChildren. https://github.com/ryanoasis/vim-devicons uses this function directly with silent set to 1. --- lib/nerdtree/tree_dir_node.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index f45a5b0b..0bea771b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -405,15 +405,17 @@ endfunction " Removes all childen from this node and re-reads them " " Args: +" silent: 1 if the function should not echo any "please wait" messages for +" large directories " " Return: the number of child nodes read -function! s:TreeDirNode._initChildren() +function! s:TreeDirNode._initChildren(silent) "remove all the current child nodes let self.children = [] let files = self._glob('*', 1) + self._glob('.*', 0) - if len(files) > g:NERDTreeNotificationThreshold + if !a:silent && len(files) > g:NERDTreeNotificationThreshold call nerdtree#echo("Please wait, caching a large dir ...") endif @@ -490,7 +492,7 @@ function! s:TreeDirNode.open(...) let l:numChildrenCached = 0 if empty(self.children) - let l:numChildrenCached = self._initChildren() + let l:numChildrenCached = self._initChildren(0) endif return l:numChildrenCached From e126b8745dc40931ae8da03d92c78264e8e4b029 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 16 Apr 2019 09:55:20 -0400 Subject: [PATCH 493/680] Remove redraw! while still clearing last message empty string. (#979) --- autoload/nerdtree.vim | 2 +- autoload/nerdtree/ui_glue.vim | 7 ++++--- lib/nerdtree/tree_dir_node.vim | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index bdf3deb7..1061d81b 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -169,7 +169,7 @@ endfunction "msg: the message to echo function! nerdtree#echo(msg) redraw - echomsg "NERDTree: " . a:msg + echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg) endfunction "FUNCTION: nerdtree#echoError {{{2 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 8da3640a..a82ff18e 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -492,7 +492,7 @@ function! s:openNodeRecursively(node) call nerdtree#echo("Recursively opening node. Please wait...") call a:node.openRecursively() call b:NERDTree.render() - redraw! + call nerdtree#echo("") endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 @@ -543,8 +543,9 @@ function! s:refreshRoot() call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call b:NERDTree.root.refresh() call b:NERDTree.render() - redraw! + redraw call nerdtree#exec(l:curWin . "wincmd w") + call nerdtree#echo("") endfunction " FUNCTION: s:refreshCurrent(node) {{{1 @@ -558,7 +559,7 @@ function! s:refreshCurrent(node) call nerdtree#echo("Refreshing node. This could take a while...") call node.refresh() call b:NERDTree.render() - redraw! + call nerdtree#echo("") endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 0bea771b..a834e7c1 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -432,7 +432,7 @@ function! s:TreeDirNode._initChildren(silent) call self.sortChildren() - redraw! + call nerdtree#echo("") if invalidFilesFound call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") From 9226eab2a873400e0debecfb2a344ae88731a5f0 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 22 Apr 2019 15:58:06 -0400 Subject: [PATCH 494/680] Allow multi-character DirArrows (#985) * Add debugging messages to diagnose issue #931. * Echo the CWD and NERDTree root too. * Ensure DirArrows are trimmed to a single character. Actually, it's up to the user to make sure it's a single character after leading and trailing spaces are removed. Spaces need to be removed so that an accurate level of indentation can be calculated. * Remove debugging statements * Simplify the algorithm for calculating indentation level. 1. Replace the DirArrows with a single space. 2. Count the leading spaces. 3. Divide by 2. This allows users to specify multi-character arrows, where a spaces prevent characters printing on top of each other. --- lib/nerdtree/ui.vim | 9 ++++----- plugin/NERD_tree.vim | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 9ae643bb..ff855895 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -280,11 +280,10 @@ endfunction " FUNCTION: s:UI._indentLevelFor(line) {{{1 function! s:UI._indentLevelFor(line) - " have to do this work around because match() returns bytes, not chars - let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') - " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ - let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) - + " Replace multi-character DirArrows with a single space so the + " indentation calculation doesn't get messed up. + let l:line = substitute(substitute(a:line, g:NERDTreeDirArrowExpandable, ' ', ''), g:NERDTreeDirArrowCollapsible, ' ', '') + let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a18082eb..4384c938 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -77,6 +77,7 @@ else call s:initVariable("g:NERDTreeDirArrowExpandable", "+") call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") endif + call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) From 3c0633578281463638235597d8208612544606ae Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Tue, 23 Apr 2019 10:26:30 -0400 Subject: [PATCH 495/680] Escape the DirArrow strings in substitute function. --- lib/nerdtree/ui.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ff855895..6ff9878e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -282,7 +282,7 @@ endfunction function! s:UI._indentLevelFor(line) " Replace multi-character DirArrows with a single space so the " indentation calculation doesn't get messed up. - let l:line = substitute(substitute(a:line, g:NERDTreeDirArrowExpandable, ' ', ''), g:NERDTreeDirArrowCollapsible, ' ', '') + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction From a3f0e6679312656a28f2461eb24ac5a2f55235f6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 9 May 2019 10:12:25 -0400 Subject: [PATCH 496/680] Change minimum vim (#991) * Add a new function to implement and() from vim 7.4. * Change minimum required version of vim to 7.3. --- autoload/nerdtree.vim | 23 +++++++++++++++++++++++ lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/nerdtree.vim | 2 +- plugin/NERD_tree.vim | 4 ++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 1061d81b..fd192827 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -10,6 +10,29 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +"FUNCTION: nerdtree#and(x,y) {{{2 +" Implements and() function for Vim <= 7.2 +function! nerdtree#and(x,y) + if exists("*and") + return and(a:x, a:y) + else + let l:x = a:x + let l:y = a:y + let l:n = 0 + let l:result = 0 + while l:x > 0 && l:y > 0 + if (l:x % 2) && (l:y % 2) + let l:result += float2nr(pow(2, l:n)) + endif + echomsg l:x . ", " . l:y . " => " l:result + let l:x = float2nr(l:x / 2) + let l:y = float2nr(l:y / 2) + let l:n += 1 + endwhile + return l:result + endif +endfunction + "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index dad3dc8c..c633a8f2 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -256,7 +256,7 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} - if and(g:NERDTreeQuitOnOpen,2) + if nerdtree#and(g:NERDTreeQuitOnOpen,2) call a:nerdtree.ui.toggleShowBookmarks() endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 5a4ebc50..c1ce5ed0 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -66,7 +66,7 @@ endfunction "FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 "Closes the NERD tree window if the close on open option is set function! s:NERDTree.CloseIfQuitOnOpen() - if and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() + if nerdtree#and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() call s:NERDTree.Close() endif endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 4384c938..fb3e567f 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -14,8 +14,8 @@ if exists("loaded_nerd_tree") finish endif -if v:version < 700 - echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!" +if v:version < 730 + echoerr "NERDTree: this plugin requires vim >= 7.3. DOWNLOAD IT! You'll thank me later!" finish endif let loaded_nerd_tree = 1 From 67fa9b3116948466234978aa6287649f98e666bd Mon Sep 17 00:00:00 2001 From: Daniel Manary Date: Thu, 9 May 2019 16:25:36 -0400 Subject: [PATCH 497/680] Change version check to look for 03 not 30 (#994) My Vim reports as 704 when it is version 7.4, so this number should be 703 not 730 --- plugin/NERD_tree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fb3e567f..595e780b 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -14,7 +14,7 @@ if exists("loaded_nerd_tree") finish endif -if v:version < 730 +if v:version < 703 echoerr "NERDTree: this plugin requires vim >= 7.3. DOWNLOAD IT! You'll thank me later!" finish endif From 28eb47e2678cf629d92b4f1f00dd56cba22fc4ae Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 7 Jun 2019 21:41:47 -0400 Subject: [PATCH 498/680] Fix refreshroot (#999) * Set t:NERDTreeBufName when creating a window tree. * Change folding markers. --- autoload/nerdtree/ui_glue.vim | 4 ++-- lib/nerdtree/creator.vim | 7 ++++--- lib/nerdtree/ui.vim | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index a82ff18e..a6f4ae5b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -367,7 +367,7 @@ function! s:jumpToLastChild(node) call s:jumpToChild(a:node, 1) endfunction -" FUNCTION: s:jumpToChild(node, last) {{{2 +" FUNCTION: s:jumpToChild(node, last) {{{1 " Jump to the first or last child node at the same file system level. " " Args: @@ -425,7 +425,7 @@ function! s:jumpToPrevSibling(node) call s:jumpToSibling(a:node, 0) endfunction -" FUNCTION: s:jumpToSibling(node, forward) {{{2 +" FUNCTION: s:jumpToSibling(node, forward) {{{1 " Move the cursor to the next or previous node at the same file system level. " " Args: diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 980cf805..a893c17e 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -96,7 +96,8 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() + let t:NERDTreeBufName = self._nextBufferName() + exec g:NERDTreeCreatePrefix . " edit " . t:NERDTreeBufName call self._createNERDTree(path, "window") let b:NERDTree._previousBuf = bufnr(previousBuf) @@ -218,14 +219,14 @@ function! s:Creator.New() return newCreator endfunction -" FUNCTION: s:Creator._nextBufferName() {{{2 +" FUNCTION: s:Creator._nextBufferName() {{{1 " returns the buffer name for the next nerd tree function! s:Creator._nextBufferName() let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() return name endfunction -" FUNCTION: s:Creator._nextBufferNumber() {{{2 +" FUNCTION: s:Creator._nextBufferNumber() {{{1 " the number to add to the nerd tree buffer name to make the buf name unique function! s:Creator._nextBufferNumber() if !exists("s:Creator._NextBufNum") diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6ff9878e..227615b5 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -6,7 +6,7 @@ let s:UI = {} let g:NERDTreeUI = s:UI -" FUNCTION: s:UI.centerView() {{{2 +" FUNCTION: s:UI.centerView() {{{1 " centers the nerd tree window around the cursor (provided the nerd tree " options permit) function! s:UI.centerView() From 70dc34cb6979546e26cc6f874fe087457522165b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 13 Jun 2019 09:16:56 -0400 Subject: [PATCH 499/680] Enable root refresh on "vim ." a different way than #999. (#1001) * Fix "R doesn't work when doing 'vim '" a different way. Instead of assigning a value to t:NERDTreeBufName for a window tree, which is used to determine if NERDTree is open, simply also look at the current buffer's name to see if it matches the NERDTree pattern. * Replace hardcoded buffer name prefix with BufNamePrefix() function. --- lib/nerdtree/creator.vim | 3 +-- lib/nerdtree/nerdtree.vim | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index a893c17e..5eac168d 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -96,8 +96,7 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - let t:NERDTreeBufName = self._nextBufferName() - exec g:NERDTreeCreatePrefix . " edit " . t:NERDTreeBufName + exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() call self._createNERDTree(path, "window") let b:NERDTree._previousBuf = bufnr(previousBuf) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index c1ce5ed0..e5ba0b5d 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -153,7 +153,7 @@ endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 + return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 From 12dea6ccb2381a2b6b8ae0bf17b4078699bbfec3 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 13 Jun 2019 09:17:19 -0400 Subject: [PATCH 500/680] Add a "copy path to clipboard" menu option (#1002) * Add menu item to copy the node's path to the clipboard. It works on Mac. Check Windows later. * Handle case where clipboard is not a compiled feature of Vim. * Change menu text if clipboard is unavailable. --- nerdtree_plugin/fs_menu.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 3eef5176..5c37e4d0 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -37,6 +37,7 @@ endif if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif +call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) if has("unix") || has("osx") call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) @@ -364,6 +365,17 @@ function! NERDTreeCopyNode() redraw! endfunction +" FUNCTION: NERDTreeCopyPath() {{{1 +function! NERDTreeCopyPath() + let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() + if has("clipboard") + let @* = l:nodePath + call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") + else + call nerdtree#echo("The full path is: " . l:nodePath) + endif +endfunction + " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() From 9bedadd062be9d5c8b3e43686b36ac1842085048 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 18 Jun 2019 10:27:00 -0400 Subject: [PATCH 501/680] Refresh a dir_node if the file wasn't found in it, and look once more. (#1005) --- lib/nerdtree/tree_dir_node.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index a834e7c1..aa9dea6a 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -620,6 +620,11 @@ function! s:TreeDirNode.reveal(path, ...) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) + " We may be looking for a newly-saved file that isn't in the tree yet. + if n == {} + call self.refresh() + let n = self.findNode(a:path) + endif if has_key(opts, "open") call n.open() endif From 318fb2d0de18c85e38320a8854ce31ccbcbfacb6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 19 Jun 2019 15:45:22 -0400 Subject: [PATCH 502/680] Add new issue template, just for bugs. --- .github/bug.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/bug.md diff --git a/.github/bug.md b/.github/bug.md new file mode 100644 index 00000000..a274776b --- /dev/null +++ b/.github/bug.md @@ -0,0 +1,35 @@ +--- +labels: bug +--- + +# Bug Report +## To assist in resolving your issue, fill out this form completely. Omitting information will delay the resolution of your issue. + +- [ ] Have you reviewed the NERDTree documentation? `:h NERDTree` +- [ ] Have you looked for an answer to your question in the [Wiki](https://github.com/scrooloose/nerdtree/wiki)? + +### Environment + + +- [ ] Operating System: +- [ ] Vim version `:version`: +- [ ] NERDTree version `git rev-parse --short HEAD`: +- [ ] NERDTree settings applied in your vimrc, if any: + ```vim + ``` + +### Process + + +1. + +### Current Result + + +### Expected Result + + +### Screenshot(s) + +### Possible Fix + From 254f7678f32d83808601f19d5eee152acdcab9cd Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 19 Jun 2019 15:50:35 -0400 Subject: [PATCH 503/680] Move bug.md to its proper folder. --- .github/{ => ISSUE_TEMPLATE}/bug.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => ISSUE_TEMPLATE}/bug.md (100%) diff --git a/.github/bug.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 100% rename from .github/bug.md rename to .github/ISSUE_TEMPLATE/bug.md From b9a421b2d56c6746e3e7e76b74b9905c72822277 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 19 Jun 2019 16:02:55 -0400 Subject: [PATCH 504/680] Remove the bug.md template. Not able to make multiple templates. --- .github/ISSUE_TEMPLATE/bug.md | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug.md diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md deleted file mode 100644 index a274776b..00000000 --- a/.github/ISSUE_TEMPLATE/bug.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -labels: bug ---- - -# Bug Report -## To assist in resolving your issue, fill out this form completely. Omitting information will delay the resolution of your issue. - -- [ ] Have you reviewed the NERDTree documentation? `:h NERDTree` -- [ ] Have you looked for an answer to your question in the [Wiki](https://github.com/scrooloose/nerdtree/wiki)? - -### Environment - - -- [ ] Operating System: -- [ ] Vim version `:version`: -- [ ] NERDTree version `git rev-parse --short HEAD`: -- [ ] NERDTree settings applied in your vimrc, if any: - ```vim - ``` - -### Process - - -1. - -### Current Result - - -### Expected Result - - -### Screenshot(s) - -### Possible Fix - From b213fae7798d21ea9351cd90d54408d80be20fe6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 19 Jun 2019 18:38:57 -0400 Subject: [PATCH 505/680] Update the issue template. Shout out to @ryanoasis for the inspiration. --- .github/ISSUE_TEMPLATE.md | 54 +++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index c3ca5eff..396cc8a8 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,28 +1,44 @@ - +# Attention! Please Read! +Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information. -### Environment - +Keep in mind that others may experience the same issue in the future. The better your information, the more likely they'll be able to answer they're own question. -* Operating System: -* Vim version `:version`: -* NERDTree version `git rev-parse --short HEAD`: -* NERDTree settings applied in your vimrc, if any: - ```vim - ``` +After reading, and before submitting your issue, please remove this introductory text. -### Process - +──────────────────── ✄ ──────────────────── -1. +#### Self-Diagnosis +- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. +- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` +- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). +- [ ] I have searched the web for an answer to my question. -### Current Result - +#### Issue Type +- [ ] General Question (Setup, How-To, etc.) +- [ ] Feature Request +- [ ] Bug Report -### Expected Result - +#### Environment (for bug reports) +- [ ] Operating System: +- [ ] Vim/Neovim version `:version`: +- [ ] NERDTree version `git rev-parse --short HEAD`: +- [ ] A link to my [vimrc](), or +- [ ] vimrc settings + - [ ] NERDTree variables + ```vim + ``` + - Other NERDTree-dependent Plugins + - [ ] jistr/vim-nerdtree-tabs + - [ ] ryanoasis/vim-devicons + - [ ] tiagofumo/vim-nerdtree-syntax-highlight + - [ ] Xuyuanp/nerdtree-git-plugin + - [ ] Others: +- [ ] I've verified the issue occurs with only NERDTree installed. + +#### Steps to Reproduce the Issue +1. -### Screenshot(s) +#### Current Result (Include screenshots where appropriate.) -### Possible Fix - +#### Expected Result From c46fbd21e3f6f294b124486f72e7e9ed7b37e29a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 20 Jun 2019 08:17:50 -0400 Subject: [PATCH 506/680] Spacing changes in issue template --- .github/ISSUE_TEMPLATE.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 396cc8a8..cf8ea677 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,5 @@ # Attention! Please Read! + Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information. Keep in mind that others may experience the same issue in the future. The better your information, the more likely they'll be able to answer they're own question. @@ -32,8 +33,8 @@ After reading, and before submitting your issue, please remove this introductory - [ ] ryanoasis/vim-devicons - [ ] tiagofumo/vim-nerdtree-syntax-highlight - [ ] Xuyuanp/nerdtree-git-plugin - - [ ] Others: -- [ ] I've verified the issue occurs with only NERDTree installed. + - [ ] Others (specify): + - [ ] I've verified the issue occurs with only NERDTree installed. #### Steps to Reproduce the Issue 1. From 33fe2fdf16a95c12e8284364c780ed405dbaad17 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 20 Jun 2019 08:50:48 -0400 Subject: [PATCH 507/680] Switch to new issue template paradigm, with separate templates. --- .../bug.md} | 13 +++++----- .github/ISSUE_TEMPLATE/feature_request.md | 8 +++++++ .github/ISSUE_TEMPLATE/question.md | 24 +++++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug.md} (85%) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 85% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug.md index cf8ea677..84218720 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,8 +1,14 @@ +--- +name: "Bug Report" +about: "NERDTree is misbehaving? Tell us about it." +labels: bug +--- + # Attention! Please Read! Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information. -Keep in mind that others may experience the same issue in the future. The better your information, the more likely they'll be able to answer they're own question. +Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves. After reading, and before submitting your issue, please remove this introductory text. @@ -14,11 +20,6 @@ After reading, and before submitting your issue, please remove this introductory - [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). - [ ] I have searched the web for an answer to my question. -#### Issue Type -- [ ] General Question (Setup, How-To, etc.) -- [ ] Feature Request -- [ ] Bug Report - #### Environment (for bug reports) - [ ] Operating System: - [ ] Vim/Neovim version `:version`: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..35db0f6a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,8 @@ +--- +name: "Feature Request" +about: "What new feature are you requesting for NERDTree?" +labels: "feature request" +--- + +#### Description + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000..12ed8e68 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,24 @@ +--- +name: "General Question" +about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." +labels: "general question" +--- + +# Attention! Please Read! + +Please fill out **ALL the information** below so that the issue can be fully understood. Omitting information will delay the resolution of your issue. It will be labeled **`Needs More Info`**, and *may* be closed until there is enough information. + +Keep in mind that others may have the same question in the future. The better your information, the more likely they'll be able to help themselves. + +After reading, and before submitting your issue, please remove this introductory text. + +──────────────────── ✄ ──────────────────── + +#### Self-Diagnosis +- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. +- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` +- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). +- [ ] I have searched the web for an answer to my question. + +#### State Your Question + From 347a58b0b0276958ccc5b2e7cf8edd9c9923906c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 27 Jun 2019 01:28:45 -0400 Subject: [PATCH 508/680] Update Changelog and create PR Template (#1007) * Update CHANGELOG and change it to Markdown format. * Add PR template with checklist for advancing the version number. * Update version number. * Change PR number in change log and PR template. --- .github/PULL_REQUEST_TEMPLATE.md | 22 +++ CHANGELOG | 179 ----------------------- CHANGELOG.md | 241 +++++++++++++++++++++++++++++++ autoload/nerdtree.vim | 2 +- 4 files changed, 264 insertions(+), 180 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 CHANGELOG create mode 100644 CHANGELOG.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..a60d1d4a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ + +### Description of Changes + +Closes # + +--- +### New Version Info + +- [ ] Derive a new version number. Increment the: + - [ ] `MAJOR` version when you make incompatible API changes, + - [ ] `MINOR` version when you add functionality in a backwards-compatible manner, and + - [ ] `PATCH` version when you make backwards-compatible bug fixes. +- [ ] Update version number in [autoload/nerdtree.vim](https://github.com/scrooloose/nerdtree/blob/master/autoload/nerdtree.vim#L7) +- [ ] Update the ChangeLog, following this format/example: + ``` + MAJOR.MINOR... + - **.PATCH**: PR Title (Author) #PR Number + + ### 5.1... + - **.1**: Update Changelog and create PR Template (@PhilRunninger) #1007 + - **.0**: Too many changes for one patch... + ``` diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 6dac46dd..00000000 --- a/CHANGELOG +++ /dev/null @@ -1,179 +0,0 @@ -Next - - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759 - - Update doc with already existing mapping variables (asnr) #699 - - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696 - - Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648 - - Remove empty segments when splitting path (sooth-sayer) #574 - - Suppress autocmds less agressively (wincent) #578 #691 - - Add an Issues template to ask for more info initially. - - Fix markdown headers in readme (josephfrazier) #676 - - Don't touch @o and @h registers when rendering - - Fix bug with files and directories with dollar signs (alegen) #649 - - Reuse/reopen existing window trees where possible #244 - - Remove NERDTree.previousBuf() - - Change color of arrow (Leeiio) #630 - - Improved a tip in README.markdown (ggicci) #628 - - Shorten delete confimration of empty directory to 'y' (mikeperri) #530 - - Fix API call to open directory tree in window (devm33) #533 - - Change default arrows on non-Windows platforms (gwilk) #546 - - Update to README - combine cd and git clone (zwhitchcox) #584 - - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 - - Escape filename when moving an open buffer (zacharyvoase) #595 - - Fixed incorrect :helptags command in README (curran) #619 - - Fixed incomplete escaping of folder arrows (adityanatraj) #548 - - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 - - Replace strchars() with backward compatible workaround. - - Add support for copy command in Windows (SkylerLipthay) #231 - - Fixed typo in README.markdown - :Helptags -> :helptags - - Rename "primary" and "secondary" trees to "tab" and "window" trees. - - Move a bunch of buffer level variables into the NERDTree and UI classes. - - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) - - Remove the old style UI - Remove 'NERDTreeDirArrows' option. - - On windows default to + and ~ for expand/collapse directory symbols. - - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. - -5.0.0 - - Refactor the code significantly: - * Break the classes out into their own files. - * Make the majority of the code OO - previously large parts were - effectively a tangle of "global" methods. - - Add an API to assign flags to nodes. This allows VCS plugins like - https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to - Xuyuanp for helping design/test/build said API. - - add 'scope' argument to the key map API see :help NERDTreeAddKeyMap() - - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - - add support for custom path filters. See :help NERDTreeAddPathFilter() - - add path listener API. See :help NERDTreePathListenerAPI. - - expand the fs menu functionality to list file properties (PhilRunninger, - apbarrero, JESii) - - make bookmarks work with `~` home shortcuts (hiberabyss) - - show OSX specific fsmenu options in regular vim on mac (evindor) - - make dir arrow icons configurable (PickRelated) - - optimise node sorting performance when opening large dirs (vtsang) - - make the root note render prettier by truncating it at a path slash (gcmt) - - remove NERDChristmasTree option - its always christmas now - - add "cascade" open and closing for dirs containing only another single - dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) - - Many other fixes, doc updates and contributions from: - actionshrimp - SchDen - egalpin - cperl82 - many small fixes - toiffel - WoLpH - handcraftedbits - devmanhinton - xiaodili - zhangoose - gastropoda - mixvin - alvan - lucascaton - kelaban - shanesmith - staeff - pendulm - stephenprater - franksort - agrussellknives - AndrewRadev - Twinside - -4.2.0 - - Add NERDTreeDirArrows option to make the UI use pretty arrow chars - instead of the old +~| chars to define the tree structure (sickill) - - shift the syntax highlighting out into its own syntax file (gnap) - - add some mac specific options to the filesystem menu - for macvim - only (andersonfreitas) - - Add NERDTreeMinimalUI option to remove some non functional parts of the - nerdtree ui (camthompson) - - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the - new behaviour (benjamingeiger) - - if no name is given to :Bookmark, make it default to the name of the - target file/dir (minyoung) - - use 'file' completion when doing copying, create, and move - operations (EvanDotPro) - - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly - Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) - -4.1.0 - features: - - NERDTreeFind to reveal the node for the current buffer in the tree, - see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by - Doug McInnes) into the script. - - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan - Ritter and Rémi Prévost. - - truncate the root node if wider than the tree window. Thanks to Victor - Gonzalez. - - bugfixes: - - really fix window state restoring - - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, - jfilip1024, and Chris Chambers - -4.0.0 - - add a new programmable menu system (see :help NERDTreeMenu). - - add new APIs to add menus/menu-items to the menu system as well as - custom key mappings to the NERD tree buffer (see :help NERDTreeAPI). - - removed the old API functions - - added a mapping to maximize/restore the size of nerd tree window, thanks - to Guillaume Duranceau for the patch. See :help NERDTree-A for details. - - - fix a bug where secondary nerd trees (netrw hijacked trees) and - 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. - - fix a bug when using the x mapping on the tree root, thanks to Bryan - Venteicher for the patch. - - fix a bug where the cursor position/window size of the nerd tree buffer - wasnt being stored on closing the window, thanks to Richard Hart. - - fix a bug where NERDTreeMirror would mirror the wrong tree - -3.1.1 - - fix a bug where a non-listed no-name buffer was getting created every - time the tree windows was created, thanks to Derek Wyatt and owen1 - - make behave the same as the 'o' mapping - - some helptag fixes in the doc, thanks strull - - fix a bug when using :set nohidden and opening a file where the previous - buf was modified. Thanks iElectric - - other minor fixes - -3.1.0 - New features: - - add mappings to open files in a vsplit, see :help NERDTree-s and :help - NERDTree-gs - - make the statusline for the nerd tree window default to something - hopefully more useful. See :help 'NERDTreeStatusline' - Bugfixes: - - make the hijack netrw functionality work when vim is started with "vim - " (thanks to Alf Mikula for the patch). - - fix a bug where the CWD wasnt being changed for some operations even when - NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) - - add -bar to all the nerd tree :commands so they can chain with other - :commands (thanks to tpope) - - fix bugs when ignorecase was set (thanks to nach) - - fix a bug with the relative path code (thanks to nach) - - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach) - - -3.0.1 - Bugfixes: - - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden - was not set - - fix a bug where :NERDTree would fail if was relative and - didnt start with a ./ or ../ Thanks to James Kanze. - - make the q mapping work with secondary (:e style) trees, - thanks to jamessan - - fix a bunch of small bugs with secondary trees - - More insane refactoring. - -3.0.0 - - hijack netrw so that doing an :edit will put a NERD tree in - the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' - - allow sharing of trees across tabs, see :help :NERDTreeMirror - - remove "top" and "bottom" as valid settings for NERDTreeWinPos - - change the '' mapping to 'i' - - change the 'H' mapping to 'I' - - lots of refactoring diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..ec6b35d2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,241 @@ +# Change Log + +### 5.1... +- **`.1`**: Update Changelog and create PR Template (@PhilRunninger) #1007 +- **`.0`**: Too many changes for one patch... + - Refresh a dir_node if the file wasn't found in it, and look once more. (@PhilRunninger) #1005 + - Add a "copy path to clipboard" menu option (@PhilRunninger) #1002 + - Enable root refresh on "vim ." a different way than #999. (@PhilRunninger) #1001 + - Fix refreshroot (@PhilRunninger) #999 + - Change version check to look for 703 not 730 (@vhalis) #994 + - Change minimum vim (@PhilRunninger) #991 + - Allow multi-character DirArrows (@PhilRunninger) #985 + - Remove redraw! while still clearing last message empty string. (@PhilRunninger) #979 + - fix _initChildren function value set to numChildrenCached error (@terryding77) #969 + - On Windows, do a case-insensitive comparison of paths. (@PhilRunninger) #967 + - Remove the "Please wait... DONE" messages. (@PhilRunninger) #966 + - Smarter delimiter default (@PhilRunninger) #963 + - Update directory .vimdc readme example (@spencerdcarlson) #961 + - Preview bookmarks (@PhilRunninger) #956 + - Add new value to NERDTreeQuitOnOpen to close bookmark table (@PhilRunninger) #955 + - Add an :EditBookmarks command to edit the bookmarks file (@PhilRunninger) #954 + - Before copying, turn off &shellslash. Restore after copy is finished. (@PhilRunninger) #952 + - Set a maximum window size when zooming. (@PhilRunninger) #950 + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (@PhilRunninger) #949 + - Escape a backslash so it can be used in a key mapping. (@PhilRunninger) #948 + - Add a NERDTreeMinimalMenu feature (@tuzz) #938 + - fixed root path error for windows (@zcodes) #935 + - Restore getDirChildren for use in nerdtree-project-plugin. (@PhilRunninger) #929 + - Document NERDTreeNodeDelimiter #912 (@PhilRunninger) #926 + - Allow modification of menu keybindings (@Leandros) #923 + - Add two more disqualifications for isCascadable(). (@PhilRunninger) #914 + - Allow highlighting more than one flag. (@kristijanhusak) #908 + - Support sorting files and directories by modification time. (@PhilRunninger) #901 + - Parse . and .. from path string with trailing slash. (@PhilRunninger) #899 + - Force sort to recalculate the cached sortKey. (@PhilRunninger) #898 + - Add NERDTreeRefreshRoot command (@wgfm) #897 + - Call Resolve on the file's path when calling :NERDTreeFind. (@PhilRunninger) #896 + - Catch all errors, not just NERDTree errors. (@PhilRunninger) #894 + - Fix typo in help file (@lvoisin) #892 + - Make NERDTreeCreator set the `'nolist'` option (@lifecrisis) #889 + - Refresh buffers after `m`, `m` operation on a folder (@PhilRunninger) #888 + - Use a better arg for FINDSTR when using the m,l command in Windows. (@PhilRunninger) #887 + - Fix the / motions, which currently fail with cascades (@lifecrisis) #886 + - Function "s:UI.getLineNum()" doesn't always work on cascades. (@lifecrisis) #882 + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (@PhilRunninger) #878 + - Use tabnext instead of gt to allow users to remap gt. (@PhilRunninger) #877 + - Do a case sensitive comparison of new/existing buffers. (@PhilRunninger) #875 + - Fix opening sub-directories that have commas in their name. (@PhilRunninger) #873 + - Add new command to open NERDTree in the root of a VCS repository. (@PhilRunninger) #872 + - Make sure the path to the bookmarks file exists before writing it. (@PhilRunninger) #871 + - Unzoom NERDTree when opening a file (@PhilRunninger) #870 + - Support unusual characters in file and directory names (@PhilRunninger) #868 + - Reword renamed-buffer prompt to be more clear (@aflock) #867 + - Default to placing cursor on root when closing bookmark table (@lifecrisis) #866 + - Fix issues with sorting of nodes (@PhilRunninger) #856 + - Better OSX detection (@bubba-h57) #853 + - Bugfix - ensure keymaps dictionary exists before using it (@mnussbaum) #852 + - Decrease startup-time by avoiding linear-time iteration over key mappings (@mnussbaum) #851 + - Add code to sort mappings in quickhelp (@lifecrisis) #849 + - Use ":clearjumps" in new NERDTree windows (@lifecrisis) #844 + - Like m-c did before, create parent directories if needed on m-m. (@PhilRunninger) #840 + - BUGFIX: Repair a problem with the `'u'` mapping. (@lifecrisis) #838 + - Make the NERDTree buffer writable when rendering it. (@PhilRunninger) #837 + - Code cleanup: Remove unsupported bookmark table mappings (@lifecrisis) #835 + - Replace strcharpart() with substitute() for backward compatibility (@bravestarr) #834 + - Fixed error `unknown function strcharpart` for older versions of Vim (@hav4ik) #833 + - Clear output when NERDTree menu is aborted (@lifecrisis) #832 + - Display a path with multi-byte characters correctly when it is truncated (@bravestarr) #830 + - Support revealing file and executing file with xdg-open for Linux (@ngnmhieu) #824 + - If node isn't open, count children on disk before deleting. (@PhilRunninger) #822 + - Add new variable g:NERDTreeRemoveFileCmd (@kutsan) #816 + - Use a better check for existence of the NERDTree buffer. (@PhilRunninger) #814 + - Fix focussing previous buffer when closing NERDTree (@mrubli) #801 + - Update the docs for "NERDTreeStatusline" (@lifecrisis) #796 + - BUGFIX: Unstable behavior in the "getPath()" method (@lifecrisis) #795 + - Revert the bugfix from pull request #785 (@lifecrisis) #794 + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (@lifecrisis) #786 + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (@lifecrisis) #785 + - Add modelines (@lifecrisis) #782 + - Change the type of completion used by NERDTreeFind (@lifecrisis) #781 + - change NERDTreeFind with args (@zhenyangze) #778 + - Style Choice: Using confirm() when deleting a bookmark (@lifecrisis) #777 + - remove useless substitute when `file =~# "/$"` (@skyblueee) #773 + - remove useless removeLeadingSpaces in _stripMarkup (@skyblueee) #772 + - Make the "o" mapping consistent with "x" (@lifecrisis) #769 + - Fix a problem with the "x" handler (@lifecrisis) #768 + - Clean up the handler for the "x" mapping (@lifecrisis) #767 + - Revert change to tab opening method (@lifecrisis) #766 + - BUGFIX: Add back support for "b:NERDTreeRoot" (@lifecrisis) #765 + - Fix broken "t" and "T" mappings, tabs now open at end (@lifecrisis) #759 + - Update doc with already existing mapping variables (@asnr) #699 + - Fix the broken g:NERDTreeBookmarksSort setting (@lifecrisis) #696 + - Correct NERDTreeIgnore pattern in doc (@cntoplolicon) #648 + - Remove empty segments when splitting path (@sooth-sayer) #574 + - Suppress autocmds less agressively (@wincent) #578 #691 + - Add an Issues template to ask for more info initially. + - Fix markdown headers in readme (@josephfrazier) #676 + - Don't touch @o and @h registers when rendering + - Fix bug with files and directories with dollar signs (@alegen) #649 + - Reuse/reopen existing window trees where possible #244 + - Remove NERDTree.previousBuf() + - Change color of arrow (@Leeiio) #630 + - Improved a tip in README.markdown (@ggicci) #628 + - Shorten delete confimration of empty directory to `y` (@mikeperri) #530 + - Fix API call to open directory tree in window (@devm33) #533 + - Change default arrows on non-Windows platforms (@gwilk) #546 + - Update to README - combine cd and git clone (@zwhitchcox) #584 + - Update to README - Tip: start NERDTree when vim starts (@therealplato) #593 + - Escape filename when moving an open buffer (@zacharyvoase) #595 + - Fixed incorrect :helptags command in README (@curran) #619 + - Fixed incomplete escaping of folder arrows (@adityanatraj) #548 + - Added NERDTreeCascadeSingleChildDir option (@juanibiapina) #558 + - Replace strchars() with backward compatible workaround. + - Add support for copy command in Windows (@SkylerLipthay) #231 + - Fixed typo in README.markdown - :Helptags -> :helptags + - Rename "primary" and "secondary" trees to "tab" and "window" trees. + - Move a bunch of buffer level variables into the NERDTree and UI classes. + - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) + - Remove the old style UI - Remove `NERDTreeDirArrows` option. + - On windows default to + and ~ for expand/collapse directory symbols. + - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. + +### 5.0.0 +- Refactor the code significantly: + * Break the classes out into their own files. + * Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods. +- Add an API to assign flags to nodes. This allows VCS plugins like https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to @Xuyuanp for helping design/test/build said API. +- add `scope` argument to the key map API see :help NERDTreeAddKeyMap() +- add magic [[dir]] and [[file]] flags to NERDTreeIgnore +- add support for custom path filters. See :help NERDTreeAddPathFilter() +- add path listener API. See :help NERDTreePathListenerAPI. +- expand the fs menu functionality to list file properties (@PhilRunninger, @apbarrero, @JESii) +- make bookmarks work with `~` home shortcuts (@hiberabyss) +- show OSX specific fsmenu options in regular vim on mac (@evindor) +- make dir arrow icons configurable (@PickRelated) +- optimise node sorting performance when opening large dirs (@vtsang) +- make the root note render prettier by truncating it at a path slash (@gcmt) +- remove NERDChristmasTree option - its always christmas now +- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (@pendulm) +- Many other fixes, doc updates and contributions from: + - @actionshrimp + - @SchDen + - @egalpin + - @cperl82 - many small fixes + - @toiffel + - @WoLpH + - @handcraftedbits + - @devmanhinton + - @xiaodili + - @zhangoose + - @gastropoda + - @mixvin + - @alvan + - @lucascaton + - @kelaban + - @shanesmith + - @staeff + - @pendulm + - @stephenprater + - @franksort + - @agrussellknives + - @AndrewRadev + - @Twinside + +### 4.2.0 +- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (@sickill) +- shift the syntax highlighting out into its own syntax file (@gnap) +- add some mac specific options to the filesystem menu - for macvim only (@andersonfreitas) +- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (@camthompson) +- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (@benjamingeiger) +- if no name is given to :Bookmark, make it default to the name of the target file/dir (@minyoung) +- use `file` completion when doing copying, create, and move operations (@EvanDotPro) +- lots of misc bug fixes from: + - @paddyoloughlin + - @sdewald + - @camthompson + - @Vitaly + - @Bogdanov + - @AndrewRadev + - @mathias + - @scottstvnsn + - @kml + - @wycats + - me RAWR! + +### 4.1.0 +- features: + - NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by Doug McInnes) into the script. + - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan Ritter and Rémi Prévost. + - truncate the root node if wider than the tree window. Thanks to Victor Gonzalez. + +- bugfixes: + - really fix window state restoring + - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, jfilip1024, and Chris Chambers + +### 4.0.0 +- add a new programmable menu system (see `:help NERDTreeMenu`). +- add new APIs to add menus/menu-items to the menu system as well as custom key mappings to the NERD tree buffer (see `:help NERDTreeAPI`). +- removed the old API functions +- added a mapping to maximize/restore the size of nerd tree window, thanks to Guillaume Duranceau for the patch. See :help NERDTree-A for details. +- fix a bug where secondary nerd trees (netrw hijacked trees) and 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. +- fix a bug when using the x mapping on the tree root, thanks to Bryan Venteicher for the patch. +- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to Richard Hart. +- fix a bug where NERDTreeMirror would mirror the wrong tree + +### 3.1.1 +- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to Derek Wyatt and owen1 +- make `` behave the same as the `o` mapping +- some helptag fixes in the doc, thanks @strull +- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks @iElectric +- other minor fixes + +### 3.1.0 +- New features: + - add mappings to open files in a vsplit, see `:help NERDTree-s` and `:help NERDTree-gs` + - make the statusline for the nerd tree window default to something hopefully more useful. See `:help 'NERDTreeStatusline'` +- Bugfixes: + - make the hijack netrw functionality work when vim is started with `vim ` (thanks to Alf Mikula for the patch). + - fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) + - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to @tpope) + - fix bugs when ignorecase was set (thanks to @nach) + - fix a bug with the relative path code (thanks to @nach) + - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks @nach) + + +### 3.0.1 +- Bugfixes: + - fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set + - fix a bug where `:NERDTree ` would fail if `` was relative and didnt start with a `./` or `../` Thanks to James Kanze. + - make the `q` mapping work with secondary (`:e ` style) trees, thanks to @jamessan + - fix a bunch of small bugs with secondary trees +- More insane refactoring. + +### 3.0.0 +- hijack netrw so that doing an `:edit ` will put a NERD tree in the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' +- allow sharing of trees across tabs, see `:help :NERDTreeMirror` +- remove "top" and "bottom" as valid settings for NERDTreeWinPos +- change the `''` mapping to `'i'` +- change the `'H'` mapping to `'I'` +- lots of refactoring diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index fd192827..d7d428d4 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -4,7 +4,7 @@ endif let g:loaded_nerdtree_autoload = 1 function! nerdtree#version() - return '5.0.0' + return '5.1.1' endfunction " SECTION: General Functions {{{1 From 2cbc76bbfd807f022031f8c789f66d105d0a5d0b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 27 Jun 2019 01:34:10 -0400 Subject: [PATCH 509/680] Fix NERDTree opening with the wrong size. (#1008) * Fix NERDTree opening with the wrong size. There were two commands that seemed to be causing the NERDTree window to open in exactly half the screen width. They are: - silent! execute 'edit ' . t:NERDTreeBufName in _createTreeWin() - setlocal nobuflisted in _setCommonBufOptions() These commands were reseting the width of NERDTree. The solution I chose was to resize the window after creating the new window, and then to set winfixwidth before setting the other common buffer options. * Update change log and version number. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 2 +- lib/nerdtree/creator.vim | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6b35d2..6b98977e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ### 5.1... +- **`.2`**: Fix NERDTree opening with the wrong size. (@PhilRunninger) #1008 - **`.1`**: Update Changelog and create PR Template (@PhilRunninger) #1007 - **`.0`**: Too many changes for one patch... - Refresh a dir_node if the file wasn't found in it, and look once more. (@PhilRunninger) #1005 diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d7d428d4..845f920e 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -4,7 +4,7 @@ endif let g:loaded_nerdtree_autoload = 1 function! nerdtree#version() - return '5.1.1' + return '5.1.2' endfunction " SECTION: General Functions {{{1 diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 5eac168d..987e02ec 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -189,18 +189,20 @@ function! s:Creator._createTreeWin() let t:NERDTreeBufName = self._nextBufferName() silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' silent! execute 'edit ' . t:NERDTreeBufName + silent! execute 'vertical resize '. l:splitSize else silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' silent! execute 'buffer ' . t:NERDTreeBufName endif + setlocal winfixwidth + call self._setCommonBufOptions() if has('patch-7.4.1925') clearjumps endif - setlocal winfixwidth endfunction " FUNCTION: s:Creator._isBufHidden(nr) {{{1 From 1c803b36f632c151c755456b68101153f407ec5e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 27 Jun 2019 08:03:50 -0400 Subject: [PATCH 510/680] Remove @mentions from PR template and change log. They weren't working. (#1009) * Remove @mentions from PR template and change log. They weren't working. * Update version number and change log. --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CHANGELOG.md | 251 ++++++++++++++++--------------- autoload/nerdtree.vim | 2 +- 3 files changed, 128 insertions(+), 127 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a60d1d4a..1a2765e2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,6 +17,6 @@ Closes # - **.PATCH**: PR Title (Author) #PR Number ### 5.1... - - **.1**: Update Changelog and create PR Template (@PhilRunninger) #1007 + - **.1**: Update Changelog and create PR Template (PhilRunninger) #1007 - **.0**: Too many changes for one patch... ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b98977e..e207f2ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,118 +1,119 @@ # Change Log ### 5.1... -- **`.2`**: Fix NERDTree opening with the wrong size. (@PhilRunninger) #1008 -- **`.1`**: Update Changelog and create PR Template (@PhilRunninger) #1007 +- **`.3`**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009 +- **`.2`**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008 +- **`.1`**: Update Changelog and create PR Template (PhilRunninger) #1007 - **`.0`**: Too many changes for one patch... - - Refresh a dir_node if the file wasn't found in it, and look once more. (@PhilRunninger) #1005 - - Add a "copy path to clipboard" menu option (@PhilRunninger) #1002 - - Enable root refresh on "vim ." a different way than #999. (@PhilRunninger) #1001 - - Fix refreshroot (@PhilRunninger) #999 - - Change version check to look for 703 not 730 (@vhalis) #994 - - Change minimum vim (@PhilRunninger) #991 - - Allow multi-character DirArrows (@PhilRunninger) #985 - - Remove redraw! while still clearing last message empty string. (@PhilRunninger) #979 - - fix _initChildren function value set to numChildrenCached error (@terryding77) #969 - - On Windows, do a case-insensitive comparison of paths. (@PhilRunninger) #967 - - Remove the "Please wait... DONE" messages. (@PhilRunninger) #966 - - Smarter delimiter default (@PhilRunninger) #963 - - Update directory .vimdc readme example (@spencerdcarlson) #961 - - Preview bookmarks (@PhilRunninger) #956 - - Add new value to NERDTreeQuitOnOpen to close bookmark table (@PhilRunninger) #955 - - Add an :EditBookmarks command to edit the bookmarks file (@PhilRunninger) #954 - - Before copying, turn off &shellslash. Restore after copy is finished. (@PhilRunninger) #952 - - Set a maximum window size when zooming. (@PhilRunninger) #950 - - Confirm the wipeout of a unsaved buffer whose file has been renamed. (@PhilRunninger) #949 - - Escape a backslash so it can be used in a key mapping. (@PhilRunninger) #948 - - Add a NERDTreeMinimalMenu feature (@tuzz) #938 - - fixed root path error for windows (@zcodes) #935 - - Restore getDirChildren for use in nerdtree-project-plugin. (@PhilRunninger) #929 - - Document NERDTreeNodeDelimiter #912 (@PhilRunninger) #926 - - Allow modification of menu keybindings (@Leandros) #923 - - Add two more disqualifications for isCascadable(). (@PhilRunninger) #914 - - Allow highlighting more than one flag. (@kristijanhusak) #908 - - Support sorting files and directories by modification time. (@PhilRunninger) #901 - - Parse . and .. from path string with trailing slash. (@PhilRunninger) #899 - - Force sort to recalculate the cached sortKey. (@PhilRunninger) #898 - - Add NERDTreeRefreshRoot command (@wgfm) #897 - - Call Resolve on the file's path when calling :NERDTreeFind. (@PhilRunninger) #896 - - Catch all errors, not just NERDTree errors. (@PhilRunninger) #894 - - Fix typo in help file (@lvoisin) #892 - - Make NERDTreeCreator set the `'nolist'` option (@lifecrisis) #889 - - Refresh buffers after `m`, `m` operation on a folder (@PhilRunninger) #888 - - Use a better arg for FINDSTR when using the m,l command in Windows. (@PhilRunninger) #887 - - Fix the / motions, which currently fail with cascades (@lifecrisis) #886 - - Function "s:UI.getLineNum()" doesn't always work on cascades. (@lifecrisis) #882 - - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (@PhilRunninger) #878 - - Use tabnext instead of gt to allow users to remap gt. (@PhilRunninger) #877 - - Do a case sensitive comparison of new/existing buffers. (@PhilRunninger) #875 - - Fix opening sub-directories that have commas in their name. (@PhilRunninger) #873 - - Add new command to open NERDTree in the root of a VCS repository. (@PhilRunninger) #872 - - Make sure the path to the bookmarks file exists before writing it. (@PhilRunninger) #871 - - Unzoom NERDTree when opening a file (@PhilRunninger) #870 - - Support unusual characters in file and directory names (@PhilRunninger) #868 - - Reword renamed-buffer prompt to be more clear (@aflock) #867 - - Default to placing cursor on root when closing bookmark table (@lifecrisis) #866 - - Fix issues with sorting of nodes (@PhilRunninger) #856 - - Better OSX detection (@bubba-h57) #853 - - Bugfix - ensure keymaps dictionary exists before using it (@mnussbaum) #852 - - Decrease startup-time by avoiding linear-time iteration over key mappings (@mnussbaum) #851 - - Add code to sort mappings in quickhelp (@lifecrisis) #849 - - Use ":clearjumps" in new NERDTree windows (@lifecrisis) #844 - - Like m-c did before, create parent directories if needed on m-m. (@PhilRunninger) #840 - - BUGFIX: Repair a problem with the `'u'` mapping. (@lifecrisis) #838 - - Make the NERDTree buffer writable when rendering it. (@PhilRunninger) #837 - - Code cleanup: Remove unsupported bookmark table mappings (@lifecrisis) #835 - - Replace strcharpart() with substitute() for backward compatibility (@bravestarr) #834 - - Fixed error `unknown function strcharpart` for older versions of Vim (@hav4ik) #833 - - Clear output when NERDTree menu is aborted (@lifecrisis) #832 - - Display a path with multi-byte characters correctly when it is truncated (@bravestarr) #830 - - Support revealing file and executing file with xdg-open for Linux (@ngnmhieu) #824 - - If node isn't open, count children on disk before deleting. (@PhilRunninger) #822 - - Add new variable g:NERDTreeRemoveFileCmd (@kutsan) #816 - - Use a better check for existence of the NERDTree buffer. (@PhilRunninger) #814 - - Fix focussing previous buffer when closing NERDTree (@mrubli) #801 - - Update the docs for "NERDTreeStatusline" (@lifecrisis) #796 - - BUGFIX: Unstable behavior in the "getPath()" method (@lifecrisis) #795 - - Revert the bugfix from pull request #785 (@lifecrisis) #794 - - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (@lifecrisis) #786 - - BUGFIX: Allow ":NERDTreeFind" to reveal new files (@lifecrisis) #785 - - Add modelines (@lifecrisis) #782 - - Change the type of completion used by NERDTreeFind (@lifecrisis) #781 - - change NERDTreeFind with args (@zhenyangze) #778 - - Style Choice: Using confirm() when deleting a bookmark (@lifecrisis) #777 - - remove useless substitute when `file =~# "/$"` (@skyblueee) #773 - - remove useless removeLeadingSpaces in _stripMarkup (@skyblueee) #772 - - Make the "o" mapping consistent with "x" (@lifecrisis) #769 - - Fix a problem with the "x" handler (@lifecrisis) #768 - - Clean up the handler for the "x" mapping (@lifecrisis) #767 - - Revert change to tab opening method (@lifecrisis) #766 - - BUGFIX: Add back support for "b:NERDTreeRoot" (@lifecrisis) #765 - - Fix broken "t" and "T" mappings, tabs now open at end (@lifecrisis) #759 - - Update doc with already existing mapping variables (@asnr) #699 - - Fix the broken g:NERDTreeBookmarksSort setting (@lifecrisis) #696 - - Correct NERDTreeIgnore pattern in doc (@cntoplolicon) #648 - - Remove empty segments when splitting path (@sooth-sayer) #574 - - Suppress autocmds less agressively (@wincent) #578 #691 + - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) #1005 + - Add a "copy path to clipboard" menu option (PhilRunninger) #1002 + - Enable root refresh on "vim ." a different way than #999. (PhilRunninger) #1001 + - Fix refreshroot (PhilRunninger) #999 + - Change version check to look for 703 not 730 (vhalis) #994 + - Change minimum vim (PhilRunninger) #991 + - Allow multi-character DirArrows (PhilRunninger) #985 + - Remove redraw! while still clearing last message empty string. (PhilRunninger) #979 + - fix _initChildren function value set to numChildrenCached error (terryding77) #969 + - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) #967 + - Remove the "Please wait... DONE" messages. (PhilRunninger) #966 + - Smarter delimiter default (PhilRunninger) #963 + - Update directory .vimdc readme example (spencerdcarlson) #961 + - Preview bookmarks (PhilRunninger) #956 + - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) #955 + - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) #954 + - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) #952 + - Set a maximum window size when zooming. (PhilRunninger) #950 + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) #949 + - Escape a backslash so it can be used in a key mapping. (PhilRunninger) #948 + - Add a NERDTreeMinimalMenu feature (tuzz) #938 + - fixed root path error for windows (zcodes) #935 + - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) #929 + - Document NERDTreeNodeDelimiter #912 (PhilRunninger) #926 + - Allow modification of menu keybindings (Leandros) #923 + - Add two more disqualifications for isCascadable(). (PhilRunninger) #914 + - Allow highlighting more than one flag. (kristijanhusak) #908 + - Support sorting files and directories by modification time. (PhilRunninger) #901 + - Parse . and .. from path string with trailing slash. (PhilRunninger) #899 + - Force sort to recalculate the cached sortKey. (PhilRunninger) #898 + - Add NERDTreeRefreshRoot command (wgfm) #897 + - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) #896 + - Catch all errors, not just NERDTree errors. (PhilRunninger) #894 + - Fix typo in help file (lvoisin) #892 + - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) #889 + - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) #888 + - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) #887 + - Fix the / motions, which currently fail with cascades (lifecrisis) #886 + - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) #882 + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) #878 + - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) #877 + - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) #875 + - Fix opening sub-directories that have commas in their name. (PhilRunninger) #873 + - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) #872 + - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) #871 + - Unzoom NERDTree when opening a file (PhilRunninger) #870 + - Support unusual characters in file and directory names (PhilRunninger) #868 + - Reword renamed-buffer prompt to be more clear (aflock) #867 + - Default to placing cursor on root when closing bookmark table (lifecrisis) #866 + - Fix issues with sorting of nodes (PhilRunninger) #856 + - Better OSX detection (bubba-h57) #853 + - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) #852 + - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) #851 + - Add code to sort mappings in quickhelp (lifecrisis) #849 + - Use ":clearjumps" in new NERDTree windows (lifecrisis) #844 + - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) #840 + - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) #838 + - Make the NERDTree buffer writable when rendering it. (PhilRunninger) #837 + - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) #835 + - Replace strcharpart() with substitute() for backward compatibility (bravestarr) #834 + - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) #833 + - Clear output when NERDTree menu is aborted (lifecrisis) #832 + - Display a path with multi-byte characters correctly when it is truncated (bravestarr) #830 + - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) #824 + - If node isn't open, count children on disk before deleting. (PhilRunninger) #822 + - Add new variable g:NERDTreeRemoveFileCmd (kutsan) #816 + - Use a better check for existence of the NERDTree buffer. (PhilRunninger) #814 + - Fix focussing previous buffer when closing NERDTree (mrubli) #801 + - Update the docs for "NERDTreeStatusline" (lifecrisis) #796 + - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) #795 + - Revert the bugfix from pull request #785 (lifecrisis) #794 + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) #786 + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) #785 + - Add modelines (lifecrisis) #782 + - Change the type of completion used by NERDTreeFind (lifecrisis) #781 + - change NERDTreeFind with args (zhenyangze) #778 + - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) #777 + - remove useless substitute when `file =~# "/$"` (skyblueee) #773 + - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) #772 + - Make the "o" mapping consistent with "x" (lifecrisis) #769 + - Fix a problem with the "x" handler (lifecrisis) #768 + - Clean up the handler for the "x" mapping (lifecrisis) #767 + - Revert change to tab opening method (lifecrisis) #766 + - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) #765 + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759 + - Update doc with already existing mapping variables (asnr) #699 + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696 + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648 + - Remove empty segments when splitting path (sooth-sayer) #574 + - Suppress autocmds less agressively (wincent) #578 #691 - Add an Issues template to ask for more info initially. - - Fix markdown headers in readme (@josephfrazier) #676 + - Fix markdown headers in readme (josephfrazier) #676 - Don't touch @o and @h registers when rendering - - Fix bug with files and directories with dollar signs (@alegen) #649 + - Fix bug with files and directories with dollar signs (alegen) #649 - Reuse/reopen existing window trees where possible #244 - Remove NERDTree.previousBuf() - - Change color of arrow (@Leeiio) #630 - - Improved a tip in README.markdown (@ggicci) #628 - - Shorten delete confimration of empty directory to `y` (@mikeperri) #530 - - Fix API call to open directory tree in window (@devm33) #533 - - Change default arrows on non-Windows platforms (@gwilk) #546 - - Update to README - combine cd and git clone (@zwhitchcox) #584 - - Update to README - Tip: start NERDTree when vim starts (@therealplato) #593 - - Escape filename when moving an open buffer (@zacharyvoase) #595 - - Fixed incorrect :helptags command in README (@curran) #619 - - Fixed incomplete escaping of folder arrows (@adityanatraj) #548 - - Added NERDTreeCascadeSingleChildDir option (@juanibiapina) #558 + - Change color of arrow (Leeiio) #630 + - Improved a tip in README.markdown (ggicci) #628 + - Shorten delete confimration of empty directory to `y` (mikeperri) #530 + - Fix API call to open directory tree in window (devm33) #533 + - Change default arrows on non-Windows platforms (gwilk) #546 + - Update to README - combine cd and git clone (zwhitchcox) #584 + - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 + - Escape filename when moving an open buffer (zacharyvoase) #595 + - Fixed incorrect :helptags command in README (curran) #619 + - Fixed incomplete escaping of folder arrows (adityanatraj) #548 + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 - Replace strchars() with backward compatible workaround. - - Add support for copy command in Windows (@SkylerLipthay) #231 + - Add support for copy command in Windows (SkylerLipthay) #231 - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. @@ -130,14 +131,14 @@ - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - add support for custom path filters. See :help NERDTreeAddPathFilter() - add path listener API. See :help NERDTreePathListenerAPI. -- expand the fs menu functionality to list file properties (@PhilRunninger, @apbarrero, @JESii) -- make bookmarks work with `~` home shortcuts (@hiberabyss) -- show OSX specific fsmenu options in regular vim on mac (@evindor) -- make dir arrow icons configurable (@PickRelated) -- optimise node sorting performance when opening large dirs (@vtsang) -- make the root note render prettier by truncating it at a path slash (@gcmt) +- expand the fs menu functionality to list file properties (PhilRunninger, apbarrero, JESii) +- make bookmarks work with `~` home shortcuts (hiberabyss) +- show OSX specific fsmenu options in regular vim on mac (evindor) +- make dir arrow icons configurable (PickRelated) +- optimise node sorting performance when opening large dirs (vtsang) +- make the root note render prettier by truncating it at a path slash (gcmt) - remove NERDChristmasTree option - its always christmas now -- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (@pendulm) +- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) - Many other fixes, doc updates and contributions from: - @actionshrimp - @SchDen @@ -164,13 +165,13 @@ - @Twinside ### 4.2.0 -- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (@sickill) -- shift the syntax highlighting out into its own syntax file (@gnap) -- add some mac specific options to the filesystem menu - for macvim only (@andersonfreitas) -- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (@camthompson) -- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (@benjamingeiger) -- if no name is given to :Bookmark, make it default to the name of the target file/dir (@minyoung) -- use `file` completion when doing copying, create, and move operations (@EvanDotPro) +- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) +- shift the syntax highlighting out into its own syntax file (gnap) +- add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) +- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson) +- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) +- if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) +- use `file` completion when doing copying, create, and move operations (EvanDotPro) - lots of misc bug fixes from: - @paddyoloughlin - @sdewald @@ -219,17 +220,17 @@ - Bugfixes: - make the hijack netrw functionality work when vim is started with `vim ` (thanks to Alf Mikula for the patch). - fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) - - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to @tpope) - - fix bugs when ignorecase was set (thanks to @nach) - - fix a bug with the relative path code (thanks to @nach) - - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks @nach) + - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to tpope) + - fix bugs when ignorecase was set (thanks to nach) + - fix a bug with the relative path code (thanks to nach) + - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks nach) ### 3.0.1 - Bugfixes: - fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set - fix a bug where `:NERDTree ` would fail if `` was relative and didnt start with a `./` or `../` Thanks to James Kanze. - - make the `q` mapping work with secondary (`:e ` style) trees, thanks to @jamessan + - make the `q` mapping work with secondary (`:e ` style) trees, thanks to jamessan - fix a bunch of small bugs with secondary trees - More insane refactoring. diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 845f920e..3951980b 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -4,7 +4,7 @@ endif let g:loaded_nerdtree_autoload = 1 function! nerdtree#version() - return '5.1.2' + return '5.1.3' endfunction " SECTION: General Functions {{{1 From cce6fb373f368f13e35482b3f1a8f1edc47fc650 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 1 Jul 2019 22:13:20 -0400 Subject: [PATCH 511/680] Expand functionality of mapping (#1011) * Define default values for new variables governing new "Default Open". "Default Open" means to open a file with the Enter key (which of course can be changed.) The key can be changed in the vimrc, and there is a variable for specifying the Opener parameters for opening the node. This lets the user decide whether Enter (or another key) will open a file in the current tab or a new one, and whether or not to open the file again in the tab or jump to a window where the file is already open. * Remove the old mapping for , a duplicate of 'o'. will be defined like all the other keys, in plugin/NERD_tree.vim * Assign functions to the new key mapping. Three separate functions handle directories, files, and bookmarks. * Rename variables: NERDTreeCustomOpen and NERDTreeCustomOpenArgs * Add documentation for NERDTreeCustomOpenArgs and NERDTree-. * Make key mapping variables be indexed in the Vim help * Remove angle brackets from to see if help navigation improves. * Rename functions from defaultOpen... to customOpen... * Use separate options for file and directory nodes. * Update documentation for separate file/directory options. * Update version number and change log. * Change CR to in help tags. * Fix missing backtick in patch number. * Update the quickhelp text. * Update Pull Request template. * Update change log with simpler formatting of patch number. * Get NERDTree version number directly from CHANGELOG.md * Reformat the lists of contributors in the Change Log. * Initialize the version text, just in case the while loop finds nothing. --- .github/ISSUE_TEMPLATE/bug.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 16 ++--- CHANGELOG.md | 104 +++++++++++------------------ autoload/nerdtree.vim | 15 ++++- autoload/nerdtree/ui_glue.vim | 39 ++++++++++- doc/NERDTree.txt | 108 +++++++++++++++++++++---------- lib/nerdtree/creator.vim | 3 - lib/nerdtree/ui.vim | 4 +- plugin/NERD_tree.vim | 1 + 9 files changed, 170 insertions(+), 122 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 84218720..cdb8b359 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -23,7 +23,7 @@ After reading, and before submitting your issue, please remove this introductory #### Environment (for bug reports) - [ ] Operating System: - [ ] Vim/Neovim version `:version`: -- [ ] NERDTree version `git rev-parse --short HEAD`: +- [ ] NERDTree version `:echo nerdtree#version(0)` or `git rev-parse --short HEAD`: - [ ] A link to my [vimrc](), or - [ ] vimrc settings - [ ] NERDTree variables diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1a2765e2..b0acd19e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,22 +1,20 @@ - ### Description of Changes +Closes # -Closes # --- ### New Version Info - [ ] Derive a new version number. Increment the: - - [ ] `MAJOR` version when you make incompatible API changes, - - [ ] `MINOR` version when you add functionality in a backwards-compatible manner, and - - [ ] `PATCH` version when you make backwards-compatible bug fixes. -- [ ] Update version number in [autoload/nerdtree.vim](https://github.com/scrooloose/nerdtree/blob/master/autoload/nerdtree.vim#L7) -- [ ] Update the ChangeLog, following this format/example: + - [ ] `MAJOR` version when you make incompatible API changes + - [ ] `MINOR` version when you add functionality in a backwards-compatible manner + - [ ] `PATCH` version when you make backwards-compatible bug fixes +- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example: ``` - MAJOR.MINOR... + #### MAJOR.MINOR... - **.PATCH**: PR Title (Author) #PR Number - ### 5.1... + #### 5.1... - **.1**: Update Changelog and create PR Template (PhilRunninger) #1007 - **.0**: Too many changes for one patch... ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index e207f2ce..a2abaffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Change Log -### 5.1... -- **`.3`**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009 -- **`.2`**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008 -- **`.1`**: Update Changelog and create PR Template (PhilRunninger) #1007 -- **`.0`**: Too many changes for one patch... +#### 5.2... +- **.0**: Expand functionality of `` mapping. (PhilRunninger) #1011 +#### 5.1... +- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009 +- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008 +- **.1**: Update Changelog and create PR Template (PhilRunninger) #1007 +- **.0**: Too many changes for one patch... - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) #1005 - Add a "copy path to clipboard" menu option (PhilRunninger) #1002 - Enable root refresh on "vim ." a different way than #999. (PhilRunninger) #1001 @@ -122,7 +124,7 @@ - On windows default to + and ~ for expand/collapse directory symbols. - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. -### 5.0.0 +#### 5.0.0 - Refactor the code significantly: * Break the classes out into their own files. * Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods. @@ -139,32 +141,9 @@ - make the root note render prettier by truncating it at a path slash (gcmt) - remove NERDChristmasTree option - its always christmas now - add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) -- Many other fixes, doc updates and contributions from: - - @actionshrimp - - @SchDen - - @egalpin - - @cperl82 - many small fixes - - @toiffel - - @WoLpH - - @handcraftedbits - - @devmanhinton - - @xiaodili - - @zhangoose - - @gastropoda - - @mixvin - - @alvan - - @lucascaton - - @kelaban - - @shanesmith - - @staeff - - @pendulm - - @stephenprater - - @franksort - - @agrussellknives - - @AndrewRadev - - @Twinside +- Many other fixes, doc updates and contributions from: **actionshrimp**, **agrussellknives**, **alvan**, **AndrewRadev**, **cperl82** (*many small fixes*), **devmanhinton**, **egalpin**, **franksort**, **gastropoda**, **handcraftedbits**, **kelaban**, **lucascaton**, **mixvin**, **pendulm**, **SchDen**, **shanesmith**, **staeff**, **stephenprater**, **toiffel**, **Twinside**, **WoLpH**, **xiaodili**, **zhangoose** -### 4.2.0 +#### 4.2.0 - Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) - shift the syntax highlighting out into its own syntax file (gnap) - add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) @@ -172,69 +151,58 @@ - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) - if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) - use `file` completion when doing copying, create, and move operations (EvanDotPro) -- lots of misc bug fixes from: - - @paddyoloughlin - - @sdewald - - @camthompson - - @Vitaly - - @Bogdanov - - @AndrewRadev - - @mathias - - @scottstvnsn - - @kml - - @wycats - - me RAWR! +- lots of misc bug fixes from: **AndrewRadev**, **Bogdanov**, **camthompson**, **kml**, **mathias**, **paddyoloughlin**, **scottstvnsn**, **sdewald**, **Vitaly**, **wycats**, me RAWR! -### 4.1.0 +#### 4.1.0 - features: - - NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by Doug McInnes) into the script. - - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan Ritter and Rémi Prévost. - - truncate the root node if wider than the tree window. Thanks to Victor Gonzalez. + - NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by **Doug McInnes**) into the script. + - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to **Stefan Ritter** and **Rémi Prévost**. + - truncate the root node if wider than the tree window. Thanks to **Victor Gonzalez**. - bugfixes: - really fix window state restoring - - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, jfilip1024, and Chris Chambers + - fix some win32 path escaping issues. Thanks to **Stephan Baumeister**, **Ricky**, **jfilip1024**, and **Chris Chambers**. -### 4.0.0 +#### 4.0.0 - add a new programmable menu system (see `:help NERDTreeMenu`). - add new APIs to add menus/menu-items to the menu system as well as custom key mappings to the NERD tree buffer (see `:help NERDTreeAPI`). - removed the old API functions - added a mapping to maximize/restore the size of nerd tree window, thanks to Guillaume Duranceau for the patch. See :help NERDTree-A for details. -- fix a bug where secondary nerd trees (netrw hijacked trees) and 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. -- fix a bug when using the x mapping on the tree root, thanks to Bryan Venteicher for the patch. -- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to Richard Hart. +- fix a bug where secondary nerd trees (netrw hijacked trees) and 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. +- fix a bug when using the x mapping on the tree root, thanks to **Bryan Venteicher** for the patch. +- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to **Richard Hart**. - fix a bug where NERDTreeMirror would mirror the wrong tree -### 3.1.1 -- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to Derek Wyatt and owen1 +#### 3.1.1 +- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to **Derek Wyatt** and **owen1** - make `` behave the same as the `o` mapping -- some helptag fixes in the doc, thanks @strull -- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks @iElectric +- some helptag fixes in the doc, thanks **strull**. +- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks **iElectric**. - other minor fixes -### 3.1.0 +#### 3.1.0 - New features: - add mappings to open files in a vsplit, see `:help NERDTree-s` and `:help NERDTree-gs` - make the statusline for the nerd tree window default to something hopefully more useful. See `:help 'NERDTreeStatusline'` - Bugfixes: - - make the hijack netrw functionality work when vim is started with `vim ` (thanks to Alf Mikula for the patch). - - fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) - - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to tpope) - - fix bugs when ignorecase was set (thanks to nach) - - fix a bug with the relative path code (thanks to nach) - - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks nach) + - make the hijack netrw functionality work when vim is started with `vim ` (thanks to **Alf Mikula** for the patch). + - fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to **Lucas S. Buchala**) + - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to **tpope**) + - fix bugs when ignorecase was set (thanks to **nach**) + - fix a bug with the relative path code (thanks to **nach**) + - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks **nach**) -### 3.0.1 +#### 3.0.1 - Bugfixes: - fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set - - fix a bug where `:NERDTree ` would fail if `` was relative and didnt start with a `./` or `../` Thanks to James Kanze. - - make the `q` mapping work with secondary (`:e ` style) trees, thanks to jamessan + - fix a bug where `:NERDTree ` would fail if `` was relative and didnt start with a `./` or `../` Thanks to **James Kanze**. + - make the `q` mapping work with secondary (`:e ` style) trees, thanks to **jamessan** - fix a bunch of small bugs with secondary trees - More insane refactoring. -### 3.0.0 +#### 3.0.0 - hijack netrw so that doing an `:edit ` will put a NERD tree in the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' - allow sharing of trees across tabs, see `:help :NERDTreeMirror` - remove "top" and "bottom" as valid settings for NERDTreeWinPos diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3951980b..6211169c 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -3,8 +3,19 @@ if exists("g:loaded_nerdtree_autoload") endif let g:loaded_nerdtree_autoload = 1 -function! nerdtree#version() - return '5.1.3' +function! nerdtree#version(...) + let l:changelog = readfile(expand(":p:h")."/CHANGELOG.md") + let l:text = 'Unknown' + let l:line = 0 + while l:line <= len(l:changelog) + if l:changelog[l:line] =~ '\d\+\.\d\+' + let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') + let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') + break + endif + let l:line += 1 + endwhile + return l:text endfunction " SECTION: General Functions {{{1 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index a6f4ae5b..89feb59f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -14,6 +14,9 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"}) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) @@ -76,6 +79,35 @@ endfunction "SECTION: Interface bindings {{{1 "============================================================ +"FUNCTION: s:customOpenFile() {{{1 +" Open file node with the "custom" key, initially . +function! s:customOpenFile(node) + call a:node.activate(s:initCustomOpenArgs().file) +endfunction + +"FUNCTION: s:customOpenDir() {{{1 +" Open directory node with the "custom" key, initially . +function! s:customOpenDir(node) + call s:activateDirNode(a:node, s:initCustomOpenArgs().dir) +endfunction + +"FUNCTION: s:customOpenBookmark() {{{1 +" Open bookmark node with the "custom" key, initially . +function! s:customOpenBookmark(node) + if node.isDirectory + call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) + else + call a:node.activate(b:NERDTree, s:initCustomOpenArgs().file) + endif +endfunction + +"FUNCTION: s:initCustomOpenArgs() {{{1 +" Make sure NERDTreeCustomOpenArgs has needed keys +function! s:initCustomOpenArgs() + let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') +endfunction + "FUNCTION: s:activateAll() {{{1 "handle the user activating the updir line function! s:activateAll() @@ -84,15 +116,16 @@ function! s:activateAll() endif endfunction -" FUNCTION: s:activateDirNode(directoryNode) {{{1 -function! s:activateDirNode(directoryNode) +" FUNCTION: s:activateDirNode(directoryNode, options) {{{1 +" Open a directory with optional options +function! s:activateDirNode(directoryNode, ...) if a:directoryNode.isRoot() && a:directoryNode.isOpen call nerdtree#echo('cannot close tree root') return endif - call a:directoryNode.activate() + call a:directoryNode.activate((a:0 > 0) ? a:1 : {}) endfunction "FUNCTION: s:activateFileNode() {{{1 diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 93635bd0..a9ccc99e 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -247,12 +247,12 @@ i........Open selected file in a split window.......................|NERDTree-i| gi.......Same as i, but leave the cursor on the NERDTree...........|NERDTree-gi| s........Open selected file in a new vsplit.........................|NERDTree-s| gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| +.....User-definable custom open action.......................|NERDTree-| O........Recursively open the selected directory....................|NERDTree-O| x........Close the current nodes parent.............................|NERDTree-x| X........Recursively close all children of the current node.........|NERDTree-X| e........Edit the current dir.......................................|NERDTree-e| -............same as |NERDTree-o|. double-click....same as |NERDTree-o|. middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. @@ -319,7 +319,7 @@ The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see ------------------------------------------------------------------------------ *NERDTree-t* Default key: t -Map setting: NERDTreeMapOpenInTab +Map setting: *NERDTreeMapOpenInTab* Applies to: files and directories. Opens the selected file in a new tab. If a directory is selected, a fresh @@ -332,7 +332,7 @@ in a new tab. ------------------------------------------------------------------------------ *NERDTree-T* Default key: T -Map setting: NERDTreeMapOpenInTabSilent +Map setting: *NERDTreeMapOpenInTabSilent* Applies to: files and directories. The same as |NERDTree-t| except that the focus is kept in the current tab. @@ -340,7 +340,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab. ------------------------------------------------------------------------------ *NERDTree-i* Default key: i -Map setting: NERDTreeMapOpenSplit +Map setting: *NERDTreeMapOpenSplit* Applies to: files. Opens the selected file in a new split window and puts the cursor in the new @@ -349,7 +349,7 @@ window. ------------------------------------------------------------------------------ *NERDTree-gi* Default key: gi -Map setting: NERDTreeMapPreviewSplit +Map setting: *NERDTreeMapPreviewSplit* Applies to: files. The same as |NERDTree-i| except that the cursor is not moved. @@ -360,7 +360,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see ------------------------------------------------------------------------------ *NERDTree-s* Default key: s -Map setting: NERDTreeMapOpenVSplit +Map setting: *NERDTreeMapOpenVSplit* Applies to: files. Opens the selected file in a new vertically split window and puts the cursor @@ -369,7 +369,7 @@ in the new window. ------------------------------------------------------------------------------ *NERDTree-gs* Default key: gs -Map setting: NERDTreeMapPreviewVSplit +Map setting: *NERDTreeMapPreviewVSplit* Applies to: files. The same as |NERDTree-s| except that the cursor is not moved. @@ -377,10 +377,19 @@ The same as |NERDTree-s| except that the cursor is not moved. The default key combo for this mapping is "g" + NERDTreeMapOpenVSplit (see |NERDTree-s|). +------------------------------------------------------------------------------ + *NERDTree-* +Default key: +Map setting: *NERDTreeMapCustomOpen* +Applies to: files, directories, and bookmarks + +Performs a customized open action on the selected node. This allows the user +to define an action that behaves differently from any of the standard +keys. See |NERDTreeCustomOpenArgs| for more details. ------------------------------------------------------------------------------ *NERDTree-O* Default key: O -Map setting: NERDTreeMapOpenRecursively +Map setting: *NERDTreeMapOpenRecursively* Applies to: directories. Recursively opens the selected directory. @@ -393,7 +402,7 @@ cached. This is handy, especially if you have .svn directories. ------------------------------------------------------------------------------ *NERDTree-x* Default key: x -Map setting: NERDTreeMapCloseDir +Map setting: *NERDTreeMapCloseDir* Applies to: files and directories. Closes the parent of the selected node. @@ -401,7 +410,7 @@ Closes the parent of the selected node. ------------------------------------------------------------------------------ *NERDTree-X* Default key: X -Map setting: NERDTreeMapCloseChildren +Map setting: *NERDTreeMapCloseChildren* Applies to: directories. Recursively closes all children of the selected directory. @@ -411,7 +420,7 @@ Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. ------------------------------------------------------------------------------ *NERDTree-e* Default key: e -Map setting: NERDTreeMapOpenExpl +Map setting: *NERDTreeMapOpenExpl* Applies to: files and directories. |:edit|s the selected directory, or the selected file's directory. This could @@ -421,7 +430,7 @@ result in a NERDTree or a netrw being opened, depending on ------------------------------------------------------------------------------ *NERDTree-D* Default key: D -Map setting: NERDTreeMapDeleteBookmark +Map setting: *NERDTreeMapDeleteBookmark* Applies to: lines in the bookmarks table Deletes the currently selected bookmark. @@ -429,7 +438,7 @@ Deletes the currently selected bookmark. ------------------------------------------------------------------------------ *NERDTree-P* Default key: P -Map setting: NERDTreeMapJumpRoot +Map setting: *NERDTreeMapJumpRoot* Applies to: no restrictions. Jump to the tree root. @@ -437,7 +446,7 @@ Jump to the tree root. ------------------------------------------------------------------------------ *NERDTree-p* Default key: p -Map setting: NERDTreeMapJumpParent +Map setting: *NERDTreeMapJumpParent* Applies to: files and directories. Jump to the parent node of the selected node. @@ -445,7 +454,7 @@ Jump to the parent node of the selected node. ------------------------------------------------------------------------------ *NERDTree-K* Default key: K -Map setting: NERDTreeMapJumpFirstChild +Map setting: *NERDTreeMapJumpFirstChild* Applies to: files and directories. Jump to the first child of the current nodes parent. @@ -458,7 +467,7 @@ If the cursor is already on the first node then do the following: ------------------------------------------------------------------------------ *NERDTree-J* Default key: J -Map setting: NERDTreeMapJumpLastChild +Map setting: *NERDTreeMapJumpLastChild* Applies to: files and directories. Jump to the last child of the current nodes parent. @@ -471,7 +480,7 @@ If the cursor is already on the last node then do the following: ------------------------------------------------------------------------------ *NERDTree-C-J* Default key: -Map setting: NERDTreeMapJumpNextSibling +Map setting: *NERDTreeMapJumpNextSibling* Applies to: files and directories. Jump to the next sibling of the selected node. @@ -479,7 +488,7 @@ Jump to the next sibling of the selected node. ------------------------------------------------------------------------------ *NERDTree-C-K* Default key: -Map setting: NERDTreeMapJumpPrevSibling +Map setting: *NERDTreeMapJumpPrevSibling* Applies to: files and directories. Jump to the previous sibling of the selected node. @@ -487,7 +496,7 @@ Jump to the previous sibling of the selected node. ------------------------------------------------------------------------------ *NERDTree-C* Default key: C -Map setting: NERDTreeMapChangeRoot +Map setting: *NERDTreeMapChangeRoot* Applies to: files and directories. Make the selected directory node the new tree root. If a file is selected, its @@ -496,7 +505,7 @@ parent is used. ------------------------------------------------------------------------------ *NERDTree-u* Default key: u -Map setting: NERDTreeMapUpdir +Map setting: *NERDTreeMapUpdir* Applies to: no restrictions. Move the tree root up a dir (like doing a "cd .."). @@ -504,7 +513,7 @@ Move the tree root up a dir (like doing a "cd .."). ------------------------------------------------------------------------------ *NERDTree-U* Default key: U -Map setting: NERDTreeMapUpdirKeepOpen +Map setting: *NERDTreeMapUpdirKeepOpen* Applies to: no restrictions. Like |NERDTree-u| except that the old tree root is kept open. @@ -512,7 +521,7 @@ Like |NERDTree-u| except that the old tree root is kept open. ------------------------------------------------------------------------------ *NERDTree-r* Default key: r -Map setting: NERDTreeMapRefresh +Map setting: *NERDTreeMapRefresh* Applies to: files and directories. If a dir is selected, recursively refresh that dir, i.e. scan the filesystem @@ -523,7 +532,7 @@ If a file node is selected then the above is done on it's parent. ------------------------------------------------------------------------------ *NERDTree-R* Default key: R -Map setting: NERDTreeMapRefreshRoot +Map setting: *NERDTreeMapRefreshRoot* Applies to: no restrictions. Recursively refresh the tree root. @@ -531,7 +540,7 @@ Recursively refresh the tree root. ------------------------------------------------------------------------------ *NERDTree-m* Default key: m -Map setting: NERDTreeMapMenu +Map setting: *NERDTreeMapMenu* Applies to: files and directories. Display the NERDTree menu. See |NERDTreeMenu| for details. @@ -539,7 +548,7 @@ Display the NERDTree menu. See |NERDTreeMenu| for details. ------------------------------------------------------------------------------ *NERDTree-cd* Default key: cd -Map setting: NERDTreeMapChdir +Map setting: *NERDTreeMapChdir* Applies to: files and directories. Change Vim's current working directory to that of the selected node. @@ -547,7 +556,7 @@ Change Vim's current working directory to that of the selected node. ------------------------------------------------------------------------------ *NERDTree-CD* Default key: CD -Map setting: NERDTreeMapCWD +Map setting: *NERDTreeMapCWD* Applies to: no restrictions. Change the NERDTree root to Vim's current working directory. @@ -555,7 +564,7 @@ Change the NERDTree root to Vim's current working directory. ------------------------------------------------------------------------------ *NERDTree-I* Default key: I -Map setting: NERDTreeMapToggleHidden +Map setting: *NERDTreeMapToggleHidden* Applies to: no restrictions. Toggles whether hidden files (i.e. "dot files") are displayed. @@ -563,7 +572,7 @@ Toggles whether hidden files (i.e. "dot files") are displayed. ------------------------------------------------------------------------------ *NERDTree-f* Default key: f -Map setting: NERDTreeMapToggleFilters +Map setting: *NERDTreeMapToggleFilters* Applies to: no restrictions. Toggles whether file filters are used. See |NERDTreeIgnore| for details. @@ -571,7 +580,7 @@ Toggles whether file filters are used. See |NERDTreeIgnore| for details. ------------------------------------------------------------------------------ *NERDTree-F* Default key: F -Map setting: NERDTreeMapToggleFiles +Map setting: *NERDTreeMapToggleFiles* Applies to: no restrictions. Toggles whether file nodes are displayed. @@ -579,7 +588,7 @@ Toggles whether file nodes are displayed. ------------------------------------------------------------------------------ *NERDTree-B* Default key: B -Map setting: NERDTreeMapToggleBookmarks +Map setting: *NERDTreeMapToggleBookmarks* Applies to: no restrictions. Toggles whether the bookmarks table is displayed. @@ -587,7 +596,7 @@ Toggles whether the bookmarks table is displayed. ------------------------------------------------------------------------------ *NERDTree-q* Default key: q -Map setting: NERDTreeMapQuit +Map setting: *NERDTreeMapQuit* Applies to: no restrictions. Closes the NERDTree window. @@ -595,7 +604,7 @@ Closes the NERDTree window. ------------------------------------------------------------------------------ *NERDTree-A* Default key: A -Map setting: NERDTreeMapToggleZoom +Map setting: *NERDTreeMapToggleZoom* Applies to: no restrictions. Maximize (zoom) and minimize the NERDTree window. @@ -603,7 +612,7 @@ Maximize (zoom) and minimize the NERDTree window. ------------------------------------------------------------------------------ *NERDTree-?* Default key: ? -Map setting: NERDTreeMapHelp +Map setting: *NERDTreeMapHelp* Applies to: no restrictions. Toggles whether the quickhelp is displayed. @@ -625,7 +634,7 @@ Related tags: |NERDTree-m| |NERDTreeApi| ------------------------------------------------------------------------------ *NERDTreeMenu-j* Default key: j -Map option: NERDTreeMenuDown +Map option: *NERDTreeMenuDown* Applies to: The NERDTree menu. Moves the cursor down. @@ -633,7 +642,7 @@ Moves the cursor down. ------------------------------------------------------------------------------ *NERDTreeMenu-k* Default key: k -Map option: NERDTreeMenuUp +Map option: *NERDTreeMenuUp* Applies to: The NERDTree menu. Moves the cursor up. @@ -754,6 +763,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`. file or directory name from the rest of the characters on the line of text. +|NERDTreeCustomOpenArgs| A dictionary with values that control how a node + is opened with the |NERDTree-| key. + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeSettingsDetails* @@ -1233,6 +1245,32 @@ when specifying by hex or Unicode. > let NERDTreeNodeDelimiter="\u00a0" "non-breaking space let NERDTreeNodeDelimiter="😀" "smiley face < +------------------------------------------------------------------------------ + *NERDTreeCustomOpenArgs* +Values: A nested dictionary, as described below +Default: {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} + +This dictionary contains two keys, 'file' and 'dir', whose values each are +another dictionary. The inner dictionary is a set of parameters used by +|NERDTree-| to open a file or directory. Setting these parameters allows you +to customize the way the node is opened. The default value matches what +|NERDTree-o| does. To change that behavior, use these keys and +values in the inner dictionaries: + +'where': specifies whether the node should be opened in a new split ("h" or + "v"), in a new tab ("t") or, in the last window ("p"). +'reuse': if file is already shown in a window, jump there; takes values + "all", "currenttab", or empty +'keepopen': boolean (0 or 1); if true, the tree window will not be closed +'stay': boolean (0 or 1); if true, remain in tree window after opening + +For example: +To open files and directories (creating a new NERDTree) in a new tab, > + {'file':{'where': 't'}, 'dir':{'where':'t'}} +< +To open a file always in the current tab, and expand directories in place, > + {'file': {'reuse':'currenttab', 'where':'p', 'keepopen':1, 'stay':1}} +< ============================================================================== 4. The NERDTree API *NERDTreeAPI* diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 987e02ec..efd3cc81 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -13,9 +13,6 @@ let g:NERDTreeCreator = s:Creator " FUNCTION: s:Creator._bindMappings() {{{1 function! s:Creator._bindMappings() - "make do the same as the activate node mapping - nnoremap :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode) - call g:NERDTreeKeyMap.BindAll() command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 227615b5..3aa5959f 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -28,7 +28,6 @@ function! s:UI._dumpHelp() let help .= "\" ============================\n" let help .= "\" File node mappings~\n" let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" - let help .= "\" ,\n" if self.nerdtree.isTabTree() let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n" else @@ -44,6 +43,7 @@ function! s:UI._dumpHelp() let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n" let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Directory node mappings~\n" @@ -52,6 +52,7 @@ function! s:UI._dumpHelp() let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" let help .= "\" current node recursively\n" @@ -66,6 +67,7 @@ function! s:UI._dumpHelp() let help .= "\" ". g:NERDTreeMapPreview .": find dir in tree\n" let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" let help .= "\"\n\" ----------------------------\n" diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 595e780b..a8e26d4e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -121,6 +121,7 @@ endif "SECTION: Init variable calls for key mappings {{{2 +call s:initVariable("g:NERDTreeMapCustomOpen", "") call s:initVariable("g:NERDTreeMapActivateNode", "o") call s:initVariable("g:NERDTreeMapChangeRoot", "C") call s:initVariable("g:NERDTreeMapChdir", "cd") From ca16df25fa1d6bc8505aadbc19f8cd95afa9a58d Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 1 Jul 2019 23:29:56 -0400 Subject: [PATCH 512/680] Fix nerdtree#version() on Windows. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2abaffd..8d2a5310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A - **.0**: Expand functionality of `` mapping. (PhilRunninger) #1011 #### 5.1... - **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009 diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 6211169c..20ef1beb 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -3,8 +3,9 @@ if exists("g:loaded_nerdtree_autoload") endif let g:loaded_nerdtree_autoload = 1 +let s:rootNERDTreePath = resolve(expand(":p:h:h")) function! nerdtree#version(...) - let l:changelog = readfile(expand(":p:h")."/CHANGELOG.md") + let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) let l:text = 'Unknown' let l:line = 0 while l:line <= len(l:changelog) @@ -21,6 +22,19 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +function! nerdtree#slash() + + if nerdtree#runningWindows() + if exists('+shellslash') && &shellslash + return '/' + endif + + return '\' + endif + + return '/' +endfunction + "FUNCTION: nerdtree#and(x,y) {{{2 " Implements and() function for Vim <= 7.2 function! nerdtree#and(x,y) From 06c9d9c963d0ffbbf3e49b4fe5dd209df2636db6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 2 Jul 2019 15:45:36 -0400 Subject: [PATCH 513/680] Make Enter work on the `.. ( up a dir )` line (#1013) * Make Enter work on the `.. ( up a dir )` line. * Simpler instructions for getting bug info. * Update changelog. --- .github/ISSUE_TEMPLATE/bug.md | 5 ++--- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index cdb8b359..88ffdf36 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -22,9 +22,8 @@ After reading, and before submitting your issue, please remove this introductory #### Environment (for bug reports) - [ ] Operating System: -- [ ] Vim/Neovim version `:version`: -- [ ] NERDTree version `:echo nerdtree#version(0)` or `git rev-parse --short HEAD`: -- [ ] A link to my [vimrc](), or +- [ ] Vim/Neovim version `:echo v:version`: +- [ ] NERDTree version, found on 1st line in NERDTree quickhelp `?`: - [ ] vimrc settings - [ ] NERDTree variables ```vim diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d2a5310..03dc27a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013 - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A - **.0**: Expand functionality of `` mapping. (PhilRunninger) #1011 #### 5.1... diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 89feb59f..057e799e 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -17,6 +17,7 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"}) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"}) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s."activateAll" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) From aef6baf6e2513f43d8b789bdc087898c82608a5f Mon Sep 17 00:00:00 2001 From: Kebin Liu Date: Wed, 3 Jul 2019 23:11:25 +0800 Subject: [PATCH 514/680] Update ui_glue.vim (#1014) Fix `` key map on the bookmark --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 057e799e..045e8adf 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -95,7 +95,7 @@ endfunction "FUNCTION: s:customOpenBookmark() {{{1 " Open bookmark node with the "custom" key, initially . function! s:customOpenBookmark(node) - if node.isDirectory + if a:node.path.isDirectory call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) else call a:node.activate(b:NERDTree, s:initCustomOpenArgs().file) From 62b78de3674de8e3d294ab2a5e6ce98d1ad35f20 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 3 Jul 2019 11:12:21 -0400 Subject: [PATCH 515/680] Update Change Log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03dc27a7..6b804bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.3**: Fix `` key map on the bookmark (lkebin) #1014 - **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013 - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A - **.0**: Expand functionality of `` mapping. (PhilRunninger) #1011 From 89a1a4355bd9572d0f5b3d23733c243c6e7b05c2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 4 Jul 2019 00:21:50 -0400 Subject: [PATCH 516/680] When searching for root line num, stop at the end of the file. (#1015) * When searching for root line num, stop at the end of the file. When using the following NERDTreeStatusLine, Vim would lock up and not work anymore. The problem was that when trying to find the root line number, the loop was continuing past the end of the file, looping "forever". The fix was to simply stop at the end of the file. let g:NERDTreeStatusline = "%{exists('g:NERDTreeFileNode')&&" . \ "has_key(g:NERDTreeFileNode.GetSelected(),'path')?" . \ "g:NERDTreeFileNode.GetSelected().path.getLastPathComponent(0):''}" * Update change log. --- CHANGELOG.md | 1 + lib/nerdtree/ui.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b804bdd..2273aa49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) #1015 - **.3**: Fix `` key map on the bookmark (lkebin) #1014 - **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013 - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 3aa5959f..97f95d93 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -254,7 +254,7 @@ endfunction " gets the line number of the root node function! s:UI.getRootLineNum() let rootLine = 1 - while getline(rootLine) !~# '^\(/\|<\)' + while rootLine <= line('$') && getline(rootLine) !~# '^\(/\|<\)' let rootLine = rootLine + 1 endwhile return rootLine From 3b1a850b85a1b160817c35872bf1978f112958bf Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 7 Jul 2019 03:19:17 -0400 Subject: [PATCH 517/680] Use :mode instead of :redraw! when updating menu. (#1016) * Use :mode instead of :redraw! when updating screen. In neovim, it will actually clear the whole screen, whereas, redraw! does not. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/menu_controller.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2273aa49..ad030a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) #1016 - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) #1015 - **.3**: Fix `` key map on the bookmark (lkebin) #1014 - **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013 diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 26dbd296..1182c539 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -31,7 +31,7 @@ function! s:MenuController.showMenu() let l:done = 0 while !l:done - redraw! + mode call self._echoPrompt() let l:key = nr2char(getchar()) From a460d6ef7f12b845eb18b8d138d07640fc5f24c1 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 7 Jul 2019 03:50:59 -0400 Subject: [PATCH 518/680] In CHANGELOG.md and PR template, make reference to PR a true HTML link. (#1017) --- .github/PULL_REQUEST_TEMPLATE.md | 4 +- CHANGELOG.md | 234 +++++++++++++++---------------- 2 files changed, 119 insertions(+), 119 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b0acd19e..df723654 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,9 +12,9 @@ Closes # - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example: ``` #### MAJOR.MINOR... - - **.PATCH**: PR Title (Author) #PR Number + - **.PATCH**: PR Title (Author) [#PR Number](link to PR) #### 5.1... - - **.1**: Update Changelog and create PR Template (PhilRunninger) #1007 + - **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) - **.0**: Too many changes for one patch... ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index ad030a62..419600af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,130 +1,130 @@ # Change Log #### 5.2... -- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) #1016 -- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) #1015 -- **.3**: Fix `` key map on the bookmark (lkebin) #1014 -- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) #1013 -- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) N/A -- **.0**: Expand functionality of `` mapping. (PhilRunninger) #1011 +- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) +- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) +- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) +- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013) +- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) +- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) #### 5.1... -- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009 -- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008 -- **.1**: Update Changelog and create PR Template (PhilRunninger) #1007 +- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009) +- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008) +- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) - **.0**: Too many changes for one patch... - - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) #1005 - - Add a "copy path to clipboard" menu option (PhilRunninger) #1002 - - Enable root refresh on "vim ." a different way than #999. (PhilRunninger) #1001 - - Fix refreshroot (PhilRunninger) #999 - - Change version check to look for 703 not 730 (vhalis) #994 - - Change minimum vim (PhilRunninger) #991 - - Allow multi-character DirArrows (PhilRunninger) #985 - - Remove redraw! while still clearing last message empty string. (PhilRunninger) #979 - - fix _initChildren function value set to numChildrenCached error (terryding77) #969 - - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) #967 - - Remove the "Please wait... DONE" messages. (PhilRunninger) #966 - - Smarter delimiter default (PhilRunninger) #963 - - Update directory .vimdc readme example (spencerdcarlson) #961 - - Preview bookmarks (PhilRunninger) #956 - - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) #955 - - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) #954 - - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) #952 - - Set a maximum window size when zooming. (PhilRunninger) #950 - - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) #949 - - Escape a backslash so it can be used in a key mapping. (PhilRunninger) #948 - - Add a NERDTreeMinimalMenu feature (tuzz) #938 - - fixed root path error for windows (zcodes) #935 - - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) #929 - - Document NERDTreeNodeDelimiter #912 (PhilRunninger) #926 - - Allow modification of menu keybindings (Leandros) #923 - - Add two more disqualifications for isCascadable(). (PhilRunninger) #914 - - Allow highlighting more than one flag. (kristijanhusak) #908 - - Support sorting files and directories by modification time. (PhilRunninger) #901 - - Parse . and .. from path string with trailing slash. (PhilRunninger) #899 - - Force sort to recalculate the cached sortKey. (PhilRunninger) #898 - - Add NERDTreeRefreshRoot command (wgfm) #897 - - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) #896 - - Catch all errors, not just NERDTree errors. (PhilRunninger) #894 - - Fix typo in help file (lvoisin) #892 - - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) #889 - - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) #888 - - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) #887 - - Fix the / motions, which currently fail with cascades (lifecrisis) #886 - - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) #882 - - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) #878 - - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) #877 - - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) #875 - - Fix opening sub-directories that have commas in their name. (PhilRunninger) #873 - - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) #872 - - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) #871 - - Unzoom NERDTree when opening a file (PhilRunninger) #870 - - Support unusual characters in file and directory names (PhilRunninger) #868 - - Reword renamed-buffer prompt to be more clear (aflock) #867 - - Default to placing cursor on root when closing bookmark table (lifecrisis) #866 - - Fix issues with sorting of nodes (PhilRunninger) #856 - - Better OSX detection (bubba-h57) #853 - - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) #852 - - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) #851 - - Add code to sort mappings in quickhelp (lifecrisis) #849 - - Use ":clearjumps" in new NERDTree windows (lifecrisis) #844 - - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) #840 - - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) #838 - - Make the NERDTree buffer writable when rendering it. (PhilRunninger) #837 - - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) #835 - - Replace strcharpart() with substitute() for backward compatibility (bravestarr) #834 - - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) #833 - - Clear output when NERDTree menu is aborted (lifecrisis) #832 - - Display a path with multi-byte characters correctly when it is truncated (bravestarr) #830 - - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) #824 - - If node isn't open, count children on disk before deleting. (PhilRunninger) #822 - - Add new variable g:NERDTreeRemoveFileCmd (kutsan) #816 - - Use a better check for existence of the NERDTree buffer. (PhilRunninger) #814 - - Fix focussing previous buffer when closing NERDTree (mrubli) #801 - - Update the docs for "NERDTreeStatusline" (lifecrisis) #796 - - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) #795 - - Revert the bugfix from pull request #785 (lifecrisis) #794 - - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) #786 - - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) #785 - - Add modelines (lifecrisis) #782 - - Change the type of completion used by NERDTreeFind (lifecrisis) #781 - - change NERDTreeFind with args (zhenyangze) #778 - - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) #777 - - remove useless substitute when `file =~# "/$"` (skyblueee) #773 - - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) #772 - - Make the "o" mapping consistent with "x" (lifecrisis) #769 - - Fix a problem with the "x" handler (lifecrisis) #768 - - Clean up the handler for the "x" mapping (lifecrisis) #767 - - Revert change to tab opening method (lifecrisis) #766 - - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) #765 - - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) #759 - - Update doc with already existing mapping variables (asnr) #699 - - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) #696 - - Correct NERDTreeIgnore pattern in doc (cntoplolicon) #648 - - Remove empty segments when splitting path (sooth-sayer) #574 - - Suppress autocmds less agressively (wincent) #578 #691 + - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/scrooloose/nerdtree/pull/1005) + - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/scrooloose/nerdtree/pull/1002) + - Enable root refresh on "vim ." a different way than [#999](https://github.com/scrooloose/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/scrooloose/nerdtree/pull/1001) + - Fix refreshroot (PhilRunninger) [#999](https://github.com/scrooloose/nerdtree/pull/999) + - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/scrooloose/nerdtree/pull/994) + - Change minimum vim (PhilRunninger) [#991](https://github.com/scrooloose/nerdtree/pull/991) + - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/scrooloose/nerdtree/pull/985) + - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/scrooloose/nerdtree/pull/979) + - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/scrooloose/nerdtree/pull/969) + - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/scrooloose/nerdtree/pull/967) + - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/scrooloose/nerdtree/pull/966) + - Smarter delimiter default (PhilRunninger) [#963](https://github.com/scrooloose/nerdtree/pull/963) + - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/scrooloose/nerdtree/pull/961) + - Preview bookmarks (PhilRunninger) [#956](https://github.com/scrooloose/nerdtree/pull/956) + - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/scrooloose/nerdtree/pull/955) + - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/scrooloose/nerdtree/pull/954) + - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/scrooloose/nerdtree/pull/952) + - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/scrooloose/nerdtree/pull/950) + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/scrooloose/nerdtree/pull/949) + - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/scrooloose/nerdtree/pull/948) + - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/scrooloose/nerdtree/pull/938) + - fixed root path error for windows (zcodes) [#935](https://github.com/scrooloose/nerdtree/pull/935) + - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/scrooloose/nerdtree/pull/929) + - Document NERDTreeNodeDelimiter [#912](https://github.com/scrooloose/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/scrooloose/nerdtree/pull/926) + - Allow modification of menu keybindings (Leandros) [#923](https://github.com/scrooloose/nerdtree/pull/923) + - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/scrooloose/nerdtree/pull/914) + - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/scrooloose/nerdtree/pull/908) + - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/scrooloose/nerdtree/pull/901) + - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/scrooloose/nerdtree/pull/899) + - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/scrooloose/nerdtree/pull/898) + - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/scrooloose/nerdtree/pull/897) + - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/scrooloose/nerdtree/pull/896) + - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/scrooloose/nerdtree/pull/894) + - Fix typo in help file (lvoisin) [#892](https://github.com/scrooloose/nerdtree/pull/892) + - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/scrooloose/nerdtree/pull/889) + - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/scrooloose/nerdtree/pull/888) + - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/scrooloose/nerdtree/pull/887) + - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/scrooloose/nerdtree/pull/886) + - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/scrooloose/nerdtree/pull/882) + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/scrooloose/nerdtree/pull/878) + - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/scrooloose/nerdtree/pull/877) + - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/scrooloose/nerdtree/pull/875) + - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/scrooloose/nerdtree/pull/873) + - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/scrooloose/nerdtree/pull/872) + - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/scrooloose/nerdtree/pull/871) + - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/scrooloose/nerdtree/pull/870) + - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/scrooloose/nerdtree/pull/868) + - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/scrooloose/nerdtree/pull/867) + - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/scrooloose/nerdtree/pull/866) + - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/scrooloose/nerdtree/pull/856) + - Better OSX detection (bubba-h57) [#853](https://github.com/scrooloose/nerdtree/pull/853) + - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/scrooloose/nerdtree/pull/852) + - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/scrooloose/nerdtree/pull/851) + - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/scrooloose/nerdtree/pull/849) + - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/scrooloose/nerdtree/pull/844) + - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/scrooloose/nerdtree/pull/840) + - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/scrooloose/nerdtree/pull/838) + - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/scrooloose/nerdtree/pull/837) + - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/scrooloose/nerdtree/pull/835) + - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/scrooloose/nerdtree/pull/834) + - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/scrooloose/nerdtree/pull/833) + - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/scrooloose/nerdtree/pull/832) + - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/scrooloose/nerdtree/pull/830) + - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/scrooloose/nerdtree/pull/824) + - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/scrooloose/nerdtree/pull/822) + - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/scrooloose/nerdtree/pull/816) + - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/scrooloose/nerdtree/pull/814) + - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/scrooloose/nerdtree/pull/801) + - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/scrooloose/nerdtree/pull/796) + - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/scrooloose/nerdtree/pull/795) + - Revert the bugfix from pull request [#785](https://github.com/scrooloose/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/scrooloose/nerdtree/pull/794) + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/scrooloose/nerdtree/pull/786) + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/scrooloose/nerdtree/pull/785) + - Add modelines (lifecrisis) [#782](https://github.com/scrooloose/nerdtree/pull/782) + - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/scrooloose/nerdtree/pull/781) + - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/scrooloose/nerdtree/pull/778) + - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/scrooloose/nerdtree/pull/777) + - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/scrooloose/nerdtree/pull/773) + - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/scrooloose/nerdtree/pull/772) + - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/scrooloose/nerdtree/pull/769) + - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/scrooloose/nerdtree/pull/768) + - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/scrooloose/nerdtree/pull/767) + - Revert change to tab opening method (lifecrisis) [#766](https://github.com/scrooloose/nerdtree/pull/766) + - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/scrooloose/nerdtree/pull/765) + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/scrooloose/nerdtree/pull/759) + - Update doc with already existing mapping variables (asnr) [#699](https://github.com/scrooloose/nerdtree/pull/699) + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/scrooloose/nerdtree/pull/696) + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/scrooloose/nerdtree/pull/648) + - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/scrooloose/nerdtree/pull/574) + - Suppress autocmds less agressively (wincent) [#578](https://github.com/scrooloose/nerdtree/pull/578) [#691](https://github.com/scrooloose/nerdtree/pull/691) - Add an Issues template to ask for more info initially. - - Fix markdown headers in readme (josephfrazier) #676 - - Don't touch @o and @h registers when rendering - - Fix bug with files and directories with dollar signs (alegen) #649 - - Reuse/reopen existing window trees where possible #244 + - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/scrooloose/nerdtree/pull/676) + - Don't touch `@o` and `@h` registers when rendering + - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/scrooloose/nerdtree/pull/649) + - Reuse/reopen existing window trees where possible [#244](https://github.com/scrooloose/nerdtree/pull/244) - Remove NERDTree.previousBuf() - - Change color of arrow (Leeiio) #630 - - Improved a tip in README.markdown (ggicci) #628 - - Shorten delete confimration of empty directory to `y` (mikeperri) #530 - - Fix API call to open directory tree in window (devm33) #533 - - Change default arrows on non-Windows platforms (gwilk) #546 - - Update to README - combine cd and git clone (zwhitchcox) #584 - - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 - - Escape filename when moving an open buffer (zacharyvoase) #595 - - Fixed incorrect :helptags command in README (curran) #619 - - Fixed incomplete escaping of folder arrows (adityanatraj) #548 - - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 + - Change color of arrow (Leeiio) [#630](https://github.com/scrooloose/nerdtree/pull/630) + - Improved a tip in README.markdown (ggicci) [#628](https://github.com/scrooloose/nerdtree/pull/628) + - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/scrooloose/nerdtree/pull/530) + - Fix API call to open directory tree in window (devm33) [#533](https://github.com/scrooloose/nerdtree/pull/533) + - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/scrooloose/nerdtree/pull/546) + - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/scrooloose/nerdtree/pull/584) + - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/scrooloose/nerdtree/pull/593) + - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/scrooloose/nerdtree/pull/595) + - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/scrooloose/nerdtree/pull/619) + - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/scrooloose/nerdtree/pull/548) + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/scrooloose/nerdtree/pull/558) - Replace strchars() with backward compatible workaround. - - Add support for copy command in Windows (SkylerLipthay) #231 + - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/scrooloose/nerdtree/pull/231) - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. - - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) + - Display cascading dirs on one line to save vertical/horizontal space (matt-gardner: brainstorming/testing) - Remove the old style UI - Remove `NERDTreeDirArrows` option. - On windows default to + and ~ for expand/collapse directory symbols. - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. @@ -133,7 +133,7 @@ - Refactor the code significantly: * Break the classes out into their own files. * Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods. -- Add an API to assign flags to nodes. This allows VCS plugins like https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to @Xuyuanp for helping design/test/build said API. +- Add an API to assign flags to nodes. This allows VCS plugins like https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to **Xuyuanp** for helping design/test/build said API. - add `scope` argument to the key map API see :help NERDTreeAddKeyMap() - add magic [[dir]] and [[file]] flags to NERDTreeIgnore - add support for custom path filters. See :help NERDTreeAddPathFilter() From 2f0d48d632dc303095084b382cb665ae57ad2e63 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sun, 7 Jul 2019 03:53:06 -0400 Subject: [PATCH 519/680] Update version in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 419600af..58a23bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) - **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) From 4ac07f52a312a24d82deba715ee489e6c5b00259 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 10 Jul 2019 09:45:58 -0400 Subject: [PATCH 520/680] Use :mode only in neovim. MacVim still needs to use :redraw! (#1019) * Use :mode only in neovim. MacVim still needs to use :redraw! * Make nerdtree#redraw do both redraw and redraw! based on a parameter. * Make bang a required parameter. * Replace all redraw statments with call nerdtree#redraw function calls. * Update version in change log. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 20 ++++++++++++++++++-- autoload/nerdtree/ui_glue.vim | 6 +++--- lib/nerdtree/menu_controller.vim | 4 ++-- nerdtree_plugin/fs_menu.vim | 10 +++++----- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58a23bf1..232fe7b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) - **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 20ef1beb..d4418591 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -22,8 +22,24 @@ endfunction " SECTION: General Functions {{{1 "============================================================ -function! nerdtree#slash() +"FUNCTION: nerdtree#redraw(bang) +" Redraws the screen (Neovim uses the mode statement). If bang is TRUE, use +" redraw! instead of redraw. +function! nerdtree#redraw(bang) + if has('nvim') + mode + else + if a:bang + redraw! + else + redraw + endif + endif +endfunction +"FUNCTION: nerdtree#slash() +" Returns the directory separator based on OS and &shellslash +function! nerdtree#slash() if nerdtree#runningWindows() if exists('+shellslash') && &shellslash return '/' @@ -216,7 +232,7 @@ endfunction "Args: "msg: the message to echo function! nerdtree#echo(msg) - redraw + call nerdtree#redraw(0) echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg) endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 045e8adf..76572fd6 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -254,7 +254,7 @@ function! s:deleteBookmark(bookmark) let l:choices = "&Yes\n&No" - echo | redraw + echo | call nerdtree#redraw(0) let l:selection = confirm(l:message, l:choices, 1, 'Warning') if l:selection != 1 @@ -266,7 +266,7 @@ function! s:deleteBookmark(bookmark) call a:bookmark.delete() silent call b:NERDTree.root.refresh() call b:NERDTree.render() - echo | redraw + echo | call nerdtree#redraw(0) catch /^NERDTree/ call nerdtree#echoWarning('could not remove bookmark') endtry @@ -577,7 +577,7 @@ function! s:refreshRoot() call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call b:NERDTree.root.refresh() call b:NERDTree.render() - redraw + call nerdtree#redraw(0) call nerdtree#exec(l:curWin . "wincmd w") call nerdtree#echo("") endfunction diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 1182c539..f0272496 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -31,7 +31,7 @@ function! s:MenuController.showMenu() let l:done = 0 while !l:done - mode + call nerdtree#redraw(1) call self._echoPrompt() let l:key = nr2char(getchar()) @@ -42,7 +42,7 @@ function! s:MenuController.showMenu() " Redraw when "Ctrl-C" or "Esc" is received. if !l:done || self.selection == -1 - redraw! + call nerdtree#redraw(1) endif endtry diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 5c37e4d0..4ba653f7 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -78,7 +78,7 @@ function! s:inputPrompt(action) endif if g:NERDTreeMenuController.isMinimal() - redraw! " Clear the menu + call nerdtree#redraw(1) " Clear the menu return minimal . " " else let divider = "==========================================================" @@ -185,7 +185,7 @@ function! NERDTreeAddNode() call newTreeNode.putCursorHere(1, 0) endif - redraw! + call nerdtree#redraw(1) catch /^NERDTree/ call nerdtree#echoWarning("Node Not Created.") endtry @@ -234,7 +234,7 @@ function! NERDTreeMoveNode() call curNode.putCursorHere(1, 0) - redraw! + call nerdtree#redraw(1) catch /^NERDTree/ call nerdtree#echoWarning("Node Not Renamed.") endtry @@ -272,7 +272,7 @@ function! NERDTreeDeleteNode() call s:promptToDelBuffer(bufnum, prompt) endif - redraw! + call nerdtree#redraw(1) catch /^NERDTree/ call nerdtree#echoWarning("Could not remove node") endtry @@ -362,7 +362,7 @@ function! NERDTreeCopyNode() call nerdtree#echo("Copy aborted.") endif let &shellslash = l:shellslash - redraw! + call nerdtree#redraw(1) endfunction " FUNCTION: NERDTreeCopyPath() {{{1 From 63c59208c1f9eef7068a944f5c3033bd1a348b97 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 14 Jul 2019 15:17:56 -0400 Subject: [PATCH 521/680] Revert #1019 to fix nvim artifacts and flickering. (#1021) * Revert "Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)" This reverts commit 4ac07f52a312a24d82deba715ee489e6c5b00259. * If not Neovim, use `:redraw!` as was done before. * Update version number. * Fix punctuation in NERDTree Menu instructions. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 20 ++------------------ autoload/nerdtree/ui_glue.vim | 6 +++--- lib/nerdtree/menu_controller.vim | 10 +++++++--- nerdtree_plugin/fs_menu.vim | 10 +++++----- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 232fe7b4..562ceee7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) - **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) - **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d4418591..20ef1beb 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -22,24 +22,8 @@ endfunction " SECTION: General Functions {{{1 "============================================================ -"FUNCTION: nerdtree#redraw(bang) -" Redraws the screen (Neovim uses the mode statement). If bang is TRUE, use -" redraw! instead of redraw. -function! nerdtree#redraw(bang) - if has('nvim') - mode - else - if a:bang - redraw! - else - redraw - endif - endif -endfunction - -"FUNCTION: nerdtree#slash() -" Returns the directory separator based on OS and &shellslash function! nerdtree#slash() + if nerdtree#runningWindows() if exists('+shellslash') && &shellslash return '/' @@ -232,7 +216,7 @@ endfunction "Args: "msg: the message to echo function! nerdtree#echo(msg) - call nerdtree#redraw(0) + redraw echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg) endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 76572fd6..045e8adf 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -254,7 +254,7 @@ function! s:deleteBookmark(bookmark) let l:choices = "&Yes\n&No" - echo | call nerdtree#redraw(0) + echo | redraw let l:selection = confirm(l:message, l:choices, 1, 'Warning') if l:selection != 1 @@ -266,7 +266,7 @@ function! s:deleteBookmark(bookmark) call a:bookmark.delete() silent call b:NERDTree.root.refresh() call b:NERDTree.render() - echo | call nerdtree#redraw(0) + echo | redraw catch /^NERDTree/ call nerdtree#echoWarning('could not remove bookmark') endtry @@ -577,7 +577,7 @@ function! s:refreshRoot() call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call b:NERDTree.root.refresh() call b:NERDTree.render() - call nerdtree#redraw(0) + redraw call nerdtree#exec(l:curWin . "wincmd w") call nerdtree#echo("") endfunction diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index f0272496..05e82d97 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -31,7 +31,11 @@ function! s:MenuController.showMenu() let l:done = 0 while !l:done - call nerdtree#redraw(1) + if has('nvim') + mode + else + redraw! + endif call self._echoPrompt() let l:key = nr2char(getchar()) @@ -42,7 +46,7 @@ function! s:MenuController.showMenu() " Redraw when "Ctrl-C" or "Esc" is received. if !l:done || self.selection == -1 - call nerdtree#redraw(1) + redraw! endif endtry @@ -64,7 +68,7 @@ function! s:MenuController._echoPrompt() echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " else - echo "NERDTree Menu. " . navHelp . " . or the shortcuts indicated" + echo "NERDTree Menu. " . navHelp . ", or the shortcuts indicated" echo "=========================================================" for i in range(0, len(self.menuItems)-1) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4ba653f7..5c37e4d0 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -78,7 +78,7 @@ function! s:inputPrompt(action) endif if g:NERDTreeMenuController.isMinimal() - call nerdtree#redraw(1) " Clear the menu + redraw! " Clear the menu return minimal . " " else let divider = "==========================================================" @@ -185,7 +185,7 @@ function! NERDTreeAddNode() call newTreeNode.putCursorHere(1, 0) endif - call nerdtree#redraw(1) + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Node Not Created.") endtry @@ -234,7 +234,7 @@ function! NERDTreeMoveNode() call curNode.putCursorHere(1, 0) - call nerdtree#redraw(1) + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Node Not Renamed.") endtry @@ -272,7 +272,7 @@ function! NERDTreeDeleteNode() call s:promptToDelBuffer(bufnum, prompt) endif - call nerdtree#redraw(1) + redraw! catch /^NERDTree/ call nerdtree#echoWarning("Could not remove node") endtry @@ -362,7 +362,7 @@ function! NERDTreeCopyNode() call nerdtree#echo("Copy aborted.") endif let &shellslash = l:shellslash - call nerdtree#redraw(1) + redraw! endfunction " FUNCTION: NERDTreeCopyPath() {{{1 From ae1c0004ec3780c18c8844181138b358333e4730 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 8 Aug 2019 22:00:35 -0400 Subject: [PATCH 522/680] Suppress events for intermediate window/tab/buffer changes (#1026) * Add an optional parameter to neredtree#exec to suppress all events. The value doesn't matter, but 1 is a good choice. Its presence is an indicator that tells NERDTree to tell Vim to ignore all events. I'm not yet sure if there needs to be an else section to that if block. It may be OK to allow all events to fire in the right situations. * Supress events in all intermediate nerdtree#exec calls. Finding all the right function calls is the key here. * Make ignoreAll a required parameter to nerdtree#exec(). * Put required ignoreAll argument (==0) in where it's now needed. * Ignore events when creating a new vertical split. * Ignore events when closing NERDTree. This may need to be reverted. * Remove debugging statment and commented-out code. * Wrap remaining buffer/window-switching commands in nerdtree#exec(). * Update version number. * Add a space between arguments in nerdtree#exec() calls. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 12 ++++++------ autoload/nerdtree/ui_glue.vim | 4 ++-- lib/nerdtree/bookmark.vim | 4 ++-- lib/nerdtree/nerdtree.vim | 14 +++++++------- lib/nerdtree/opener.vim | 30 +++++++++++++++--------------- lib/nerdtree/ui.vim | 8 ++++---- nerdtree_plugin/fs_menu.vim | 20 ++++++++++---------- 8 files changed, 47 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 562ceee7..e98ea0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.2... +- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) - **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) - **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 20ef1beb..4391565e 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -154,13 +154,13 @@ function! nerdtree#deprecated(func, ...) endif endfunction -" FUNCTION: nerdtree#exec(cmd) {{{2 -" Same as :exec cmd but with eventignore set for the duration -" to disable the autocommands used by NERDTree (BufEnter, -" BufLeave and VimEnter) -function! nerdtree#exec(cmd) +" FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2 +" Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration +function! nerdtree#exec(cmd, ignoreAll) let old_ei = &ei - set ei=BufEnter,BufLeave,VimEnter + if a:ignoreAll + set ei=all + endif exec a:cmd let &ei = old_ei endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 045e8adf..f0458680 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -574,11 +574,11 @@ function! s:refreshRoot() call nerdtree#echo("Refreshing the root node. This could take a while...") let l:curWin = winnr() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) call b:NERDTree.root.refresh() call b:NERDTree.render() redraw - call nerdtree#exec(l:curWin . "wincmd w") + call nerdtree#exec(l:curWin . "wincmd w", 1) call nerdtree#echo("") endfunction diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index c633a8f2..b206e7a4 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -159,8 +159,8 @@ endfunction " FUNCTION: s:Edit() {{{1 " opens the NERDTreeBookmarks file for manual editing function! s:Bookmark.Edit() - execute "wincmd w" - execute "edit ".g:NERDTreeBookmarksFile + call nerdtree#exec("wincmd w", 1) + call nerdtree#exec("edit ".g:NERDTreeBookmarksFile, 1) endfunction " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index e5ba0b5d..705d4f9b 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -44,19 +44,19 @@ function! s:NERDTree.Close() let l:useWinId = exists('*win_getid') && exists('*win_gotoid') if winnr() == s:NERDTree.GetWinNum() - call nerdtree#exec("wincmd p") + call nerdtree#exec("wincmd p", 1) let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") - call nerdtree#exec("wincmd p") + call nerdtree#exec("wincmd p", 1) else let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") endif - call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w") - close + call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) + call nerdtree#exec("close", 1) if l:useWinId - call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")") + call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) else - call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w") + call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w", 0) endif else close @@ -98,7 +98,7 @@ endfunction "Places the cursor in the nerd tree window function! s:NERDTree.CursorToTreeWin() call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index f4bd6e06..5953eea2 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -107,10 +107,10 @@ function! s:Opener._isWindowUsable(winnumber) endif let oldwinnr = winnr() - call nerdtree#exec(a:winnumber . "wincmd p") + call nerdtree#exec(a:winnumber . "wincmd p", 1) let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') let modified = &modified - call nerdtree#exec(oldwinnr . "wincmd p") + call nerdtree#exec(oldwinnr . "wincmd p", 1) "if its a special window e.g. quickfix or another explorer plugin then we "have to split @@ -172,7 +172,7 @@ function! s:Opener._newSplit() let below=0 " Attempt to go to adjacent window - call nerdtree#exec(back) + call nerdtree#exec(back, 1) let onlyOneWin = (winnr("$") ==# 1) @@ -201,9 +201,9 @@ function! s:Opener._newSplit() "resize the tree window if no other window was open before if onlyOneWin let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec(there) + call nerdtree#exec(there, 1) exec("silent ". splitMode ." resize ". size) - call nerdtree#exec('wincmd p') + call nerdtree#exec('wincmd p', 0) endif " Restore splitmode settings @@ -219,8 +219,8 @@ function! s:Opener._newVSplit() let l:winwidth = g:NERDTreeWinSize endif - call nerdtree#exec('wincmd p') - vnew + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('vnew', 1) let l:currentWindowNumber = winnr() @@ -228,7 +228,7 @@ function! s:Opener._newVSplit() call g:NERDTree.CursorToTreeWin() execute 'silent vertical resize ' . l:winwidth - call nerdtree#exec(l:currentWindowNumber . 'wincmd w') + call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) endfunction " FUNCTION: Opener.open(target) {{{1 @@ -290,9 +290,9 @@ function! s:Opener._previousWindow() else try if !self._isWindowUsable(winnr("#")) - call nerdtree#exec(self._firstUsableWindow() . "wincmd w") + call nerdtree#exec(self._firstUsableWindow() . "wincmd w", 1) else - call nerdtree#exec('wincmd p') + call nerdtree#exec('wincmd p', 1) endif catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() @@ -305,8 +305,8 @@ endfunction " FUNCTION: Opener._restoreCursorPos() {{{1 function! s:Opener._restoreCursorPos() - call nerdtree#exec(self._tabnr . 'tabnext') - call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') + call nerdtree#exec(self._tabnr . 'tabnext', 1) + call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w', 1) endfunction " FUNCTION: Opener._reuseWindow() {{{1 @@ -321,7 +321,7 @@ function! s:Opener._reuseWindow() "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') if winnr != -1 - call nerdtree#exec(winnr . "wincmd w") + call nerdtree#exec(winnr . "wincmd w", 0) call self._checkToCloseTree(0) return 1 endif @@ -334,9 +334,9 @@ function! s:Opener._reuseWindow() let tabnr = self._path.tabnr() if tabnr call self._checkToCloseTree(1) - call nerdtree#exec(tabnr . 'tabnext') + call nerdtree#exec(tabnr . 'tabnext', 1) let winnr = bufwinnr('^' . self._path.str() . '$') - call nerdtree#exec(winnr . "wincmd w") + call nerdtree#exec(winnr . "wincmd w", 0) return 1 endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 97f95d93..d384071d 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -340,7 +340,7 @@ function! s:UI.restoreScreenState() if !has_key(self, '_screenState') return endif - exec("silent vertical resize " . self._screenState['oldWindowSize']) + call nerdtree#exec("silent vertical resize " . self._screenState['oldWindowSize'], 1) let old_scrolloff=&scrolloff let &scrolloff=0 @@ -360,7 +360,7 @@ function! s:UI.saveScreenState() let self._screenState['oldPos'] = getpos(".") let self._screenState['oldTopLine'] = line("w0") let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w") + call nerdtree#exec(win . "wincmd w", 1) endfunction " FUNCTION: s:UI.setShowHidden(val) {{{1 @@ -506,10 +506,10 @@ endfunction function! s:UI.toggleZoom() if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - exec "silent vertical resize ". size + call nerdtree#exec("silent vertical resize ". size, 1) let b:NERDTreeZoomed = 0 else - exec "vertical resize ". get(g:, 'NERDTreeWinSizeMax', '') + call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''), 1) let b:NERDTreeZoomed = 1 endif endfunction diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 5c37e4d0..0a5de8a4 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -114,14 +114,14 @@ function! s:promptToDelBuffer(bufnum, msg) let l:listedBufferCount = 0 endif if l:listedBufferCount > 1 - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif" + call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif", 1) else - exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif" + call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif", 1) endif - exec "tabnext " . s:originalTabNumber - exec s:originalWindowNumber . "wincmd w" + call nerdtree#exec("tabnext " . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) " 3. We don't need a previous buffer anymore - exec "bwipeout! " . a:bufnum + call nerdtree#exec("bwipeout! " . a:bufnum, 0) endif endfunction @@ -141,17 +141,17 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif " 1. ensure that a new buffer is loaded - exec "badd " . quotedFileName + call nerdtree#exec("badd " . quotedFileName, 1) " 2. ensure that all windows which display the just deleted filename " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif" - exec "tabnext " . s:originalTabNumber - exec s:originalWindowNumber . "wincmd w" + call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) + call nerdtree#exec("tabnext " . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) " 3. We don't need a previous buffer anymore try - exec "confirm bwipeout " . a:bufNum + call nerdtree#exec("confirm bwipeout " . a:bufNum, 0) catch " This happens when answering Cancel if confirmation is needed. Do nothing. endtry From 858b3c0004c26b8ea7e2f33949feb19e8d5af00c Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Fri, 9 Aug 2019 09:45:46 -0400 Subject: [PATCH 523/680] Update PR template, moving some text into a comment. --- .github/PULL_REQUEST_TEMPLATE.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index df723654..58ec73f2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,12 +9,11 @@ Closes # - [ ] `MAJOR` version when you make incompatible API changes - [ ] `MINOR` version when you add functionality in a backwards-compatible manner - [ ] `PATCH` version when you make backwards-compatible bug fixes -- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example: - ``` - #### MAJOR.MINOR... - - **.PATCH**: PR Title (Author) [#PR Number](link to PR) +- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md). + From 03073bb1c818ad0a02cdcfc0f417d5e01298c6b6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Fri, 9 Aug 2019 10:07:14 -0400 Subject: [PATCH 524/680] Update issue templates, moving some text into comments. --- .github/ISSUE_TEMPLATE/bug.md | 19 ++++++++++--------- .github/ISSUE_TEMPLATE/question.md | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 88ffdf36..b0baedb3 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -3,18 +3,19 @@ name: "Bug Report" about: "NERDTree is misbehaving? Tell us about it." labels: bug --- + #### Self-Diagnosis + - [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. - [ ] I have reviewed the NERDTree documentation. `:h NERDTree` - [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 12ed8e68..de1484ea 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -3,18 +3,19 @@ name: "General Question" about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." labels: "general question" --- + #### Self-Diagnosis + - [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. - [ ] I have reviewed the NERDTree documentation. `:h NERDTree` - [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). From 184fbb6ffea6dc69726b229a08153c9d08522386 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Fri, 9 Aug 2019 10:27:47 -0400 Subject: [PATCH 525/680] Better spacing of comment in issue templates. --- .github/ISSUE_TEMPLATE/bug.md | 7 +++---- .github/ISSUE_TEMPLATE/question.md | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index b0baedb3..dd351350 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -3,8 +3,7 @@ name: "Bug Report" about: "NERDTree is misbehaving? Tell us about it." labels: bug --- - +your information, the more likely they'll be able to help themselves. --> + #### Self-Diagnosis - [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index de1484ea..25f15b02 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -3,8 +3,7 @@ name: "General Question" about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." labels: "general question" --- - +your information, the more likely they'll be able to help themselves. --> + #### Self-Diagnosis - [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. From c4a7ca084efab73ec107b4ac85d37a89eee88d60 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 19 Aug 2019 03:51:34 -0400 Subject: [PATCH 526/680] Add file extension and size to sorting capabilities (#1029) * Add ability to sort by extension and file size. Use the tags [[extension]], [[size]], or [[-size]] in the g:NERDTreeSortOrder list to accomplish this sorting. * Prevent metadata tags being misused in getSortOrderIndex(). * Apply metadata tags only to files. * Update NERDTreeSortOrder in help file. * Update version number in CHANGELOG. --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 43 ++++++++++++++++++++++-------------------- lib/nerdtree/path.vim | 44 +++++++++++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e98ea0ea..9e494175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +#### 5.3... +- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) #### 5.2... - **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index a9ccc99e..14f70782 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1043,28 +1043,31 @@ window. Use one of the follow lines for this setting: > Values: a list of regular expressions. Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -This setting is a list of regular expressions which are used to specify the -order of nodes under their parent. +This setting is a list of regular expressions which are used to group or sort +the nodes under their parent. For example, if the setting is: > ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] < -then all .vim files will be placed at the top, followed by all .c files then +then all .vim files will be grouped at the top, followed by all .c files then all .h files. All files containing the string 'foobar' will be placed at the end. The star is a special flag: it tells the script that every node that doesn't match any of the other regexps should be placed here. -If no star is present in NERDTreeSortOrder then one is automatically -appended to the array. +If no star is present in NERDTreeSortOrder, then one is automatically +appended to the end of the list. The regex '\/$' should be used to match directory nodes. -A special flag can be used to sort by the modification timestamps of files and -directories. It is either '[[timestamp]]' for ascending, or '[[-timestamp]]' -for descending. If placed at the beginning of the list, files and directories -are sorted by timestamp, and then by the remaining items in the sort order -list. If this flag is in any other position of the list, timestamp sorting is -done secondarily. See examples 4, 5, and 6 below. +Files can also be sorted by 1) the modification timestamp, 2) the size, or 3) +the extension. Directories are always sorted by name. To accomplish this, the +following special flags are used: + [[timestamp]] [[-timestamp]] [[size]] [[-size]] [[extension]] +The hyphen specifies a descending sort; extensions are sorted in ascending +order only. If placed at the beginning of the list, files are sorted according +to these flags first, and then grouped by the remaining items in the list. If +the flags are in any other position of the list, this special sorting is done +secondarily. See examples 4, 5, and 6 below. After this sorting is done, the files in each group are sorted alphabetically. @@ -1072,20 +1075,20 @@ Examples: > (1) ['*', '\/$'] (2) [] (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] - (4) ['[[timestamp]]'] - (5) ['\/$', '*', '[[-timestamp]]'] - (6) ['\.md$', '\.c$', '[[-timestamp]]', '*'] + (4) ['[[-size]]'] + (5) ['\/$', '*', '[[timestamp]]'] + (6) ['foo','\/$','[[extension]]'] < 1. Directories will appear last, everything else will appear above. 2. Everything will simply appear in alphabetical order. 3. Dirs will appear first, then ruby and php. Swap files, bak files and vim backup files will appear last with everything else preceding them. -4. All files and directories are sorted by timestamp, oldest first. If any - files have identical timestamps, they are sorted alphabetically. -5. Directories are first, newest to oldest, then everything else, newest to - oldest. -6. Markdown files first, followed by C source files, then everything else. - Each group is shown newest to oldest. +4. Everything is sorted by size, largest to smallest, with directories + considered to have size 0 bytes. +5. Directories will appear first alphabetically, followed by files, sorted by + timestamp, oldest first. +6. Files and directories matching 'foo' first, followed by other directories, + then all other files. Each section of files is sorted by file extension. ------------------------------------------------------------------------------ *NERDTreeStatusline* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index c3af1952..fb1fbf8f 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -380,7 +380,8 @@ endfunction function! s:Path.getSortOrderIndex() let i = 0 while i < len(g:NERDTreeSortOrder) - if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i] + if g:NERDTreeSortOrder[i] !~? '\[\[-\?\(timestamp\|size\|extension\)\]\]' && + \ self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i] return i endif let i = i + 1 @@ -407,15 +408,38 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - let l:ascending = index(g:NERDTreeSortOrder,'[[timestamp]]') - let l:descending = index(g:NERDTreeSortOrder,'[[-timestamp]]') - if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder || l:ascending >= 0 || l:descending >= 0 - let self._sortKey = [self.getSortOrderIndex()] - - if l:descending >= 0 - call insert(self._sortKey, -getftime(self.str()), l:descending == 0 ? 0 : len(self._sortKey)) - elseif l:ascending >= 0 - call insert(self._sortKey, getftime(self.str()), l:ascending == 0 ? 0 : len(self._sortKey)) + if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + " Look for file metadata tags: [[timestamp]], [[extension]], [[size]] + let metadata = [] + for tag in g:NERDTreeSortOrder + if tag =~? '\[\[-\?timestamp\]\]' + if self.isDirectory + call add(metadata, 0) + else + call add(metadata, (tag =~ '-' ? -1 : 1) * getftime(self.str())) + endif + elseif tag =~? '\[\[-\?size\]\]' + if self.isDirectory + call add(metadata, 0) + else + call add(metadata, (tag =~ '-' ? -1 : 1) * getfsize(self.str())) + endif + elseif tag =~? '\[\[extension\]\]' + if self.isDirectory + call add(metadata, '') + else + let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') + call add(metadata, extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension) + endif + endif + endfor + + if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]' + " Apply tags' sorting first if specified first. + let self._sortKey = metadata + [self.getSortOrderIndex()] + else + " Otherwise, do regex grouping first. + let self._sortKey = [self.getSortOrderIndex()] + metadata endif let path = self.getLastPathComponent(1) From 877f41e243687a65e67024bb9e76cfaecd2dc775 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 19 Aug 2019 09:36:50 -0400 Subject: [PATCH 527/680] Update PR template with instructions to tag the release. --- .github/PULL_REQUEST_TEMPLATE.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 58ec73f2..ccd5bf8d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,11 +9,5 @@ Closes # - [ ] `MAJOR` version when you make incompatible API changes - [ ] `MINOR` version when you add functionality in a backwards-compatible manner - [ ] `PATCH` version when you make backwards-compatible bug fixes -- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md). - +- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. +- [ ] Tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` From 9afab6257b954a1e9591928e7a8cd220fde51552 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 19 Aug 2019 14:39:17 -0400 Subject: [PATCH 528/680] Condense code: ternary operators vs. if-then-else blocks. --- lib/nerdtree/path.vim | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index fb1fbf8f..d00bb898 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -413,24 +413,12 @@ function! s:Path.getSortKey() let metadata = [] for tag in g:NERDTreeSortOrder if tag =~? '\[\[-\?timestamp\]\]' - if self.isDirectory - call add(metadata, 0) - else - call add(metadata, (tag =~ '-' ? -1 : 1) * getftime(self.str())) - endif + let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~ '-' ? -1 : 1)] elseif tag =~? '\[\[-\?size\]\]' - if self.isDirectory - call add(metadata, 0) - else - call add(metadata, (tag =~ '-' ? -1 : 1) * getfsize(self.str())) - endif + let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~ '-' ? -1 : 1)] elseif tag =~? '\[\[extension\]\]' - if self.isDirectory - call add(metadata, '') - else - let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') - call add(metadata, extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension) - endif + let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') + let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)] endif endfor From 3d508aedce35e1d952d3ce92378ad27ea5960fa6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 27 Aug 2019 20:53:23 -0400 Subject: [PATCH 529/680] Fix the `e` key mapping to use netrw if desired (#1031) * Use :edit in openExplorer to allow NERDTreeHijackNetrw to do its thing. * Remove commented-out code. * Make `e` work on file nodes, opening a new NERDTree or netrw buffer. * Update change log. --- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 1 + lib/nerdtree/tree_dir_node.vim | 3 ++- lib/nerdtree/tree_file_node.vim | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e494175..e8b4290a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.3... +- **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) #### 5.2... - **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index f0458680..b82e7918 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -72,6 +72,7 @@ function! nerdtree#ui_glue#createDefaultBindings() call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "FileNode", 'callback': s."openExplorer" }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index aa9dea6a..4015f0be 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -523,7 +523,8 @@ endfunction " Open an explorer window for this node in the previous window. The explorer " can be a NERDTree window or a netrw window. function! s:TreeDirNode.openExplorer() - call self.open({'where': 'p'}) + execute "wincmd p" + execute "edit ".self.path.str({'format':'Edit'}) endfunction " FUNCTION: TreeDirNode.openInNewTab(options) {{{1 diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index d4c060fc..c14f62a9 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -246,6 +246,12 @@ function! s:TreeFileNode.openInNewTab(options) call self.open(extend({'where': 't'}, a:options)) endfunction +" FUNCTION: TreeFileNode.openExplorer() +function! s:TreeFileNode.openExplorer() + execute "wincmd p" + execute "edit ".self.path.getParent().str({'format':'Edit'}) +endfunction + " FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 " Places the cursor on the line number this node is rendered on " From 79ef87b0099fe90d91592d89ba807d99c9d3d92c Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 9 Sep 2019 05:27:48 -0400 Subject: [PATCH 530/680] Update version number in change log. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b4290a..2045af81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +#### 6.0... +- **.0**: Make the behavior of window splits consistent [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... - **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) From 51fc75efdb8ac58c853492c3f61d854f65ed78ec Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 9 Sep 2019 09:40:18 -0400 Subject: [PATCH 531/680] Fix version number. I was on the wrong branch. --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2045af81..e8b4290a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ # Change Log -#### 6.0... -- **.0**: Make the behavior of window splits consistent [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... - **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) From 60ec10b477eefc81eeafafa2a8c1b00046ee48fb Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 13 Sep 2019 10:49:26 -0400 Subject: [PATCH 532/680] Enable events when closing NerdTree window. (#1037) * Enable events when closing NT window. Triggers updates in Airline. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/nerdtree.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b4290a..1885f1c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.3... +- **.2**: Enable events when closing NerdTree window. [#1037](https://github.com/scrooloose/nerdtree/pull/1037) - **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) #### 5.2... diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 705d4f9b..eb305d60 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -52,7 +52,7 @@ function! s:NERDTree.Close() endif call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) - call nerdtree#exec("close", 1) + call nerdtree#exec("close", 0) if l:useWinId call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) else From 2eaedd8bf403202eeacb363abe2de4753141b00a Mon Sep 17 00:00:00 2001 From: Chris Patuzzo Date: Sun, 15 Sep 2019 19:41:27 +0100 Subject: [PATCH 533/680] Fix (p)ath not displaying in the minimal menu (#1038) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ‘copy (p)ath to clipboard’ menu item was added recently in this pull request: https://github.com/scrooloose/nerdtree/pull/1002/files However, this caused the NERDTreeMinimalMenu to display ‘copy’ instead of ‘(p)ath’ because it was simply using the first word of the item’s text. This change fixes that bug by using a regex to pick out the first word beginning with ‘(’ --- lib/nerdtree/menu_controller.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 05e82d97..874c09dc 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -62,9 +62,10 @@ function! s:MenuController._echoPrompt() if self.isMinimal() let selection = self.menuItems[self.selection].text + let keyword = matchstr(selection, "\([^ ]*") let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") - let shortcuts[self.selection] = " " . split(selection)[0] . " " + let shortcuts[self.selection] = " " . keyword . " " echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " else From 9193962ad88f15d9f426c3cfb8a274ff1dd0c5b2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 15 Sep 2019 14:44:09 -0400 Subject: [PATCH 534/680] Update version number in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1885f1c0..ca0f987b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 5.3... +- **.3**: Fix (p)ath not displaying in the minimal menu [#1038](https://github.com/scrooloose/nerdtree/pull/1038) - **.2**: Enable events when closing NerdTree window. [#1037](https://github.com/scrooloose/nerdtree/pull/1037) - **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) From bd744eab8df5730db167a26486bc9afde46c4046 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 24 Sep 2019 01:19:27 -0400 Subject: [PATCH 535/680] Make the behavior of window splits consistent (#1035) * add option to spawn split from previous window * Update some comments and remove debugging statement. * Simplify the code, and make it respect NERDTreeWinPos and 'splitbelow'. * Better logic for getting NERDTree window number when not active window. * Use common functions for splitting windows. Make splitting respect user. The placement of split windows now respects the user's choices for the splitright and splitbelow settings, and the g:NERDTreeWinPos variable. * Update version number in change log. --- CHANGELOG.md | 2 ++ autoload/nerdtree.vim | 7 ++++- lib/nerdtree/nerdtree.vim | 9 ++++++- lib/nerdtree/opener.vim | 55 +++++++++++---------------------------- 4 files changed, 31 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca0f987b..b103b305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +#### 6.0... +- **.0**: Make the behavior of window splits consistent [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... - **.3**: Fix (p)ath not displaying in the minimal menu [#1038](https://github.com/scrooloose/nerdtree/pull/1038) - **.2**: Enable events when closing NerdTree window. [#1037](https://github.com/scrooloose/nerdtree/pull/1037) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 4391565e..61adb9c5 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -4,6 +4,11 @@ endif let g:loaded_nerdtree_autoload = 1 let s:rootNERDTreePath = resolve(expand(":p:h:h")) + +"FUNCTION: nerdtree#version(...) {{{1 +" If any value is given as an argument, the entire line of text from the +" change log is shown for the current version; otherwise, only the version +" number is shown. function! nerdtree#version(...) let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) let l:text = 'Unknown' @@ -22,6 +27,7 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +"FUNCTION: nerdtree#slash() {{{2 function! nerdtree#slash() if nerdtree#runningWindows() @@ -49,7 +55,6 @@ function! nerdtree#and(x,y) if (l:x % 2) && (l:y % 2) let l:result += float2nr(pow(2, l:n)) endif - echomsg l:x . ", " . l:y . " => " l:result let l:x = float2nr(l:x / 2) let l:y = float2nr(l:y / 2) let l:n += 1 diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index eb305d60..a12eb366 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -148,12 +148,19 @@ function! s:NERDTree.GetWinNum() return bufwinnr(t:NERDTreeBufName) endif + " If WindowTree, there is no t:NERDTreeBufName variable. Search all windows. + for w in range(1,winnr('$')) + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return w + endif + endfor + return -1 endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return s:NERDTree.GetWinNum() != -1 endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 5953eea2..ffc75068 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -71,9 +71,9 @@ endfunction function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() if self._where == 'v' - vsplit + call self._newVSplit() elseif self._where == 'h' - split + call self._newSplit() elseif self._where == 't' tabnew endif @@ -153,44 +153,17 @@ endfunction " FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call nerdtree#exec(back, 1) - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately + let savesplitright = &splitright if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below + let &splitright = (g:NERDTreeWinPos ==# "left") endif - let splitMode = onlyOneWin ? "vertical" : "" - " Open the new window try - exec(splitMode." sp ") + call nerdtree#exec('wincmd p', 1) + " If only one window (ie. NERDTree), split vertically instead. + call nerdtree#exec(onlyOneWin ? "vertical split" : "split",1) catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." @@ -200,14 +173,12 @@ function! s:Opener._newSplit() "resize the tree window if no other window was open before if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec(there, 1) - exec("silent ". splitMode ." resize ". size) + let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('silent '. splitMode .' resize '. size, 1) call nerdtree#exec('wincmd p', 0) endif - " Restore splitmode settings - let &splitbelow=savesplitbelow let &splitright=savesplitright endfunction @@ -215,7 +186,10 @@ endfunction function! s:Opener._newVSplit() let l:winwidth = winwidth('.') - if winnr('$') == 1 + let onlyOneWin = (winnr("$") ==# 1) + let savesplitright = &splitright + if onlyOneWin + let &splitright = (g:NERDTreeWinPos ==# "left") let l:winwidth = g:NERDTreeWinSize endif @@ -229,6 +203,7 @@ function! s:Opener._newVSplit() execute 'silent vertical resize ' . l:winwidth call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) + let &splitright=savesplitright endfunction " FUNCTION: Opener.open(target) {{{1 From 5af6859846cc37f1056f2400a932e703e5e4aac5 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 26 Sep 2019 08:47:36 -0400 Subject: [PATCH 536/680] Reintroduce necessary variable mistakenly removed. (#1040) * Reintroduce lost variable: splitMode. * Add a space between splitMode and "split". `verticalsplit` is invalid. * Update version number, and add attributions (PR authors) --- CHANGELOG.md | 17 +++++++++-------- lib/nerdtree/opener.vim | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b103b305..69ea21b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,18 @@ # Change Log #### 6.0... -- **.0**: Make the behavior of window splits consistent [#1035](https://github.com/scrooloose/nerdtree/pull/1035) +- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) +- **.0**: Make the behavior of window splits consistent (PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... -- **.3**: Fix (p)ath not displaying in the minimal menu [#1038](https://github.com/scrooloose/nerdtree/pull/1038) -- **.2**: Enable events when closing NerdTree window. [#1037](https://github.com/scrooloose/nerdtree/pull/1037) -- **.1**: Fix the `e` key mapping to use netrw if desired [#1031](https://github.com/scrooloose/nerdtree/pull/1031) -- **.0**: Add file extension and size to sorting capabilities [#1029](https://github.com/scrooloose/nerdtree/pull/1029) +- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038) +- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037) +- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031) +- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029) #### 5.2... -- **.9**: Suppress events for intermediate window/tab/buffer changes [#1026](https://github.com/scrooloose/nerdtree/pull/1026) +- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) -- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! [#1019](https://github.com/scrooloose/nerdtree/pull/1019) -- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019) +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) - **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index ffc75068..fa0c9884 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -158,12 +158,13 @@ function! s:Opener._newSplit() if onlyOneWin let &splitright = (g:NERDTreeWinPos ==# "left") endif + " If only one window (ie. NERDTree), split vertically instead. + let splitMode = onlyOneWin ? "vertical" : "" " Open the new window try call nerdtree#exec('wincmd p', 1) - " If only one window (ie. NERDTree), split vertically instead. - call nerdtree#exec(onlyOneWin ? "vertical split" : "split",1) + call nerdtree#exec(splitMode . " split",1) catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." From 496b61ead1acd80128164cce5c2ff8e89c42ded2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 26 Sep 2019 08:48:57 -0400 Subject: [PATCH 537/680] Give @dragonxlwang proper credit on PR #1035. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ea21b5..dbcdfc83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### 6.0... - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) -- **.0**: Make the behavior of window splits consistent (PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) +- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) #### 5.3... - **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038) - **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037) From 6318406f6606481b5e3a42a5754096063d996587 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 29 Sep 2019 11:28:59 -0400 Subject: [PATCH 538/680] If file path doesn't exist, :NERDTreeFind its parent directory instead. (#1043) * If file path doesn't exist, :NERDTreeFind its parent directory instead. This happens in the following scenario: ``` :edit path/new_file :NERDTreeFind ``` Instead of an error message about an **invalid path**, this change will now find the parent directory instead. It will not work if the new file is **path/new_folder/new_file**, and that's OK because even vim itself cannot handle both the new folder and the new file; `:w` won't create the new folder. * Update version number in change log. * Change version change from PATCH to MINOR. --- CHANGELOG.md | 2 ++ autoload/nerdtree/ui_glue.vim | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbcdfc83..bcb99c6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +#### 6.1... +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) #### 6.0... - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) - **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index b82e7918..4ba5b05f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -284,6 +284,9 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + endif if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') From 2d639b70e73ecf3f62884a578fe5e5937e6d8a92 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 1 Oct 2019 09:17:32 -0400 Subject: [PATCH 539/680] Catch errors when trying to read CHANGELOG.md. (#1045) * Catch errors when trying to read CHANGELOG.md. The ArchLinux package (https://www.archlinux.org/packages/community/any/vim-nerdtree/) puts this file in the wrong location. * Update version number in change log. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb99c6b..8795c6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 6.1... +- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) #### 6.0... - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 61adb9c5..76c076e9 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -10,17 +10,20 @@ let s:rootNERDTreePath = resolve(expand(":p:h:h")) " change log is shown for the current version; otherwise, only the version " number is shown. function! nerdtree#version(...) - let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) let l:text = 'Unknown' - let l:line = 0 - while l:line <= len(l:changelog) - if l:changelog[l:line] =~ '\d\+\.\d\+' - let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') - let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') - break - endif - let l:line += 1 - endwhile + try + let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) + let l:line = 0 + while l:line <= len(l:changelog) + if l:changelog[l:line] =~ '\d\+\.\d\+' + let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') + let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') + break + endif + let l:line += 1 + endwhile + catch + endtry return l:text endfunction From 4fe24d31569d365712b5fa95ac2688a68528b723 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 8 Oct 2019 14:01:50 -0400 Subject: [PATCH 540/680] Wrap saveScreenState's statements in a try-catch block. (#1047) * Wrap saveScreenState's statements in a try-catch block. If you're in NERDTree, and you press : to open a command line, and then press Ctrl+F to open the [Command Line] window, you will see errors related to switching windows while in this function. (Those commands are not allowed while in the [Command Line] window.) The try-catch block handles the errors, preventing their being displayed. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/ui.vim | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8795c6b1..239ce815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 6.1... +- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) - **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) #### 6.0... diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index d384071d..5e8b3b64 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -355,12 +355,15 @@ endfunction " scroll position function! s:UI.saveScreenState() let win = winnr() - call g:NERDTree.CursorToTreeWin() let self._screenState = {} - let self._screenState['oldPos'] = getpos(".") - let self._screenState['oldTopLine'] = line("w0") - let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w", 1) + try + call g:NERDTree.CursorToTreeWin() + let self._screenState['oldPos'] = getpos(".") + let self._screenState['oldTopLine'] = line("w0") + let self._screenState['oldWindowSize']= winwidth("") + call nerdtree#exec(win . "wincmd w", 1) + catch + endtry endfunction " FUNCTION: s:UI.setShowHidden(val) {{{1 From 53eef21ad6a21806329a2571159f2ff8e5a3160b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 11 Oct 2019 01:04:06 -0400 Subject: [PATCH 541/680] Save/Set screen state also on WinLeave and WinEnter. (#1048) * Save/Set screen state also on WinLeave and WinEnter. The particular use case here is when switching tabs with `gt` and the NERDTrees have been mirrored. * Update version number and change log. --- CHANGELOG.md | 1 + plugin/NERD_tree.vim | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 239ce815..d390cf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log #### 6.1... +- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) - **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) - **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a8e26d4e..40609f02 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -170,10 +170,10 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" + exec "autocmd BufLeave,WinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" "disallow insert mode in the NERDTree - exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" + exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" augroup END if g:NERDTreeHijackNetrw From 926ff0ec038d2be0bf4ff3412d3c7144b5f82498 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 11 Oct 2019 10:44:25 -0400 Subject: [PATCH 542/680] Update version number instructions in PR template and change log. --- .github/PULL_REQUEST_TEMPLATE.md | 13 ++++++++----- CHANGELOG.md | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ccd5bf8d..24dba3f5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,9 +5,12 @@ Closes # --- ### New Version Info -- [ ] Derive a new version number. Increment the: - - [ ] `MAJOR` version when you make incompatible API changes - - [ ] `MINOR` version when you add functionality in a backwards-compatible manner - - [ ] `PATCH` version when you make backwards-compatible bug fixes +#### Author's Instructions +- [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the: + - `MAJOR` version when you make incompatible API changes + - `MINOR` version when you add functionality in a backwards-compatible manner + - `PATCH` version when you make backwards-compatible bug fixes - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. -- [ ] Tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` +#### Collaborator's Instructions +- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. +- [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` diff --git a/CHANGELOG.md b/CHANGELOG.md index d390cf6d..991da008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,27 @@ -# Change Log +# NERDTree Change Log -#### 6.1... + + +#### 6.1 - **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) - **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) - **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) - **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) -#### 6.0... +#### 6.0 - **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) - **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) -#### 5.3... +#### 5.3 - **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038) - **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037) - **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031) - **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029) -#### 5.2... +#### 5.2 - **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026) - **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) - **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019) @@ -24,7 +32,7 @@ - **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013) - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) - **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) -#### 5.1... +#### 5.1 - **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009) - **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008) - **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) From 42455176896560bf8cf7fc8457232131231b358f Mon Sep 17 00:00:00 2001 From: Farid Ahmadian Date: Mon, 14 Oct 2019 15:13:20 +0200 Subject: [PATCH 543/680] Add VIM built-in package management to readme (#1049) --- CHANGELOG.md | 1 + README.markdown | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 991da008..f79be93d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ --> #### 6.1 +- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049) - **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) - **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) - **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) diff --git a/README.markdown b/README.markdown index 75b311a6..a9ff7d19 100644 --- a/README.markdown +++ b/README.markdown @@ -17,6 +17,13 @@ included documentation. Installation ------------ +If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: + + git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree + vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q + +Otherwise, these are some of the other options: + #### [pathogen.vim](https://github.com/tpope/vim-pathogen) git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree From 371feb7e540afc1d25c3369d4157358d21f51681 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 16 Oct 2019 13:26:20 -0400 Subject: [PATCH 544/680] Support tab-specific CWDs (#1032) * Change CWD when switching tabs to the tab's NERDTree root. * Remove commented-out code. * List the new possible value for NERDTreeChDirMode in doc. * Add new option to select between `:cd` and `:tcd`. * Document the new NERDTreeUseTCD option. * Update version number in change log. --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 16 +++++++++++++--- lib/nerdtree/nerdtree.vim | 2 +- lib/nerdtree/path.vim | 9 +++++++-- plugin/NERD_tree.vim | 7 +++++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79be93d..73d17b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.2 +- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032) #### 6.1 - **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049) - **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 14f70782..32b0b5d1 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -849,9 +849,17 @@ above nodes would then be sorted like this: > z110.txt < ------------------------------------------------------------------------------ - *NERDTreeChDirMode* + *NERDTreeUseTCD* +Values: 0 or 1. +Default: 0. + +By default, NERDTree will use the `:cd` command to change the current working +directory. If this setting is turned on, and the `:tcd` command is available, it +will be used instead. -Values: 0, 1 or 2. +------------------------------------------------------------------------------ + *NERDTreeChDirMode* +Values: 0, 1, 2, or 3. Default: 0. Use this setting to tell the script when (if at all) to change the current @@ -871,6 +879,9 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new root then the CWD will become /home/marty/foobar/baz. +If the set to 3, then it behaves the same as if set to 2, and the CWD is +changed whenever changing tabs to whatever the tree root is on that tab. + ------------------------------------------------------------------------------ *NERDTreeHighlightCursorline* Values: 0 or 1. @@ -980,7 +991,6 @@ then (to single click activate it) you must click somewhere in ------------------------------------------------------------------------------ *NERDTreeQuitOnOpen* - Values: 0,1,2 or 3. Default: 0 diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a12eb366..3e7ade8a 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -20,7 +20,7 @@ function! s:NERDTree.changeRoot(node) call self.root.open() "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 + if g:NERDTreeChDirMode >= 2 call self.root.path.changeToDir() endif diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index d00bb898..ccb94238 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -87,8 +87,13 @@ function! s:Path.changeToDir() endif try - execute "cd " . dir - call nerdtree#echo("CWD is now: " . getcwd()) + if g:NERDTreeUseTCD && exists(":tcd") == 2 + execute "tcd " . dir + call nerdtree#echo("Tab's CWD is now: " . getcwd()) + else + execute "cd " . dir + call nerdtree#echo("CWD is now: " . getcwd()) + endif catch throw "NERDTree.PathChangeError: cannot change CWD to " . dir endtry diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 40609f02..5faebaaf 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) call s:initVariable("g:NERDTreeNaturalSort", 0) call s:initVariable("g:NERDTreeSortHiddenFirst", 1) +call s:initVariable("g:NERDTreeUseTCD", 0) call s:initVariable("g:NERDTreeChDirMode", 0) call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeMinimalUI", 0) @@ -183,6 +184,12 @@ if g:NERDTreeHijackNetrw augroup END endif +if g:NERDTreeChDirMode == 3 + augroup NERDTreeChDirOnTabSwitch + autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif + augroup END +endif + " SECTION: Public API {{{1 "============================================================ function! NERDTreeAddMenuItem(options) From fec3e57ad23e4c268d07181d6afb858925b647a1 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 22 Oct 2019 01:21:23 -0400 Subject: [PATCH 545/680] Closes #1050. Update README; don't show NERDTree if opening a session. --- README.markdown | 104 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 32 deletions(-) diff --git a/README.markdown b/README.markdown index a9ff7d19..9e539523 100644 --- a/README.markdown +++ b/README.markdown @@ -17,34 +17,62 @@ included documentation. Installation ------------ -If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: +Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them. - git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree - vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +#### Vim 8+ packages -Otherwise, these are some of the other options: +If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: -#### [pathogen.vim](https://github.com/tpope/vim-pathogen) +```bash +git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +``` - git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree +Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take. -Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`, and check out `:help NERDTree.txt`. +#### [pathogen.vim](https://github.com/tpope/vim-pathogen) +In the terminal, +```bash +git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree +``` +In your vimrc, +```vim +call pathogen#infect() +syntax on +filetype plugin indent on +``` + +Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. + +#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim) +```vim +call vundle#begin() +Plugin 'scrooloose/nerdtree' +call vundle#end() +``` + +#### [vim-plug](https://github.com/junegunn/vim-plug) +```vim +call plug#begin() +Plug 'scrooloose/nerdtree' +call plug#end() +``` #### [apt-vim](https://github.com/egalpin/apt-vim) +```bash +apt-vim install -y https://github.com/scrooloose/nerdtree.git +``` - apt-vim install -y https://github.com/scrooloose/nerdtree.git - -F.A.Q. +F.A.Q. (here, and in the [Wiki](https://github.com/scrooloose/nerdtree/wiki)) ------ -> Is there any support for `git` flags? +#### Is there any support for `git` flags? Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). --- - -> Can I have the nerdtree on every tab automatically? +#### Can I have the nerdtree on every tab automatically? Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this @@ -53,53 +81,65 @@ http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) --- -> How can I open a NERDTree automatically when vim starts up? +#### How can I open a NERDTree automatically when vim starts up? Stick this in your vimrc: `autocmd vimenter * NERDTree` --- -> How can I open a NERDTree automatically when vim starts up if no files were specified? +#### How can I open a NERDTree automatically when vim starts up if no files were specified? Stick this in your vimrc: - - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +``` Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree automatically when vim starts up on opening a directory? +#### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif +``` - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +--- +#### How can I open NERDTree automatically when vim starts up on opening a directory? +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +``` This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` --- -> How can I map a specific key or shortcut to open NERDTree? +#### How can I map a specific key or shortcut to open NERDTree? Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): - - map :NERDTreeToggle +```vim +map :NERDTreeToggle +``` --- -> How can I close vim if the only window left open is a NERDTree? +#### How can I close vim if the only window left open is a NERDTree? Stick this in your vimrc: - - autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +```vim +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +``` --- -> Can I have different highlighting for different file extensions? +#### Can I have different highlighting for different file extensions? See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 --- -> How can I change default arrows? +#### How can I change default arrows? Use these variables in your vimrc. Note that below are default arrow symbols - - let g:NERDTreeDirArrowExpandable = '▸' - let g:NERDTreeDirArrowCollapsible = '▾' +```vim +let g:NERDTreeDirArrowExpandable = '▸' +let g:NERDTreeDirArrowCollapsible = '▾' +``` From 960fda6299188eb82e2307c1b377e2c3e2dc7501 Mon Sep 17 00:00:00 2001 From: jhzn Date: Wed, 13 Nov 2019 14:58:42 +0100 Subject: [PATCH 546/680] Menu option, 'copy path to clipboard' is aware of VIM clipboard option (#1056) VIM noob here, so code might not be optimal. My setup is as follows. NVIM v0.5.0-95-g2e14dffbb, Linux Mint 19.2. I have this in init.vim ```vim set clipboard=unnamedplus ``` This enables me to share clipboard between VIM and X clipboard. The problem is that the menu option in NERDTree copies the file path to the "* register. This means I can't access the value in the X clipboard. --- nerdtree_plugin/fs_menu.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 0a5de8a4..4167df00 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -369,7 +369,11 @@ endfunction function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() if has("clipboard") - let @* = l:nodePath + if &clipboard == "unnamedplus" + let @+ = l:nodePath + else + let @* = l:nodePath + endif call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") else call nerdtree#echo("The full path is: " . l:nodePath) From 8d9b8dae67c5a6affbfd0304e0949ce9e79065ea Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 13 Nov 2019 09:00:41 -0500 Subject: [PATCH 547/680] Update version number in changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73d17b13..ac12c9f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ --> #### 6.2 +- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/scrooloose/nerdtree/pull/1056) - **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032) #### 6.1 - **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049) From 82b1649f2e1c79ff17730fe0a3750bbec203dd29 Mon Sep 17 00:00:00 2001 From: William Findlay Date: Fri, 22 Nov 2019 11:26:25 -0500 Subject: [PATCH 548/680] Add a NERDTreeToggleVCS command to the vcs plugin (#1060) * NERDTreeToggleVCS * nerdtree toggle vcs documentation * fix function documentation * changelog * Update CHANGELOG.md * Update CHANGELOG.md * simplify toggletreevcs * Update CHANGELOG.md --- CHANGELOG.md | 3 ++- doc/NERDTree.txt | 8 ++++++++ nerdtree_plugin/vcs.vim | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac12c9f0..fe5d51aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> - +#### 6.3 +- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/scrooloose/nerdtree/pull/1060) #### 6.2 - **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/scrooloose/nerdtree/pull/1056) - **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 32b0b5d1..e88a6802 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -125,6 +125,14 @@ The following features and functionality are provided by the NERDTree: again. If no NERDTree exists for this tab then this command acts the same as the |:NERDTree| command. +:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* + Like |:NERDTreeToggle|, but searches up the directory tree to find the top of + the version control system repository, and roots the NERDTree there. It + works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A + couple of examples: > + :NERDTreeToggleVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) + :NERDTreeToggleVCS (opens root of repository containing CWD) + :NERDTreeFocus *:NERDTreeFocus* Opens (or reopens) the NERDTree if it is not currently visible; otherwise, the cursor is moved to the already-open NERDTree. diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim index c30579ae..d9901b83 100644 --- a/nerdtree_plugin/vcs.vim +++ b/nerdtree_plugin/vcs.vim @@ -11,6 +11,7 @@ " " ============================================================================ command! -n=? -complete=dir -bar NERDTreeVCS :call CreateTabTreeVCS('') +command! -n=? -complete=dir -bar NERDTreeToggleVCS :call ToggleTabTreeVCS('') " FUNCTION: s:CreateTabTreeVCS(a:name) {{{1 function! s:CreateTabTreeVCS(name) @@ -19,6 +20,14 @@ function! s:CreateTabTreeVCS(name) call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str()) endfunction +" FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1 +" Behaves the same as ToggleTabTree except roots directory at VCS root +function! s:ToggleTabTreeVCS(name) + let l:path = g:NERDTreeCreator._pathForString(a:name) + let l:path = s:FindParentVCSRoot(l:path) + call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? "" : l:path._str()) +endfunction + " FUNCTION: s:FindParentVCSRoot(a:path) {{{1 " Finds the root version control system folder of the given path. If a:path is " not part of a repository, return the original path. From a7886fb6c468afbfabb8b8daf300022f1cee2401 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Sun, 15 Dec 2019 02:25:17 +0100 Subject: [PATCH 549/680] Allow use of function references as callbacks (#1067) --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 4 ++++ lib/nerdtree/key_map.vim | 2 +- lib/nerdtree/menu_item.vim | 8 ++++++-- lib/nerdtree/notifier.vim | 5 +++-- lib/nerdtree/path.vim | 5 +++-- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5d51aa..619e1540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.4 +- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067) #### 6.3 - **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/scrooloose/nerdtree/pull/1060) #### 6.2 diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index e88a6802..be0011d2 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1315,6 +1315,10 @@ following code conventions are used: See this blog post for more details: http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html +A number of API functions take a callback argument to call. The callback can +be either a string with the name of a function to call, or a |Funcref| object +which will be called directly. + ------------------------------------------------------------------------------ 4.1. Key map API *NERDTreeKeymapAPI* diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 584da1f1..2ee971d3 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -66,7 +66,7 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = function(self.callback) + let Callback = type(self.callback) == v:t_func ? self.callback : function(self.callback) if a:0 call Callback(a:1) else diff --git a/lib/nerdtree/menu_item.vim b/lib/nerdtree/menu_item.vim index 92c1bbbf..2d5122d1 100644 --- a/lib/nerdtree/menu_item.vim +++ b/lib/nerdtree/menu_item.vim @@ -79,7 +79,7 @@ endfunction "specified function! s:MenuItem.enabled() if self.isActiveCallback != -1 - return {self.isActiveCallback}() + return type(self.isActiveCallback) == v:t_func ? self.isActiveCallback() : {self.isActiveCallback}() endif return 1 endfunction @@ -94,7 +94,11 @@ function! s:MenuItem.execute() call mc.showMenu() else if self.callback != -1 - call {self.callback}() + if type(self.callback) == v:t_func + call self.callback() + else + call {self.callback}() + endif endif endif endfunction diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index d24fc8f8..cb290ca2 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -14,8 +14,9 @@ endfunction function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) - for listener in s:Notifier.GetListenersForEvent(a:event) - call {listener}(event) + for Listener in s:Notifier.GetListenersForEvent(a:event) + let Callback = type(Listener) == v:t_func ? Listener : function(Listener) + call Callback(event) endfor endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index ccb94238..5f669f03 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -500,8 +500,9 @@ function! s:Path.ignore(nerdtree) endif endfor - for callback in g:NERDTree.PathFilters() - if {callback}({'path': self, 'nerdtree': a:nerdtree}) + for Callback in g:NERDTree.PathFilters() + let Callback = type(Callback) == v:t_func ? Callback : function(Callback) + if Callback({'path': self, 'nerdtree': a:nerdtree}) return 1 endif endfor From c962796b030f39db596fde5048464e57c2c6ca8d Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 16 Dec 2019 09:04:16 -0500 Subject: [PATCH 550/680] Ensure backward compatibility. v:t_func is not available before 8.0. --- lib/nerdtree/key_map.vim | 2 +- lib/nerdtree/menu_item.vim | 4 ++-- lib/nerdtree/notifier.vim | 2 +- lib/nerdtree/path.vim | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 2ee971d3..6714ee41 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -66,7 +66,7 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) == v:t_func ? self.callback : function(self.callback) + let Callback = type(self.callback) == type(function("tr")) ? self.callback : function(self.callback) if a:0 call Callback(a:1) else diff --git a/lib/nerdtree/menu_item.vim b/lib/nerdtree/menu_item.vim index 2d5122d1..8a74bb1a 100644 --- a/lib/nerdtree/menu_item.vim +++ b/lib/nerdtree/menu_item.vim @@ -79,7 +79,7 @@ endfunction "specified function! s:MenuItem.enabled() if self.isActiveCallback != -1 - return type(self.isActiveCallback) == v:t_func ? self.isActiveCallback() : {self.isActiveCallback}() + return type(self.isActiveCallback) == type(function("tr")) ? self.isActiveCallback() : {self.isActiveCallback}() endif return 1 endfunction @@ -94,7 +94,7 @@ function! s:MenuItem.execute() call mc.showMenu() else if self.callback != -1 - if type(self.callback) == v:t_func + if type(self.callback) == type(function("tr")) call self.callback() else call {self.callback}() diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index cb290ca2..dfd48b33 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -15,7 +15,7 @@ function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) for Listener in s:Notifier.GetListenersForEvent(a:event) - let Callback = type(Listener) == v:t_func ? Listener : function(Listener) + let Callback = type(Listener) == type(function("tr")) ? Listener : function(Listener) call Callback(event) endfor endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 5f669f03..4ececf9e 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -501,7 +501,7 @@ function! s:Path.ignore(nerdtree) endfor for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) == v:t_func ? Callback : function(Callback) + let Callback = type(Callback) == type(function("tr")) ? Callback : function(Callback) if Callback({'path': self, 'nerdtree': a:nerdtree}) return 1 endif From 1ab85e33bef8763a618c505ee5a0611519f81e5a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 16 Dec 2019 09:06:45 -0500 Subject: [PATCH 551/680] Update version in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 619e1540..cec006c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) - **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067) #### 6.3 - **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/scrooloose/nerdtree/pull/1060) From f64c0062ee716eb13d8a66250600a987821e2930 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 30 Dec 2019 23:31:06 -0500 Subject: [PATCH 552/680] Set theme jekyll-theme-cayman --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..c4192631 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file From fff397560869e1a8fc605db026383a0d99e01f1d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 07:52:58 +0300 Subject: [PATCH 553/680] Configure Vint linter --- .vintrc.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vintrc.yaml diff --git a/.vintrc.yaml b/.vintrc.yaml new file mode 100644 index 00000000..c44b6aba --- /dev/null +++ b/.vintrc.yaml @@ -0,0 +1,5 @@ +cmdargs: + severity: style_problem + color: true + env: + neovim: false From ec0fca4c7d4c540385a656b59ddb6f4954b271bb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 07:52:14 +0300 Subject: [PATCH 554/680] Add CI job that lints VimL and reviews PRs --- .github/workflows/vint.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/vint.yml diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml new file mode 100644 index 00000000..36d72580 --- /dev/null +++ b/.github/workflows/vint.yml @@ -0,0 +1,15 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1.0.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review From d8d799a4d6d9be5d629c9e435069fcb0c7945f85 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 08:56:10 +0300 Subject: [PATCH 555/680] Fix VimL syntax error: escapes work differently outside quotes --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 99773bf1..d8e8f95d 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -27,7 +27,7 @@ exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' -syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark +syn match NERDTreeExecFile '^ .*\*\($\| \)' contains=NERDTreeRO,NERDTreeBookmark exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' "highlighting for readonly files From 8d81510aa6b0b2053131617003c013025953290e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:36:36 +0300 Subject: [PATCH 556/680] Fix VimL syntax error: undefined variable --- lib/nerdtree/creator.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index efd3cc81..bbc9bca5 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -82,7 +82,7 @@ function! s:Creator.createWindowTree(dir) try let path = g:NERDTreePath.New(a:dir) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("Invalid directory name:" . a:name) + call nerdtree#echo("Invalid directory name:" . a:dir) return endtry From 45e33f25021f5473f5b7b70f3e97d06e0922ccf8 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 08:50:25 +0300 Subject: [PATCH 557/680] Fix lint warnings: prefer single quoted strings --- autoload/nerdtree.vim | 24 ++--- autoload/nerdtree/ui_glue.vim | 138 ++++++++++++------------ lib/nerdtree/bookmark.vim | 34 +++--- lib/nerdtree/creator.vim | 30 +++--- lib/nerdtree/flag_set.vim | 4 +- lib/nerdtree/key_map.vim | 22 ++-- lib/nerdtree/menu_controller.vim | 18 ++-- lib/nerdtree/menu_item.vim | 10 +- lib/nerdtree/nerdtree.vim | 38 +++---- lib/nerdtree/notifier.vim | 4 +- lib/nerdtree/opener.vim | 46 ++++---- lib/nerdtree/path.vim | 46 ++++---- lib/nerdtree/tree_dir_node.vim | 46 ++++---- lib/nerdtree/tree_file_node.vim | 14 +-- lib/nerdtree/ui.vim | 160 +++++++++++++-------------- nerdtree_plugin/exec_menuitem.vim | 4 +- nerdtree_plugin/fs_menu.vim | 138 ++++++++++++------------ nerdtree_plugin/vcs.vim | 4 +- plugin/NERD_tree.vim | 172 +++++++++++++++--------------- syntax/nerdtree.vim | 4 +- 20 files changed, 478 insertions(+), 478 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 76c076e9..c2f7f1c9 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -1,9 +1,9 @@ -if exists("g:loaded_nerdtree_autoload") +if exists('g:loaded_nerdtree_autoload') finish endif let g:loaded_nerdtree_autoload = 1 -let s:rootNERDTreePath = resolve(expand(":p:h:h")) +let s:rootNERDTreePath = resolve(expand(':p:h:h')) "FUNCTION: nerdtree#version(...) {{{1 " If any value is given as an argument, the entire line of text from the @@ -12,7 +12,7 @@ let s:rootNERDTreePath = resolve(expand(":p:h:h")) function! nerdtree#version(...) let l:text = 'Unknown' try - let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash())) + let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) let l:line = 0 while l:line <= len(l:changelog) if l:changelog[l:line] =~ '\d\+\.\d\+' @@ -47,7 +47,7 @@ endfunction "FUNCTION: nerdtree#and(x,y) {{{2 " Implements and() function for Vim <= 7.2 function! nerdtree#and(x,y) - if exists("*and") + if exists('*and') return and(a:x, a:y) else let l:x = a:x @@ -83,18 +83,18 @@ endfunction "FUNCTION: s:reuseWin(dir) {{{2 "finds a NERDTree buffer with root of dir, and opens it. function! s:reuseWin(dir) abort - let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p")) + let path = g:NERDTreePath.New(fnamemodify(a:dir, ':p')) - for i in range(1, bufnr("$")) + for i in range(1, bufnr('$')) unlet! nt - let nt = getbufvar(i, "NERDTree") + let nt = getbufvar(i, 'NERDTree') if empty(nt) continue endif if nt.isWinTree() && nt.root.path.equals(path) - call nt.setPreviousBuf(bufnr("#")) - exec "buffer " . i + call nt.setPreviousBuf(bufnr('#')) + exec 'buffer ' . i return 1 endif endfor @@ -207,12 +207,12 @@ endfunction "FUNCTION: nerdtree#runningWindows(dir) {{{2 function! nerdtree#runningWindows() - return has("win16") || has("win32") || has("win64") + return has('win16') || has('win32') || has('win64') endfunction "FUNCTION: nerdtree#runningCygwin(dir) {{{2 function! nerdtree#runningCygwin() - return has("win32unix") + return has('win32unix') endfunction " SECTION: View Functions {{{1 @@ -225,7 +225,7 @@ endfunction "msg: the message to echo function! nerdtree#echo(msg) redraw - echomsg empty(a:msg) ? "" : ("NERDTree: " . a:msg) + echomsg empty(a:msg) ? '' : ('NERDTree: ' . a:msg) endfunction "FUNCTION: nerdtree#echoError {{{2 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 4ba5b05f..96d0fa71 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -1,4 +1,4 @@ -if exists("g:loaded_nerdtree_ui_glue_autoload") +if exists('g:loaded_nerdtree_ui_glue_autoload') finish endif let g:loaded_nerdtree_ui_glue_autoload = 1 @@ -8,73 +8,73 @@ function! nerdtree#ui_glue#createDefaultBindings() let s = '' . s:SID() . '_' call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s . 'handleMiddleMouse' }) - call NERDTreeAddKeyMap({ 'key': '', 'scope': "all", 'callback': s."handleLeftClick" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s.'handleLeftClick' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"}) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s.'customOpenFile'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s.'customOpenDir'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s.'customOpenBookmark'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewBookmark" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Node', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Node', 'callback': s.'openVSplit' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Node', 'callback': s.'previewNodeCurrent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Node', 'callback': s.'previewNodeHSplit' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': 'all', 'callback': s . 'upDirCurrentRootClosed' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': 'all', 'callback': s . 'upDirCurrentRootOpen' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': 'Node', 'callback': s . 'chRoot' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': 'Node', 'callback': s.'chCwd' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': 'all', 'callback': s.'closeTreeWindow' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': 'all', 'callback': 'nerdtree#ui_glue#chRootCwd' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': 'all', 'callback': s.'refreshRoot' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': 'Node', 'callback': s.'refreshCurrent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': 'all', 'callback': s.'displayHelp' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': 'all', 'callback': s.'toggleZoom' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': 'all', 'callback': s.'toggleShowHidden' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': 'all', 'callback': s.'toggleShowBookmarks' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': 'Node', 'callback': s.'closeCurrentDir' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': 'Node', 'callback': s.'showMenu' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': 'Node', 'callback': s.'jumpToParent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': 'Node', 'callback': s.'jumpToFirstChild' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': 'Node', 'callback': s.'jumpToLastChild' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "FileNode", 'callback': s."openExplorer" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'DirNode', 'callback': s.'openExplorer' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'FileNode', 'callback': s.'openExplorer' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': 'Bookmark', 'callback': s.'deleteBookmark' }) endfunction @@ -82,19 +82,19 @@ endfunction "============================================================ "FUNCTION: s:customOpenFile() {{{1 -" Open file node with the "custom" key, initially . +" Open file node with the 'custom' key, initially . function! s:customOpenFile(node) call a:node.activate(s:initCustomOpenArgs().file) endfunction "FUNCTION: s:customOpenDir() {{{1 -" Open directory node with the "custom" key, initially . +" Open directory node with the 'custom' key, initially . function! s:customOpenDir(node) call s:activateDirNode(a:node, s:initCustomOpenArgs().dir) endfunction "FUNCTION: s:customOpenBookmark() {{{1 -" Open bookmark node with the "custom" key, initially . +" Open bookmark node with the 'custom' key, initially . function! s:customOpenBookmark(node) if a:node.path.isDirectory call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) @@ -113,7 +113,7 @@ endfunction "FUNCTION: s:activateAll() {{{1 "handle the user activating the updir line function! s:activateAll() - if getline(".") ==# g:NERDTreeUI.UpDirLine() + if getline('.') ==# g:NERDTreeUI.UpDirLine() return nerdtree#ui_glue#upDir(0) endif endfunction @@ -155,10 +155,10 @@ function! nerdtree#ui_glue#bookmarkNode(...) call currentNode.bookmark(name) call b:NERDTree.render() catch /^NERDTree.IllegalBookmarkNameError/ - call nerdtree#echo("bookmark names must not contain spaces") + call nerdtree#echo('bookmark names must not contain spaces') endtry else - call nerdtree#echo("select a node first") + call nerdtree#echo('select a node first') endif endfunction @@ -167,7 +167,7 @@ function! s:chCwd(node) try call a:node.path.changeToDir() catch /^NERDTree.PathChangeError/ - call nerdtree#echoWarning("could not change cwd") + call nerdtree#echoWarning('could not change cwd') endtry endfunction @@ -237,12 +237,12 @@ endfunction " close the tree window function! s:closeTreeWindow() if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 - exec "buffer " . b:NERDTree.previousBuf() + exec 'buffer ' . b:NERDTree.previousBuf() else - if winnr("$") > 1 + if winnr('$') > 1 call g:NERDTree.Close() else - call nerdtree#echo("Cannot close last window") + call nerdtree#echo('Cannot close last window') endif endif endfunction @@ -250,8 +250,8 @@ endfunction " FUNCTION: s:deleteBookmark(bookmark) {{{1 " Prompt the user to confirm the deletion of the selected bookmark. function! s:deleteBookmark(bookmark) - let l:message = "Delete the bookmark \"" . a:bookmark.name - \ . "\" from the bookmark list?" + let l:message = 'Delete the bookmark "' . a:bookmark.name + \ . '" from the bookmark list?' let l:choices = "&Yes\n&No" @@ -340,8 +340,8 @@ function! s:handleLeftClick() "the dir arrows are multibyte chars, and vim's string functions only "deal with single bytes - so split the line up with the hack below and "take the line substring manually - let line = split(getline(line(".")), '\zs') - let startToCur = "" + let line = split(getline(line('.')), '\zs') + let startToCur = '' for i in range(0,len(line)-1) let startToCur .= line[i] endfor @@ -483,7 +483,7 @@ endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 " Open the Bookmark that has the specified name. This function provides the -" implementation for the ":OpenBookmark" command. +" implementation for the :OpenBookmark command. function! nerdtree#ui_glue#openBookmark(name) try let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) @@ -527,10 +527,10 @@ endfunction " FUNCTION: s:openNodeRecursively(node) {{{1 function! s:openNodeRecursively(node) - call nerdtree#echo("Recursively opening node. Please wait...") + call nerdtree#echo('Recursively opening node. Please wait...') call a:node.openRecursively() call b:NERDTree.render() - call nerdtree#echo("") + call nerdtree#echo('') endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 @@ -564,7 +564,7 @@ function! nerdtree#ui_glue#revealBookmark(name) let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) catch /^NERDTree.BookmarkNotFoundError/ - call nerdtree#echo("Bookmark isnt cached under the current root") + call nerdtree#echo('Bookmark isnt cached under the current root') endtry endfunction @@ -575,15 +575,15 @@ function! s:refreshRoot() if !g:NERDTree.IsOpen() return endif - call nerdtree#echo("Refreshing the root node. This could take a while...") + call nerdtree#echo('Refreshing the root node. This could take a while...') let l:curWin = winnr() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) call b:NERDTree.root.refresh() call b:NERDTree.render() redraw - call nerdtree#exec(l:curWin . "wincmd w", 1) - call nerdtree#echo("") + call nerdtree#exec(l:curWin . 'wincmd w', 1) + call nerdtree#echo('') endfunction " FUNCTION: s:refreshCurrent(node) {{{1 @@ -594,10 +594,10 @@ function! s:refreshCurrent(node) let node = node.parent endif - call nerdtree#echo("Refreshing node. This could take a while...") + call nerdtree#echo('Refreshing node. This could take a while...') call node.refresh() call b:NERDTree.render() - call nerdtree#echo("") + call nerdtree#echo('') endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 @@ -615,7 +615,7 @@ endfunction " Function: s:SID() {{{1 function s:SID() - if !exists("s:sid") + if !exists('s:sid') let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') endif return s:sid diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index b206e7a4..ccb6f987 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -33,7 +33,7 @@ endfunction " Class method to get all bookmarks. Lazily initializes the bookmarks global " variable function! s:Bookmark.Bookmarks() - if !exists("g:NERDTreeBookmarks") + if !exists('g:NERDTreeBookmarks') let g:NERDTreeBookmarks = [] endif return g:NERDTreeBookmarks @@ -53,7 +53,7 @@ endfunction " FUNCTION: Bookmark.BookmarkFor(name) {{{1 " Class method that returns the Bookmark object having the specified name. -" Throws "NERDTree.BookmarkNotFoundError" if no Bookmark is found. +" Throws NERDTree.BookmarkNotFoundError if no Bookmark is found. function! s:Bookmark.BookmarkFor(name) let l:result = {} for l:bookmark in s:Bookmark.Bookmarks() @@ -111,7 +111,7 @@ function! s:Bookmark.CacheBookmarks(silent) if invalidBookmarksFound call s:Bookmark.Write() if !a:silent - call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") + call nerdtree#echo(invalidBookmarksFound . ' invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.') endif endif endif @@ -120,7 +120,7 @@ endfunction " FUNCTION: Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) {{{1 " Class method that indicates the relative position of two bookmarks when " placed in alphabetical order by name. Case-sensitivity is determined by an -" option. Supports the "s:Bookmark.SortBookmarksList()" method. +" option. Supports the s:Bookmark.SortBookmarksList() method. function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) let l:result = 0 if g:NERDTreeBookmarksSort == 1 @@ -159,13 +159,13 @@ endfunction " FUNCTION: s:Edit() {{{1 " opens the NERDTreeBookmarks file for manual editing function! s:Bookmark.Edit() - call nerdtree#exec("wincmd w", 1) - call nerdtree#exec("edit ".g:NERDTreeBookmarksFile, 1) + call nerdtree#exec('wincmd w', 1) + call nerdtree#exec('edit '.g:NERDTreeBookmarksFile, 1) endfunction " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " Returns the tree node object associated with this Bookmark. -" Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. +" Throws NERDTree.BookmarkedNodeNotFoundError if the node is not found. " " Args: " searchFromAbsoluteRoot: boolean flag, search from the highest cached node @@ -185,8 +185,8 @@ endfunction " FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 " Class method that returns the tree node object for the Bookmark with the -" given name. Throws "NERDTree.BookmarkNotFoundError" if a Bookmark with the -" name does not exist. Throws "NERDTree.BookmarkedNodeNotFoundError" if a +" given name. Throws NERDTree.BookmarkNotFoundError if a Bookmark with the +" name does not exist. Throws NERDTree.BookmarkedNodeNotFoundError if a " tree node for the named Bookmark could not be found. function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) let l:bookmark = s:Bookmark.BookmarkFor(a:name) @@ -196,7 +196,7 @@ endfunction " FUNCTION: Bookmark.GetSelected() {{{1 " returns the Bookmark the cursor is over, or {} function! s:Bookmark.GetSelected() - let line = getline(".") + let line = getline('.') let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') if name != line try @@ -212,7 +212,7 @@ endfunction " Class method to get all invalid bookmark strings read from the bookmarks " file function! s:Bookmark.InvalidBookmarks() - if !exists("g:NERDTreeInvalidBookmarks") + if !exists('g:NERDTreeInvalidBookmarks') let g:NERDTreeInvalidBookmarks = [] endif return g:NERDTreeInvalidBookmarks @@ -222,8 +222,8 @@ endfunction function! s:Bookmark.mustExist() if !self.path.exists() call s:Bookmark.CacheBookmarks(1) - throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". - \ self.name ."\" points to a non existing location: \"". self.path.str() + throw 'NERDTree.BookmarkPointsToInvalidLocationError: the bookmark "'. + \ self.name .'" points to a non existing location: "'. self.path.str() endif endfunction @@ -231,7 +231,7 @@ endfunction " Create a new bookmark object with the given name and path object function! s:Bookmark.New(name, path) if a:name =~# ' ' - throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name + throw 'NERDTree.IllegalBookmarkNameError: illegal name:' . a:name endif let newBookmark = copy(self) @@ -335,7 +335,7 @@ function! s:Bookmark.validate() return 1 else call s:Bookmark.CacheBookmarks(1) - call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") + call nerdtree#echo(self.name . 'now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.') return 0 endif endfunction @@ -349,7 +349,7 @@ function! s:Bookmark.Write() endfor "add a blank line before the invalid ones - call add(bookmarkStrings, "") + call add(bookmarkStrings, '') for j in s:Bookmark.InvalidBookmarks() call add(bookmarkStrings, j) @@ -358,7 +358,7 @@ function! s:Bookmark.Write() try call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) catch - call nerdtree#echoError("Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.") + call nerdtree#echoError('Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.') endtry endfunction diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index bbc9bca5..294d9a82 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -82,20 +82,20 @@ function! s:Creator.createWindowTree(dir) try let path = g:NERDTreePath.New(a:dir) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("Invalid directory name:" . a:dir) + call nerdtree#echo('Invalid directory name:' . a:dir) return endtry "we want the directory buffer to disappear when we do the :edit below setlocal bufhidden=wipe - let previousBuf = expand("#") + let previousBuf = expand('#') "we need a unique name for each window tree buffer to ensure they are "all independent - exec g:NERDTreeCreatePrefix . " edit " . self._nextBufferName() + exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName() - call self._createNERDTree(path, "window") + call self._createNERDTree(path, 'window') let b:NERDTree._previousBuf = bufnr(previousBuf) call self._setCommonBufOptions() @@ -109,7 +109,7 @@ function! s:Creator._createNERDTree(path, type) let b:NERDTree = g:NERDTree.New(a:path, a:type) " TODO: This assignment is kept for compatibility reasons. Many other - " plugins use "b:NERDTreeRoot" instead of "b:NERDTree.root". Remove this + " plugins use b:NERDTreeRoot instead of b:NERDTree.root. Remove this " assignment in the future. let b:NERDTreeRoot = b:NERDTree.root @@ -126,9 +126,9 @@ endfunction function! s:Creator.createMirror() "get the names off all the nerd tree buffers let treeBufNames = [] - for i in range(1, tabpagenr("$")) + for i in range(1, tabpagenr('$')) let nextName = self._tabpagevar(i, 'NERDTreeBufName') - if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) + if nextName != -1 && (!exists('t:NERDTreeBufName') || nextName != t:NERDTreeBufName) call add(treeBufNames, nextName) endif endfor @@ -140,7 +140,7 @@ function! s:Creator.createMirror() let i = 0 while i < len(treeBufNames) let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTree").root + let treeRoot = getbufvar(bufName, 'NERDTree').root let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName let i = i + 1 endwhile @@ -148,7 +148,7 @@ function! s:Creator.createMirror() "work out which tree to mirror, if there is more than 1 then ask the user let bufferName = '' if len(keys(options)) > 1 - let choices = ["Choose a tree to mirror"] + let choices = ['Choose a tree to mirror'] let choices = extend(choices, sort(keys(options))) let choice = inputlist(choices) if choice < 1 || choice > len(options) || choice ==# '' @@ -159,7 +159,7 @@ function! s:Creator.createMirror() elseif len(keys(options)) ==# 1 let bufferName = values(options)[0] else - call nerdtree#echo("No trees to mirror") + call nerdtree#echo('No trees to mirror') return endif @@ -227,7 +227,7 @@ endfunction " FUNCTION: s:Creator._nextBufferNumber() {{{1 " the number to add to the nerd tree buffer name to make the buf name unique function! s:Creator._nextBufferNumber() - if !exists("s:Creator._NextBufNum") + if !exists('s:Creator._NextBufNum') let s:Creator._NextBufNum = 1 else let s:Creator._NextBufNum += 1 @@ -254,7 +254,7 @@ function! s:Creator._pathForString(str) try let path = g:NERDTreePath.New(dir) catch /^NERDTree.InvalidArgumentsError/ - call nerdtree#echo("No bookmark or directory found for: " . a:str) + call nerdtree#echo('No bookmark or directory found for: ' . a:str) return {} endtry endif @@ -274,7 +274,7 @@ function! s:Creator._removeTreeBufForTab() "nerdtree buf may be mirrored/displayed elsewhere if self._isBufHidden(buf) - exec "bwipeout " . buf + exec 'bwipeout ' . buf endif endif @@ -333,12 +333,12 @@ function! s:Creator._tabpagevar(tabnr, var) let old_ei = &ei set ei=all - exec "tabnext " . a:tabnr + exec 'tabnext ' . a:tabnr let v = -1 if exists('t:' . a:var) exec 'let v = t:' . a:var endif - exec "tabnext " . currentTab + exec 'tabnext ' . currentTab let &ei = old_ei diff --git a/lib/nerdtree/flag_set.vim b/lib/nerdtree/flag_set.vim index bc6e8879..75528674 100644 --- a/lib/nerdtree/flag_set.vim +++ b/lib/nerdtree/flag_set.vim @@ -43,13 +43,13 @@ endfunction "FUNCTION: FlagSet.renderToString() {{{1 function! s:FlagSet.renderToString() - let flagstring = "" + let flagstring = '' for i in values(self._flags) let flagstring .= join(i) endfor if len(flagstring) == 0 - return "" + return '' endif return '[' . flagstring . ']' diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 6714ee41..5c96c61f 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -53,7 +53,7 @@ function! s:KeyMap.bind() endif let keymapInvokeString = escape(keymapInvokeString, '\') - let premap = self.key == "" ? " " : " " + let premap = self.key == '' ? ' ' : ' ' exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' endfunction @@ -66,7 +66,7 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) == type(function("tr")) ? self.callback : function(self.callback) + let Callback = type(self.callback) == type(function('tr')) ? self.callback : function(self.callback) if a:0 call Callback(a:1) else @@ -78,11 +78,11 @@ endfunction "Find a keymapping for a:key and the current scope invoke it. " "Scope is determined as follows: -" * if the cursor is on a dir node then "DirNode" -" * if the cursor is on a file node then "FileNode" -" * if the cursor is on a bookmark then "Bookmark" +" * if the cursor is on a dir node then DirNode +" * if the cursor is on a file node then FileNode +" * if the cursor is on a bookmark then Bookmark " -"If a keymap has the scope of "all" then it will be called if no other keymap +"If a keymap has the scope of 'all' then it will be called if no other keymap "is found for a:key and the scope. function! s:KeyMap.Invoke(key) @@ -100,7 +100,7 @@ function! s:KeyMap.Invoke(key) "try file node if !node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "FileNode") + let km = s:KeyMap.FindFor(a:key, 'FileNode') if !empty(km) return km.invoke(node) endif @@ -108,14 +108,14 @@ function! s:KeyMap.Invoke(key) "try dir node if node.path.isDirectory - let km = s:KeyMap.FindFor(a:key, "DirNode") + let km = s:KeyMap.FindFor(a:key, 'DirNode') if !empty(km) return km.invoke(node) endif endif "try generic node - let km = s:KeyMap.FindFor(a:key, "Node") + let km = s:KeyMap.FindFor(a:key, 'Node') if !empty(km) return km.invoke(node) endif @@ -125,14 +125,14 @@ function! s:KeyMap.Invoke(key) "try bookmark let bm = g:NERDTreeBookmark.GetSelected() if !empty(bm) - let km = s:KeyMap.FindFor(a:key, "Bookmark") + let km = s:KeyMap.FindFor(a:key, 'Bookmark') if !empty(km) return km.invoke(bm) endif endif "try all - let km = s:KeyMap.FindFor(a:key, "all") + let km = s:KeyMap.FindFor(a:key, 'all') if !empty(km) return km.invoke() endif diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index 874c09dc..a3b168b4 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -44,7 +44,7 @@ function! s:MenuController.showMenu() finally call self._restoreOptions() - " Redraw when "Ctrl-C" or "Esc" is received. + " Redraw when Ctrl-C or Esc is received. if !l:done || self.selection == -1 redraw! endif @@ -58,25 +58,25 @@ endfunction "FUNCTION: MenuController._echoPrompt() {{{1 function! s:MenuController._echoPrompt() - let navHelp = "Use " . g:NERDTreeMenuDown . "/" . g:NERDTreeMenuUp . "/enter" + let navHelp = 'Use ' . g:NERDTreeMenuDown . '/' . g:NERDTreeMenuUp . '/enter' if self.isMinimal() let selection = self.menuItems[self.selection].text - let keyword = matchstr(selection, "\([^ ]*") + let keyword = matchstr(selection, '\([^ ]*') let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") - let shortcuts[self.selection] = " " . keyword . " " + let shortcuts[self.selection] = ' ' . keyword . ' ' - echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): " + echo 'Menu: [' . join(shortcuts, ',') . '] (' . navHelp . ' or shortcut): ' else - echo "NERDTree Menu. " . navHelp . ", or the shortcuts indicated" - echo "=========================================================" + echo 'NERDTree Menu. ' . navHelp . ', or the shortcuts indicated' + echo '=========================================================' for i in range(0, len(self.menuItems)-1) if self.selection == i - echo "> " . self.menuItems[i].text + echo '> ' . self.menuItems[i].text else - echo " " . self.menuItems[i].text + echo ' ' . self.menuItems[i].text endif endfor endif diff --git a/lib/nerdtree/menu_item.vim b/lib/nerdtree/menu_item.vim index 8a74bb1a..7f259171 100644 --- a/lib/nerdtree/menu_item.vim +++ b/lib/nerdtree/menu_item.vim @@ -6,7 +6,7 @@ let g:NERDTreeMenuItem = s:MenuItem "FUNCTION: MenuItem.All() {{{1 "get all top level menu items function! s:MenuItem.All() - if !exists("s:menuItems") + if !exists('s:menuItems') let s:menuItems = [] endif return s:menuItems @@ -58,7 +58,7 @@ function! s:MenuItem.CreateSeparator(options) let standard_options = { 'text': '--------------------', \ 'shortcut': -1, \ 'callback': -1 } - let options = extend(a:options, standard_options, "force") + let options = extend(a:options, standard_options, 'force') return s:MenuItem.Create(options) endfunction @@ -67,7 +67,7 @@ endfunction "make a new submenu and add it to global list function! s:MenuItem.CreateSubmenu(options) let standard_options = { 'callback': -1 } - let options = extend(a:options, standard_options, "force") + let options = extend(a:options, standard_options, 'force') return s:MenuItem.Create(options) endfunction @@ -79,7 +79,7 @@ endfunction "specified function! s:MenuItem.enabled() if self.isActiveCallback != -1 - return type(self.isActiveCallback) == type(function("tr")) ? self.isActiveCallback() : {self.isActiveCallback}() + return type(self.isActiveCallback) == type(function('tr')) ? self.isActiveCallback() : {self.isActiveCallback}() endif return 1 endfunction @@ -94,7 +94,7 @@ function! s:MenuItem.execute() call mc.showMenu() else if self.callback != -1 - if type(self.callback) == type(function("tr")) + if type(self.callback) == type(function('tr')) call self.callback() else call {self.callback}() diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 3e7ade8a..03878a48 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -37,26 +37,26 @@ function! s:NERDTree.Close() return endif - if winnr("$") != 1 + if winnr('$') != 1 " Use the window ID to identify the currently active window or fall " back on the buffer ID if win_getid/win_gotoid are not available, in " which case we'll focus an arbitrary window showing the buffer. let l:useWinId = exists('*win_getid') && exists('*win_gotoid') if winnr() == s:NERDTree.GetWinNum() - call nerdtree#exec("wincmd p", 1) - let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") - call nerdtree#exec("wincmd p", 1) + call nerdtree#exec('wincmd p', 1) + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') + call nerdtree#exec('wincmd p', 1) else - let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') endif - call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1) - call nerdtree#exec("close", 0) + call nerdtree#exec(s:NERDTree.GetWinNum() . ' wincmd w', 1) + call nerdtree#exec('close', 0) if l:useWinId - call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0) + call nerdtree#exec('call win_gotoid(' . l:activeBufOrWin . ')', 0) else - call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w", 0) + call nerdtree#exec(bufwinnr(l:activeBufOrWin) . ' wincmd w', 0) endif else close @@ -75,7 +75,7 @@ endfunction "Places the cursor at the top of the bookmarks table function! s:NERDTree.CursorToBookmarkTable() if !b:NERDTree.ui.getShowBookmarks() - throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" + throw 'NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active' endif if g:NERDTreeMinimalUI @@ -88,7 +88,7 @@ function! s:NERDTree.CursorToBookmarkTable() while getline(line) !~# '^>-\+Bookmarks-\+$' let line = line + 1 if line >= rootNodeLine - throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" + throw 'NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table' endif endwhile call cursor(line, 2) @@ -98,19 +98,19 @@ endfunction "Places the cursor in the nerd tree window function! s:NERDTree.CursorToTreeWin() call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 " Returns 1 if a nerd tree root exists in the current buffer function! s:NERDTree.ExistsForBuf() - return exists("b:NERDTree") + return exists('b:NERDTree') endfunction " Function: s:NERDTree.ExistsForTab() {{{1 " Returns 1 if a nerd tree root exists in the current tab function! s:NERDTree.ExistsForTab() - if !exists("t:NERDTreeBufName") + if !exists('t:NERDTreeBufName') return end @@ -133,7 +133,7 @@ function! s:NERDTree.ForCurrentTab() endif let bufnr = bufnr(t:NERDTreeBufName) - return getbufvar(bufnr, "NERDTree") + return getbufvar(bufnr, 'NERDTree') endfunction "FUNCTION: s:NERDTree.getRoot() {{{1 @@ -144,7 +144,7 @@ endfunction "FUNCTION: s:NERDTree.GetWinNum() {{{1 "gets the nerd tree window number for this tab function! s:NERDTree.GetWinNum() - if exists("t:NERDTreeBufName") + if exists('t:NERDTreeBufName') return bufwinnr(t:NERDTreeBufName) endif @@ -165,18 +165,18 @@ endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 function! s:NERDTree.isTabTree() - return self._type == "tab" + return self._type == 'tab' endfunction "FUNCTION: s:NERDTree.isWinTree() {{{1 function! s:NERDTree.isWinTree() - return self._type == "window" + return self._type == 'window' endfunction "FUNCTION: s:NERDTree.MustBeOpen() {{{1 function! s:NERDTree.MustBeOpen() if !s:NERDTree.IsOpen() - throw "NERDTree.TreeNotOpen" + throw 'NERDTree.TreeNotOpen' endif endfunction diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index dfd48b33..fc3155d7 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -15,13 +15,13 @@ function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) for Listener in s:Notifier.GetListenersForEvent(a:event) - let Callback = type(Listener) == type(function("tr")) ? Listener : function(Listener) + let Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) call Callback(event) endfor endfunction function! s:Notifier.GetListenersMap() - if !exists("s:refreshListenersMap") + if !exists('s:refreshListenersMap') let s:refreshListenersMap = {} endif return s:refreshListenersMap diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index fa0c9884..d9a8868a 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -1,7 +1,7 @@ " ============================================================================ " CLASS: Opener " -" The Opener class defines an API for "opening" operations. +" The Opener class defines an API for 'opening' operations. " ============================================================================ @@ -54,7 +54,7 @@ endfunction " find the window number of the first normal window function! s:Opener._firstUsableWindow() let i = 1 - while i <= winnr("$") + while i <= winnr('$') let bnum = winbufnr(i) if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' \ && !getwinvar(i, '&previewwindow') @@ -102,15 +102,15 @@ endfunction " winnumber: the number of the window in question function! s:Opener._isWindowUsable(winnumber) "gotta split if theres only one window (i.e. the NERD tree) - if winnr("$") ==# 1 + if winnr('$') ==# 1 return 0 endif let oldwinnr = winnr() - call nerdtree#exec(a:winnumber . "wincmd p", 1) - let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') + call nerdtree#exec(a:winnumber . 'wincmd p', 1) + let specialWindow = getbufvar('%', '&buftype') != '' || getwinvar('%', '&previewwindow') let modified = &modified - call nerdtree#exec(oldwinnr . "wincmd p", 1) + call nerdtree#exec(oldwinnr . 'wincmd p', 1) "if its a special window e.g. quickfix or another explorer plugin then we "have to split @@ -131,9 +131,9 @@ endfunction " a:path: the path object that is to be opened " a:opts: a dictionary containing the following optional keys... " 'where': specifies whether the node should be opened in new split, in -" a new tab or, in the last window; takes values "v", "h", or "t" +" a new tab or, in the last window; takes values 'v', 'h', or 't' " 'reuse': if file is already shown in a window, jump there; takes values -" "all", "currenttab", or empty +" 'all', 'currenttab', or empty " 'keepopen': boolean (0 or 1); if true, the tree window will not be closed " 'stay': boolean (0 or 1); if true, remain in tree window after opening function! s:Opener.New(path, opts) @@ -153,21 +153,21 @@ endfunction " FUNCTION: Opener._newSplit() {{{1 function! s:Opener._newSplit() - let onlyOneWin = (winnr("$") ==# 1) + let onlyOneWin = (winnr('$') ==# 1) let savesplitright = &splitright if onlyOneWin - let &splitright = (g:NERDTreeWinPos ==# "left") + let &splitright = (g:NERDTreeWinPos ==# 'left') endif " If only one window (ie. NERDTree), split vertically instead. - let splitMode = onlyOneWin ? "vertical" : "" + let splitMode = onlyOneWin ? 'vertical' : '' " Open the new window try call nerdtree#exec('wincmd p', 1) - call nerdtree#exec(splitMode . " split",1) + call nerdtree#exec(splitMode . ' split',1) catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' catch /^Vim\%((\a\+)\)\=:/ "do nothing endtry @@ -187,10 +187,10 @@ endfunction function! s:Opener._newVSplit() let l:winwidth = winwidth('.') - let onlyOneWin = (winnr("$") ==# 1) + let onlyOneWin = (winnr('$') ==# 1) let savesplitright = &splitright if onlyOneWin - let &splitright = (g:NERDTreeWinPos ==# "left") + let &splitright = (g:NERDTreeWinPos ==# 'left') let l:winwidth = g:NERDTreeWinSize endif @@ -219,7 +219,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif @@ -261,18 +261,18 @@ endfunction " FUNCTION: Opener._previousWindow() {{{1 function! s:Opener._previousWindow() - if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1 + if !self._isWindowUsable(winnr('#')) && self._firstUsableWindow() ==# -1 call self._newSplit() else try - if !self._isWindowUsable(winnr("#")) - call nerdtree#exec(self._firstUsableWindow() . "wincmd w", 1) + if !self._isWindowUsable(winnr('#')) + call nerdtree#exec(self._firstUsableWindow() . 'wincmd w', 1) else call nerdtree#exec('wincmd p', 1) endif catch /^Vim\%((\a\+)\)\=:E37/ call g:NERDTree.CursorToTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified." + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' catch /^Vim\%((\a\+)\)\=:/ echo v:exception endtry @@ -297,7 +297,7 @@ function! s:Opener._reuseWindow() "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') if winnr != -1 - call nerdtree#exec(winnr . "wincmd w", 0) + call nerdtree#exec(winnr . 'wincmd w', 0) call self._checkToCloseTree(0) return 1 endif @@ -312,7 +312,7 @@ function! s:Opener._reuseWindow() call self._checkToCloseTree(1) call nerdtree#exec(tabnr . 'tabnext', 1) let winnr = bufwinnr('^' . self._path.str() . '$') - call nerdtree#exec(winnr . "wincmd w", 0) + call nerdtree#exec(winnr . 'wincmd w', 0) return 1 endif @@ -321,7 +321,7 @@ endfunction " FUNCTION: Opener._saveCursorPos() {{{1 function! s:Opener._saveCursorPos() - let self._bufnr = bufnr("") + let self._bufnr = bufnr('') let self._tabnr = tabpagenr() endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 4ececf9e..a77331f3 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -37,7 +37,7 @@ endfunction " FUNCTION: Path.bookmarkNames() {{{1 function! s:Path.bookmarkNames() - if !exists("self._bookmarkNames") + if !exists('self._bookmarkNames') call self.cacheDisplayString() endif return self._bookmarkNames @@ -87,22 +87,22 @@ function! s:Path.changeToDir() endif try - if g:NERDTreeUseTCD && exists(":tcd") == 2 - execute "tcd " . dir + if g:NERDTreeUseTCD && exists(':tcd') == 2 + execute 'tcd ' . dir call nerdtree#echo("Tab's CWD is now: " . getcwd()) else - execute "cd " . dir - call nerdtree#echo("CWD is now: " . getcwd()) + execute 'cd ' . dir + call nerdtree#echo('CWD is now: ' . getcwd()) endif catch - throw "NERDTree.PathChangeError: cannot change CWD to " . dir + throw 'NERDTree.PathChangeError: cannot change CWD to ' . dir endtry endfunction " FUNCTION: Path.compareTo() {{{1 " " Compares this Path to the given path and returns 0 if they are equal, -1 if -" this Path is "less than" the given path, or 1 if it is "greater". +" this Path is 'less than' the given path, or 1 if it is 'greater'. " " Args: " path: the path object to compare this to @@ -188,7 +188,7 @@ endfunction " dest: the location to copy this dir/file to function! s:Path.copy(dest) if !s:Path.CopyingSupported() - throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS" + throw 'NERDTree.CopyingNotSupportedError: Copying is not supported on this OS' endif call s:Path.createParentDirectories(a:dest) @@ -199,10 +199,10 @@ function! s:Path.copy(dest) let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) endif - let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(a:dest, self._escChars()) + let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) let success = system(cmd) if v:shell_error != 0 - throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" + throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" endif endfunction @@ -286,7 +286,7 @@ endfunction " Returns a string that specifies how the path should be represented as a " string function! s:Path.displayString() - if self.cachedDisplayString ==# "" + if self.cachedDisplayString ==# '' call self.cacheDisplayString() endif @@ -295,7 +295,7 @@ endfunction " FUNCTION: Path.edit() {{{1 function! s:Path.edit() - exec "edit " . self.str({'format': 'Edit'}) + exec 'edit ' . self.str({'format': 'Edit'}) endfunction " FUNCTION: Path.extractDriveLetter(fullpath) {{{1 @@ -306,7 +306,7 @@ function! s:Path.extractDriveLetter(fullpath) if a:fullpath =~ '^\(\\\\\|\/\/\)' "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') - let self.drive = substitute(self.drive, '/', '\', "g") + let self.drive = substitute(self.drive, '/', '\', 'g') else let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '') endif @@ -413,7 +413,7 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + if !exists('self._sortKey') || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder " Look for file metadata tags: [[timestamp]], [[extension]], [[size]] let metadata = [] for tag in g:NERDTreeSortOrder @@ -501,7 +501,7 @@ function! s:Path.ignore(nerdtree) endfor for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) == type(function("tr")) ? Callback : function(Callback) + let Callback = type(Callback) == type(function('tr')) ? Callback : function(Callback) if Callback({'path': self, 'nerdtree': a:nerdtree}) return 1 endif @@ -637,8 +637,8 @@ function! s:Path.readInfoFromDisk(fullpath) let fullpath = s:Path.WinToUnixPath(a:fullpath) - if getftype(fullpath) ==# "fifo" - throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath + if getftype(fullpath) ==# 'fifo' + throw 'NERDTree.InvalidFiletypeError: Cant handle FIFO files: ' . a:fullpath endif let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)') @@ -650,7 +650,7 @@ function! s:Path.readInfoFromDisk(fullpath) let self.isDirectory = 0 let self.isReadOnly = filewritable(a:fullpath) ==# 0 else - throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath + throw 'NERDTree.InvalidArgumentsError: Invalid path = ' . a:fullpath endif let self.isExecutable = 0 @@ -700,7 +700,7 @@ endfunction " Renames this node on the filesystem function! s:Path.rename(newPath) if a:newPath ==# '' - throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath + throw 'NERDTree.InvalidArgumentsError: Invalid newPath for renaming = '. a:newPath endif call s:Path.createParentDirectories(a:newPath) @@ -742,7 +742,7 @@ endfunction " value associated with 'truncateTo'. A '<' is prepended. function! s:Path.str(...) let options = a:0 ? a:1 : {} - let toReturn = "" + let toReturn = '' if has_key(options, 'format') let format = options['format'] @@ -883,13 +883,13 @@ function! s:Path.WinToUnixPath(pathstr) let toReturn = a:pathstr "remove the x:\ of the front - let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") + let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', '') "remove the \\ network share from the front - let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "") + let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', '') "convert all \ chars to / - let toReturn = substitute(toReturn, '\', '/', "g") + let toReturn = substitute(toReturn, '\', '/', 'g') return toReturn endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 4015f0be..f59c064f 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -218,7 +218,7 @@ endfunction function! s:TreeDirNode.getChildByIndex(indx, visible) let array_to_search = a:visible? self.getVisibleChildren() : self.children if a:indx > len(array_to_search) - throw "NERDTree.InvalidArgumentsError: Index is out of bounds." + throw 'NERDTree.InvalidArgumentsError: Index is out of bounds.' endif return array_to_search[a:indx] endfunction @@ -255,7 +255,7 @@ function! s:TreeDirNode.getChildIndex(path) endfunction " FUNCTION: TreeDirNode.getDirChildren() {{{1 -" Return a list of all child nodes from "self.children" that are of type +" Return a list of all child nodes from 'self.children' that are of type " TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. function! s:TreeDirNode.getDirChildren() return filter(copy(self.children), 'v:val.path.isDirectory == 1') @@ -267,7 +267,7 @@ endfunction " " Args: " pattern: (string) the glob pattern to apply -" all: (0 or 1) if 1, include "." and ".." if they match "pattern"; if 0, +" all: (0 or 1) if 1, include '.' and '..' if they match 'pattern'; if 0, " always exclude them " " Note: If the pathnames in the result list are below the working directory, @@ -276,14 +276,14 @@ endfunction " relative paths. function! s:TreeDirNode._glob(pattern, all) - " Construct a path specification such that "globpath()" will return + " Construct a path specification such that globpath() will return " relative pathnames, if possible. if self.path.str() == getcwd() let l:pathSpec = ',' else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') - " On Windows, the drive letter may be removed by "fnamemodify()". + " On Windows, the drive letter may be removed by fnamemodify(). if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() let l:pathSpec = self.path.drive . l:pathSpec endif @@ -291,8 +291,8 @@ function! s:TreeDirNode._glob(pattern, all) let l:globList = [] - " See ":h version7.txt" and ":h version8.txt" for details on the - " development of the "glob()" and "globpath()" functions. + " See ':h version7.txt' and ':h version8.txt' for details on the + " development of the glob() and globpath() functions. if v:version > 704 || (v:version == 704 && has('patch654')) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) elseif v:version == 704 && has('patch279') @@ -305,7 +305,7 @@ function! s:TreeDirNode._glob(pattern, all) let l:globList = split(l:globString, "\n") endif - " If "a:all" is false, filter "." and ".." from the output. + " If a:all is false, filter '.' and '..' from the output. if !a:all let l:toRemove = [] @@ -405,7 +405,7 @@ endfunction " Removes all childen from this node and re-reads them " " Args: -" silent: 1 if the function should not echo any "please wait" messages for +" silent: 1 if the function should not echo any 'please wait' messages for " large directories " " Return: the number of child nodes read @@ -416,7 +416,7 @@ function! s:TreeDirNode._initChildren(silent) let files = self._glob('*', 1) + self._glob('.*', 0) if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call nerdtree#echo("Please wait, caching a large dir ...") + call nerdtree#echo('Please wait, caching a large dir ...') endif let invalidFilesFound = 0 @@ -432,10 +432,10 @@ function! s:TreeDirNode._initChildren(silent) call self.sortChildren() - call nerdtree#echo("") + call nerdtree#echo('') if invalidFilesFound - call nerdtree#echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") + call nerdtree#echoWarning(invalidFilesFound . ' file(s) could not be loaded into the NERD tree') endif return self.getChildCount() endfunction @@ -448,7 +448,7 @@ endfunction " nerdtree: the tree the node belongs to function! s:TreeDirNode.New(path, nerdtree) if a:path.isDirectory != 1 - throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." + throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' endif let newTreeNode = copy(self) @@ -523,8 +523,8 @@ endfunction " Open an explorer window for this node in the previous window. The explorer " can be a NERDTree window or a netrw window. function! s:TreeDirNode.openExplorer() - execute "wincmd p" - execute "edit ".self.path.str({'format':'Edit'}) + execute 'wincmd p' + execute 'edit '.self.path.str({'format':'Edit'}) endfunction " FUNCTION: TreeDirNode.openInNewTab(options) {{{1 @@ -587,7 +587,7 @@ function! s:TreeDirNode.refresh() call self.sortChildren() if invalidFilesFound - call nerdtree#echoWarning("some files could not be loaded into the NERD tree") + call nerdtree#echoWarning('some files could not be loaded into the NERD tree') endif endif endfunction @@ -614,7 +614,7 @@ function! s:TreeDirNode.reveal(path, ...) let opts = a:0 ? a:1 : {} if !a:path.isUnder(self.path) - throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() + throw 'NERDTree.InvalidArgumentsError: ' . a:path.str() . ' should be under ' . self.path.str() endif call self.open() @@ -626,7 +626,7 @@ function! s:TreeDirNode.reveal(path, ...) call self.refresh() let n = self.findNode(a:path) endif - if has_key(opts, "open") + if has_key(opts, 'open') call n.open() endif return n @@ -642,8 +642,8 @@ function! s:TreeDirNode.reveal(path, ...) endfunction " FUNCTION: TreeDirNode.removeChild(treenode) {{{1 -" Remove the given treenode from "self.children". -" Throws "NERDTree.ChildNotFoundError" if the node is not found. +" Remove the given treenode from self.children. +" Throws NERDTree.ChildNotFoundError if the node is not found. " " Args: " treenode: the node object to remove @@ -655,16 +655,16 @@ function! s:TreeDirNode.removeChild(treenode) endif endfor - throw "NERDTree.ChildNotFoundError: child node was not found" + throw 'NERDTree.ChildNotFoundError: child node was not found' endfunction " FUNCTION: TreeDirNode.sortChildren() {{{1 -" Sort "self.children" by alphabetical order and directory priority. +" Sort self.children by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() if count(g:NERDTreeSortOrder, '*') < 1 call add(g:NERDTreeSortOrder, '*') endif - let CompareFunc = function("nerdtree#compareNodesBySortKey") + let CompareFunc = function('nerdtree#compareNodesBySortKey') call sort(self.children, CompareFunc) let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index c14f62a9..34074a25 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -1,7 +1,7 @@ " ============================================================================ " CLASS: TreeFileNode " -" This class is the parent of the "TreeDirNode" class and is the "Component" +" This class is the parent of the TreeDirNode class and is the 'Component' " part of the composite design pattern between the NERDTree node classes. " ============================================================================ @@ -42,7 +42,7 @@ function! s:TreeFileNode.cacheParent() if empty(self.parent) let parentPath = self.path.getParent() if parentPath.equals(self.path) - throw "NERDTree.CannotCacheParentError: already at root" + throw 'NERDTree.CannotCacheParentError: already at root' endif let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree()) endif @@ -195,7 +195,7 @@ endfunction " FUNCTION: TreeFileNode.isRoot() {{{1 function! s:TreeFileNode.isRoot() if !g:NERDTree.ExistsForBuf() - throw "NERDTree.NoTreeError: No tree exists for the current buffer" + throw 'NERDTree.NoTreeError: No tree exists for the current buffer' endif return self.equals(self.getNerdtree().root) @@ -248,8 +248,8 @@ endfunction " FUNCTION: TreeFileNode.openExplorer() function! s:TreeFileNode.openExplorer() - execute "wincmd p" - execute "edit ".self.path.getParent().str({'format':'Edit'}) + execute 'wincmd p' + execute 'edit '.self.path.getParent().str({'format':'Edit'}) endfunction " FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 @@ -265,7 +265,7 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) if a:isJump mark ' endif - call cursor(ln, col(".")) + call cursor(ln, col('.')) else if a:recurseUpward let node = self @@ -317,7 +317,7 @@ endfunction " child nodes are rendered only) " for each depth in the tree function! s:TreeFileNode._renderToString(depth, drawText) - let output = "" + let output = '' if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5e8b3b64..6dc0d21e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -27,94 +27,94 @@ function! s:UI._dumpHelp() let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n" let help .= "\" ============================\n" let help .= "\" File node mappings~\n" - let help .= "\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 3 ? 'single' : 'double') ."-click,\n" if self.nerdtree.isTabTree() - let help .= "\" ". g:NERDTreeMapActivateNode .": open in prev window\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open in prev window\n" else - let help .= "\" ". g:NERDTreeMapActivateNode .": open in current window\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open in current window\n" endif if self.nerdtree.isTabTree() - let help .= "\" ". g:NERDTreeMapPreview .": preview\n" + let help .= '" '. g:NERDTreeMapPreview .": preview\n" endif - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" let help .= "\" middle-click,\n" - let help .= "\" ". g:NERDTreeMapOpenSplit .": open split\n" - let help .= "\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let help .= "\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let help .= "\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Directory node mappings~\n" - let help .= "\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let help .= "\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let help .= "\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" - let help .= "\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let help .= "\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 1 ? 'double' : 'single') ."-click,\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open & close node\n" + let help .= '" '. g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapCloseDir .": close parent of node\n" + let help .= '" '. g:NERDTreeMapCloseChildren .": close all child nodes of\n" let help .= "\" current node recursively\n" let help .= "\" middle-click,\n" - let help .= "\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" + let help .= '" '. g:NERDTreeMapOpenExpl.": explore selected dir\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark table mappings~\n" let help .= "\" double-click,\n" - let help .= "\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let help .= "\" ". g:NERDTreeMapPreview .": preview file\n" - let help .= "\" ". g:NERDTreeMapPreview .": find dir in tree\n" - let help .= "\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let help .= "\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let help .= "\" ". g:NERDTreeMapCustomOpen .": custom open\n" - let help .= "\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n" + let help .= '" '. g:NERDTreeMapPreview .": preview file\n" + let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Tree navigation mappings~\n" - let help .= "\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let help .= "\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let help .= "\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let help .= "\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let help .= "\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let help .= "\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + let help .= '" '. g:NERDTreeMapJumpRoot .": go to root\n" + let help .= '" '. g:NERDTreeMapJumpParent .": go to parent\n" + let help .= '" '. g:NERDTreeMapJumpFirstChild .": go to first child\n" + let help .= '" '. g:NERDTreeMapJumpLastChild .": go to last child\n" + let help .= '" '. g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let help .= '" '. g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Filesystem mappings~\n" - let help .= "\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" + let help .= '" '. g:NERDTreeMapChangeRoot .": change tree root to the\n" let help .= "\" selected dir\n" - let help .= "\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let help .= "\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let help .= '" '. g:NERDTreeMapUpdir .": move tree root up a dir\n" + let help .= '" '. g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" let help .= "\" but leave old root open\n" - let help .= "\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let help .= "\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let help .= "\" ". g:NERDTreeMapMenu .": Show menu\n" - let help .= "\" ". g:NERDTreeMapChdir .":change the CWD to the\n" + let help .= '" '. g:NERDTreeMapRefresh .": refresh cursor dir\n" + let help .= '" '. g:NERDTreeMapRefreshRoot .": refresh current root\n" + let help .= '" '. g:NERDTreeMapMenu .": Show menu\n" + let help .= '" '. g:NERDTreeMapChdir .":change the CWD to the\n" let help .= "\" selected dir\n" - let help .= "\" ". g:NERDTreeMapCWD .":change tree root to CWD\n" + let help .= '" '. g:NERDTreeMapCWD .":change tree root to CWD\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Tree filtering mappings~\n" - let help .= "\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n" - let help .= "\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n" + let help .= '" '. g:NERDTreeMapToggleHidden .': hidden files (' . (self.getShowHidden() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFilters .': file filters (' . (self.isIgnoreFilterEnabled() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFiles .': files (' . (self.getShowFiles() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleBookmarks .': bookmarks (' . (self.getShowBookmarks() ? 'on' : 'off') . ")\n" " add quickhelp entries for each custom key map let help .= "\"\n\" ----------------------------\n" let help .= "\" Custom mappings~\n" for i in g:NERDTreeKeyMap.All() if !empty(i.quickhelpText) - let help .= "\" ". i.key .": ". i.quickhelpText ."\n" + let help .= '" '. i.key .': '. i.quickhelpText ."\n" endif endfor let help .= "\"\n\" ----------------------------\n" let help .= "\" Other mappings~\n" - let help .= "\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" - let help .= "\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let help .= '" '. g:NERDTreeMapQuit .": Close the NERDTree window\n" + let help .= '" '. g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" let help .= "\" the NERDTree window\n" - let help .= "\" ". g:NERDTreeMapHelp .": toggle help\n" + let help .= '" '. g:NERDTreeMapHelp .": toggle help\n" let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark commands~\n" let help .= "\" :Bookmark []\n" @@ -128,7 +128,7 @@ function! s:UI._dumpHelp() let help .= "\" :EditBookmarks\n" silent! put =help elseif !self.isMinimal() - let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" + let help ='" Press '. g:NERDTreeMapHelp ." for help\n" silent! put =help endif endfunction @@ -148,8 +148,8 @@ function! s:UI.New(nerdtree) endfunction " FUNCTION: s:UI.getPath(ln) {{{1 -" Return the "Path" object for the node that is rendered on the given line -" number. If the "up a dir" line is selected, return the "Path" object for +" Return the Path object for the node that is rendered on the given line +" number. If the 'up a dir' line is selected, return the Path object for " the parent of the root. Return the empty dictionary if the given line " does not reference a tree node. function! s:UI.getPath(ln) @@ -174,7 +174,7 @@ function! s:UI.getPath(ln) " remove the tree parts and the leading space let curFile = self._stripMarkup(line) - let dir = "" + let dir = '' let lnum = a:ln while lnum > 0 let lnum = lnum - 1 @@ -191,7 +191,7 @@ function! s:UI.getPath(ln) if lpindent < indent let indent = indent - 1 - let dir = substitute (curLineStripped,'^\\', "", "") . dir + let dir = substitute (curLineStripped,'^\\', '', '') . dir continue endif endif @@ -226,7 +226,7 @@ function! s:UI.getLineNum(node) let l:currentLine = self._stripMarkup(l:currentLine) let l:currentPath = join(l:pathComponents, '/') . '/' . l:currentLine - " Directories: If the current path "starts with" the full path, then + " Directories: If the current path 'starts with' the full path, then " either the paths are equal or the line is a cascade containing the " full path. if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 @@ -313,8 +313,8 @@ endfunction function! s:UI._renderBookmarks() if !self.isMinimal() - call setline(line(".")+1, ">----------Bookmarks----------") - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '>----------Bookmarks----------') + call cursor(line('.')+1, col('.')) endif if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 @@ -322,12 +322,12 @@ function! s:UI._renderBookmarks() endif for i in g:NERDTreeBookmark.Bookmarks() - call setline(line(".")+1, i.str()) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, i.str()) + call cursor(line('.')+1, col('.')) endfor - call setline(line(".")+1, '') - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) endfunction " FUNCTION: s:UI.restoreScreenState() {{{1 @@ -340,13 +340,13 @@ function! s:UI.restoreScreenState() if !has_key(self, '_screenState') return endif - call nerdtree#exec("silent vertical resize " . self._screenState['oldWindowSize'], 1) + call nerdtree#exec('silent vertical resize ' . self._screenState['oldWindowSize'], 1) let old_scrolloff=&scrolloff let &scrolloff=0 call cursor(self._screenState['oldTopLine'], 0) normal! zt - call setpos(".", self._screenState['oldPos']) + call setpos('.', self._screenState['oldPos']) let &scrolloff=old_scrolloff endfunction @@ -358,10 +358,10 @@ function! s:UI.saveScreenState() let self._screenState = {} try call g:NERDTree.CursorToTreeWin() - let self._screenState['oldPos'] = getpos(".") - let self._screenState['oldTopLine'] = line("w0") - let self._screenState['oldWindowSize']= winwidth("") - call nerdtree#exec(win . "wincmd w", 1) + let self._screenState['oldPos'] = getpos('.') + let self._screenState['oldTopLine'] = line('w0') + let self._screenState['oldWindowSize']= winwidth('') + call nerdtree#exec(win . 'wincmd w', 1) catch endtry endfunction @@ -387,9 +387,9 @@ function! s:UI.render() " remember the top line of the buffer and the current line so we can " restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") + let curLine = line('.') + let curCol = col('.') + let topLine = line('w0') " delete all lines in the buffer (being careful not to clobber a register) silent 1,$delete _ @@ -398,8 +398,8 @@ function! s:UI.render() " delete the blank line before the help and add one after it if !self.isMinimal() - call setline(line(".")+1, "") - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) endif if self.getShowBookmarks() @@ -408,14 +408,14 @@ function! s:UI.render() " add the 'up a dir' line if !self.isMinimal() - call setline(line(".")+1, s:UI.UpDirLine()) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, s:UI.UpDirLine()) + call cursor(line('.')+1, col('.')) endif " draw the header line let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) - call setline(line(".")+1, header) - call cursor(line(".")+1, col(".")) + call setline(line('.')+1, header) + call cursor(line('.')+1, col('.')) " draw the tree silent put =self.nerdtree.root.renderToString() @@ -507,12 +507,12 @@ endfunction " FUNCTION: s:UI.toggleZoom() {{{1 " zoom (maximize/minimize) the NERDTree window function! s:UI.toggleZoom() - if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec("silent vertical resize ". size, 1) + if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + call nerdtree#exec('silent vertical resize '. size, 1) let b:NERDTreeZoomed = 0 else - call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''), 1) + call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) let b:NERDTreeZoomed = 1 endif endfunction diff --git a/nerdtree_plugin/exec_menuitem.vim b/nerdtree_plugin/exec_menuitem.vim index c53650a5..20083e03 100644 --- a/nerdtree_plugin/exec_menuitem.vim +++ b/nerdtree_plugin/exec_menuitem.vim @@ -9,7 +9,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -if exists("g:loaded_nerdtree_exec_menuitem") +if exists('g:loaded_nerdtree_exec_menuitem') finish endif let g:loaded_nerdtree_exec_menuitem = 1 @@ -35,6 +35,6 @@ function! NERDTreeExecFile() if cmd != '' exec ':!' . cmd else - echo "Aborted" + echo 'Aborted' endif endfunction diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4167df00..b2eda5a7 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -9,13 +9,13 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " ============================================================================ -if exists("g:loaded_nerdtree_fs_menu") +if exists('g:loaded_nerdtree_fs_menu') finish endif let g:loaded_nerdtree_fs_menu = 1 "Automatically delete the buffer after deleting or renaming a file -if !exists("g:NERDTreeAutoDeleteBuffer") +if !exists('g:NERDTreeAutoDeleteBuffer') let g:NERDTreeAutoDeleteBuffer = 0 endif @@ -23,13 +23,13 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if has("gui_mac") || has("gui_macvim") || has("mac") +if has('gui_mac') || has('gui_macvim') || has('mac') call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) endif -if executable("xdg-open") +if executable('xdg-open') call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) endif @@ -37,9 +37,9 @@ endif if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif -call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) +call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) -if has("unix") || has("osx") +if has('unix') || has('osx') call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) @@ -51,37 +51,37 @@ endif "Args: "action: the action that is being performed, e.g. 'delete' function! s:inputPrompt(action) - if a:action == "add" - let title = "Add a childnode" + if a:action == 'add' + let title = 'Add a childnode' let info = "Enter the dir/file name to be created. Dirs end with a '/'" - let minimal = "Add node:" + let minimal = 'Add node:' - elseif a:action == "copy" - let title = "Copy the current node" - let info = "Enter the new path to copy the node to:" - let minimal = "Copy to:" + elseif a:action == 'copy' + let title = 'Copy the current node' + let info = 'Enter the new path to copy the node to:' + let minimal = 'Copy to:' - elseif a:action == "delete" - let title = "Delete the current node" - let info = "Are you sure you wish to delete the node:" - let minimal = "Delete?" + elseif a:action == 'delete' + let title = 'Delete the current node' + let info = 'Are you sure you wish to delete the node:' + let minimal = 'Delete?' - elseif a:action == "deleteNonEmpty" - let title = "Delete the current node" + elseif a:action == 'deleteNonEmpty' + let title = 'Delete the current node' let info = "STOP! Directory is not empty! To delete, type 'yes'" - let minimal = "Delete directory?" + let minimal = 'Delete directory?' - elseif a:action == "move" - let title = "Rename the current node" - let info = "Enter the new path for the node:" - let minimal = "Move to:" + elseif a:action == 'move' + let title = 'Rename the current node' + let info = 'Enter the new path for the node:' + let minimal = 'Move to:' endif if g:NERDTreeMenuController.isMinimal() redraw! " Clear the menu - return minimal . " " + return minimal . ' ' else - let divider = "==========================================================" + let divider = '==========================================================' return title . "\n" . divider . "\n" . info . "\n" end endfunction @@ -114,14 +114,14 @@ function! s:promptToDelBuffer(bufnum, msg) let l:listedBufferCount = 0 endif if l:listedBufferCount > 1 - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':bnext! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':bnext! ' | endif", 1) else - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':enew! ' | endif", 1) endif - call nerdtree#exec("tabnext " . s:originalTabNumber, 1) - call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore - call nerdtree#exec("bwipeout! " . a:bufnum, 0) + call nerdtree#exec('bwipeout! ' . a:bufnum, 0) endif endfunction @@ -141,17 +141,17 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif " 1. ensure that a new buffer is loaded - call nerdtree#exec("badd " . quotedFileName, 1) + call nerdtree#exec('badd ' . quotedFileName, 1) " 2. ensure that all windows which display the just deleted filename " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) - call nerdtree#exec("tabnext " . s:originalTabNumber, 1) - call nerdtree#exec(s:originalWindowNumber . "wincmd w", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore try - call nerdtree#exec("confirm bwipeout " . a:bufNum, 0) + call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) catch " This happens when answering Cancel if confirmation is needed. Do nothing. endtry @@ -160,11 +160,11 @@ endfunction "FUNCTION: NERDTreeAddNode(){{{1 function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() - let prompt = s:inputPrompt("add") - let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), "file") + let prompt = s:inputPrompt('add') + let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), 'file') if newNodeName ==# '' - call nerdtree#echo("Node Creation Aborted.") + call nerdtree#echo('Node Creation Aborted.') return endif @@ -187,26 +187,26 @@ function! NERDTreeAddNode() redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Node Not Created.") + call nerdtree#echoWarning('Node Not Created.') endtry endfunction "FUNCTION: NERDTreeMoveNode(){{{1 function! NERDTreeMoveNode() let curNode = g:NERDTreeFileNode.GetSelected() - let prompt = s:inputPrompt("move") - let newNodePath = input(prompt, curNode.path.str(), "file") + let prompt = s:inputPrompt('move') + let newNodePath = input(prompt, curNode.path.str(), 'file') if newNodePath ==# '' - call nerdtree#echo("Node Renaming Aborted.") + call nerdtree#echo('Node Renaming Aborted.') return endif try if curNode.path.isDirectory - let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') else - let l:openBuffers = filter(range(1,bufnr("$")),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') endif call curNode.rename(newNodePath) @@ -221,9 +221,9 @@ function! NERDTreeMoveNode() " renamed files. if !empty(l:openBuffers) if curNode.path.isDirectory - echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . ". Replace these buffers with the new files? (yN)" + echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . '. Replace these buffers with the new files? (yN)' else - echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . ". Replace this buffer with the new file? (yN)" + echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . '. Replace this buffer with the new file? (yN)' endif if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' for bufNum in l:openBuffers @@ -236,7 +236,7 @@ function! NERDTreeMoveNode() redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Node Not Renamed.") + call nerdtree#echoWarning('Node Not Renamed.') endtry endfunction @@ -249,11 +249,11 @@ function! NERDTreeDeleteNode() if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || \ (len(currentNode._glob('*', 1)) > 0)) - let prompt = s:inputPrompt("deleteNonEmpty") . currentNode.path.str() . ": " + let prompt = s:inputPrompt('deleteNonEmpty') . currentNode.path.str() . ': ' let choice = input(prompt) let confirmed = choice ==# 'yes' else - let prompt = s:inputPrompt("delete") . currentNode.path.str() . " (yN): " + let prompt = s:inputPrompt('delete') . currentNode.path.str() . ' (yN): ' echo prompt let choice = nr2char(getchar()) let confirmed = choice ==# 'y' @@ -266,18 +266,18 @@ function! NERDTreeDeleteNode() "if the node is open in a buffer, ask the user if they want to "close that buffer - let bufnum = bufnr("^".currentNode.path.str()."$") + let bufnum = bufnr('^'.currentNode.path.str().'$') if buflisted(bufnum) - let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" + let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? ' (hidden)' : '') .'. Delete this buffer? (yN)' call s:promptToDelBuffer(bufnum, prompt) endif redraw! catch /^NERDTree/ - call nerdtree#echoWarning("Could not remove node") + call nerdtree#echoWarning('Could not remove node') endtry else - call nerdtree#echo("delete aborted") + call nerdtree#echo('delete aborted') endif let &shellslash = l:shellslash endfunction @@ -286,10 +286,10 @@ endfunction function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if !empty(treenode) - let s:uname = system("uname") + let s:uname = system('uname') let stat_cmd = 'stat -c "%s" ' - if s:uname =~? "Darwin" + if s:uname =~? 'Darwin' let stat_cmd = 'stat -f "%z" ' endif @@ -300,7 +300,7 @@ function! NERDTreeListNode() let metadata = split(system(cmd),'\n') call nerdtree#echo(metadata[0]) else - call nerdtree#echo("No information available") + call nerdtree#echo('No information available') endif endfunction @@ -310,10 +310,10 @@ function! NERDTreeListNodeWin32() if !empty(l:node) let l:path = l:node.path.str() - call nerdtree#echo(printf("%s:%s MOD:%s BYTES:%d PERMISSIONS:%s", + call nerdtree#echo(printf('%s:%s MOD:%s BYTES:%d PERMISSIONS:%s', \ toupper(getftype(l:path)), \ fnamemodify(l:path, ':t'), - \ strftime("%c", getftime(l:path)), + \ strftime('%c', getftime(l:path)), \ getfsize(l:path), \ getfperm(l:path))) return @@ -327,16 +327,16 @@ function! NERDTreeCopyNode() let l:shellslash = &shellslash let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() - let prompt = s:inputPrompt("copy") - let newNodePath = input(prompt, currentNode.path.str(), "file") + let prompt = s:inputPrompt('copy') + let newNodePath = input(prompt, currentNode.path.str(), 'file') - if newNodePath != "" + if newNodePath != '' "strip trailing slash let newNodePath = substitute(newNodePath, '\/$', '', '') let confirmed = 1 if currentNode.path.copyingWillOverwrite(newNodePath) - call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)") + call nerdtree#echo('Warning: copying may overwrite files! Continue? (yN)') let choice = nr2char(getchar()) let confirmed = choice ==# 'y' endif @@ -355,11 +355,11 @@ function! NERDTreeCopyNode() call newNode.putCursorHere(0, 0) endif catch /^NERDTree/ - call nerdtree#echoWarning("Could not copy node") + call nerdtree#echoWarning('Could not copy node') endtry endif else - call nerdtree#echo("Copy aborted.") + call nerdtree#echo('Copy aborted.') endif let &shellslash = l:shellslash redraw! @@ -368,15 +368,15 @@ endfunction " FUNCTION: NERDTreeCopyPath() {{{1 function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() - if has("clipboard") - if &clipboard == "unnamedplus" + if has('clipboard') + if &clipboard == 'unnamedplus' let @+ = l:nodePath else let @* = l:nodePath endif - call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.") + call nerdtree#echo('The path [' . l:nodePath . '] was copied to your clipboard.') else - call nerdtree#echo("The full path is: " . l:nodePath) + call nerdtree#echo('The full path is: ' . l:nodePath) endif endfunction diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim index d9901b83..29de1e76 100644 --- a/nerdtree_plugin/vcs.vim +++ b/nerdtree_plugin/vcs.vim @@ -17,7 +17,7 @@ command! -n=? -complete=dir -bar NERDTreeToggleVCS :call ToggleTabTreeVCS(' function! s:CreateTabTreeVCS(name) let l:path = g:NERDTreeCreator._pathForString(a:name) let l:path = s:FindParentVCSRoot(l:path) - call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str()) + call g:NERDTreeCreator.createTabTree(empty(l:path) ? '' : l:path._str()) endfunction " FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1 @@ -25,7 +25,7 @@ endfunction function! s:ToggleTabTreeVCS(name) let l:path = g:NERDTreeCreator._pathForString(a:name) let l:path = s:FindParentVCSRoot(l:path) - call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? "" : l:path._str()) + call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? '' : l:path._str()) endfunction " FUNCTION: s:FindParentVCSRoot(a:path) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 5faebaaf..8264efa1 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -11,7 +11,7 @@ " " SECTION: Script init stuff {{{1 "============================================================ -if exists("loaded_nerd_tree") +if exists('loaded_nerd_tree') finish endif if v:version < 703 @@ -36,65 +36,65 @@ set cpo&vim "1 if the var is set, 0 otherwise function! s:initVariable(var, value) if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'" + exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", 'g') . "'" return 1 endif return 0 endfunction "SECTION: Init variable calls and other random constants {{{2 -call s:initVariable("g:NERDTreeAutoCenter", 1) -call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) -call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) -call s:initVariable("g:NERDTreeNaturalSort", 0) -call s:initVariable("g:NERDTreeSortHiddenFirst", 1) -call s:initVariable("g:NERDTreeUseTCD", 0) -call s:initVariable("g:NERDTreeChDirMode", 0) -call s:initVariable("g:NERDTreeCreatePrefix", "silent") -call s:initVariable("g:NERDTreeMinimalUI", 0) -call s:initVariable("g:NERDTreeMinimalMenu", 0) -if !exists("g:NERDTreeIgnore") +call s:initVariable('g:NERDTreeAutoCenter', 1) +call s:initVariable('g:NERDTreeAutoCenterThreshold', 3) +call s:initVariable('g:NERDTreeCaseSensitiveSort', 0) +call s:initVariable('g:NERDTreeNaturalSort', 0) +call s:initVariable('g:NERDTreeSortHiddenFirst', 1) +call s:initVariable('g:NERDTreeUseTCD', 0) +call s:initVariable('g:NERDTreeChDirMode', 0) +call s:initVariable('g:NERDTreeCreatePrefix', 'silent') +call s:initVariable('g:NERDTreeMinimalUI', 0) +call s:initVariable('g:NERDTreeMinimalMenu', 0) +if !exists('g:NERDTreeIgnore') let g:NERDTreeIgnore = ['\~$'] endif -call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') -call s:initVariable("g:NERDTreeBookmarksSort", 1) -call s:initVariable("g:NERDTreeHighlightCursorline", 1) -call s:initVariable("g:NERDTreeHijackNetrw", 1) +call s:initVariable('g:NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') +call s:initVariable('g:NERDTreeBookmarksSort', 1) +call s:initVariable('g:NERDTreeHighlightCursorline', 1) +call s:initVariable('g:NERDTreeHijackNetrw', 1) call s:initVariable('g:NERDTreeMarkBookmarks', 1) -call s:initVariable("g:NERDTreeMouseMode", 1) -call s:initVariable("g:NERDTreeNotificationThreshold", 100) -call s:initVariable("g:NERDTreeQuitOnOpen", 0) -call s:initVariable("g:NERDTreeRespectWildIgnore", 0) -call s:initVariable("g:NERDTreeShowBookmarks", 0) -call s:initVariable("g:NERDTreeShowFiles", 1) -call s:initVariable("g:NERDTreeShowHidden", 0) -call s:initVariable("g:NERDTreeShowLineNumbers", 0) -call s:initVariable("g:NERDTreeSortDirs", 1) +call s:initVariable('g:NERDTreeMouseMode', 1) +call s:initVariable('g:NERDTreeNotificationThreshold', 100) +call s:initVariable('g:NERDTreeQuitOnOpen', 0) +call s:initVariable('g:NERDTreeRespectWildIgnore', 0) +call s:initVariable('g:NERDTreeShowBookmarks', 0) +call s:initVariable('g:NERDTreeShowFiles', 1) +call s:initVariable('g:NERDTreeShowHidden', 0) +call s:initVariable('g:NERDTreeShowLineNumbers', 0) +call s:initVariable('g:NERDTreeSortDirs', 1) if !nerdtree#runningWindows() && !nerdtree#runningCygwin() - call s:initVariable("g:NERDTreeDirArrowExpandable", "▸") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾") + call s:initVariable('g:NERDTreeDirArrowExpandable', '▸') + call s:initVariable('g:NERDTreeDirArrowCollapsible', '▾') else - call s:initVariable("g:NERDTreeDirArrowExpandable", "+") - call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") + call s:initVariable('g:NERDTreeDirArrowExpandable', '+') + call s:initVariable('g:NERDTreeDirArrowCollapsible', '~') endif -call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) -call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) +call s:initVariable('g:NERDTreeCascadeOpenSingleChildDir', 1) +call s:initVariable('g:NERDTreeCascadeSingleChildDir', 1) -if !exists("g:NERDTreeSortOrder") +if !exists('g:NERDTreeSortOrder') let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] endif let g:NERDTreeOldSortOrder = [] -call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") +call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') -if has("conceal") - call s:initVariable("g:NERDTreeNodeDelimiter", "\x07") +if has('conceal') + call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") - call s:initVariable("g:NERDTreeNodeDelimiter", "\u00b7") + call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") else - call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") + call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") endif if !exists('g:NERDTreeStatusline') @@ -105,60 +105,60 @@ if !exists('g:NERDTreeStatusline') let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" endif -call s:initVariable("g:NERDTreeWinPos", "left") -call s:initVariable("g:NERDTreeWinSize", 31) +call s:initVariable('g:NERDTreeWinPos', 'left') +call s:initVariable('g:NERDTreeWinSize', 31) "init the shell commands that will be used to copy nodes, and remove dir trees " "Note: the space after the command is important if nerdtree#runningWindows() - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') - call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') - call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') + call s:initVariable('g:NERDTreeRemoveDirCmd', 'rmdir /s /q ') + call s:initVariable('g:NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') + call s:initVariable('g:NERDTreeCopyFileCmd', 'copy /y ') else - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') - call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') + call s:initVariable('g:NERDTreeRemoveDirCmd', 'rm -rf ') + call s:initVariable('g:NERDTreeCopyCmd', 'cp -r ') endif "SECTION: Init variable calls for key mappings {{{2 -call s:initVariable("g:NERDTreeMapCustomOpen", "") -call s:initVariable("g:NERDTreeMapActivateNode", "o") -call s:initVariable("g:NERDTreeMapChangeRoot", "C") -call s:initVariable("g:NERDTreeMapChdir", "cd") -call s:initVariable("g:NERDTreeMapCloseChildren", "X") -call s:initVariable("g:NERDTreeMapCloseDir", "x") -call s:initVariable("g:NERDTreeMapDeleteBookmark", "D") -call s:initVariable("g:NERDTreeMapMenu", "m") -call s:initVariable("g:NERDTreeMapHelp", "?") -call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") -call s:initVariable("g:NERDTreeMapJumpLastChild", "J") -call s:initVariable("g:NERDTreeMapJumpNextSibling", "") -call s:initVariable("g:NERDTreeMapJumpParent", "p") -call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") -call s:initVariable("g:NERDTreeMapJumpRoot", "P") -call s:initVariable("g:NERDTreeMapOpenExpl", "e") -call s:initVariable("g:NERDTreeMapOpenInTab", "t") -call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T") -call s:initVariable("g:NERDTreeMapOpenRecursively", "O") -call s:initVariable("g:NERDTreeMapOpenSplit", "i") -call s:initVariable("g:NERDTreeMapOpenVSplit", "s") -call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode) -call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit) -call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit) -call s:initVariable("g:NERDTreeMapQuit", "q") -call s:initVariable("g:NERDTreeMapRefresh", "r") -call s:initVariable("g:NERDTreeMapRefreshRoot", "R") -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") -call s:initVariable("g:NERDTreeMapCWD", "CD") -call s:initVariable("g:NERDTreeMenuDown", "j") -call s:initVariable("g:NERDTreeMenuUp", "k") +call s:initVariable('g:NERDTreeMapCustomOpen', '') +call s:initVariable('g:NERDTreeMapActivateNode', 'o') +call s:initVariable('g:NERDTreeMapChangeRoot', 'C') +call s:initVariable('g:NERDTreeMapChdir', 'cd') +call s:initVariable('g:NERDTreeMapCloseChildren', 'X') +call s:initVariable('g:NERDTreeMapCloseDir', 'x') +call s:initVariable('g:NERDTreeMapDeleteBookmark', 'D') +call s:initVariable('g:NERDTreeMapMenu', 'm') +call s:initVariable('g:NERDTreeMapHelp', '?') +call s:initVariable('g:NERDTreeMapJumpFirstChild', 'K') +call s:initVariable('g:NERDTreeMapJumpLastChild', 'J') +call s:initVariable('g:NERDTreeMapJumpNextSibling', '') +call s:initVariable('g:NERDTreeMapJumpParent', 'p') +call s:initVariable('g:NERDTreeMapJumpPrevSibling', '') +call s:initVariable('g:NERDTreeMapJumpRoot', 'P') +call s:initVariable('g:NERDTreeMapOpenExpl', 'e') +call s:initVariable('g:NERDTreeMapOpenInTab', 't') +call s:initVariable('g:NERDTreeMapOpenInTabSilent', 'T') +call s:initVariable('g:NERDTreeMapOpenRecursively', 'O') +call s:initVariable('g:NERDTreeMapOpenSplit', 'i') +call s:initVariable('g:NERDTreeMapOpenVSplit', 's') +call s:initVariable('g:NERDTreeMapPreview', 'g' . NERDTreeMapActivateNode) +call s:initVariable('g:NERDTreeMapPreviewSplit', 'g' . NERDTreeMapOpenSplit) +call s:initVariable('g:NERDTreeMapPreviewVSplit', 'g' . NERDTreeMapOpenVSplit) +call s:initVariable('g:NERDTreeMapQuit', 'q') +call s:initVariable('g:NERDTreeMapRefresh', 'r') +call s:initVariable('g:NERDTreeMapRefreshRoot', 'R') +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') +call s:initVariable('g:NERDTreeMapCWD', 'CD') +call s:initVariable('g:NERDTreeMenuDown', 'j') +call s:initVariable('g:NERDTreeMenuUp', 'k') "SECTION: Load class files{{{2 call nerdtree#loadClassFiles() @@ -171,16 +171,16 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec "autocmd BufLeave,WinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif" + exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif' "disallow insert mode in the NERDTree - exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" + exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert' augroup END if g:NERDTreeHijackNetrw augroup NERDTreeHijackNetrw autocmd VimEnter * silent! autocmd! FileExplorer - au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand("")) + au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand('')) augroup END endif @@ -217,7 +217,7 @@ function! NERDTreeFocus() if g:NERDTree.IsOpen() call g:NERDTree.CursorToTreeWin() else - call g:NERDTreeCreator.ToggleTabTree("") + call g:NERDTreeCreator.ToggleTabTree('') endif endfunction diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index d8e8f95d..0df9d12e 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -3,7 +3,7 @@ syn match NERDTreeIgnore #\~# exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' "highlighting for the .. (up dir) line at the top of the tree -execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" +execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line .'#' "quickhelp syntax elements syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 @@ -37,7 +37,7 @@ syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExec syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir "highlighing to conceal the delimiter around the file/dir name -if has("conceal") +if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' setlocal conceallevel=3 concealcursor=nvic else From a722613f36d07eb410aac55acfcf2645598e642e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:29:58 +0300 Subject: [PATCH 558/680] Fix lint warnings: use robust operators --- autoload/nerdtree.vim | 10 +++---- autoload/nerdtree/ui_glue.vim | 10 +++---- lib/nerdtree/bookmark.vim | 8 +++--- lib/nerdtree/key_map.vim | 6 ++--- lib/nerdtree/menu_controller.vim | 24 ++++++++--------- lib/nerdtree/nerdtree.vim | 10 +++---- lib/nerdtree/opener.vim | 26 +++++++++--------- lib/nerdtree/path.vim | 44 +++++++++++++++---------------- lib/nerdtree/tree_dir_node.vim | 44 +++++++++++++++---------------- lib/nerdtree/ui.vim | 18 ++++++------- nerdtree_plugin/exec_menuitem.vim | 2 +- nerdtree_plugin/fs_menu.vim | 30 ++++++++++----------- nerdtree_plugin/vcs.vim | 4 +-- plugin/NERD_tree.vim | 4 +-- 14 files changed, 120 insertions(+), 120 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index c2f7f1c9..0e509b25 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -15,7 +15,7 @@ function! nerdtree#version(...) let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) let l:line = 0 while l:line <= len(l:changelog) - if l:changelog[l:line] =~ '\d\+\.\d\+' + if l:changelog[l:line] =~# '\d\+\.\d\+' let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') break @@ -122,15 +122,15 @@ function! nerdtree#compareNodesBySortKey(n1, n2) " Compare chunks upto common length. " If chunks have different type, the one which has " integer type is the lesser. - if type(sortKey1[i]) == type(sortKey2[i]) + if type(sortKey1[i]) ==# type(sortKey2[i]) if sortKey1[i] <# sortKey2[i] return - 1 elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif type(sortKey1[i]) == v:t_number + elseif type(sortKey1[i]) ==# v:t_number return -1 - elseif type(sortKey2[i]) == v:t_number + elseif type(sortKey2[i]) ==# v:t_number return 1 endif let i = i + 1 @@ -175,7 +175,7 @@ endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 function! nerdtree#has_opt(options, name) - return has_key(a:options, a:name) && a:options[a:name] == 1 + return has_key(a:options, a:name) && a:options[a:name] ==# 1 endfunction " FUNCTION: nerdtree#loadClassFiles() {{{2 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 96d0fa71..b5002305 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -146,7 +146,7 @@ endfunction " Associate the current node with the given name function! nerdtree#ui_glue#bookmarkNode(...) let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} let name = a:1 if empty(name) let name = currentNode.path.getLastPathComponent(0) @@ -187,7 +187,7 @@ endfunction function! nerdtree#ui_glue#clearBookmarks(bookmarks) if a:bookmarks ==# '' let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} call currentNode.clearBookmarks() endif else @@ -236,7 +236,7 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window function! s:closeTreeWindow() - if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1 + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1 exec 'buffer ' . b:NERDTree.previousBuf() else if winnr('$') > 1 @@ -258,7 +258,7 @@ function! s:deleteBookmark(bookmark) echo | redraw let l:selection = confirm(l:message, l:choices, 1, 'Warning') - if l:selection != 1 + if l:selection !=# 1 call nerdtree#echo('bookmark not deleted') return endif @@ -335,7 +335,7 @@ endfunction "Checks if the click should open the current node function! s:handleLeftClick() let currentNode = g:NERDTreeFileNode.GetSelected() - if currentNode != {} + if currentNode !=# {} "the dir arrows are multibyte chars, and vim's string functions only "deal with single bytes - so split the line up with the hack below and diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index ccb6f987..b457a8a9 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -93,7 +93,7 @@ function! s:Bookmark.CacheBookmarks(silent) for i in bookmarkStrings "ignore blank lines - if i != '' + if i !=# '' let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') @@ -123,13 +123,13 @@ endfunction " option. Supports the s:Bookmark.SortBookmarksList() method. function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) let l:result = 0 - if g:NERDTreeBookmarksSort == 1 + if g:NERDTreeBookmarksSort ==# 1 if a:firstBookmark.name ? a:secondBookmark.name let l:result = 1 endif - elseif g:NERDTreeBookmarksSort == 2 + elseif g:NERDTreeBookmarksSort ==# 2 if a:firstBookmark.name <# a:secondBookmark.name let l:result = -1 elseif a:firstBookmark.name ># a:secondBookmark.name @@ -198,7 +198,7 @@ endfunction function! s:Bookmark.GetSelected() let line = getline('.') let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') - if name != line + if name !=# line try return s:Bookmark.BookmarkFor(name) catch /^NERDTree.BookmarkNotFoundError/ diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index 5c96c61f..f3268c26 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -53,7 +53,7 @@ function! s:KeyMap.bind() endif let keymapInvokeString = escape(keymapInvokeString, '\') - let premap = self.key == '' ? ' ' : ' ' + let premap = self.key ==# '' ? ' ' : ' ' exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' endfunction @@ -66,7 +66,7 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) == type(function('tr')) ? self.callback : function(self.callback) + let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) if a:0 call Callback(a:1) else @@ -143,7 +143,7 @@ function! s:KeyMap.Create(options) let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) "dont override other mappings unless the 'override' option is given - if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + if get(opts, 'override', 0) ==# 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) return end diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index a3b168b4..ca93efa2 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -45,12 +45,12 @@ function! s:MenuController.showMenu() call self._restoreOptions() " Redraw when Ctrl-C or Esc is received. - if !l:done || self.selection == -1 + if !l:done || self.selection ==# -1 redraw! endif endtry - if self.selection != -1 + if self.selection !=# -1 let l:m = self._current() call l:m.execute() endif @@ -73,7 +73,7 @@ function! s:MenuController._echoPrompt() echo '=========================================================' for i in range(0, len(self.menuItems)-1) - if self.selection == i + if self.selection ==# i echo '> ' . self.menuItems[i].text else echo ' ' . self.menuItems[i].text @@ -92,20 +92,20 @@ endfunction "change the selection (if appropriate) and return 1 if the user has made "their choice, 0 otherwise function! s:MenuController._handleKeypress(key) - if a:key == g:NERDTreeMenuDown + if a:key ==# g:NERDTreeMenuDown call self._cursorDown() - elseif a:key == g:NERDTreeMenuUp + elseif a:key ==# g:NERDTreeMenuUp call self._cursorUp() - elseif a:key == nr2char(27) "escape + elseif a:key ==# nr2char(27) "escape let self.selection = -1 return 1 - elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j + elseif a:key ==# "\r" || a:key ==# "\n" "enter and ctrl-j return 1 else let index = self._nextIndexFor(a:key) - if index != -1 + if index !=# -1 let self.selection = index - if len(self._allIndexesFor(a:key)) == 1 + if len(self._allIndexesFor(a:key)) ==# 1 return 1 endif endif @@ -120,7 +120,7 @@ function! s:MenuController._allIndexesFor(shortcut) let toReturn = [] for i in range(0, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut call add(toReturn, i) endif endfor @@ -133,13 +133,13 @@ endfunction "current cursor location and wraps around to the top again if need be function! s:MenuController._nextIndexFor(shortcut) for i in range(self.selection+1, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor for i in range(0, self.selection) - if self.menuItems[i].shortcut == a:shortcut + if self.menuItems[i].shortcut ==# a:shortcut return i endif endfor diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 03878a48..a48f6a86 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -37,13 +37,13 @@ function! s:NERDTree.Close() return endif - if winnr('$') != 1 + if winnr('$') !=# 1 " Use the window ID to identify the currently active window or fall " back on the buffer ID if win_getid/win_gotoid are not available, in " which case we'll focus an arbitrary window showing the buffer. let l:useWinId = exists('*win_getid') && exists('*win_gotoid') - if winnr() == s:NERDTree.GetWinNum() + if winnr() ==# s:NERDTree.GetWinNum() call nerdtree#exec('wincmd p', 1) let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') call nerdtree#exec('wincmd p', 1) @@ -160,17 +160,17 @@ endfunction "FUNCTION: s:NERDTree.IsOpen() {{{1 function! s:NERDTree.IsOpen() - return s:NERDTree.GetWinNum() != -1 + return s:NERDTree.GetWinNum() !=# -1 endfunction "FUNCTION: s:NERDTree.isTabTree() {{{1 function! s:NERDTree.isTabTree() - return self._type == 'tab' + return self._type ==# 'tab' endfunction "FUNCTION: s:NERDTree.isWinTree() {{{1 function! s:NERDTree.isWinTree() - return self._type == 'window' + return self._type ==# 'window' endfunction "FUNCTION: s:NERDTree.MustBeOpen() {{{1 diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index d9a8868a..d8dba34e 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -45,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab) return endif - if (a:newtab && self._where == 't') || !a:newtab + if (a:newtab && self._where ==# 't') || !a:newtab call g:NERDTree.CloseIfQuitOnOpen() endif endfunction @@ -56,7 +56,7 @@ function! s:Opener._firstUsableWindow() let i = 1 while i <= winnr('$') let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' + if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# '' \ && !getwinvar(i, '&previewwindow') \ && (!getbufvar(bnum, '&modified') || &hidden) return i @@ -70,23 +70,23 @@ endfunction " FUNCTION: Opener._gotoTargetWin() {{{1 function! s:Opener._gotoTargetWin() if b:NERDTree.isWinTree() - if self._where == 'v' + if self._where ==# 'v' call self._newVSplit() - elseif self._where == 'h' + elseif self._where ==# 'h' call self._newSplit() - elseif self._where == 't' + elseif self._where ==# 't' tabnew endif else call self._checkToCloseTree(1) - if self._where == 'v' + if self._where ==# 'v' call self._newVSplit() - elseif self._where == 'h' + elseif self._where ==# 'h' call self._newSplit() - elseif self._where == 't' + elseif self._where ==# 't' tabnew - elseif self._where == 'p' + elseif self._where ==# 'p' call self._previousWindow() endif @@ -108,7 +108,7 @@ function! s:Opener._isWindowUsable(winnumber) let oldwinnr = winnr() call nerdtree#exec(a:winnumber . 'wincmd p', 1) - let specialWindow = getbufvar('%', '&buftype') != '' || getwinvar('%', '&previewwindow') + let specialWindow = getbufvar('%', '&buftype') !=# '' || getwinvar('%', '&previewwindow') let modified = &modified call nerdtree#exec(oldwinnr . 'wincmd p', 1) @@ -247,7 +247,7 @@ function! s:Opener._openDirectory(node) else if empty(self._where) call b:NERDTree.changeRoot(a:node) - elseif self._where == 't' + elseif self._where ==# 't' call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) else call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) @@ -296,13 +296,13 @@ function! s:Opener._reuseWindow() "check the current tab for the window let winnr = bufwinnr('^' . self._path.str() . '$') - if winnr != -1 + if winnr !=# -1 call nerdtree#exec(winnr . 'wincmd w', 0) call self._checkToCloseTree(0) return 1 endif - if self._reuse == 'currenttab' + if self._reuse ==# 'currenttab' return 0 endif diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index a77331f3..6a23c7ba 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -25,7 +25,7 @@ function! s:Path.AbsolutePathFor(pathStr) if l:prependWorkingDir let l:result = getcwd() - if l:result[-1:] == s:Path.Slash() + if l:result[-1:] ==# s:Path.Slash() let l:result = l:result . a:pathStr else let l:result = l:result . s:Path.Slash() . a:pathStr @@ -57,7 +57,7 @@ function! s:Path.cacheDisplayString() abort call add(self._bookmarkNames, i.name) endif endfor - if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 + if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks ==# 1 let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' endif @@ -87,7 +87,7 @@ function! s:Path.changeToDir() endif try - if g:NERDTreeUseTCD && exists(':tcd') == 2 + if g:NERDTreeUseTCD && exists(':tcd') ==# 2 execute 'tcd ' . dir call nerdtree#echo("Tab's CWD is now: " . getcwd()) else @@ -201,7 +201,7 @@ function! s:Path.copy(dest) let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) let success = system(cmd) - if v:shell_error != 0 + if v:shell_error !=# 0 throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" endif endfunction @@ -258,7 +258,7 @@ function! s:Path.delete() let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) let success = system(cmd) - if v:shell_error != 0 + if v:shell_error !=# 0 throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" endif else @@ -269,7 +269,7 @@ function! s:Path.delete() let success = delete(self.str()) endif - if success != 0 + if success !=# 0 throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" endif endif @@ -303,7 +303,7 @@ endfunction " If running windows, cache the drive letter for this path function! s:Path.extractDriveLetter(fullpath) if nerdtree#runningWindows() - if a:fullpath =~ '^\(\\\\\|\/\/\)' + if a:fullpath =~# '^\(\\\\\|\/\/\)' "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') let self.drive = substitute(self.drive, '/', '\', 'g') @@ -402,7 +402,7 @@ function! s:Path._splitChunks(path) let i = 0 while i < len(chunks) "convert number literals to numbers - if match(chunks[i], '^\d\+$') == 0 + if match(chunks[i], '^\d\+$') ==# 0 let chunks[i] = str2nr(chunks[i]) endif let i = i + 1 @@ -418,16 +418,16 @@ function! s:Path.getSortKey() let metadata = [] for tag in g:NERDTreeSortOrder if tag =~? '\[\[-\?timestamp\]\]' - let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[-\?size\]\]' - let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~ '-' ? -1 : 1)] + let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~# '-' ? -1 : 1)] elseif tag =~? '\[\[extension\]\]' let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') - let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)] + let metadata += [self.isDirectory ? '' : (extension ==# '' ? nr2char(str2nr('0x10ffff',16)) : extension)] endif endfor - if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]' + if g:NERDTreeSortOrder[0] =~# '\[\[.*\]\]' " Apply tags' sorting first if specified first. let self._sortKey = metadata + [self.getSortOrderIndex()] else @@ -501,7 +501,7 @@ function! s:Path.ignore(nerdtree) endfor for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) == type(function('tr')) ? Callback : function(Callback) + let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback) if Callback({'path': self, 'nerdtree': a:nerdtree}) return 1 endif @@ -524,12 +524,12 @@ endfunction " returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern - if strpart(pat,len(pat)-7) == '[[dir]]' + if strpart(pat,len(pat)-7) ==# '[[dir]]' if !self.isDirectory return 0 endif let pat = strpart(pat,0, len(pat)-7) - elseif strpart(pat,len(pat)-8) == '[[file]]' + elseif strpart(pat,len(pat)-8) ==# '[[file]]' if self.isDirectory return 0 endif @@ -550,19 +550,19 @@ function! s:Path.isAncestor(path) let this = self.str() let that = a:path.str() - return stridx(that, this) == 0 + return stridx(that, this) ==# 0 endfunction " FUNCTION: Path.isUnder(path) {{{1 " return 1 if this path is somewhere under the given path in the filesystem. function! s:Path.isUnder(path) - if a:path.isDirectory == 0 + if a:path.isDirectory ==# 0 return 0 endif let this = self.str() let that = a:path.str() - return stridx(this, that . s:Path.Slash()) == 0 + return stridx(this, that . s:Path.Slash()) ==# 0 endfunction " FUNCTION: Path.JoinPathStrings(...) {{{1 @@ -665,7 +665,7 @@ function! s:Path.readInfoFromDisk(fullpath) let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent "if the last part of the path is a symlink then flag it as such - let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath) + let self.isSymLink = (s:Path.Resolve(hardPath) !=# hardPath) if self.isSymLink let self.symLinkDest = s:Path.Resolve(fullpath) @@ -706,7 +706,7 @@ function! s:Path.rename(newPath) call s:Path.createParentDirectories(a:newPath) let success = rename(self.str(), a:newPath) - if success != 0 + if success !=# 0 throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath endif call self.readInfoFromDisk(a:newPath) @@ -779,7 +779,7 @@ endfunction " FUNCTION: Path._strForUI() {{{1 function! s:Path._strForUI() let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' + if self.isDirectory && toReturn !=# '/' let toReturn = toReturn . '/' endif return toReturn @@ -802,7 +802,7 @@ function! s:Path._strForEdit() " On Windows, the drive letter may be removed by "fnamemodify()". Add it " back, if necessary. - if nerdtree#runningWindows() && l:result[0] == s:Path.Slash() + if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash() let l:result = self.drive . l:result endif diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index f59c064f..1502ea73 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -14,7 +14,7 @@ let g:NERDTreeDirNode = s:TreeDirNode " Class method that returns the highest cached ancestor of the current root. function! s:TreeDirNode.AbsoluteTreeRoot() let currentNode = b:NERDTree.root - while currentNode.parent != {} + while currentNode.parent !=# {} let currentNode = currentNode.parent endwhile return currentNode @@ -100,7 +100,7 @@ function! s:TreeDirNode.displayString() let l:cascade = self.getCascade() for l:dirNode in l:cascade let l:next = l:dirNode.path.displayString() - let l:label .= l:label == '' ? l:next : substitute(l:next,'^.','','') + let l:label .= l:label ==# '' ? l:next : substitute(l:next,'^.','','') endfor " Select the appropriate open/closed status indicator symbol. @@ -133,7 +133,7 @@ function! s:TreeDirNode.findNode(path) if self.path.isDirectory for i in self.children let retVal = i.findNode(a:path) - if retVal != {} + if retVal !=# {} return retVal endif endfor @@ -169,7 +169,7 @@ function! s:TreeDirNode.getCascadeRoot() while !empty(l:parent) && !l:parent.isRoot() - if index(l:parent.getCascade(), self) == -1 + if index(l:parent.getCascade(), self) ==# -1 break endif @@ -258,7 +258,7 @@ endfunction " Return a list of all child nodes from 'self.children' that are of type " TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. function! s:TreeDirNode.getDirChildren() - return filter(copy(self.children), 'v:val.path.isDirectory == 1') + return filter(copy(self.children), 'v:val.path.isDirectory ==# 1') endfunction " FUNCTION: TreeDirNode._glob(pattern, all) {{{1 @@ -278,13 +278,13 @@ function! s:TreeDirNode._glob(pattern, all) " Construct a path specification such that globpath() will return " relative pathnames, if possible. - if self.path.str() == getcwd() + if self.path.str() ==# getcwd() let l:pathSpec = ',' else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') " On Windows, the drive letter may be removed by fnamemodify(). - if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() + if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash() let l:pathSpec = self.path.drive . l:pathSpec endif endif @@ -293,11 +293,11 @@ function! s:TreeDirNode._glob(pattern, all) " See ':h version7.txt' and ':h version8.txt' for details on the " development of the glob() and globpath() functions. - if v:version > 704 || (v:version == 704 && has('patch654')) + if v:version > 704 || (v:version ==# 704 && has('patch654')) let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) - elseif v:version == 704 && has('patch279') + elseif v:version ==# 704 && has('patch279') let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) - elseif v:version > 702 || (v:version == 702 && has('patch051')) + elseif v:version > 702 || (v:version ==# 702 && has('patch051')) let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) let l:globList = split(l:globString, "\n") else @@ -315,13 +315,13 @@ function! s:TreeDirNode._glob(pattern, all) " If l:file has a trailing slash, then its :tail will be ''. Use " :h to drop the slash and the empty string after it; then use :t " to get the directory name. - if l:tail == '' + if l:tail ==# '' let l:tail = fnamemodify(l:file, ':h:t') endif - if l:tail == '.' || l:tail == '..' + if l:tail ==# '.' || l:tail ==# '..' call add(l:toRemove, l:file) - if len(l:toRemove) == 2 + if len(l:toRemove) ==# 2 break endif endif @@ -341,7 +341,7 @@ endfunction unlet s:TreeDirNode.GetSelected function! s:TreeDirNode.GetSelected() let currentDir = g:NERDTreeFileNode.GetSelected() - if currentDir != {} && !currentDir.isRoot() + if currentDir !=# {} && !currentDir.isRoot() if currentDir.path.isDirectory ==# 0 let currentDir = currentDir.parent endif @@ -373,7 +373,7 @@ endfunction " FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 " returns 1 if this node has any childre, 0 otherwise.. function! s:TreeDirNode.hasVisibleChildren() - return self.getVisibleChildCount() != 0 + return self.getVisibleChildCount() !=# 0 endfunction " FUNCTION: TreeDirNode.isCascadable() {{{1 @@ -383,7 +383,7 @@ endfunction " 2. If the parent is a symlink or is bookmarked, you end up with unparsable " text, and NERDTree cannot get the path of any child node. function! s:TreeDirNode.isCascadable() - if g:NERDTreeCascadeSingleChildDir == 0 + if g:NERDTreeCascadeSingleChildDir ==# 0 return 0 endif @@ -398,7 +398,7 @@ function! s:TreeDirNode.isCascadable() endfor let c = self.getVisibleChildren() - return len(c) == 1 && c[0].path.isDirectory + return len(c) ==# 1 && c[0].path.isDirectory endfunction " FUNCTION: TreeDirNode._initChildren() {{{1 @@ -447,7 +447,7 @@ endfunction " path: dir that the node represents " nerdtree: the tree the node belongs to function! s:TreeDirNode.New(path, nerdtree) - if a:path.isDirectory != 1 + if a:path.isDirectory !=# 1 throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' endif @@ -510,7 +510,7 @@ function! s:TreeDirNode.openAlong(...) while node.path.isDirectory call node.open(opts) let level += 1 - if node.getVisibleChildCount() == 1 + if node.getVisibleChildCount() ==# 1 let node = node.getChildByIndex(0, 1) else break @@ -567,7 +567,7 @@ function! s:TreeDirNode.refresh() "create a new path and see if it exists in this nodes children let path = g:NERDTreePath.New(i) let newNode = self.getChild(path) - if newNode != {} + if newNode !=# {} call newNode.refresh() call add(newChildNodes, newNode) @@ -622,7 +622,7 @@ function! s:TreeDirNode.reveal(path, ...) if self.path.equals(a:path.getParent()) let n = self.findNode(a:path) " We may be looking for a newly-saved file that isn't in the tree yet. - if n == {} + if n ==# {} call self.refresh() let n = self.findNode(a:path) endif @@ -676,7 +676,7 @@ function! s:TreeDirNode.toggleOpen(...) if self.isOpen ==# 1 call self.close() else - if g:NERDTreeCascadeOpenSingleChildDir == 0 + if g:NERDTreeCascadeOpenSingleChildDir ==# 0 call self.open(opts) else call self.openAlong(opts) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6dc0d21e..fc9db71e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -157,7 +157,7 @@ function! s:UI.getPath(ln) let rootLine = self.getRootLineNum() - if a:ln == rootLine + if a:ln ==# rootLine return self.nerdtree.root.path endif @@ -182,7 +182,7 @@ function! s:UI.getPath(ln) let curLineStripped = self._stripMarkup(curLine) " have we reached the top of the tree? - if lnum == rootLine + if lnum ==# rootLine let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir break endif @@ -219,7 +219,7 @@ function! s:UI.getLineNum(node) let l:currentLine = getline(l:lineNumber) let l:indentLevel = self._indentLevelFor(l:currentLine) - if l:indentLevel != l:currentPathComponent + if l:indentLevel !=# l:currentPathComponent continue endif @@ -229,7 +229,7 @@ function! s:UI.getLineNum(node) " Directories: If the current path 'starts with' the full path, then " either the paths are equal or the line is a cascade containing the " full path. - if l:fullPath[-1:] == '/' && stridx(l:currentPath, l:fullPath) == 0 + if l:fullPath[-1:] ==# '/' && stridx(l:currentPath, l:fullPath) ==# 0 return l:lineNumber endif @@ -240,7 +240,7 @@ function! s:UI.getLineNum(node) " Otherwise: If the full path starts with the current path and the " current path is a directory, we add a new path component. - if stridx(l:fullPath, l:currentPath) == 0 && l:currentPath[-1:] == '/' + if stridx(l:fullPath, l:currentPath) ==# 0 && l:currentPath[-1:] ==# '/' let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') call add(l:pathComponents, l:currentLine) let l:currentPathComponent += 1 @@ -296,7 +296,7 @@ endfunction " FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 function! s:UI.isIgnoreFilterEnabled() - return self._ignoreEnabled == 1 + return self._ignoreEnabled ==# 1 endfunction " FUNCTION: s:UI.isMinimal() {{{1 @@ -317,7 +317,7 @@ function! s:UI._renderBookmarks() call cursor(line('.')+1, col('.')) endif - if g:NERDTreeBookmarksSort == 1 || g:NERDTreeBookmarksSort == 2 + if g:NERDTreeBookmarksSort ==# 1 || g:NERDTreeBookmarksSort ==# 2 call g:NERDTreeBookmark.SortBookmarksList() endif @@ -443,13 +443,13 @@ function! s:UI.renderViewSavingPosition() " go up the tree till we find a node that will be visible or till we run " out of nodes - while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() + while currentNode !=# {} && !currentNode.isVisible() && !currentNode.isRoot() let currentNode = currentNode.parent endwhile call self.render() - if currentNode != {} + if currentNode !=# {} call currentNode.putCursorHere(0, 0) endif endfunction diff --git a/nerdtree_plugin/exec_menuitem.vim b/nerdtree_plugin/exec_menuitem.vim index 20083e03..fb6c4862 100644 --- a/nerdtree_plugin/exec_menuitem.vim +++ b/nerdtree_plugin/exec_menuitem.vim @@ -32,7 +32,7 @@ function! NERDTreeExecFile() let cmd = treenode.path.str({'escape': 1}) let cmd = input(':!', cmd . ' ') - if cmd != '' + if cmd !=# '' exec ':!' . cmd else echo 'Aborted' diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index b2eda5a7..3ecfa816 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -51,27 +51,27 @@ endif "Args: "action: the action that is being performed, e.g. 'delete' function! s:inputPrompt(action) - if a:action == 'add' + if a:action ==# 'add' let title = 'Add a childnode' let info = "Enter the dir/file name to be created. Dirs end with a '/'" let minimal = 'Add node:' - elseif a:action == 'copy' + elseif a:action ==# 'copy' let title = 'Copy the current node' let info = 'Enter the new path to copy the node to:' let minimal = 'Copy to:' - elseif a:action == 'delete' + elseif a:action ==# 'delete' let title = 'Delete the current node' let info = 'Are you sure you wish to delete the node:' let minimal = 'Delete?' - elseif a:action == 'deleteNonEmpty' + elseif a:action ==# 'deleteNonEmpty' let title = 'Delete the current node' let info = "STOP! Directory is not empty! To delete, type 'yes'" let minimal = 'Delete directory?' - elseif a:action == 'move' + elseif a:action ==# 'move' let title = 'Rename the current node' let info = 'Enter the new path for the node:' let minimal = 'Move to:' @@ -114,9 +114,9 @@ function! s:promptToDelBuffer(bufnum, msg) let l:listedBufferCount = 0 endif if l:listedBufferCount > 1 - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':bnext! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1) else - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufnum . " | exec ':enew! ' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1) endif call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) @@ -146,7 +146,7 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec('tabdo windo if winbufnr(0) == ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore @@ -330,7 +330,7 @@ function! NERDTreeCopyNode() let prompt = s:inputPrompt('copy') let newNodePath = input(prompt, currentNode.path.str(), 'file') - if newNodePath != '' + if newNodePath !=# '' "strip trailing slash let newNodePath = substitute(newNodePath, '\/$', '', '') @@ -369,7 +369,7 @@ endfunction function! NERDTreeCopyPath() let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() if has('clipboard') - if &clipboard == 'unnamedplus' + if &clipboard ==# 'unnamedplus' let @+ = l:nodePath else let @* = l:nodePath @@ -383,7 +383,7 @@ endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") endif endfunction @@ -391,7 +391,7 @@ endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("open -R '" . treenode.path.str() . "'") endif endfunction @@ -399,7 +399,7 @@ endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("open '" . treenode.path.str() . "'") endif endfunction @@ -408,7 +408,7 @@ endfunction function! NERDTreeRevealFileLinux() let treenode = g:NERDTreeFileNode.GetSelected() let parentnode = treenode.parent - if parentnode != {} + if parentnode !=# {} call system("xdg-open '" . parentnode.path.str() . "' &") endif endfunction @@ -416,7 +416,7 @@ endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() let treenode = g:NERDTreeFileNode.GetSelected() - if treenode != {} + if treenode !=# {} call system("xdg-open '" . treenode.path.str() . "' &") endif endfunction diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim index 29de1e76..36d5427e 100644 --- a/nerdtree_plugin/vcs.vim +++ b/nerdtree_plugin/vcs.vim @@ -34,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~ '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:\\\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~ '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 8264efa1..9b4df5d7 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -91,7 +91,7 @@ call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') if has('conceal') call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") -elseif (g:NERDTreeDirArrowExpandable == "\u00a0" || g:NERDTreeDirArrowCollapsible == "\u00a0") +elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") else call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") @@ -184,7 +184,7 @@ if g:NERDTreeHijackNetrw augroup END endif -if g:NERDTreeChDirMode == 3 +if g:NERDTreeChDirMode ==# 3 augroup NERDTreeChDirOnTabSwitch autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif augroup END From 10868dd94cb32f2a30395196979f29f9d2ecab86 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:31:59 +0300 Subject: [PATCH 559/680] Fix lint warnings: use scriptencoding when multibyte char exists --- plugin/NERD_tree.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 9b4df5d7..5a1abe55 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -11,6 +11,8 @@ " " SECTION: Script init stuff {{{1 "============================================================ +scriptencoding utf-8 + if exists('loaded_nerd_tree') finish endif From 38b1e5e7aac9238f93c2caca85d72318489470f9 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:34:55 +0300 Subject: [PATCH 560/680] Fix lint warnings: use the abort attribute for functions in autoload --- autoload/nerdtree.vim | 36 +++++------ autoload/nerdtree/ui_glue.vim | 112 +++++++++++++++++----------------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 0e509b25..3c5e6ec3 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -9,7 +9,7 @@ let s:rootNERDTreePath = resolve(expand(':p:h:h')) " If any value is given as an argument, the entire line of text from the " change log is shown for the current version; otherwise, only the version " number is shown. -function! nerdtree#version(...) +function! nerdtree#version(...) abort let l:text = 'Unknown' try let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) @@ -31,7 +31,7 @@ endfunction "============================================================ "FUNCTION: nerdtree#slash() {{{2 -function! nerdtree#slash() +function! nerdtree#slash() abort if nerdtree#runningWindows() if exists('+shellslash') && &shellslash @@ -46,7 +46,7 @@ endfunction "FUNCTION: nerdtree#and(x,y) {{{2 " Implements and() function for Vim <= 7.2 -function! nerdtree#and(x,y) +function! nerdtree#and(x,y) abort if exists('*and') return and(a:x, a:y) else @@ -68,7 +68,7 @@ endfunction "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate -function! nerdtree#checkForBrowse(dir) +function! nerdtree#checkForBrowse(dir) abort if !isdirectory(a:dir) return endif @@ -104,17 +104,17 @@ endfunction " FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 " completion function for the bookmark commands -function! nerdtree#completeBookmarks(A,L,P) +function! nerdtree#completeBookmarks(A,L,P) abort return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction "FUNCTION: nerdtree#compareNodes(dir) {{{2 -function! nerdtree#compareNodes(n1, n2) +function! nerdtree#compareNodes(n1, n2) abort return a:n1.path.compareTo(a:n2.path) endfunction "FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 -function! nerdtree#compareNodesBySortKey(n1, n2) +function! nerdtree#compareNodesBySortKey(n1, n2) abort let sortKey1 = a:n1.path.getSortKey() let sortKey2 = a:n2.path.getSortKey() let i = 0 @@ -150,7 +150,7 @@ endfunction " FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 " Issue a deprecation warning for a:func. If a second arg is given, use this " as the deprecation message -function! nerdtree#deprecated(func, ...) +function! nerdtree#deprecated(func, ...) abort let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' if !exists('s:deprecationWarnings') @@ -164,7 +164,7 @@ endfunction " FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2 " Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration -function! nerdtree#exec(cmd, ignoreAll) +function! nerdtree#exec(cmd, ignoreAll) abort let old_ei = &ei if a:ignoreAll set ei=all @@ -174,12 +174,12 @@ function! nerdtree#exec(cmd, ignoreAll) endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 -function! nerdtree#has_opt(options, name) +function! nerdtree#has_opt(options, name) abort return has_key(a:options, a:name) && a:options[a:name] ==# 1 endfunction " FUNCTION: nerdtree#loadClassFiles() {{{2 -function! nerdtree#loadClassFiles() +function! nerdtree#loadClassFiles() abort runtime lib/nerdtree/path.vim runtime lib/nerdtree/menu_controller.vim runtime lib/nerdtree/menu_item.vim @@ -197,7 +197,7 @@ function! nerdtree#loadClassFiles() endfunction " FUNCTION: nerdtree#postSourceActions() {{{2 -function! nerdtree#postSourceActions() +function! nerdtree#postSourceActions() abort call g:NERDTreeBookmark.CacheBookmarks(1) call nerdtree#ui_glue#createDefaultBindings() @@ -206,12 +206,12 @@ function! nerdtree#postSourceActions() endfunction "FUNCTION: nerdtree#runningWindows(dir) {{{2 -function! nerdtree#runningWindows() +function! nerdtree#runningWindows() abort return has('win16') || has('win32') || has('win64') endfunction "FUNCTION: nerdtree#runningCygwin(dir) {{{2 -function! nerdtree#runningCygwin() +function! nerdtree#runningCygwin() abort return has('win32unix') endfunction @@ -223,7 +223,7 @@ endfunction " "Args: "msg: the message to echo -function! nerdtree#echo(msg) +function! nerdtree#echo(msg) abort redraw echomsg empty(a:msg) ? '' : ('NERDTree: ' . a:msg) endfunction @@ -232,7 +232,7 @@ endfunction "Wrapper for nerdtree#echo, sets the message type to errormsg for this message "Args: "msg: the message to echo -function! nerdtree#echoError(msg) +function! nerdtree#echoError(msg) abort echohl errormsg call nerdtree#echo(a:msg) echohl normal @@ -242,14 +242,14 @@ endfunction "Wrapper for nerdtree#echo, sets the message type to warningmsg for this message "Args: "msg: the message to echo -function! nerdtree#echoWarning(msg) +function! nerdtree#echoWarning(msg) abort echohl warningmsg call nerdtree#echo(a:msg) echohl normal endfunction "FUNCTION: nerdtree#renderView {{{2 -function! nerdtree#renderView() +function! nerdtree#renderView() abort call b:NERDTree.render() endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index b5002305..400e52dc 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -4,7 +4,7 @@ endif let g:loaded_nerdtree_ui_glue_autoload = 1 " FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1 -function! nerdtree#ui_glue#createDefaultBindings() +function! nerdtree#ui_glue#createDefaultBindings() abort let s = '' . s:SID() . '_' call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s . 'handleMiddleMouse' }) @@ -83,19 +83,19 @@ endfunction "FUNCTION: s:customOpenFile() {{{1 " Open file node with the 'custom' key, initially . -function! s:customOpenFile(node) +function! s:customOpenFile(node) abort call a:node.activate(s:initCustomOpenArgs().file) endfunction "FUNCTION: s:customOpenDir() {{{1 " Open directory node with the 'custom' key, initially . -function! s:customOpenDir(node) +function! s:customOpenDir(node) abort call s:activateDirNode(a:node, s:initCustomOpenArgs().dir) endfunction "FUNCTION: s:customOpenBookmark() {{{1 " Open bookmark node with the 'custom' key, initially . -function! s:customOpenBookmark(node) +function! s:customOpenBookmark(node) abort if a:node.path.isDirectory call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) else @@ -105,14 +105,14 @@ endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 " Make sure NERDTreeCustomOpenArgs has needed keys -function! s:initCustomOpenArgs() +function! s:initCustomOpenArgs() abort let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') endfunction "FUNCTION: s:activateAll() {{{1 "handle the user activating the updir line -function! s:activateAll() +function! s:activateAll() abort if getline('.') ==# g:NERDTreeUI.UpDirLine() return nerdtree#ui_glue#upDir(0) endif @@ -120,7 +120,7 @@ endfunction " FUNCTION: s:activateDirNode(directoryNode, options) {{{1 " Open a directory with optional options -function! s:activateDirNode(directoryNode, ...) +function! s:activateDirNode(directoryNode, ...) abort if a:directoryNode.isRoot() && a:directoryNode.isOpen call nerdtree#echo('cannot close tree root') @@ -132,19 +132,19 @@ endfunction "FUNCTION: s:activateFileNode() {{{1 "handle the user activating a tree node -function! s:activateFileNode(node) +function! s:activateFileNode(node) abort call a:node.activate({'reuse': 'all', 'where': 'p'}) endfunction "FUNCTION: s:activateBookmark(bookmark) {{{1 "handle the user activating a bookmark -function! s:activateBookmark(bm) +function! s:activateBookmark(bm) abort call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) endfunction " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 " Associate the current node with the given name -function! nerdtree#ui_glue#bookmarkNode(...) +function! nerdtree#ui_glue#bookmarkNode(...) abort let currentNode = g:NERDTreeFileNode.GetSelected() if currentNode !=# {} let name = a:1 @@ -163,7 +163,7 @@ function! nerdtree#ui_glue#bookmarkNode(...) endfunction " FUNCTION: s:chCwd(node) {{{1 -function! s:chCwd(node) +function! s:chCwd(node) abort try call a:node.path.changeToDir() catch /^NERDTree.PathChangeError/ @@ -173,18 +173,18 @@ endfunction " FUNCTION: s:chRoot(node) {{{1 " changes the current root to the selected one -function! s:chRoot(node) +function! s:chRoot(node) abort call b:NERDTree.changeRoot(a:node) endfunction " FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 " Change the NERDTree root to match the current working directory. -function! nerdtree#ui_glue#chRootCwd() +function! nerdtree#ui_glue#chRootCwd() abort NERDTreeCWD endfunction " FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 -function! nerdtree#ui_glue#clearBookmarks(bookmarks) +function! nerdtree#ui_glue#clearBookmarks(bookmarks) abort if a:bookmarks ==# '' let currentNode = g:NERDTreeFileNode.GetSelected() if currentNode !=# {} @@ -202,7 +202,7 @@ endfunction " FUNCTION: s:closeChildren(node) {{{1 " closes all childnodes of the current node -function! s:closeChildren(node) +function! s:closeChildren(node) abort call a:node.closeChildren() call b:NERDTree.render() call a:node.putCursorHere(0, 0) @@ -210,7 +210,7 @@ endfunction " FUNCTION: s:closeCurrentDir(node) {{{1 " Close the parent directory of the current node. -function! s:closeCurrentDir(node) +function! s:closeCurrentDir(node) abort if a:node.isRoot() call nerdtree#echo('cannot close parent of tree root') @@ -235,7 +235,7 @@ endfunction " FUNCTION: s:closeTreeWindow() {{{1 " close the tree window -function! s:closeTreeWindow() +function! s:closeTreeWindow() abort if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1 exec 'buffer ' . b:NERDTree.previousBuf() else @@ -249,7 +249,7 @@ endfunction " FUNCTION: s:deleteBookmark(bookmark) {{{1 " Prompt the user to confirm the deletion of the selected bookmark. -function! s:deleteBookmark(bookmark) +function! s:deleteBookmark(bookmark) abort let l:message = 'Delete the bookmark "' . a:bookmark.name \ . '" from the bookmark list?' @@ -275,14 +275,14 @@ endfunction " FUNCTION: s:displayHelp() {{{1 " toggles the help display -function! s:displayHelp() +function! s:displayHelp() abort call b:NERDTree.ui.toggleHelp() call b:NERDTree.render() call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 -function! s:findAndRevealPath(pathStr) +function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') if !filereadable(l:pathStr) let l:pathStr = fnamemodify(l:pathStr, ':h') @@ -333,7 +333,7 @@ endfunction "FUNCTION: s:handleLeftClick() {{{1 "Checks if the click should open the current node -function! s:handleLeftClick() +function! s:handleLeftClick() abort let currentNode = g:NERDTreeFileNode.GetSelected() if currentNode !=# {} @@ -368,7 +368,7 @@ function! s:handleLeftClick() endfunction " FUNCTION: s:handleMiddleMouse() {{{1 -function! s:handleMiddleMouse() +function! s:handleMiddleMouse() abort " A middle mouse click does not automatically position the cursor as one " would expect. Forcing the execution of a regular left mouse click here @@ -391,17 +391,17 @@ endfunction " FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 "this is needed since I cant figure out how to invoke dict functions from a "key map -function! nerdtree#ui_glue#invokeKeyMap(key) +function! nerdtree#ui_glue#invokeKeyMap(key) abort call g:NERDTreeKeyMap.Invoke(a:key) endfunction " FUNCTION: s:jumpToFirstChild(node) {{{1 -function! s:jumpToFirstChild(node) +function! s:jumpToFirstChild(node) abort call s:jumpToChild(a:node, 0) endfunction " FUNCTION: s:jumpToLastChild(node) {{{1 -function! s:jumpToLastChild(node) +function! s:jumpToLastChild(node) abort call s:jumpToChild(a:node, 1) endfunction @@ -411,7 +411,7 @@ endfunction " Args: " node: the node on which the cursor currently sits " last: 1 (true) if jumping to last child, 0 (false) if jumping to first -function! s:jumpToChild(node, last) +function! s:jumpToChild(node, last) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node if l:node.isRoot() @@ -430,7 +430,7 @@ endfunction " FUNCTION: s:jumpToParent(node) {{{1 " Move the cursor to the parent of the specified node. For a cascade, move to " the parent of the cascade's first node. At the root node, do nothing. -function! s:jumpToParent(node) +function! s:jumpToParent(node) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node if l:node.isRoot() @@ -448,18 +448,18 @@ endfunction " FUNCTION: s:jumpToRoot() {{{1 " moves the cursor to the root node -function! s:jumpToRoot() +function! s:jumpToRoot() abort call b:NERDTree.root.putCursorHere(1, 0) call b:NERDTree.ui.centerView() endfunction " FUNCTION: s:jumpToNextSibling(node) {{{1 -function! s:jumpToNextSibling(node) +function! s:jumpToNextSibling(node) abort call s:jumpToSibling(a:node, 1) endfunction " FUNCTION: s:jumpToPrevSibling(node) {{{1 -function! s:jumpToPrevSibling(node) +function! s:jumpToPrevSibling(node) abort call s:jumpToSibling(a:node, 0) endfunction @@ -469,7 +469,7 @@ endfunction " Args: " node: the node on which the cursor currently sits " forward: 0 to jump to previous sibling, 1 to jump to next sibling -function! s:jumpToSibling(node, forward) +function! s:jumpToSibling(node, forward) abort let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node let l:sibling = l:node.findSibling(a:forward) @@ -484,7 +484,7 @@ endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 " Open the Bookmark that has the specified name. This function provides the " implementation for the :OpenBookmark command. -function! nerdtree#ui_glue#openBookmark(name) +function! nerdtree#ui_glue#openBookmark(name) abort try let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) catch /^NERDTree.BookmarkNotFoundError/ @@ -499,34 +499,34 @@ function! nerdtree#ui_glue#openBookmark(name) endfunction " FUNCTION: s:openHSplit(target) {{{1 -function! s:openHSplit(target) +function! s:openHSplit(target) abort call a:target.activate({'where': 'h'}) endfunction " FUNCTION: s:openVSplit(target) {{{1 -function! s:openVSplit(target) +function! s:openVSplit(target) abort call a:target.activate({'where': 'v'}) endfunction " FUNCTION: s:openExplorer(node) {{{1 -function! s:openExplorer(node) +function! s:openExplorer(node) abort call a:node.openExplorer() endfunction " FUNCTION: s:openInNewTab(target) {{{1 -function! s:openInNewTab(target) +function! s:openInNewTab(target) abort let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) call l:opener.open(a:target) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 -function! s:openInNewTabSilent(target) +function! s:openInNewTabSilent(target) abort let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) call l:opener.open(a:target) endfunction " FUNCTION: s:openNodeRecursively(node) {{{1 -function! s:openNodeRecursively(node) +function! s:openNodeRecursively(node) abort call nerdtree#echo('Recursively opening node. Please wait...') call a:node.openRecursively() call b:NERDTree.render() @@ -534,7 +534,7 @@ function! s:openNodeRecursively(node) endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 -function! s:previewBookmark(bookmark) +function! s:previewBookmark(bookmark) abort if a:bookmark.path.isDirectory execute 'NERDTreeFind '.a:bookmark.path.str() else @@ -543,23 +543,23 @@ function! s:previewBookmark(bookmark) endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 -function! s:previewNodeCurrent(node) +function! s:previewNodeCurrent(node) abort call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeHSplit(node) {{{1 -function! s:previewNodeHSplit(node) +function! s:previewNodeHSplit(node) abort call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) endfunction "FUNCTION: s:previewNodeVSplit(node) {{{1 -function! s:previewNodeVSplit(node) +function! s:previewNodeVSplit(node) abort call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) endfunction " FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1 " put the cursor on the node associate with the given name -function! nerdtree#ui_glue#revealBookmark(name) +function! nerdtree#ui_glue#revealBookmark(name) abort try let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) @@ -571,7 +571,7 @@ endfunction " FUNCTION: s:refreshRoot() {{{1 " Reloads the current root. All nodes below this will be lost and the root dir " will be reloaded. -function! s:refreshRoot() +function! s:refreshRoot() abort if !g:NERDTree.IsOpen() return endif @@ -588,7 +588,7 @@ endfunction " FUNCTION: s:refreshCurrent(node) {{{1 " refreshes the root for the current node -function! s:refreshCurrent(node) +function! s:refreshCurrent(node) abort let node = a:node if !node.path.isDirectory let node = node.parent @@ -601,7 +601,7 @@ function! s:refreshCurrent(node) endfunction " FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 -function! nerdtree#ui_glue#setupCommands() +function! nerdtree#ui_glue#setupCommands() abort command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() @@ -614,7 +614,7 @@ function! nerdtree#ui_glue#setupCommands() endfunction " Function: s:SID() {{{1 -function s:SID() +function! s:SID() abort if !exists('s:sid') let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') endif @@ -622,34 +622,34 @@ function s:SID() endfun " FUNCTION: s:showMenu(node) {{{1 -function! s:showMenu(node) +function! s:showMenu(node) abort let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) call mc.showMenu() endfunction " FUNCTION: s:toggleIgnoreFilter() {{{1 -function! s:toggleIgnoreFilter() +function! s:toggleIgnoreFilter() abort call b:NERDTree.ui.toggleIgnoreFilter() endfunction " FUNCTION: s:toggleShowBookmarks() {{{1 -function! s:toggleShowBookmarks() +function! s:toggleShowBookmarks() abort call b:NERDTree.ui.toggleShowBookmarks() endfunction " FUNCTION: s:toggleShowFiles() {{{1 -function! s:toggleShowFiles() +function! s:toggleShowFiles() abort call b:NERDTree.ui.toggleShowFiles() endfunction " FUNCTION: s:toggleShowHidden() {{{1 " toggles the display of hidden files -function! s:toggleShowHidden() +function! s:toggleShowHidden() abort call b:NERDTree.ui.toggleShowHidden() endfunction " FUNCTION: s:toggleZoom() {{{1 -function! s:toggleZoom() +function! s:toggleZoom() abort call b:NERDTree.ui.toggleZoom() endfunction @@ -659,7 +659,7 @@ endfunction " Args: " preserveState: if 1, the current root is left open when the new tree is " rendered; if 0, the current root node is closed -function! nerdtree#ui_glue#upDir(preserveState) +function! nerdtree#ui_glue#upDir(preserveState) abort try call b:NERDTree.root.cacheParent() @@ -683,12 +683,12 @@ function! nerdtree#ui_glue#upDir(preserveState) endfunction " FUNCTION: s:upDirCurrentRootOpen() {{{1 -function! s:upDirCurrentRootOpen() +function! s:upDirCurrentRootOpen() abort call nerdtree#ui_glue#upDir(1) endfunction " FUNCTION: s:upDirCurrentRootClosed() {{{1 -function! s:upDirCurrentRootClosed() +function! s:upDirCurrentRootClosed() abort call nerdtree#ui_glue#upDir(0) endfunction From 907587f7a3ffe35ebbf358828cfd42e07ddf3fed Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:40:39 +0300 Subject: [PATCH 561/680] Fix lint warnings: use the full option name --- autoload/nerdtree.vim | 6 +++--- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/creator.vim | 12 ++++++------ plugin/NERD_tree.vim | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 3c5e6ec3..5c9af895 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -165,12 +165,12 @@ endfunction " FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2 " Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration function! nerdtree#exec(cmd, ignoreAll) abort - let old_ei = &ei + let old_ei = &eventignore if a:ignoreAll - set ei=all + set eventignore=all endif exec a:cmd - let &ei = old_ei + let &eventignore = old_ei endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index b457a8a9..248bb074 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -292,7 +292,7 @@ endfunction " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - strdisplaywidth(self.name) - if &nu + if &number let pathStrMaxLen = pathStrMaxLen - &numberwidth endif diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 294d9a82..39e3f554 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -300,11 +300,11 @@ function! s:Creator._setCommonBufOptions() setlocal nowrap if g:NERDTreeShowLineNumbers - setlocal nu + setlocal number else - setlocal nonu + setlocal nonumber if v:version >= 703 - setlocal nornu + setlocal norelativenumber endif endif @@ -330,8 +330,8 @@ endfunction " FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1 function! s:Creator._tabpagevar(tabnr, var) let currentTab = tabpagenr() - let old_ei = &ei - set ei=all + let old_ei = &eventignore + set eventignore=all exec 'tabnext ' . a:tabnr let v = -1 @@ -340,7 +340,7 @@ function! s:Creator._tabpagevar(tabnr, var) endif exec 'tabnext ' . currentTab - let &ei = old_ei + let &eventignore = old_ei return v endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 5a1abe55..639f87bb 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -22,9 +22,9 @@ if v:version < 703 endif let loaded_nerd_tree = 1 -"for line continuation - i.e dont want C in &cpo -let s:old_cpo = &cpo -set cpo&vim +"for line continuation - i.e dont want C in &cpoptions +let s:old_cpo = &cpoptions +set cpoptions&vim "Function: s:initVariable() function {{{2 "This function is used to initialise a given variable to a given value. The @@ -255,7 +255,7 @@ endfunction " SECTION: Post Source Actions {{{1 call nerdtree#postSourceActions() -"reset &cpo back to users setting -let &cpo = s:old_cpo +"reset &cpoptions back to users setting +let &cpoptions = s:old_cpo " vim: set sw=4 sts=4 et fdm=marker: From 3fb31b2e811252a9c545d41516c5c355acd5b5d1 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 09:55:37 +0300 Subject: [PATCH 562/680] Update changelog for 6.4.2 and add CI badge --- CHANGELOG.md | 1 + README.markdown | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec006c9..c92dd664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) - **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) - **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067) #### 6.3 diff --git a/README.markdown b/README.markdown index 9e539523..7a429312 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -The NERDTree +The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) ============= Introduction From 914970157f674ec63723276ecd66d12b99ee9307 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 31 Dec 2019 10:55:03 +0300 Subject: [PATCH 563/680] Update links to repository with new org namespace --- CHANGELOG.md | 264 +++++++++++++++++++++++------------------------ README.markdown | 16 +-- doc/NERDTree.txt | 8 +- 3 files changed, 144 insertions(+), 144 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec006c9..f052a2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,151 +9,151 @@ --> #### 6.4 - **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) -- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067) +- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/preservim/nerdtree/pull/1067) #### 6.3 -- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/scrooloose/nerdtree/pull/1060) +- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/preservim/nerdtree/pull/1060) #### 6.2 -- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/scrooloose/nerdtree/pull/1056) -- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032) +- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/preservim/nerdtree/pull/1056) +- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/preservim/nerdtree/pull/1032) #### 6.1 -- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049) -- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048) -- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047) -- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045) -- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043) +- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/preservim/nerdtree/pull/1049) +- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/preservim/nerdtree/pull/1048) +- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/preservim/nerdtree/pull/1047) +- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/preservim/nerdtree/pull/1045) +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/preservim/nerdtree/pull/1043) #### 6.0 -- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040) -- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035) +- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/preservim/nerdtree/pull/1040) +- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/preservim/nerdtree/pull/1035) #### 5.3 -- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038) -- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037) -- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031) -- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029) +- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/preservim/nerdtree/pull/1038) +- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/preservim/nerdtree/pull/1037) +- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/preservim/nerdtree/pull/1031) +- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/preservim/nerdtree/pull/1029) #### 5.2 -- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026) -- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021) -- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019) -- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/scrooloose/nerdtree/pull/1017) -- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/scrooloose/nerdtree/pull/1016) -- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015) -- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) -- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013) +- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/preservim/nerdtree/pull/1026) +- **.8**: Revert [#1019](https://github.com/preservim/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/preservim/nerdtree/pull/1021) +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/preservim/nerdtree/pull/1019) +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/preservim/nerdtree/pull/1017) +- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/preservim/nerdtree/pull/1016) +- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/preservim/nerdtree/pull/1015) +- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/preservim/nerdtree/pull/1014) +- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/preservim/nerdtree/pull/1013) - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) -- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) +- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/preservim/nerdtree/pull/1011) #### 5.1 -- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009) -- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008) -- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007) +- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/preservim/nerdtree/pull/1009) +- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/preservim/nerdtree/pull/1008) +- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/preservim/nerdtree/pull/1007) - **.0**: Too many changes for one patch... - - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/scrooloose/nerdtree/pull/1005) - - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/scrooloose/nerdtree/pull/1002) - - Enable root refresh on "vim ." a different way than [#999](https://github.com/scrooloose/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/scrooloose/nerdtree/pull/1001) - - Fix refreshroot (PhilRunninger) [#999](https://github.com/scrooloose/nerdtree/pull/999) - - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/scrooloose/nerdtree/pull/994) - - Change minimum vim (PhilRunninger) [#991](https://github.com/scrooloose/nerdtree/pull/991) - - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/scrooloose/nerdtree/pull/985) - - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/scrooloose/nerdtree/pull/979) - - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/scrooloose/nerdtree/pull/969) - - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/scrooloose/nerdtree/pull/967) - - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/scrooloose/nerdtree/pull/966) - - Smarter delimiter default (PhilRunninger) [#963](https://github.com/scrooloose/nerdtree/pull/963) - - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/scrooloose/nerdtree/pull/961) - - Preview bookmarks (PhilRunninger) [#956](https://github.com/scrooloose/nerdtree/pull/956) - - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/scrooloose/nerdtree/pull/955) - - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/scrooloose/nerdtree/pull/954) - - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/scrooloose/nerdtree/pull/952) - - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/scrooloose/nerdtree/pull/950) - - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/scrooloose/nerdtree/pull/949) - - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/scrooloose/nerdtree/pull/948) - - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/scrooloose/nerdtree/pull/938) - - fixed root path error for windows (zcodes) [#935](https://github.com/scrooloose/nerdtree/pull/935) - - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/scrooloose/nerdtree/pull/929) - - Document NERDTreeNodeDelimiter [#912](https://github.com/scrooloose/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/scrooloose/nerdtree/pull/926) - - Allow modification of menu keybindings (Leandros) [#923](https://github.com/scrooloose/nerdtree/pull/923) - - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/scrooloose/nerdtree/pull/914) - - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/scrooloose/nerdtree/pull/908) - - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/scrooloose/nerdtree/pull/901) - - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/scrooloose/nerdtree/pull/899) - - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/scrooloose/nerdtree/pull/898) - - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/scrooloose/nerdtree/pull/897) - - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/scrooloose/nerdtree/pull/896) - - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/scrooloose/nerdtree/pull/894) - - Fix typo in help file (lvoisin) [#892](https://github.com/scrooloose/nerdtree/pull/892) - - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/scrooloose/nerdtree/pull/889) - - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/scrooloose/nerdtree/pull/888) - - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/scrooloose/nerdtree/pull/887) - - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/scrooloose/nerdtree/pull/886) - - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/scrooloose/nerdtree/pull/882) - - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/scrooloose/nerdtree/pull/878) - - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/scrooloose/nerdtree/pull/877) - - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/scrooloose/nerdtree/pull/875) - - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/scrooloose/nerdtree/pull/873) - - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/scrooloose/nerdtree/pull/872) - - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/scrooloose/nerdtree/pull/871) - - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/scrooloose/nerdtree/pull/870) - - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/scrooloose/nerdtree/pull/868) - - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/scrooloose/nerdtree/pull/867) - - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/scrooloose/nerdtree/pull/866) - - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/scrooloose/nerdtree/pull/856) - - Better OSX detection (bubba-h57) [#853](https://github.com/scrooloose/nerdtree/pull/853) - - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/scrooloose/nerdtree/pull/852) - - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/scrooloose/nerdtree/pull/851) - - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/scrooloose/nerdtree/pull/849) - - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/scrooloose/nerdtree/pull/844) - - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/scrooloose/nerdtree/pull/840) - - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/scrooloose/nerdtree/pull/838) - - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/scrooloose/nerdtree/pull/837) - - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/scrooloose/nerdtree/pull/835) - - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/scrooloose/nerdtree/pull/834) - - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/scrooloose/nerdtree/pull/833) - - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/scrooloose/nerdtree/pull/832) - - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/scrooloose/nerdtree/pull/830) - - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/scrooloose/nerdtree/pull/824) - - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/scrooloose/nerdtree/pull/822) - - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/scrooloose/nerdtree/pull/816) - - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/scrooloose/nerdtree/pull/814) - - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/scrooloose/nerdtree/pull/801) - - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/scrooloose/nerdtree/pull/796) - - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/scrooloose/nerdtree/pull/795) - - Revert the bugfix from pull request [#785](https://github.com/scrooloose/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/scrooloose/nerdtree/pull/794) - - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/scrooloose/nerdtree/pull/786) - - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/scrooloose/nerdtree/pull/785) - - Add modelines (lifecrisis) [#782](https://github.com/scrooloose/nerdtree/pull/782) - - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/scrooloose/nerdtree/pull/781) - - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/scrooloose/nerdtree/pull/778) - - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/scrooloose/nerdtree/pull/777) - - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/scrooloose/nerdtree/pull/773) - - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/scrooloose/nerdtree/pull/772) - - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/scrooloose/nerdtree/pull/769) - - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/scrooloose/nerdtree/pull/768) - - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/scrooloose/nerdtree/pull/767) - - Revert change to tab opening method (lifecrisis) [#766](https://github.com/scrooloose/nerdtree/pull/766) - - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/scrooloose/nerdtree/pull/765) - - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/scrooloose/nerdtree/pull/759) - - Update doc with already existing mapping variables (asnr) [#699](https://github.com/scrooloose/nerdtree/pull/699) - - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/scrooloose/nerdtree/pull/696) - - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/scrooloose/nerdtree/pull/648) - - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/scrooloose/nerdtree/pull/574) - - Suppress autocmds less agressively (wincent) [#578](https://github.com/scrooloose/nerdtree/pull/578) [#691](https://github.com/scrooloose/nerdtree/pull/691) + - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/preservim/nerdtree/pull/1005) + - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/preservim/nerdtree/pull/1002) + - Enable root refresh on "vim ." a different way than [#999](https://github.com/preservim/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/preservim/nerdtree/pull/1001) + - Fix refreshroot (PhilRunninger) [#999](https://github.com/preservim/nerdtree/pull/999) + - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/preservim/nerdtree/pull/994) + - Change minimum vim (PhilRunninger) [#991](https://github.com/preservim/nerdtree/pull/991) + - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/preservim/nerdtree/pull/985) + - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/preservim/nerdtree/pull/979) + - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/preservim/nerdtree/pull/969) + - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/preservim/nerdtree/pull/967) + - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/preservim/nerdtree/pull/966) + - Smarter delimiter default (PhilRunninger) [#963](https://github.com/preservim/nerdtree/pull/963) + - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/preservim/nerdtree/pull/961) + - Preview bookmarks (PhilRunninger) [#956](https://github.com/preservim/nerdtree/pull/956) + - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/preservim/nerdtree/pull/955) + - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/preservim/nerdtree/pull/954) + - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/preservim/nerdtree/pull/952) + - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/preservim/nerdtree/pull/950) + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/preservim/nerdtree/pull/949) + - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/preservim/nerdtree/pull/948) + - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/preservim/nerdtree/pull/938) + - fixed root path error for windows (zcodes) [#935](https://github.com/preservim/nerdtree/pull/935) + - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/preservim/nerdtree/pull/929) + - Document NERDTreeNodeDelimiter [#912](https://github.com/preservim/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/preservim/nerdtree/pull/926) + - Allow modification of menu keybindings (Leandros) [#923](https://github.com/preservim/nerdtree/pull/923) + - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/preservim/nerdtree/pull/914) + - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/preservim/nerdtree/pull/908) + - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/preservim/nerdtree/pull/901) + - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/preservim/nerdtree/pull/899) + - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/preservim/nerdtree/pull/898) + - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/preservim/nerdtree/pull/897) + - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/preservim/nerdtree/pull/896) + - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/preservim/nerdtree/pull/894) + - Fix typo in help file (lvoisin) [#892](https://github.com/preservim/nerdtree/pull/892) + - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/preservim/nerdtree/pull/889) + - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/preservim/nerdtree/pull/888) + - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/preservim/nerdtree/pull/887) + - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/preservim/nerdtree/pull/886) + - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/preservim/nerdtree/pull/882) + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/preservim/nerdtree/pull/878) + - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/preservim/nerdtree/pull/877) + - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/preservim/nerdtree/pull/875) + - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/preservim/nerdtree/pull/873) + - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/preservim/nerdtree/pull/872) + - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/preservim/nerdtree/pull/871) + - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/preservim/nerdtree/pull/870) + - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/preservim/nerdtree/pull/868) + - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/preservim/nerdtree/pull/867) + - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/preservim/nerdtree/pull/866) + - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/preservim/nerdtree/pull/856) + - Better OSX detection (bubba-h57) [#853](https://github.com/preservim/nerdtree/pull/853) + - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/preservim/nerdtree/pull/852) + - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/preservim/nerdtree/pull/851) + - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/preservim/nerdtree/pull/849) + - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/preservim/nerdtree/pull/844) + - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/preservim/nerdtree/pull/840) + - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/preservim/nerdtree/pull/838) + - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/preservim/nerdtree/pull/837) + - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/preservim/nerdtree/pull/835) + - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/preservim/nerdtree/pull/834) + - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/preservim/nerdtree/pull/833) + - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/preservim/nerdtree/pull/832) + - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/preservim/nerdtree/pull/830) + - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/preservim/nerdtree/pull/824) + - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/preservim/nerdtree/pull/822) + - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/preservim/nerdtree/pull/816) + - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/preservim/nerdtree/pull/814) + - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/preservim/nerdtree/pull/801) + - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/preservim/nerdtree/pull/796) + - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/preservim/nerdtree/pull/795) + - Revert the bugfix from pull request [#785](https://github.com/preservim/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/preservim/nerdtree/pull/794) + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/preservim/nerdtree/pull/786) + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/preservim/nerdtree/pull/785) + - Add modelines (lifecrisis) [#782](https://github.com/preservim/nerdtree/pull/782) + - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/preservim/nerdtree/pull/781) + - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/preservim/nerdtree/pull/778) + - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/preservim/nerdtree/pull/777) + - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/preservim/nerdtree/pull/773) + - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/preservim/nerdtree/pull/772) + - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/preservim/nerdtree/pull/769) + - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/preservim/nerdtree/pull/768) + - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/preservim/nerdtree/pull/767) + - Revert change to tab opening method (lifecrisis) [#766](https://github.com/preservim/nerdtree/pull/766) + - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/preservim/nerdtree/pull/765) + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/preservim/nerdtree/pull/759) + - Update doc with already existing mapping variables (asnr) [#699](https://github.com/preservim/nerdtree/pull/699) + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/preservim/nerdtree/pull/696) + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/preservim/nerdtree/pull/648) + - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/preservim/nerdtree/pull/574) + - Suppress autocmds less agressively (wincent) [#578](https://github.com/preservim/nerdtree/pull/578) [#691](https://github.com/preservim/nerdtree/pull/691) - Add an Issues template to ask for more info initially. - - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/scrooloose/nerdtree/pull/676) + - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/preservim/nerdtree/pull/676) - Don't touch `@o` and `@h` registers when rendering - - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/scrooloose/nerdtree/pull/649) - - Reuse/reopen existing window trees where possible [#244](https://github.com/scrooloose/nerdtree/pull/244) + - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/preservim/nerdtree/pull/649) + - Reuse/reopen existing window trees where possible [#244](https://github.com/preservim/nerdtree/pull/244) - Remove NERDTree.previousBuf() - - Change color of arrow (Leeiio) [#630](https://github.com/scrooloose/nerdtree/pull/630) - - Improved a tip in README.markdown (ggicci) [#628](https://github.com/scrooloose/nerdtree/pull/628) - - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/scrooloose/nerdtree/pull/530) - - Fix API call to open directory tree in window (devm33) [#533](https://github.com/scrooloose/nerdtree/pull/533) - - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/scrooloose/nerdtree/pull/546) - - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/scrooloose/nerdtree/pull/584) - - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/scrooloose/nerdtree/pull/593) - - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/scrooloose/nerdtree/pull/595) - - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/scrooloose/nerdtree/pull/619) - - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/scrooloose/nerdtree/pull/548) - - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/scrooloose/nerdtree/pull/558) + - Change color of arrow (Leeiio) [#630](https://github.com/preservim/nerdtree/pull/630) + - Improved a tip in README.markdown (ggicci) [#628](https://github.com/preservim/nerdtree/pull/628) + - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/preservim/nerdtree/pull/530) + - Fix API call to open directory tree in window (devm33) [#533](https://github.com/preservim/nerdtree/pull/533) + - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/preservim/nerdtree/pull/546) + - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/preservim/nerdtree/pull/584) + - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/preservim/nerdtree/pull/593) + - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/preservim/nerdtree/pull/595) + - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/preservim/nerdtree/pull/619) + - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/preservim/nerdtree/pull/548) + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/preservim/nerdtree/pull/558) - Replace strchars() with backward compatible workaround. - - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/scrooloose/nerdtree/pull/231) + - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/preservim/nerdtree/pull/231) - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. diff --git a/README.markdown b/README.markdown index 9e539523..a3fe4fec 100644 --- a/README.markdown +++ b/README.markdown @@ -12,7 +12,7 @@ This plugin can also be extended with custom mappings using a special API. The details of this API and of other NERDTree features are described in the included documentation. -![NERDTree Screenshot](https://github.com/scrooloose/nerdtree/raw/master/screenshot.png) +![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) Installation ------------ @@ -24,7 +24,7 @@ Below are just some of the methods for installing NERDTree. Do not follow all of If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: ```bash -git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q ``` @@ -34,7 +34,7 @@ Otherwise, these are some of the several 3rd-party plugin managers you can choos In the terminal, ```bash -git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree +git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree ``` In your vimrc, ```vim @@ -48,23 +48,23 @@ Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. #### [Vundle.vim](https://github.com/VundleVim/Vundle.vim) ```vim call vundle#begin() -Plugin 'scrooloose/nerdtree' +Plugin 'preservim/nerdtree' call vundle#end() ``` #### [vim-plug](https://github.com/junegunn/vim-plug) ```vim call plug#begin() -Plug 'scrooloose/nerdtree' +Plug 'preservim/nerdtree' call plug#end() ``` #### [apt-vim](https://github.com/egalpin/apt-vim) ```bash -apt-vim install -y https://github.com/scrooloose/nerdtree.git +apt-vim install -y https://github.com/preservim/nerdtree.git ``` -F.A.Q. (here, and in the [Wiki](https://github.com/scrooloose/nerdtree/wiki)) +F.A.Q. (here, and in the [Wiki](https://github.com/preservim/nerdtree/wiki)) ------ #### Is there any support for `git` flags? @@ -133,7 +133,7 @@ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isT --- #### Can I have different highlighting for different file extensions? -See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 +See here: https://github.com/preservim/nerdtree/issues/433#issuecomment-92590696 --- #### How can I change default arrows? diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index be0011d2..857e6823 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1238,7 +1238,7 @@ This character is used to separate the file or directory name from the rest of the characters in the line of text. It allows filenames to contain special characters that are otherwise used in the NERDTree, such as square brackets, braces, trailing asterisk, and leading space. For more details, see the -responsible pull request: https://github.com/scrooloose/nerdtree/pull/868. +responsible pull request: https://github.com/preservim/nerdtree/pull/868. The default value of this variable depends on the features compiled into your vim and the values of |NERDTreeDirArrowCollapsible| and @@ -1498,11 +1498,11 @@ in the fridge for later ;) Martyzilla recruited two other unwitting accomplices to become his minions in his quest to conquer the Vim plugin world. While he may still love to receive your emails, the best way to send suggestions, bug reports, and questions is -to submit an issue at http://github.com/scrooloose/nerdtree/issues. +to submit an issue at http://github.com/preservim/nerdtree/issues. The latest stable and development versions are on Github. - Stable: http://github.com/scrooloose/nerdtree (master branch) - Development: http://github.com/scrooloose/nerdtree/branches + Stable: http://github.com/preservim/nerdtree (master branch) + Development: http://github.com/preservim/nerdtree/branches Title Credit: * http://ascii.co.uk/art/tree From b579c7751df9e97c230353d371eb5fae6e4c7d1b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 6 Jan 2020 09:16:16 -0500 Subject: [PATCH 564/680] Fix regex that finds keyword for minimal menu. --- CHANGELOG.md | 1 + lib/nerdtree/menu_controller.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1da3cdeb..c8989ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) - **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) - **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) - **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/preservim/nerdtree/pull/1067) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index ca93efa2..952c67bd 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -62,7 +62,7 @@ function! s:MenuController._echoPrompt() if self.isMinimal() let selection = self.menuItems[self.selection].text - let keyword = matchstr(selection, '\([^ ]*') + let keyword = matchstr(selection, '[^ ]*([^ ]*') let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") let shortcuts[self.selection] = ' ' . keyword . ' ' From 97e4b47aa3b6c6acb6621eedd7fcaa299c5dea88 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 15 Jan 2020 19:51:39 -0500 Subject: [PATCH 565/680] Prevent overwriting existing files/dirs on node move. (m-m) --- nerdtree_plugin/fs_menu.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 3ecfa816..87ec0cf2 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -196,6 +196,11 @@ function! NERDTreeMoveNode() let curNode = g:NERDTreeFileNode.GetSelected() let prompt = s:inputPrompt('move') let newNodePath = input(prompt, curNode.path.str(), 'file') + while filereadable(newNodePath) + call nerdtree#echoWarning('This destination already exists. Try again.') + let newNodePath = input(prompt, curNode.path.str(), 'file') + endwhile + if newNodePath ==# '' call nerdtree#echo('Node Renaming Aborted.') From a046ba5c5bedf4e1539623fdd39a62eddca4142a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 15 Jan 2020 19:54:06 -0500 Subject: [PATCH 566/680] Update version number in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8989ef3..d1c45001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) - **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) - **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) - **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) From 5fbf0d7dba2ec12af6d0ca145a1cc2e87663c702 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 16 Jan 2020 10:51:12 -0500 Subject: [PATCH 567/680] Put the eventignore reset inside a finally block to ensure it's called. --- autoload/nerdtree.vim | 7 +++++-- lib/nerdtree/creator.vim | 17 ++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 5c9af895..156b2602 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -169,8 +169,11 @@ function! nerdtree#exec(cmd, ignoreAll) abort if a:ignoreAll set eventignore=all endif - exec a:cmd - let &eventignore = old_ei + try + exec a:cmd + finally + let &eventignore = old_ei + endtry endfunction " FUNCTION: nerdtree#has_opt(options, name) {{{2 diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 39e3f554..67fd3ce9 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -333,14 +333,17 @@ function! s:Creator._tabpagevar(tabnr, var) let old_ei = &eventignore set eventignore=all - exec 'tabnext ' . a:tabnr - let v = -1 - if exists('t:' . a:var) - exec 'let v = t:' . a:var - endif - exec 'tabnext ' . currentTab + try + exec 'tabnext ' . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec 'tabnext ' . currentTab - let &eventignore = old_ei + finally + let &eventignore = old_ei + endtry return v endfunction From 3a3636b7cb8d8cb725f38ed9cff8082c46f434df Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 16 Jan 2020 11:17:33 -0500 Subject: [PATCH 568/680] Don't ignore events when opening renamed files. --- nerdtree_plugin/fs_menu.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 87ec0cf2..281116fd 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -141,12 +141,12 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif " 1. ensure that a new buffer is loaded - call nerdtree#exec('badd ' . quotedFileName, 1) + call nerdtree#exec('badd ' . quotedFileName, 0) " 2. ensure that all windows which display the just deleted filename " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1) + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 0) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) " 3. We don't need a previous buffer anymore From 6d5e185cef1d6f45dc8135e1bb51a97bca4388f2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 16 Jan 2020 13:25:57 -0500 Subject: [PATCH 569/680] Update version in change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1c45001..7f7dcc1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) - **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) - **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) - **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) From 881c265438f94673a36005860b4335fd6eb94799 Mon Sep 17 00:00:00 2001 From: andys8 Date: Sun, 19 Jan 2020 20:42:08 +0100 Subject: [PATCH 570/680] [BUGFIX] Shows error for empty filenames (vim-startify) There was a fix in #1043 which improves the behavior for non saved filenames. Those are not on disk, but also not empty. This lead to an issue #1059 where actual "empty files" like created with vim-startify or stdin lead to an error. This change fixes this by adapting the order of the tests. It'll print "no file for the current buffer" for empty files. Solves #1059 --- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f7dcc1d..2576d475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 +- **.6:** NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) - **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) - **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) - **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 400e52dc..57af126b 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -284,15 +284,16 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') - if !filereadable(l:pathStr) - let l:pathStr = fnamemodify(l:pathStr, ':h') - endif if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') return endif + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + endif + try let l:pathStr = g:NERDTreePath.Resolve(l:pathStr) let l:pathObj = g:NERDTreePath.New(l:pathStr) From f7b09634ba2305d19cd4c73988452698c93f74d3 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 28 Jan 2020 03:20:07 -0500 Subject: [PATCH 571/680] Fix typo in version number. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2576d475..edbcfae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.4 -- **.6:** NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) +- **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) - **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) - **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) - **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) From e48b5728f921cfd745514499e29afdc200b992bc Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 28 Jan 2020 03:55:58 -0500 Subject: [PATCH 572/680] NERDTree always sets NERDTree root. --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 5 +++-- lib/nerdtree/creator.vim | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edbcfae8..873cb296 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.5 +- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1082](https://github.com/preservim/nerdtree/pull/1082) #### 6.4 - **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) - **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 857e6823..e2dd56a3 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -122,8 +122,9 @@ The following features and functionality are provided by the NERDTree: :NERDTreeToggle [ | ] *:NERDTreeToggle* If a NERDTree already exists for this tab, it is reopened and rendered - again. If no NERDTree exists for this tab then this command acts the - same as the |:NERDTree| command. + again. If or is given, the root of NERDTree + is set to that path. If no NERDTree exists for this tab then this command + acts the same as the |:NERDTree| command. :NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* Like |:NERDTreeToggle|, but searches up the directory tree to find the top of diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 67fd3ce9..e2b3fa0a 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -355,17 +355,20 @@ function! s:Creator.ToggleTabTree(dir) endfunction " FUNCTION: s:Creator.toggleTabTree(dir) {{{1 -" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -" closed it is restored or initialized (if it doesnt exist) +" Toggles the NERD tree. I.e if the NERD tree is open, it is closed. If it is +" closed, it is restored or initialized. If dir is not empty, it will be set +" as the new root. " " Args: -" dir: the full path for the root node (is only used if the NERD tree is being -" initialized. +" dir: the full path for the root node (is used if the NERD tree is being +" initialized, or to change the root to a new dir.) function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !&hidden + if !empty(a:dir) + call self.createTabTree(a:dir) + elseif !&hidden call b:NERDTree.render() endif call b:NERDTree.ui.restoreScreenState() From b16553ac540aa6aed712aba701ff79d768a44afb Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 28 Jan 2020 03:57:50 -0500 Subject: [PATCH 573/680] Update pull request number in change log. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 873cb296..e163c6c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.5 -- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1082](https://github.com/preservim/nerdtree/pull/1082) +- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) #### 6.4 - **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) - **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) From 26333ceeabaa6770475fd0d80c47c0ff585c898f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 01:58:00 -0500 Subject: [PATCH 574/680] If arrows are empty strings, don't print their trailing spaces. --- lib/nerdtree/tree_dir_node.vim | 11 +++-------- lib/nerdtree/tree_file_node.vim | 6 ++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 1502ea73..f38e8098 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -104,16 +104,11 @@ function! s:TreeDirNode.displayString() endfor " Select the appropriate open/closed status indicator symbol. - if l:cascade[-1].isOpen - let l:symbol = g:NERDTreeDirArrowCollapsible - else - let l:symbol = g:NERDTreeDirArrowExpandable - endif - + let l:padding = g:NERDTreeDirArrowExpandable == '' ? '' : ' ' + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) . l:padding let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . l:label - return l:result + return l:symbol . l:flags . l:label endfunction " FUNCTION: TreeDirNode.findNode(path) {{{1 diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 34074a25..9ae84e42 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -321,13 +321,11 @@ function! s:TreeFileNode._renderToString(depth, drawText) if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - - if !self.path.isDirectory - let treeParts = treeParts . ' ' + if !self.path.isDirectory && g:NERDTreeDirArrowExpandable != '' + let treeParts .= ' ' endif let line = treeParts . self.displayString() - let output = output . line . "\n" endif From 961c3571c4ffafa462022814b1fe24de0c7d38c8 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 01:59:41 -0500 Subject: [PATCH 575/680] WIP: Fix syntax highlighting when arrows are empty strings. Also improved some highlighting to make use of g:NERDTreeNodeDelimiter, which directly surrounds the filename. More of this to come as errors are tracked down and fixed in this file. --- syntax/nerdtree.vim | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 0df9d12e..7e8db1a9 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -22,19 +22,23 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir -exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' -exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' - -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') -exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' -syn match NERDTreeExecFile '^ .*\*\($\| \)' contains=NERDTreeRO,NERDTreeBookmark -exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +if g:NERDTreeDirArrowExpandable != '' + exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +else + exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' + exec 'syn match NERDTreeExecFile #'.g:NERDTreeNodeDelimiter.'.\{-}\*\($\|'.g:NERDTreeNodeDelimiter.'\)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^.\{-}'.g:NERDTreeNodeDelimiter.'.\{-}[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +endif "highlighting for readonly files -exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' -syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExecFile -syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir' "highlighing to conceal the delimiter around the file/dir name if has('conceal') From 6d3743549c822533929b3cec5cee392b17552e03 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 02:28:53 -0500 Subject: [PATCH 576/680] Fix vint errors: Use robust operators ==# and !=# --- lib/nerdtree/tree_dir_node.vim | 2 +- lib/nerdtree/tree_file_node.vim | 2 +- syntax/nerdtree.vim | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index f38e8098..1f8da01e 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -104,7 +104,7 @@ function! s:TreeDirNode.displayString() endfor " Select the appropriate open/closed status indicator symbol. - let l:padding = g:NERDTreeDirArrowExpandable == '' ? '' : ' ' + let l:padding = g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ' let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) . l:padding let l:flags = l:cascade[-1].path.flagSet.renderToString() diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 9ae84e42..b06b6a7d 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -321,7 +321,7 @@ function! s:TreeFileNode._renderToString(depth, drawText) if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - if !self.path.isDirectory && g:NERDTreeDirArrowExpandable != '' + if !self.path.isDirectory && g:NERDTreeDirArrowExpandable !=# '' let treeParts .= ' ' endif diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7e8db1a9..99238fd5 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -22,7 +22,7 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir -if g:NERDTreeDirArrowExpandable != '' +if g:NERDTreeDirArrowExpandable !=# '' exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') From 450abd1820402e82f5477764a473e3ac36965c01 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 08:00:06 -0500 Subject: [PATCH 577/680] Fix indentLevelFor(), which was getting the right answer the wrong way. --- lib/nerdtree/ui.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index fc9db71e..9ffadf6e 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -284,7 +284,11 @@ endfunction function! s:UI._indentLevelFor(line) " Replace multi-character DirArrows with a single space so the " indentation calculation doesn't get messed up. - let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + if g:NERDTreeDirArrowExpandable ==# '' + let l:line = ' '.a:line + else + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + endif let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction From c3d7c141bb11f5417c1ba77b88233aa55d410e52 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 09:30:08 -0500 Subject: [PATCH 578/680] Simplify and make similar statements more similarer --- lib/nerdtree/tree_dir_node.vim | 4 ++-- lib/nerdtree/tree_file_node.vim | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 1f8da01e..88ac319f 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -104,8 +104,8 @@ function! s:TreeDirNode.displayString() endfor " Select the appropriate open/closed status indicator symbol. - let l:padding = g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ' - let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) . l:padding + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) + let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let l:flags = l:cascade[-1].path.flagSet.renderToString() return l:symbol . l:flags . l:label diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index b06b6a7d..957b98ac 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -321,9 +321,7 @@ function! s:TreeFileNode._renderToString(depth, drawText) if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - if !self.path.isDirectory && g:NERDTreeDirArrowExpandable !=# '' - let treeParts .= ' ' - endif + let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let line = treeParts . self.displayString() let output = output . line . "\n" From 2388af7754f7c01af01cd57e98bbeaaad4212484 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 4 Feb 2020 02:08:08 -0500 Subject: [PATCH 579/680] WIP: A better regex for NERDTreeExecFile. Still not all right. --- syntax/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 99238fd5..bbc92f72 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -31,8 +31,8 @@ if g:NERDTreeDirArrowExpandable !=# '' exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' else exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' - exec 'syn match NERDTreeExecFile #'.g:NERDTreeNodeDelimiter.'.\{-}\*\($\|'.g:NERDTreeNodeDelimiter.'\)# contains=NERDTreeRO,NERDTreeBookmark' - exec 'syn match NERDTreeFile #^.\{-}'.g:NERDTreeNodeDelimiter.'.\{-}[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' endif "highlighting for readonly files From e41dd019d91fb8a28da31fdeb94be61ed0e93aba Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 5 Feb 2020 15:09:24 -0500 Subject: [PATCH 580/680] Reorder syntax statements to fix highlighting. --- syntax/nerdtree.vim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index bbc92f72..df0c8046 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -19,6 +19,15 @@ syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir +"highlighting to conceal the delimiter around the file/dir name +if has('conceal') + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' + setlocal conceallevel=3 concealcursor=nvic +else + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' + hi! link NERDTreeNodeDelimiters Ignore +endif + "highlighing for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir @@ -40,15 +49,6 @@ exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNod exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir' -"highlighing to conceal the delimiter around the file/dir name -if has('conceal') - exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' - setlocal conceallevel=3 concealcursor=nvic -else - exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' - hi! link NERDTreeNodeDelimiters Ignore -endif - syn match NERDTreeCWD #^[ Date: Thu, 6 Feb 2020 13:01:04 -0500 Subject: [PATCH 581/680] Update the documentation/README. --- README.markdown | 5 +++++ doc/NERDTree.txt | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index e7632420..cd03b515 100644 --- a/README.markdown +++ b/README.markdown @@ -143,3 +143,8 @@ Use these variables in your vimrc. Note that below are default arrow symbols let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` +You can remove the arrows altogether by setting these variables to empty strings, as shown below. This will remove not only the arrows, but a single space following them, shifting the whole tree two character positions to the left. +```vim +let g:NERDTreeDirArrowExpandable = '' +let g:NERDTreeDirArrowCollapsible = '' +``` diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index e2dd56a3..47d65ccc 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1223,13 +1223,19 @@ Values: Any single character. Defaults: Windows: ~ and + Others: ▾ and ▸ These characters indicate whether a directory is collapsible or expandable. - -They can be set to "\u00a0" to hide the arrows, but if you do this you may -need to change the node delimiter. See |NERDTreeNodeDelimiter|. You cannot use -the same character for both the arrows and the delimiter. Example: > +Example: > let NERDTreeDirArrowExpandable=">" let NERDTreeDirArrowCollapsible="v" < +They can be set to "\u00a0" to replace the arrows with a non-breaking space. +If you do this you may need to change the node delimiter. See +|NERDTreeNodeDelimiter|. You cannot use the same character for both the arrows +and the delimiter. + +Alternatively, they can be set to '' (an empty string). This removes the +arrows and the single space that follows them, shifting the entire tree two +character positions to the left. + ------------------------------------------------------------------------------ *NERDTreeNodeDelimiter* Values: Any single character. From 1f5018dc452515c3e6dc8be611440a048c9f0cfe Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 6 Feb 2020 17:43:46 -0500 Subject: [PATCH 582/680] Update version number in change log. --- CHANGELOG.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e163c6c9..ed79ff49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,11 @@ # NERDTree Change Log - - +#### 6.6 +- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) #### 6.5 - **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) #### 6.4 From 41a44be8d5c28f5ce0853ec891ae0c7b03a30d76 Mon Sep 17 00:00:00 2001 From: kazukazuinaina Date: Sat, 8 Feb 2020 02:42:47 +0900 Subject: [PATCH 583/680] [add] How to install using dein.vim update changelog --- CHANGELOG.md | 1 + README.markdown | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed79ff49..a80acf25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.6 +- **.1**: [add] How to install using dein.vim [#1087](https://github.com/preservim/nerdtree/pull/1087) - **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) #### 6.5 - **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) diff --git a/README.markdown b/README.markdown index cd03b515..09173a65 100644 --- a/README.markdown +++ b/README.markdown @@ -59,6 +59,13 @@ Plug 'preservim/nerdtree' call plug#end() ``` +#### [dein.vim](https://github.com/Shougo/dein.vim) +```vim +call dein#begin() +call dein#add('preservim/nerdtree') +call dein#end() +``` + #### [apt-vim](https://github.com/egalpin/apt-vim) ```bash apt-vim install -y https://github.com/preservim/nerdtree.git From 07612557ebb4118ef4a337faa7033d0270773c71 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 7 Feb 2020 14:11:00 -0500 Subject: [PATCH 584/680] Give kazukazuinaina proper credit. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a80acf25..6309a712 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.6 -- **.1**: [add] How to install using dein.vim [#1087](https://github.com/preservim/nerdtree/pull/1087) +- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) - **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) #### 6.5 - **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) From 6224d20698da46376c25adb264a989962ad242c2 Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Thu, 20 Feb 2020 10:45:09 +0100 Subject: [PATCH 585/680] Open the parent directory when revealing a non-existent file Right now it just reveals the directory but leaves it closed. Related to #1043 --- autoload/nerdtree/ui_glue.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 57af126b..68871326 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -284,6 +284,7 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + let l:revealOpts = {} if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') @@ -292,6 +293,7 @@ function! s:findAndRevealPath(pathStr) abort if !filereadable(l:pathStr) let l:pathStr = fnamemodify(l:pathStr, ':h') + let l:revealOpts["open"] = 1 endif try @@ -327,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort call b:NERDTree.ui.setShowHidden(1) endif - let l:node = b:NERDTree.root.reveal(l:pathObj) + let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts) call b:NERDTree.render() call l:node.putCursorHere(1, 0) endfunction From 09b165cfacc8e3ac23eb9d0df22de10f47d2a097 Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Thu, 20 Feb 2020 10:49:03 +0100 Subject: [PATCH 586/680] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6309a712..54eef600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.7 +- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) #### 6.6 - **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) - **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) From 5249b30fbf829c035201c4c8280b871bcba60146 Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Thu, 20 Feb 2020 10:50:15 +0100 Subject: [PATCH 587/680] Use single-quoted string to comply with styleguide --- autoload/nerdtree/ui_glue.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 68871326..aef1b046 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -293,7 +293,7 @@ function! s:findAndRevealPath(pathStr) abort if !filereadable(l:pathStr) let l:pathStr = fnamemodify(l:pathStr, ':h') - let l:revealOpts["open"] = 1 + let l:revealOpts['open'] = 1 endif try From 495b4e781ad83d9290f1ba0838217f6a4255768a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 24 Mar 2020 15:08:06 -0400 Subject: [PATCH 588/680] File Move: Escape existing directory name when looking for open files. (#1094) * File Move: Escape existing directory name when looking for open files. * Update version number in change log. Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54eef600..77b86e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) - **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) #### 6.6 - **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 281116fd..a1fa2ee7 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -209,7 +209,8 @@ function! NERDTreeMoveNode() try if curNode.path.isDirectory - let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') else let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') endif From 343508e9fd981928f1e830c71c9d8b2a54edb7dd Mon Sep 17 00:00:00 2001 From: Eugenij <62702485+Eugenij-W@users.noreply.github.com> Date: Fri, 27 Mar 2020 02:33:11 +0600 Subject: [PATCH 589/680] Fix infinity loop in FindParentVCSRoot (#1095) * Fix infinity loop in FindParentVCSRoot (on windows os with 'set shellslash' in vimrc and no VCS in path) * update CHANGELOG.md * Update CHANGELOG.md Co-Authored-By: Phil Runninger Co-authored-by: evgenij.vidershpan Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + nerdtree_plugin/vcs.vim | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77b86e88..e3183155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) - **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) - **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) #### 6.6 diff --git a/nerdtree_plugin/vcs.vim b/nerdtree_plugin/vcs.vim index 36d5427e..d20e35e5 100644 --- a/nerdtree_plugin/vcs.vim +++ b/nerdtree_plugin/vcs.vim @@ -34,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~# '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path endfunction From 832bbaa729da2d0e4ccf0e0e45388e0c1ece9ce7 Mon Sep 17 00:00:00 2001 From: Rolando Date: Tue, 31 Mar 2020 23:21:37 -0600 Subject: [PATCH 590/680] Fix vsplit to not open empty buffer (#1098) * Fix vsplit to not open empty buffer * Add changelog entry --- CHANGELOG.md | 1 + lib/nerdtree/opener.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3183155..c81612c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) - **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) - **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) - **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index d8dba34e..0d9f9ba8 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -195,7 +195,7 @@ function! s:Opener._newVSplit() endif call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('vnew', 1) + call nerdtree#exec('vsplit', 1) let l:currentWindowNumber = winnr() From f767dd34a0bda0a6db8efa43257c90981947f0ab Mon Sep 17 00:00:00 2001 From: lifecrisis <15251574+lifecrisis@users.noreply.github.com> Date: Thu, 9 Apr 2020 21:37:55 -0400 Subject: [PATCH 591/680] Add missing calls to the shellescape() function (#1099) * Improve "g:NERDTreeQuickLook()" The following improvements were made... - Use variable sigils - Shorten a local variable name - Prefer an early return over testing for a negative - Switch to single quotes - Call "shellescape()" to pass a command argument [IMPORTANT!] The final change is a critical fix for the security and reliability of this function (see ":h system()"). Similar fixes for the other functions in this script will follow. * Improve "g:NERDTreeRevealInFinder()" This commit makes several style improvements and adds a missing call to the "shellescape()" function. See also: 56cfbcff1e6281b5057ebe1d04210c81c1fd8750 * Improve "g:NERDTreeExecuteFile()" Refer to: 56cfbcff1e6281b5057ebe1d04210c81c1fd8750 * Improve "g:NERDTreeRevealFileLinux()" Refer to: 56cfbcff1e6281b5057ebe1d04210c81c1fd8750 * Improve "g:NERDTreeExecuteFileLinux()" Refer to: 56cfbcff1e6281b5057ebe1d04210c81c1fd8750 * Properly reveal "/" on Linux This commit handles the edge case where a user invokes the "reveal" function on "/" on a Linux box. There is nothing to do but open the root directory itself since "/" has no parent. * Update the "CHANGELOG.md" file * Add final missing "shellescape()" calls I initially thought that there were several more locations where a call to "shellescape()" was required but omitted. However, there are only two. I suppose I should have taken the time to look. Fixing these was easy. I would be surprised if this change breaks anything on the user side. * Update the "CHANGELOG.md" file (again) Use a more fitting description of the change... --- CHANGELOG.md | 1 + lib/nerdtree/path.vim | 2 +- nerdtree_plugin/fs_menu.vim | 57 ++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c81612c9..22d6c5c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) - **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) - **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) - **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 6a23c7ba..83342198 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -199,7 +199,7 @@ function! s:Path.copy(dest) let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) endif - let cmd = cmd_prefix . ' ' . escape(self.str(), self._escChars()) . ' ' . escape(a:dest, self._escChars()) + let cmd = cmd_prefix . ' ' . shellescape(self.str()) . ' ' . shellescape(a:dest) let success = system(cmd) if v:shell_error !=# 0 throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index a1fa2ee7..9750976f 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -388,44 +388,67 @@ endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open -R '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open -R ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealFileLinux() {{{1 function! NERDTreeRevealFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - let parentnode = treenode.parent - if parentnode !=# {} - call system("xdg-open '" . parentnode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + " Handle the edge case of "/", which has no parent. + if l:node.path.str() ==# '/' + call system('xdg-open /') + return + endif + + if empty(l:node.parent) + return endif + + call system('xdg-open ' . shellescape(l:node.parent.path.str())) endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("xdg-open '" . treenode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('xdg-open ' . shellescape(l:node.path.str())) endfunction " vim: set sw=4 sts=4 et fdm=marker: - From 2d7cb043d475ffe7620a8d2d2cd5de7a1f0c6aa7 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 13 Apr 2020 17:05:27 -0400 Subject: [PATCH 592/680] Prevent unneeded tree creation in :NERDTreeToggle[VCS] (#1101) * Don't recreate the NERDTree if its root is the same as being requested. * Use single quotes per Vint's style recommendation. * Update version number in changelog. * Use a simpler method of getting the NERDTree root path. * Remove variable. Just compare agains the function call's result. --- CHANGELOG.md | 1 + lib/nerdtree/creator.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d6c5c0..6417b1a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.5**: Prevent unneeded tree creation in :NERDTreeToggle[VCS] (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) - **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) - **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) - **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index e2b3fa0a..abaa8dbe 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -366,7 +366,7 @@ function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !empty(a:dir) + if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str() call self.createTabTree(a:dir) elseif !&hidden call b:NERDTree.render() From 0257d64248e43f3ff70e9a1fce3b2aa10ba57bb9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 15 Apr 2020 00:55:13 -0400 Subject: [PATCH 593/680] If a file's already open in the window, don't edit it again. (#1103) * If a file's already open in the window, don't edit it again. * Update version number in change log. * Make only one call to self.str(). --- CHANGELOG.md | 3 ++- lib/nerdtree/path.vim | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6417b1a3..2d744b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 -- **.5**: Prevent unneeded tree creation in :NERDTreeToggle[VCS] (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) +- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) +- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) - **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) - **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) - **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 83342198..3158bbfc 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -295,7 +295,10 @@ endfunction " FUNCTION: Path.edit() {{{1 function! s:Path.edit() - exec 'edit ' . self.str({'format': 'Edit'}) + let l:bufname = self.str({'format': 'Edit'}) + if bufname() !=# l:bufname + exec 'edit ' . l:bufname + endif endfunction " FUNCTION: Path.extractDriveLetter(fullpath) {{{1 From 29a321d061032df5b2ec347b6b4b778f665305a6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 15 Apr 2020 08:58:07 -0400 Subject: [PATCH 594/680] Put '%' argument in bufname() for backwards compatibility. (#1105) * Put '%' argument in bufname() for backwards compatibility. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/path.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d744b3e..d0de2be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.7**: Put '%' argument in bufname() for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) - **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) - **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) - **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 3158bbfc..2ac8c71c 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -296,7 +296,7 @@ endfunction " FUNCTION: Path.edit() {{{1 function! s:Path.edit() let l:bufname = self.str({'format': 'Edit'}) - if bufname() !=# l:bufname + if bufname('%') !=# l:bufname exec 'edit ' . l:bufname endif endfunction From 5e77fb2fef6720eabbfe957cf3a47f3f0a218e05 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 3 May 2020 01:21:34 -0400 Subject: [PATCH 595/680] Fix example code for the NERDTreeAddKeyMap function. (#1116) * Fix example code for the NERDTreeAddKeyMap function. The quickhelpText didn't match what the statement in the callback function actually did. * Update version number in change log. --- CHANGELOG.md | 1 + doc/NERDTree.txt | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0de2be7..67f64357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.8**: Fix example code for the NERDTreeAddKeyMap function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) - **.7**: Put '%' argument in bufname() for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) - **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) - **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 47d65ccc..6c11a94d 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1353,12 +1353,12 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* Example: > call NERDTreeAddKeyMap({ \ 'key': 'foo', - \ 'callback': 'NERDTreeCDHandler', + \ 'callback': 'NERDTreeEchoPathHandler', \ 'quickhelpText': 'echo full path of current node', \ 'scope': 'DirNode' }) - function! NERDTreeCDHandler(dirnode) - call a:dirnode.changeToDir() + function! NERDTreeEchoPathHandler(dirnode) + echo a:dirnode.path.str() endfunction < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. From a7d585f7af8c81651a274cae9f9e09639483c785 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 4 May 2020 07:59:25 -0400 Subject: [PATCH 596/680] Force NERDTreeFocus to allow events to be fired when switching windows. --- lib/nerdtree/nerdtree.vim | 4 ++-- plugin/NERD_tree.vim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a48f6a86..982db16c 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -96,9 +96,9 @@ endfunction "FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 "Places the cursor in the nerd tree window -function! s:NERDTree.CursorToTreeWin() +function! s:NERDTree.CursorToTreeWin(...) call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1) endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 639f87bb..ca8070d1 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -217,7 +217,7 @@ endfunction function! NERDTreeFocus() if g:NERDTree.IsOpen() - call g:NERDTree.CursorToTreeWin() + call g:NERDTree.CursorToTreeWin(0) else call g:NERDTreeCreator.ToggleTabTree('') endif From 3005a0e9c0fa6a7757d65ba2a5187d0f675dd225 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 4 May 2020 08:11:49 -0400 Subject: [PATCH 597/680] Update version number in change log. --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f64357..2e1d4305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 -- **.8**: Fix example code for the NERDTreeAddKeyMap function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) -- **.7**: Put '%' argument in bufname() for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) +- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) +- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) +- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) - **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) - **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) - **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) From 4cc6097ecb18b52c023a9487c2cf3220290ba0a1 Mon Sep 17 00:00:00 2001 From: lifecrisis <15251574+lifecrisis@users.noreply.github.com> Date: Wed, 6 May 2020 23:24:01 -0400 Subject: [PATCH 598/680] Do not consider the tree root to be "cascadable" (#1120) * Do not consider the tree root to be "cascadable" * Update "CHANGELOG.md" --- CHANGELOG.md | 1 + lib/nerdtree/tree_dir_node.vim | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e1d4305..0bcf4d74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) - **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) - **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) - **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 88ac319f..14d29964 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -377,11 +377,17 @@ endfunction " 1. If cascaded, we don't know which dir is bookmarked or is a symlink. " 2. If the parent is a symlink or is bookmarked, you end up with unparsable " text, and NERDTree cannot get the path of any child node. +" Also, return false if this directory is the tree root, which should never be +" part of a cascade. function! s:TreeDirNode.isCascadable() if g:NERDTreeCascadeSingleChildDir ==# 0 return 0 endif + if self.isRoot() + return 0 + endif + if self.path.isSymLink return 0 endif From e2670f0d190c9c0593ad7ac7b5708a4c198e423d Mon Sep 17 00:00:00 2001 From: Eugenij <62702485+Eugenij-W@users.noreply.github.com> Date: Fri, 15 May 2020 00:24:36 +0600 Subject: [PATCH 599/680] * fix duplicated slash in s:Path.isUnder() (on windows OS) (#1122) * * fix duplicated slash in s:Path.isUnder() (on windows OS, for root directory on drive Path.str() return path with [back]slash) * * Rewrite NERDTreePath.isUnder() and NERDTreePath.isAncestor() for direct comparison of paths without transformations * Remove trailing slash, so we don't end up with two on root folder. The str() function returns "C:\" on the root folder and "C:\temp" on non-root folders, one with and one without a trailing backslash. This inconsistency needs to be handled so the stridx() function will work correctly. * Make sure the change also works in a non-windows file system. This commit handles an edge case that can be triggered with these commands: :cd /home/me :e /foobar.txt (an existing file) :NERDTreeFind What happened was the root directory name '/' was being Resolved(), and the trailing (and only) slash was being removed. The NERDTree was then created in the current working directory, instead of the root directory. :NERDTreeFind then wasn't able to find foobar.txt, and printed an error. * Remove degugging statements. * * ambiguity issue fix Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + lib/nerdtree/creator.vim | 6 +++++- lib/nerdtree/path.vim | 38 ++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bcf4d74..c68c8dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122) - **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) - **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) - **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index abaa8dbe..f845361d 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -249,7 +249,11 @@ function! s:Creator._pathForString(str) if dir =~# '^\.' let dir = getcwd() . g:NERDTreePath.Slash() . dir endif - let dir = g:NERDTreePath.Resolve(dir) + + "hack to prevent removing slash if dir is the root of the file system. + if dir !=# '/' + let dir = g:NERDTreePath.Resolve(dir) + endif try let path = g:NERDTreePath.New(dir) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2ac8c71c..61cdfa88 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -546,26 +546,36 @@ endfunction " return 1 if this path is somewhere above the given path in the filesystem. " " a:path should be a dir -function! s:Path.isAncestor(path) - if !self.isDirectory - return 0 - endif - - let this = self.str() - let that = a:path.str() - return stridx(that, this) ==# 0 +function! s:Path.isAncestor(child) + return a:child.isUnder(self) endfunction " FUNCTION: Path.isUnder(path) {{{1 " return 1 if this path is somewhere under the given path in the filesystem. -function! s:Path.isUnder(path) - if a:path.isDirectory ==# 0 +function! s:Path.isUnder(parent) + if a:parent.isDirectory ==# 0 return 0 endif - - let this = self.str() - let that = a:path.str() - return stridx(this, that . s:Path.Slash()) ==# 0 + if nerdtree#runningWindows() && a:parent.drive !=# self.drive + return 0 + endif + let l:this_count = len(self.pathSegments) + if l:this_count ==# 0 + return 0 + endif + let l:that_count = len(a:parent.pathSegments) + if l:that_count ==# 0 + return 1 + endif + if l:that_count >= l:this_count + return 0 + endif + for i in range(0, l:that_count-1) + if self.pathSegments[i] !=# a:parent.pathSegments[i] + return 0 + endif + endfor + return 1 endfunction " FUNCTION: Path.JoinPathStrings(...) {{{1 From 10eaa3a2f42d395a9a6dca14957a5862e709651b Mon Sep 17 00:00:00 2001 From: Eugenij <62702485+Eugenij-W@users.noreply.github.com> Date: Thu, 21 May 2020 12:23:35 +0600 Subject: [PATCH 600/680] Fixed a bug that caused the file-tree construction to slow down significantly. (#1126) Co-authored-by: evgenij.vidershpan --- CHANGELOG.md | 1 + lib/nerdtree/tree_dir_node.vim | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c68c8dec..95c290ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. [#1126](https://github.com/preservim/nerdtree/pull/1126) - **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122) - **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) - **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 14d29964..d2ad1cd7 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -431,6 +431,7 @@ function! s:TreeDirNode._initChildren(silent) endtry endfor + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder call self.sortChildren() call nerdtree#echo('') From 2e9d43b6f83b2d392521397693a940449fa7565c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Altay=C3=B3?= Date: Fri, 22 May 2020 14:57:19 +0200 Subject: [PATCH 601/680] cmd.exe /c start "" for windows default viewer support (#1130) * support for default viewer in Windows * updated changelog * Update nerdtree_plugin/fs_menu.vim Co-authored-by: Phil Runninger * Update nerdtree_plugin/fs_menu.vim Co-authored-by: Phil Runninger Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c290ff..30f47587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.13**: Invoke-Item for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) - **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. [#1126](https://github.com/preservim/nerdtree/pull/1126) - **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122) - **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9750976f..30734147 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -34,6 +34,10 @@ if executable('xdg-open') call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) endif +if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif @@ -451,4 +455,15 @@ function! NERDTreeExecuteFileLinux() call system('xdg-open ' . shellescape(l:node.path.str())) endfunction +" FUNCTION: NERDTreeExecuteFileWindows() {{{1 +function! NERDTreeExecuteFileWindows() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) +endfunction + " vim: set sw=4 sts=4 et fdm=marker: From 484dc84b47efe7163803451771e189347fe99eed Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 22 May 2020 09:02:39 -0400 Subject: [PATCH 602/680] Update title of pull request. Add PR authors where missing. --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f47587..6fd2c5bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,9 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 -- **.13**: Invoke-Item for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) -- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. [#1126](https://github.com/preservim/nerdtree/pull/1126) -- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) [#1122](https://github.com/preservim/nerdtree/pull/1122) +- **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) +- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) +- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122) - **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) - **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) - **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) From f63132cade94e0937e51d55e4f9ddd33bec69e4e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 25 May 2020 11:33:20 -0400 Subject: [PATCH 603/680] Use backward-compatible nerdtree#and() in one place that was missed. (#1134) * Use backward-compatible nerdtree#and() in one place that was missed. * Update version number in change log. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 2 +- lib/nerdtree/opener.vim | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fd2c5bc..7f95ecfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) - **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) - **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) - **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 156b2602..d0785a4c 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -45,7 +45,7 @@ function! nerdtree#slash() abort endfunction "FUNCTION: nerdtree#and(x,y) {{{2 -" Implements and() function for Vim <= 7.2 +" Implements and() function for Vim <= 7.4 function! nerdtree#and(x,y) abort if exists('*and') return and(a:x, a:y) diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 0d9f9ba8..6cdd9dfc 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -219,7 +219,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + if !self._stay && !nerdtree#and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif From 052b1f00a0ef14b0019f4d0cda9906ba93f9a0d6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 26 May 2020 00:15:17 -0400 Subject: [PATCH 604/680] Add curly braces to the list of characters to be escaped. (#1128) * Add curly braces to the list of characters to be escaped. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/path.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f95ecfd..66d250cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.7 +- **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128) - **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) - **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) - **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 61cdfa88..d30dd511 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -332,7 +332,7 @@ function! s:Path._escChars() return " `\|\"#%&,?()\*^<>$" endif - return " \\`\|\"#%&,?()\*^<>[]$" + return " \\`\|\"#%&,?()\*^<>[]{}$" endfunction " FUNCTION: Path.getDir() {{{1 From 635071dcc883f1da9034b4a011419e559620d377 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 1 Jun 2020 01:51:27 -0400 Subject: [PATCH 605/680] Closes #1136. Allow concealed characters to show another character. conceallevel=3 always hides the character, but conceallevel=2 allows an alternate character to be displayed instead. --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index df0c8046..fc7269ea 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -22,7 +22,7 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighting to conceal the delimiter around the file/dir name if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' - setlocal conceallevel=3 concealcursor=nvic + setlocal conceallevel=2 concealcursor=nvic else exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore From 9de5b3e785531804245509a866e20a54accf8666 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 1 Jun 2020 02:08:13 -0400 Subject: [PATCH 606/680] Allow concealed characters to show another character. (#1138) * Closes #1136. Allow concealed characters to show another character. conceallevel=3 always hides the character, but conceallevel=2 allows an alternate character to be displayed instead. * Update version number in changelog. --- CHANGELOG.md | 2 ++ syntax/nerdtree.vim | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d250cc..0f1f1f5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.8 +- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) #### 6.7 - **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128) - **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index df0c8046..fc7269ea 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -22,7 +22,7 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighting to conceal the delimiter around the file/dir name if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' - setlocal conceallevel=3 concealcursor=nvic + setlocal conceallevel=2 concealcursor=nvic else exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore From 6571452857fd1b14f15a3886f9fffc113c36bbac Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 23 Jun 2020 10:40:30 -0400 Subject: [PATCH 607/680] Enable opening bookmarks in split windows. (#1144) * Add open/preview in split/vsplit to bookmarks. * Make preview split/vsplit bookmark work only on file nodes. * Add quickhelp text for split/vsplit commands on bookmarks. * Handle previewing directory bookmarks properly. * Update documentation: bookmarks can be opened in a split/vsplit. * Update version number in change log. --- CHANGELOG.md | 2 ++ autoload/nerdtree/ui_glue.vim | 28 +++++++++++++++++++++++++++- doc/NERDTree.txt | 4 ++-- lib/nerdtree/ui.vim | 4 ++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1f1f5e..0380c67e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.9 +- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) #### 6.8 - **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) #### 6.7 diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index aef1b046..612145f5 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -26,11 +26,15 @@ function! nerdtree#ui_glue#createDefaultBindings() abort call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Node', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Node', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Node', 'callback': s.'previewNodeCurrent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Node', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) @@ -511,6 +515,28 @@ function! s:openVSplit(target) abort call a:target.activate({'where': 'v'}) endfunction +"FUNCTION: s:openHSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openHSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h'} : {}) +endfunction + +"FUNCTION: s:openVSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openVSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v'} : {}) +endfunction + +" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 +function! s:previewNodeHSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) +endfunction + +" FUNCTION: s:previewVSplitBookmark(bookmark) {{{1 +function! s:previewNodeVSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'v', 'keepopen': 1} : {}) +endfunction + " FUNCTION: s:openExplorer(node) {{{1 function! s:openExplorer(node) abort call a:node.openExplorer() diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 6c11a94d..7a6a931b 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -350,7 +350,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab. *NERDTree-i* Default key: i Map setting: *NERDTreeMapOpenSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new split window and puts the cursor in the new window. @@ -370,7 +370,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see *NERDTree-s* Default key: s Map setting: *NERDTreeMapOpenVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new vertically split window and puts the cursor in the new window. diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 9ffadf6e..ed8a248a 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -67,6 +67,10 @@ function! s:UI._dumpHelp() let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" From aa37cb40dae26f21a2e343d17ac9f4be9d8bec37 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 12 Jul 2020 10:03:24 -0400 Subject: [PATCH 608/680] Fix the scope of several key mappings (#1151) * Limit opening or previewing into a split window to only file nodes. * Prevent previwing directory nodes, which would create another NERDTree. * Refactor the previewBookmark code to open directories a better way. * Update version number in change log. * Update documentation. --- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 16 ++++++---------- doc/NERDTree.txt | 9 ++++----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0380c67e..068646ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) - **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) #### 6.8 - **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 612145f5..78b3fa1f 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -25,15 +25,15 @@ function! nerdtree#ui_glue#createDefaultBindings() abort call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Node', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'FileNode', 'callback': s.'openHSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Node', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'FileNode', 'callback': s.'openVSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Node', 'callback': s.'previewNodeCurrent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Node', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'FileNode', 'callback': s.'previewNodeCurrent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'FileNode', 'callback': s.'previewNodeHSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'FileNode', 'callback': s.'previewNodeVSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) @@ -564,11 +564,7 @@ endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 function! s:previewBookmark(bookmark) abort - if a:bookmark.path.isDirectory - execute 'NERDTreeFind '.a:bookmark.path.str() - else - call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1}) - endif + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 7a6a931b..2989718c 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -318,9 +318,8 @@ Applies to: files. If a file node or a bookmark that links to a file is selected, it is opened in the previous window, but the cursor does not move. -If a bookmark that links to a directory is selected, that directory is found -in the current NERDTree. If the directory couldn't be found, a new NERDTree is -created. +If a bookmark that links to a directory is selected then that directory +becomes the new root. The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). @@ -359,7 +358,7 @@ window. *NERDTree-gi* Default key: gi Map setting: *NERDTreeMapPreviewSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-i| except that the cursor is not moved. @@ -379,7 +378,7 @@ in the new window. *NERDTree-gs* Default key: gs Map setting: *NERDTreeMapPreviewVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-s| except that the cursor is not moved. From f8aa749985754091e980c1dc93ec3206ee3dec1f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 14 Jul 2020 07:20:48 -0400 Subject: [PATCH 609/680] Fix new NERDTrees' width when previous one was in the only window. (#1153) * Fix new NERDTrees' width when previous one was in the only window. When leaving a NERDTree buffer, its window's width is remembered so that that width can be used when showing the buffer again in a new window. If NERDTree is the only window when leaving the buffer, it remembers the whole width of the editor. When a new NERDTree window is created, it is sized such that there is only a very small window for files to be opened into. To fix this, if NERDTree is the ONLY window, remember its width as the value of g:NERDTreeWinSize, not the width of the editor. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/ui.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 068646ee..f82701c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) - **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) - **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) #### 6.8 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index ed8a248a..2ea813c7 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -368,7 +368,7 @@ function! s:UI.saveScreenState() call g:NERDTree.CursorToTreeWin() let self._screenState['oldPos'] = getpos('.') let self._screenState['oldTopLine'] = line('w0') - let self._screenState['oldWindowSize']= winwidth('') + let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('') call nerdtree#exec(win . 'wincmd w', 1) catch endtry From 42a5a2c1065c4b31c26d56abd1ee6ca6f877cbd1 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 14 Jul 2020 08:32:29 -0400 Subject: [PATCH 610/680] Update PULL_REQUEST_TEMPLATE.md Make the tag creation process semi-automatic by making bash do more of the legwork. The included bash commands will: 1. Make sure your master branch is up to date 2. Display all the patch releases in the current MAJOR.MINOR version 3. Ask for a version number to use as the tag (one of the ones previously displayed, presumably) 4. Get the latest commit's subject line, and use it in the tag's message field. 5. Create the tag, and push all tags to the origin. --- .github/PULL_REQUEST_TEMPLATE.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 24dba3f5..39959b41 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ ### Description of Changes -Closes # +Closes # --- @@ -13,4 +13,10 @@ Closes # - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. #### Collaborator's Instructions - [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. -- [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` +- [ ] After merging, tag the commit using these (Mac-compatible) bash commands: + ```bash + git checkout master + git pull + sed -n "$(grep -n '####' CHANGELOG.md | head -2 | sed -e 's/:.*//' | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d' + git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags + ``` From 2af10e3589307fea749012a2d757feda0f4e108a Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 14 Jul 2020 08:49:44 -0400 Subject: [PATCH 611/680] Update PULL_REQUEST_TEMPLATE.md Use a shorter command to display the recent patches: replace `| head -2` with `-m2` grep switch; replace a `sed` with `cut` to get the line numbers. --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 39959b41..d2e3b7d4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,6 +17,6 @@ Closes # #### 6.9 +- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) - **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) - **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) - **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index fc7269ea..af1581c6 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -47,7 +47,7 @@ endif "highlighting for readonly files exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' -exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir' +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' syn match NERDTreeCWD #^[ Date: Fri, 24 Jul 2020 22:14:54 +0700 Subject: [PATCH 614/680] fix highlight for file node (#1157) * fix #960 953 highlight for file node * update changelog --- CHANGELOG.md | 1 + syntax/nerdtree.vim | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 439ca056..4487861d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) - **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) - **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) - **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index af1581c6..bf523d15 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -93,3 +93,5 @@ hi def link NERDTreeBookmark Statement hi def link NERDTreeFlags Number hi def link NERDTreeCurrentNode Search + +hi NERDTreeFile ctermbg=NONE guibg=NONE From 373a4b28e4444a5ec88ed3a81eb09073e8c92fc0 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 7 Aug 2020 00:37:56 -0400 Subject: [PATCH 615/680] Don't use silent when raising User events (#1164) * Remove silent from doautocmd. Prevent errors with exists('#...'). * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/creator.vim | 4 +++- lib/nerdtree/nerdtree.vim | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4487861d..61f01112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) - **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) - **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) - **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 210ec37c..4f0a7dc5 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -28,7 +28,9 @@ endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 function! s:Creator._broadcastInitEvent() - silent doautocmd User NERDTreeInit + if exists('#NERDTreeInit') + doautocmd User NERDTreeInit + endif endfunction " FUNCTION: s:Creator.BufNamePrefix() {{{1 diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 982db16c..ed060f6e 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -27,7 +27,9 @@ function! s:NERDTree.changeRoot(node) call self.render() call self.root.putCursorHere(0, 0) - silent doautocmd User NERDTreeNewRoot + if exists('#NERDTreeNewRoot') + doautocmd User NERDTreeNewRoot + endif endfunction "FUNCTION: s:NERDTree.Close() {{{1 From 6b5d70e5bf307bd84fec90ba77fa661036ff0361 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 9 Aug 2020 07:07:55 -0400 Subject: [PATCH 616/680] Fix argument of exists() function calls checking for autocommands. (#1165) * Fix syntax of exists function calls checking for autocommands. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/creator.vim | 2 +- lib/nerdtree/nerdtree.vim | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61f01112..4a6e454a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) - **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) - **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) - **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 4f0a7dc5..4a984131 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -28,7 +28,7 @@ endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 function! s:Creator._broadcastInitEvent() - if exists('#NERDTreeInit') + if exists('#User#NERDTreeInit') doautocmd User NERDTreeInit endif endfunction diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index ed060f6e..db9e2b55 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -27,7 +27,7 @@ function! s:NERDTree.changeRoot(node) call self.render() call self.root.putCursorHere(0, 0) - if exists('#NERDTreeNewRoot') + if exists('#User#NERDTreeNewRoot') doautocmd User NERDTreeNewRoot endif endfunction From 23000acd7f9744667abc840dd10dd07a16e18fc6 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 14 Aug 2020 18:06:03 -0400 Subject: [PATCH 617/680] Refactor sort comparison functions, removing redundancy (#1166) * Add a function to compare path objects. * Remove redundant node comparison function, and rename the ones left. * Remove the compareTo function in the Path object. Use nerdtree#compareNodePaths(p1,p2) instead. There was no need for two comparison functions that do the same thing. They were a little different in their details, but that shouldn't be the case. Having only one such function makes better sense and is easier to maintain. * Update version number in change log. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 12 +++++----- lib/nerdtree/path.vim | 44 ---------------------------------- lib/nerdtree/tree_dir_node.vim | 4 ++-- 4 files changed, 9 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a6e454a..55806cbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) - **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) - **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) - **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index c935827c..983bb621 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -110,15 +110,15 @@ function! nerdtree#completeBookmarks(A,L,P) abort return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction -"FUNCTION: nerdtree#compareNodes(dir) {{{2 +"FUNCTION: nerdtree#compareNodes(n1, n2) {{{2 function! nerdtree#compareNodes(n1, n2) abort - return a:n1.path.compareTo(a:n2.path) + return nerdtree#compareNodePaths(a:n1.path, a:n2.path) endfunction -"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 -function! nerdtree#compareNodesBySortKey(n1, n2) abort - let sortKey1 = a:n1.path.getSortKey() - let sortKey2 = a:n2.path.getSortKey() +"FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2 +function! nerdtree#compareNodePaths(p1, p2) abort + let sortKey1 = a:p1.getSortKey() + let sortKey2 = a:p2.getSortKey() let i = 0 while i < min([len(sortKey1), len(sortKey2)]) " Compare chunks upto common length. diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 21e357b5..786ccd90 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -99,50 +99,6 @@ function! s:Path.changeToDir() endtry endfunction -" FUNCTION: Path.compareTo() {{{1 -" -" Compares this Path to the given path and returns 0 if they are equal, -1 if -" this Path is 'less than' the given path, or 1 if it is 'greater'. -" -" Args: -" path: the path object to compare this to -" -" Return: -" 1, -1 or 0 -function! s:Path.compareTo(path) - let thisPath = self.getLastPathComponent(1) - let thatPath = a:path.getLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath ==# thatPath - return 0 - endif - - let thisSS = self.getSortOrderIndex() - let thatSS = a:path.getSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - if !g:NERDTreeSortHiddenFirst - let thisPath = substitute(thisPath, '^[._]', '', '') - let thatPath = substitute(thatPath, '^[._]', '', '') - endif - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath Date: Tue, 18 Aug 2020 11:14:05 -0400 Subject: [PATCH 618/680] Updated Readme (#1167) * Updated Readme Fixed typo in readme * Updated Changelog --- CHANGELOG.md | 1 + README.markdown | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55806cbb..cd168485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) - **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) - **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) - **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) diff --git a/README.markdown b/README.markdown index 09173a65..018923cf 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/ner vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q ``` -Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take. +Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you need to take. #### [pathogen.vim](https://github.com/tpope/vim-pathogen) From 14af89743ac1c31ff9bb43682025eda50333a7d5 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 14 Oct 2020 18:08:18 -0400 Subject: [PATCH 619/680] Open a mirrored NERDTree with correct width (#1177) * Make sure a mirrored NERDTree is displayed at correct width. * Remove references to unused variables. b:NERDTreeOldWindowSize was referenced, but never set anywhere. No need to keep it around. * Refactor: Initialize variables a different way. Using the get() function allows us to "let" variables more directly, without using the execute command or requiring strings to be escaped. This also eliminates the s:initVariable function. The new format is shown below, and defines a default value if the user didn't provide a value in the vimrc file. let g:var = get(g: 'var', 'default value') * Update version number in change log. * Fix alignment of `let g:var = get(g:, 'var', )` statements. --- CHANGELOG.md | 1 + lib/nerdtree/creator.vim | 1 + lib/nerdtree/opener.vim | 3 +- lib/nerdtree/ui.vim | 3 +- plugin/NERD_tree.vim | 197 +++++++++++++++++---------------------- 5 files changed, 89 insertions(+), 116 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd168485..e558036b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) - **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) - **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) - **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 4a984131..b9d45dc9 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -172,6 +172,7 @@ function! s:Creator.createMirror() let t:NERDTreeBufName = bufferName call self._createTreeWin() exec 'buffer ' . bufferName + call b:NERDTree.ui.restoreScreenState() if !&hidden call b:NERDTree.render() endif diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 6cdd9dfc..9c62b723 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -174,9 +174,8 @@ function! s:Opener._newSplit() "resize the tree window if no other window was open before if onlyOneWin - let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('silent '. splitMode .' resize '. size, 1) + call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1) call nerdtree#exec('wincmd p', 0) endif diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 2ea813c7..a481ba47 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -516,8 +516,7 @@ endfunction " zoom (maximize/minimize) the NERDTree window function! s:UI.toggleZoom() if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed - let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec('silent vertical resize '. size, 1) + call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1) let b:NERDTreeZoomed = 0 else call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ca8070d1..ef60cca1 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -26,141 +26,114 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpoptions set cpoptions&vim -"Function: s:initVariable() function {{{2 -"This function is used to initialise a given variable to a given value. The -"variable is only initialised if it does not exist prior -" -"Args: -"var: the name of the var to be initialised -"value: the value to initialise var to -" -"Returns: -"1 if the var is set, 0 otherwise -function! s:initVariable(var, value) - if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", 'g') . "'" - return 1 - endif - return 0 -endfunction - -"SECTION: Init variable calls and other random constants {{{2 -call s:initVariable('g:NERDTreeAutoCenter', 1) -call s:initVariable('g:NERDTreeAutoCenterThreshold', 3) -call s:initVariable('g:NERDTreeCaseSensitiveSort', 0) -call s:initVariable('g:NERDTreeNaturalSort', 0) -call s:initVariable('g:NERDTreeSortHiddenFirst', 1) -call s:initVariable('g:NERDTreeUseTCD', 0) -call s:initVariable('g:NERDTreeChDirMode', 0) -call s:initVariable('g:NERDTreeCreatePrefix', 'silent') -call s:initVariable('g:NERDTreeMinimalUI', 0) -call s:initVariable('g:NERDTreeMinimalMenu', 0) -if !exists('g:NERDTreeIgnore') - let g:NERDTreeIgnore = ['\~$'] -endif -call s:initVariable('g:NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') -call s:initVariable('g:NERDTreeBookmarksSort', 1) -call s:initVariable('g:NERDTreeHighlightCursorline', 1) -call s:initVariable('g:NERDTreeHijackNetrw', 1) -call s:initVariable('g:NERDTreeMarkBookmarks', 1) -call s:initVariable('g:NERDTreeMouseMode', 1) -call s:initVariable('g:NERDTreeNotificationThreshold', 100) -call s:initVariable('g:NERDTreeQuitOnOpen', 0) -call s:initVariable('g:NERDTreeRespectWildIgnore', 0) -call s:initVariable('g:NERDTreeShowBookmarks', 0) -call s:initVariable('g:NERDTreeShowFiles', 1) -call s:initVariable('g:NERDTreeShowHidden', 0) -call s:initVariable('g:NERDTreeShowLineNumbers', 0) -call s:initVariable('g:NERDTreeSortDirs', 1) +"SECTION: Initialize variable calls and other random constants {{{2 +let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1) +let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3) +let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0) +let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0) +let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1) +let g:NERDTreeUseTCD = get(g:, 'NERDTreeUseTCD', 0) +let g:NERDTreeChDirMode = get(g:, 'NERDTreeChDirMode', 0) +let g:NERDTreeCreatePrefix = get(g:, 'NERDTreeCreatePrefix', 'silent') +let g:NERDTreeMinimalUI = get(g:, 'NERDTreeMinimalUI', 0) +let g:NERDTreeMinimalMenu = get(g:, 'NERDTreeMinimalMenu', 0) +let g:NERDTreeIgnore = get(g:, 'NERDTreeIgnore', ['\~$']) +let g:NERDTreeBookmarksFile = get(g:, 'NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') +let g:NERDTreeBookmarksSort = get(g:, 'NERDTreeBookmarksSort', 1) +let g:NERDTreeHighlightCursorline = get(g:, 'NERDTreeHighlightCursorline', 1) +let g:NERDTreeHijackNetrw = get(g:, 'NERDTreeHijackNetrw', 1) +let g:NERDTreeMarkBookmarks = get(g:, 'NERDTreeMarkBookmarks', 1) +let g:NERDTreeMouseMode = get(g:, 'NERDTreeMouseMode', 1) +let g:NERDTreeNotificationThreshold = get(g:, 'NERDTreeNotificationThreshold', 100) +let g:NERDTreeQuitOnOpen = get(g:, 'NERDTreeQuitOnOpen', 0) +let g:NERDTreeRespectWildIgnore = get(g:, 'NERDTreeRespectWildIgnore', 0) +let g:NERDTreeShowBookmarks = get(g:, 'NERDTreeShowBookmarks', 0) +let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1) +let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0) +let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0) +let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1) if !nerdtree#runningWindows() && !nerdtree#runningCygwin() - call s:initVariable('g:NERDTreeDirArrowExpandable', '▸') - call s:initVariable('g:NERDTreeDirArrowCollapsible', '▾') + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾') else - call s:initVariable('g:NERDTreeDirArrowExpandable', '+') - call s:initVariable('g:NERDTreeDirArrowCollapsible', '~') + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '+') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '~') endif -call s:initVariable('g:NERDTreeCascadeOpenSingleChildDir', 1) -call s:initVariable('g:NERDTreeCascadeSingleChildDir', 1) +let g:NERDTreeCascadeOpenSingleChildDir = get(g:, 'NERDTreeCascadeOpenSingleChildDir', 1) +let g:NERDTreeCascadeSingleChildDir = get(g:, 'NERDTreeCascadeSingleChildDir', 1) -if !exists('g:NERDTreeSortOrder') - let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -endif +let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$', '\.bak$', '\~$']) let g:NERDTreeOldSortOrder = [] -call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') +let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO') if has('conceal') - call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07") elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") - call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00b7") else - call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00a0") endif -if !exists('g:NERDTreeStatusline') - - "the exists() crap here is a hack to stop vim spazzing out when - "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTree(its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" +"the exists() crap here is a hack to stop vim spazzing out when +"loading a session that was created with an open nerd tree. It spazzes +"because it doesnt store b:NERDTree(its a b: var, and its a hash) +let g:NERDTreeStatusline = get(g:, 'NERDTreeStatusline', "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}") -endif -call s:initVariable('g:NERDTreeWinPos', 'left') -call s:initVariable('g:NERDTreeWinSize', 31) +let g:NERDTreeWinPos = get(g:, 'NERDTreeWinPos', 'left') +let g:NERDTreeWinSize = get(g:, 'NERDTreeWinSize', 31) "init the shell commands that will be used to copy nodes, and remove dir trees -" "Note: the space after the command is important if nerdtree#runningWindows() - call s:initVariable('g:NERDTreeRemoveDirCmd', 'rmdir /s /q ') - call s:initVariable('g:NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') - call s:initVariable('g:NERDTreeCopyFileCmd', 'copy /y ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rmdir /s /q ') + let g:NERDTreeCopyDirCmd = get(g:, 'NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') + let g:NERDTreeCopyFileCmd = get(g:, 'NERDTreeCopyFileCmd', 'copy /y ') else - call s:initVariable('g:NERDTreeRemoveDirCmd', 'rm -rf ') - call s:initVariable('g:NERDTreeCopyCmd', 'cp -r ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rm -rf ') + let g:NERDTreeCopyCmd = get(g:, 'NERDTreeCopyCmd', 'cp -r ') endif - "SECTION: Init variable calls for key mappings {{{2 -call s:initVariable('g:NERDTreeMapCustomOpen', '') -call s:initVariable('g:NERDTreeMapActivateNode', 'o') -call s:initVariable('g:NERDTreeMapChangeRoot', 'C') -call s:initVariable('g:NERDTreeMapChdir', 'cd') -call s:initVariable('g:NERDTreeMapCloseChildren', 'X') -call s:initVariable('g:NERDTreeMapCloseDir', 'x') -call s:initVariable('g:NERDTreeMapDeleteBookmark', 'D') -call s:initVariable('g:NERDTreeMapMenu', 'm') -call s:initVariable('g:NERDTreeMapHelp', '?') -call s:initVariable('g:NERDTreeMapJumpFirstChild', 'K') -call s:initVariable('g:NERDTreeMapJumpLastChild', 'J') -call s:initVariable('g:NERDTreeMapJumpNextSibling', '') -call s:initVariable('g:NERDTreeMapJumpParent', 'p') -call s:initVariable('g:NERDTreeMapJumpPrevSibling', '') -call s:initVariable('g:NERDTreeMapJumpRoot', 'P') -call s:initVariable('g:NERDTreeMapOpenExpl', 'e') -call s:initVariable('g:NERDTreeMapOpenInTab', 't') -call s:initVariable('g:NERDTreeMapOpenInTabSilent', 'T') -call s:initVariable('g:NERDTreeMapOpenRecursively', 'O') -call s:initVariable('g:NERDTreeMapOpenSplit', 'i') -call s:initVariable('g:NERDTreeMapOpenVSplit', 's') -call s:initVariable('g:NERDTreeMapPreview', 'g' . NERDTreeMapActivateNode) -call s:initVariable('g:NERDTreeMapPreviewSplit', 'g' . NERDTreeMapOpenSplit) -call s:initVariable('g:NERDTreeMapPreviewVSplit', 'g' . NERDTreeMapOpenVSplit) -call s:initVariable('g:NERDTreeMapQuit', 'q') -call s:initVariable('g:NERDTreeMapRefresh', 'r') -call s:initVariable('g:NERDTreeMapRefreshRoot', 'R') -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') -call s:initVariable('g:NERDTreeMapCWD', 'CD') -call s:initVariable('g:NERDTreeMenuDown', 'j') -call s:initVariable('g:NERDTreeMenuUp', 'k') +let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '') +let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o') +let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C') +let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd') +let g:NERDTreeMapCloseChildren = get(g:, 'NERDTreeMapCloseChildren', 'X') +let g:NERDTreeMapCloseDir = get(g:, 'NERDTreeMapCloseDir', 'x') +let g:NERDTreeMapDeleteBookmark = get(g:, 'NERDTreeMapDeleteBookmark', 'D') +let g:NERDTreeMapMenu = get(g:, 'NERDTreeMapMenu', 'm') +let g:NERDTreeMapHelp = get(g:, 'NERDTreeMapHelp', '?') +let g:NERDTreeMapJumpFirstChild = get(g:, 'NERDTreeMapJumpFirstChild', 'K') +let g:NERDTreeMapJumpLastChild = get(g:, 'NERDTreeMapJumpLastChild', 'J') +let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '') +let g:NERDTreeMapJumpParent = get(g:, 'NERDTreeMapJumpParent', 'p') +let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '') +let g:NERDTreeMapJumpRoot = get(g:, 'NERDTreeMapJumpRoot', 'P') +let g:NERDTreeMapOpenExpl = get(g:, 'NERDTreeMapOpenExpl', 'e') +let g:NERDTreeMapOpenInTab = get(g:, 'NERDTreeMapOpenInTab', 't') +let g:NERDTreeMapOpenInTabSilent = get(g:, 'NERDTreeMapOpenInTabSilent', 'T') +let g:NERDTreeMapOpenRecursively = get(g:, 'NERDTreeMapOpenRecursively', 'O') +let g:NERDTreeMapOpenSplit = get(g:, 'NERDTreeMapOpenSplit', 'i') +let g:NERDTreeMapOpenVSplit = get(g:, 'NERDTreeMapOpenVSplit', 's') +let g:NERDTreeMapPreview = get(g:, 'NERDTreeMapPreview', 'g'.NERDTreeMapActivateNode) +let g:NERDTreeMapPreviewSplit = get(g:, 'NERDTreeMapPreviewSplit', 'g'.NERDTreeMapOpenSplit) +let g:NERDTreeMapPreviewVSplit = get(g:, 'NERDTreeMapPreviewVSplit', 'g'.NERDTreeMapOpenVSplit) +let g:NERDTreeMapQuit = get(g:, 'NERDTreeMapQuit', 'q') +let g:NERDTreeMapRefresh = get(g:, 'NERDTreeMapRefresh', 'r') +let g:NERDTreeMapRefreshRoot = get(g:, 'NERDTreeMapRefreshRoot', 'R') +let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B') +let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F') +let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f') +let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I') +let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') +let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') +let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') +let g:NERDTreeMapCWD = get(g:, 'NERDTreeMapCWD', 'CD') +let g:NERDTreeMenuDown = get(g:, 'NERDTreeMenuDown', 'j') +let g:NERDTreeMenuUp = get(g:, 'NERDTreeMenuUp', 'k') "SECTION: Load class files{{{2 call nerdtree#loadClassFiles() From 474d735b7d68a315e1f426920f9aa7391369b606 Mon Sep 17 00:00:00 2001 From: buncis Date: Fri, 18 Dec 2020 12:36:10 +0700 Subject: [PATCH 620/680] readme update add script for automatically open NERDTree and focus on file (#1192) * update readme for auto startup NERDTree and focus on file * readme update add how to open NERDTree automatically and focus on file --- README.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.markdown b/README.markdown index 018923cf..da87fbca 100644 --- a/README.markdown +++ b/README.markdown @@ -92,6 +92,11 @@ If you are interested in this behaviour then consider [vim-nerdtree-tabs](https: Stick this in your vimrc: `autocmd vimenter * NERDTree` +--- +#### How can I open a NERDTree automatically when vim starts up and autofocus on file? + +Stick this in your vimrc: `autocmd vimenter * NERDTree | wincmd p` + --- #### How can I open a NERDTree automatically when vim starts up if no files were specified? @@ -103,6 +108,15 @@ autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif Note: Now start vim with plain `vim`, not `vim .` +--- +#### How to autofocus on file and focus on NERDTREE when no files were specified? + +Stick this in your vimrc: +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | else | NERDTree | wincmd p | endif +``` + --- #### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. ```vim From 2406c456ee73d32289c2c304ecd8dd1735bc2f2c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 18 Dec 2020 15:03:38 -0500 Subject: [PATCH 621/680] Revamp the README file (#1193) * Revamp the README to improve clarity and provide more information. * Verify correct behavior of suggested auto commands. * Add my tribute to Norm Abrams. Be careful with those plugin managers. * Other minor formatting and cleanup. * Fix typos, reorder some sections, and tidy up the README. * Give a better answer to the single NERDTree for all tabs question. * More reformatting of text. * Add basic installation instructions. Switch to single quotes. * Update version number in CHANGELOG. --- CHANGELOG.md | 1 + README.markdown | 218 ++++++++++++++++++++++++------------------------ 2 files changed, 111 insertions(+), 108 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e558036b..d9c1b453 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) - **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) - **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) - **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) diff --git a/README.markdown b/README.markdown index da87fbca..a3a62c1c 100644 --- a/README.markdown +++ b/README.markdown @@ -1,171 +1,173 @@ -The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) -============= +# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) -Introduction ------------- +## Introduction -The NERDTree is a file system explorer for the Vim editor. Using this plugin, -users can visually browse complex directory hierarchies, quickly open files for -reading or editing, and perform basic file system operations. - -This plugin can also be extended with custom mappings using a special API. The -details of this API and of other NERDTree features are described in the -included documentation. +The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations. ![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) -Installation ------------- - -Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them. +## Installation -#### Vim 8+ packages +Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVimVundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunnvim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** -If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: +If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g). -```bash -git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree -vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q -``` +
    +Pathogen +Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim. -Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you need to take. -#### [pathogen.vim](https://github.com/tpope/vim-pathogen) +1. In the terminal, + ```bash + git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree + ``` +1. In your `vimrc`, + ```vim + call pathogen#infect() + syntax on + filetype plugin indent on + ``` +1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +
    -In the terminal, -```bash -git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree -``` -In your vimrc, -```vim -call pathogen#infect() -syntax on -filetype plugin indent on -``` +
    + Vundle -Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +1. Install Vundle, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call vundle#begin() + Plugin 'preservim/nerdtree' + call vundle#end() + ``` +1. Restart Vim, and run the `:PluginInstall` statement to install your plugins. +
    -#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim) -```vim -call vundle#begin() -Plugin 'preservim/nerdtree' -call vundle#end() -``` +
    + Vim-Plug -#### [vim-plug](https://github.com/junegunn/vim-plug) +1. Install Vim-Plug, according to its instructions. +1. Add the following text to your `vimrc`. ```vim call plug#begin() -Plug 'preservim/nerdtree' + Plug 'preservim/nerdtree' call plug#end() ``` +1. Restart Vim, and run the `:PlugInstall` statement to install your plugins. +
    -#### [dein.vim](https://github.com/Shougo/dein.vim) -```vim -call dein#begin() -call dein#add('preservim/nerdtree') -call dein#end() -``` +
    + Dein -#### [apt-vim](https://github.com/egalpin/apt-vim) -```bash -apt-vim install -y https://github.com/preservim/nerdtree.git -``` +1. Install Dein, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call dein#begin() + call dein#add('preservim/nerdtree') + call dein#end() + ``` +1. Restart Vim, and run the `:call dein#install()` statement to install your plugins. +
    -F.A.Q. (here, and in the [Wiki](https://github.com/preservim/nerdtree/wiki)) ------- +
    +Vim 8+ packages -#### Is there any support for `git` flags? +If you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: -Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). +```bash +git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +``` +
    ---- -#### Can I have the nerdtree on every tab automatically? +## Getting Started +After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`. -Nope. If this is something you want then chances are you aren't using tabs and -buffers as they were intended to be used. Read this -http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers +## NERDTree Plugins +NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API and are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. -If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) +* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree. +* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders, +* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype. +* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions. +* [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree. +* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once. ---- -#### How can I open a NERDTree automatically when vim starts up? +If any others should be listed, mention them in an issue or pull request. -Stick this in your vimrc: `autocmd vimenter * NERDTree` ---- -#### How can I open a NERDTree automatically when vim starts up and autofocus on file? +## Frequently Asked Questions -Stick this in your vimrc: `autocmd vimenter * NERDTree | wincmd p` +In the answers to these questions, you will see code blocks that you can put in your `vimrc` file. ---- -#### How can I open a NERDTree automatically when vim starts up if no files were specified? +### How can I map a specific key or shortcut to open NERDTree? -Stick this in your vimrc: +NERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples. ```vim -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind ``` -Note: Now start vim with plain `vim`, not `vim .` +### How do I open NERDTree automatically when Vim starts? +Each code block below is slightly different, as described in the `" Comment lines`. +```vim +" Start NERDTree and leave the cursor in it. +autocmd VimEnter * NERDTree +``` +--- +```vim +" Start NERDTree and put the cursor back in the other window. +autocmd VimEnter * NERDTree | wincmd p +``` --- -#### How to autofocus on file and focus on NERDTREE when no files were specified? - -Stick this in your vimrc: ```vim +" Start NERDTree when Vim is started without file arguments. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | else | NERDTree | wincmd p | endif +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif ``` - --- -#### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. ```vim +" Start NERDTree. If a file is specified, move the cursor to its window. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif +autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif ``` - --- -#### How can I open NERDTree automatically when vim starts up on opening a directory? ```vim +" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif ``` - -This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. - -Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` - --- -#### How can I map a specific key or shortcut to open NERDTree? - -Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): ```vim -map :NERDTreeToggle +" Start NERDTree when Vim starts with a directory argument. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif ``` ---- -#### How can I close vim if the only window left open is a NERDTree? +### How can I close Vim automatically when NERDTree is the last window? -Stick this in your vimrc: ```vim -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +" Exit Vim if NERDTree is the only window left. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif ``` ---- -#### Can I have different highlighting for different file extensions? +### Can I have the same NERDTree on every tab automatically? -See here: https://github.com/preservim/nerdtree/issues/433#issuecomment-92590696 +```vim +" Open the existing NERDTree on each new tab. +autocmd BufWinEnter * silent NERDTreeMirror +``` ---- -#### How can I change default arrows? +### How can I change the default arrows? -Use these variables in your vimrc. Note that below are default arrow symbols ```vim let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` -You can remove the arrows altogether by setting these variables to empty strings, as shown below. This will remove not only the arrows, but a single space following them, shifting the whole tree two character positions to the left. -```vim -let g:NERDTreeDirArrowExpandable = '' -let g:NERDTreeDirArrowCollapsible = '' -``` +The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. + From aaa946fb6bd79b9af86fbaf4b6b63fd81d839bd9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sat, 19 Dec 2020 20:28:15 -0500 Subject: [PATCH 622/680] Provide alternate way to mirror the NERDTree on all tabs. --- README.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.markdown b/README.markdown index a3a62c1c..7c6ba3c2 100644 --- a/README.markdown +++ b/README.markdown @@ -162,6 +162,11 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr " Open the existing NERDTree on each new tab. autocmd BufWinEnter * silent NERDTreeMirror ``` +or change your NERDTree-launching shortcut key like so: +```vim +" Mirror the NERDTree before showing it. This makes it the same on all tabs. +nnoremap :NERDTreeMirror:NERDTreeFocus +``` ### How can I change the default arrows? From 7e1713853ad8f75ab48007356a3803112195972f Mon Sep 17 00:00:00 2001 From: Tomasz N Date: Mon, 18 Jan 2021 02:00:17 +0100 Subject: [PATCH 623/680] Respect NERDTreeCustomOpenArgs when opening bookmark (#1200) * Respect NERDTreeCustomOpenArgs when opening bookmark * Update CHANGELOG * Do not duplicate s:initCustomOpenArgs() * Restore missing assignment * fixup! Restore missing assignment * fixup! Do not duplicate s:initCustomOpenArgs() * Simplify loop iteration --- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 39 +++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c1b453..a1ec8430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.9 +- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) - **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) - **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) - **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 78b3fa1f..b0cedee9 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -110,8 +110,38 @@ endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 " Make sure NERDTreeCustomOpenArgs has needed keys function! s:initCustomOpenArgs() abort - let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) - return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') + let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} + let l:customOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + + if v:false is# s:validateType(l:customOpenArgs, v:t_dict) + return l:defaultOpenArgs + endif + + for l:typeKey in keys(l:defaultOpenArgs) + if v:false is# s:validateType(get(l:customOpenArgs, l:typeKey, {}), v:t_dict) + let l:customOpenArgs[l:typeKey] = l:defaultOpenArgs[l:typeKey] + continue + endif + + for l:optionName in keys(l:defaultOpenArgs[l:typeKey]) + if s:validateType(get(l:customOpenArgs[l:typeKey], l:optionName, v:null), v:t_string) + continue + endif + let l:customOpenArgs[l:typeKey][l:optionName] = l:defaultOpenArgs[l:typeKey][l:optionName] + endfor + endfor + + let g:NERDTreeCustomOpenArgs = l:customOpenArgs + + return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep') +endfunction + +function! s:validateType(variable, type) abort + if type(a:variable) is# a:type + return v:true + endif + + return v:false endfunction "FUNCTION: s:activateAll() {{{1 @@ -500,9 +530,10 @@ function! nerdtree#ui_glue#openBookmark(name) abort endtry if l:bookmark.path.isDirectory call l:bookmark.open(b:NERDTree) - else - call l:bookmark.open(b:NERDTree, {'where': 'p'}) + return endif + + call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file) endfunction " FUNCTION: s:openHSplit(target) {{{1 From a7eb011e47a9b55bb20b4da981092816f940c932 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 17 Jan 2021 22:16:38 -0500 Subject: [PATCH 624/680] Revert #1200, due to bug (#1205) it introduced. --- autoload/nerdtree/ui_glue.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index b0cedee9..aabd2eea 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -112,6 +112,7 @@ endfunction function! s:initCustomOpenArgs() abort let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} let l:customOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep') if v:false is# s:validateType(l:customOpenArgs, v:t_dict) return l:defaultOpenArgs From 7099f638edd3eda5cd5687b4e13d342bb7f9949d Mon Sep 17 00:00:00 2001 From: Tomasz N Date: Tue, 19 Jan 2021 03:23:52 +0100 Subject: [PATCH 625/680] Fix missing key case, add BC type checking (#1206) * Fix missing key case, add BC type checking Resolves #1205 * Assign g:NERDTreeCustomOpenArgs also before quick return * Fix syntax to be compatibile with Vim 7.3 --- autoload/nerdtree/ui_glue.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index aabd2eea..31b58c44 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -108,24 +108,24 @@ function! s:customOpenBookmark(node) abort endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 -" Make sure NERDTreeCustomOpenArgs has needed keys function! s:initCustomOpenArgs() abort let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} let l:customOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) - return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep') - if v:false is# s:validateType(l:customOpenArgs, v:t_dict) + if !s:validateType(l:customOpenArgs, type({})) || empty(l:customOpenArgs) + let g:NERDTreeCustomOpenArgs = l:customOpenArgs return l:defaultOpenArgs endif for l:typeKey in keys(l:defaultOpenArgs) - if v:false is# s:validateType(get(l:customOpenArgs, l:typeKey, {}), v:t_dict) + if !s:validateType(get(l:customOpenArgs, l:typeKey, {}), type({})) + \ || !has_key(l:customOpenArgs, l:typeKey) let l:customOpenArgs[l:typeKey] = l:defaultOpenArgs[l:typeKey] continue endif for l:optionName in keys(l:defaultOpenArgs[l:typeKey]) - if s:validateType(get(l:customOpenArgs[l:typeKey], l:optionName, v:null), v:t_string) + if s:validateType(get(l:customOpenArgs[l:typeKey], l:optionName, v:null), type('')) continue endif let l:customOpenArgs[l:typeKey][l:optionName] = l:defaultOpenArgs[l:typeKey][l:optionName] @@ -138,7 +138,7 @@ function! s:initCustomOpenArgs() abort endfunction function! s:validateType(variable, type) abort - if type(a:variable) is# a:type + if type(a:variable) == a:type return v:true endif From b134f6518b902c7e0482ae770b804fd47c2d2426 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 19 Jan 2021 20:07:26 -0500 Subject: [PATCH 626/680] Enable full path specifications for NERDTreeIgnore (#1207) * Add ability to specify a path to be ignored. This ignore expression compares itself against the whole path of the node, instead of just the tail component of the node. * Remove debug statements and make it work on Windows. * Restore the original self.str() to get OS-specific paths for comparing. Using the UI-formatted path had two problems. 1. It always appended a forward slash at the end of the path, which was unnecessary and made patterns like '/tmp/cache$[[path]]' not work as expected. 2. It always used forward slashes to join the path components. I thought this would be a good thing, but there's no reason to force Windows users to use that syntax. They'll just need to remember to escape the backslashes, like so: '\\Temp\\cache$[[path]]' * Add documentation for the new [[path]] tag for NERDTreeIgnore. * Replace the abbreviation 'dir' with the full word 'directory'. * Update version number in change log. --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 71 ++++++++++++++++++++++++------------------- lib/nerdtree/path.vim | 5 ++- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ec8430..e5783e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.10 +- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) #### 6.9 - **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) - **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 2989718c..95742a30 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -116,7 +116,7 @@ The following features and functionality are provided by the NERDTree: :NERDTreeVCS (opens root of repository containing CWD) < :NERDTreeFromBookmark *:NERDTreeFromBookmark* - Opens a fresh NERDTree with the root initialized to the dir for + Opens a fresh NERDTree with the root initialized to the directory for . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). @@ -126,7 +126,7 @@ The following features and functionality are provided by the NERDTree: is set to that path. If no NERDTree exists for this tab then this command acts the same as the |:NERDTree| command. -:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* +:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* Like |:NERDTreeToggle|, but searches up the directory tree to find the top of the version control system repository, and roots the NERDTree there. It works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A @@ -249,7 +249,7 @@ Key Description help-tag~ o........Open files, directories and bookmarks......................|NERDTree-o| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| - Open selected bookmark dir in current NERDTree + Open selected bookmark directory in current NERDTree t........Open selected node/bookmark in a new tab...................|NERDTree-t| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| i........Open selected file in a split window.......................|NERDTree-i| @@ -260,10 +260,10 @@ gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| O........Recursively open the selected directory....................|NERDTree-O| x........Close the current nodes parent.............................|NERDTree-x| X........Recursively close all children of the current node.........|NERDTree-X| -e........Edit the current dir.......................................|NERDTree-e| +e........Edit the current directory.................................|NERDTree-e| double-click....same as |NERDTree-o|. -middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. +middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for directories. D........Delete the current bookmark ...............................|NERDTree-D| @@ -274,13 +274,13 @@ J........Jump down inside directories at the current tree depth.....|NERDTree-J| ....Jump down to next sibling of the current directory.......|NERDTree-C-J| ....Jump up to previous sibling of the current directory.....|NERDTree-C-K| -C........Change the tree root to the selected dir...................|NERDTree-C| +C........Change the tree root to the selected directory.............|NERDTree-C| u........Move the tree root up one directory........................|NERDTree-u| U........Same as 'u' except the old root node is left open..........|NERDTree-U| r........Recursively refresh the current directory..................|NERDTree-r| R........Recursively refresh the current root.......................|NERDTree-R| m........Display the NERDTree menu..................................|NERDTree-m| -cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| +cd.......Change the CWD to the directory of the selected node......|NERDTree-cd| CD.......Change tree root to the CWD...............................|NERDTree-CD| I........Toggle whether hidden files displayed......................|NERDTree-I| @@ -469,7 +469,7 @@ Jump to the first child of the current nodes parent. If the cursor is already on the first node then do the following: * loop back thru the siblings of the current nodes parent until we find an - open dir with children + open directory with children * go to the first child of that node ------------------------------------------------------------------------------ @@ -482,7 +482,7 @@ Jump to the last child of the current nodes parent. If the cursor is already on the last node then do the following: * loop forward thru the siblings of the current nodes parent until we find - an open dir with children + an open directory with children * go to the last child of that node ------------------------------------------------------------------------------ @@ -516,7 +516,7 @@ Default key: u Map setting: *NERDTreeMapUpdir* Applies to: no restrictions. -Move the tree root up a dir (like doing a "cd .."). +Move the tree root up a directory (like doing a "cd .."). ------------------------------------------------------------------------------ *NERDTree-U* @@ -532,8 +532,8 @@ Default key: r Map setting: *NERDTreeMapRefresh* Applies to: files and directories. -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. +If a directory is selected, recursively refresh that directory, i.e. scan the +filesystem for changes and represent them in the tree. If a file node is selected then the above is done on it's parent. @@ -634,8 +634,8 @@ file explorers have. The script comes with two default menu plugins: exec_menuitem.vim and fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for -creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a -menu item to execute executable files. +creating/deleting/moving/copying files and directories. exec_menuitem.vim +provides a menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| @@ -921,7 +921,7 @@ Default: ['\~$']. This setting is used to specify which files the NERDTree should ignore. It must be a list of regular expressions. When the NERDTree is rendered, any -files/dirs that match any of the regex's in NERDTreeIgnore won't be +files/directories that match any of the regex's in NERDTreeIgnore won't be displayed. For example if you put the following line in your vimrc: > @@ -929,13 +929,18 @@ For example if you put the following line in your vimrc: > < then all files ending in .vim or ~ will be ignored. -There are 2 magic flags that can be appended to the end of each regular -expression to specify that the regex should match only files or only dirs. -These flags are "[[dir]]" and "[[file]]". Example: > - let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]'] +There are 3 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only filenames, only lowest +level directories, or a full path. These flags are "[[dir]]", "[[file]]", and +"[[path]]". Example: > + let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]', 'tmp/cache$[[path]]'] < -This will cause all dirs ending in ".d" to be ignored and all files ending in -".o" to be ignored. +This will cause all directories ending in ".d" to be ignored, all files ending +in ".o" to be ignored, and the "cache" subdirectory of any "tmp" directory to +be ignored. All other "cache" directories will be displayed. + +When using the "[[path]]" tag on Windows, make sure you use escaped +backslashes for the separators in the regex, eg. 'Temp\\cache$[[path]]' Note: to tell the NERDTree not to ignore any files you must use the following line: > @@ -1099,8 +1104,8 @@ Examples: > < 1. Directories will appear last, everything else will appear above. 2. Everything will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. +3. Directories will appear first, then ruby and php. Swap files, bak files + and vim backup files will appear last with everything else preceding them. 4. Everything is sorted by size, largest to smallest, with directories considered to have size 0 bytes. 5. Directories will appear first alphabetically, followed by files, sorted by @@ -1174,8 +1179,9 @@ Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When displaying dir nodes, this setting tells NERDTree to collapse dirs that -have only one child. Use one of the following lines for this setting: > +When displaying directory nodes, this setting tells NERDTree to collapse +directories that have only one child. Use one of the following lines for this +setting: > let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=1 < @@ -1184,11 +1190,12 @@ have only one child. Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When opening dir nodes, this setting tells NERDTree to recursively open dirs -that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. This setting also causes -the |NERDTree-x| mapping to close dirs in the same manner. This setting may be -useful for Java projects. Use one of the following lines for this setting: > +When opening directory nodes, this setting tells NERDTree to recursively open +directories that have only one child which is also a directory. NERDTree will +stop when it finds a directory that contains anything but another single +directory. This setting also causes the |NERDTree-x| mapping to close +directories in the same manner. This setting may be useful for Java projects. +Use one of the following lines for this setting: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < @@ -1362,8 +1369,8 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of - the current dir node. Note this mapping will only fire when the cursor is - on a directory node. + the current directory node. Note this mapping will only fire when the + cursor is on a directory node. ------------------------------------------------------------------------------ 4.2. Menu API *NERDTreeMenuAPI* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 786ccd90..26749c61 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -483,7 +483,10 @@ endfunction " returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern - if strpart(pat,len(pat)-7) ==# '[[dir]]' + if strpart(pat,len(pat)-8) ==# '[[path]]' + let pat = strpart(pat,0, len(pat)-8) + return self.str() =~# pat + elseif strpart(pat,len(pat)-7) ==# '[[dir]]' if !self.isDirectory return 0 endif From 628098fff1d75ad104934009b4ce60c4e23204ec Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sat, 30 Jan 2021 23:43:29 -0500 Subject: [PATCH 627/680] Escape quotation marks so they can be used in key mappings. (#1213) * Escape quotation marks so they can be used in key mappings. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/key_map.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5783e60..8d8eef98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) - **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) #### 6.9 - **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index f3268c26..e6afb824 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -51,7 +51,7 @@ function! s:KeyMap.bind() else let keymapInvokeString = self.key endif - let keymapInvokeString = escape(keymapInvokeString, '\') + let keymapInvokeString = escape(keymapInvokeString, '\"') let premap = self.key ==# '' ? ' ' : ' ' From c8be9458dddb986dc17a3f5a00aaf29cd60b1b5f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sat, 30 Jan 2021 23:45:56 -0500 Subject: [PATCH 628/680] New menu command: Run a system command in this directory. (#1214) * New menu command: Run system command in this directory. * Echo the output from the system command. * Update version number in change log. * Address Vim linter message: change "\n" to nr2char(10) * Use single quoted strings. * Use system() instead of systemlist() for greater version compatibility. systemlist() was introduced sometime in Vim 8+, so I switched to system() for 7.4 compatibility. --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8eef98..1192d48c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) - **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) - **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) #### 6.9 diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index b3ef42e7..09cb69b5 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -49,6 +49,10 @@ else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif +if exists('*system') + call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'}) +endif + "FUNCTION: s:inputPrompt(action){{{1 "returns the string that should be prompted to the user for the given action " @@ -460,4 +464,21 @@ function! NERDTreeExecuteFileWindows() call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) endfunction +" FUNCTION: NERDTreeSystemCommand() {{{1 +function! NERDTreeSystemCommand() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + let l:cwd = getcwd() + let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str() + execute 'cd '.l:directory + + let l:nl = nr2char(10) + echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ '))) + execute 'cd '.l:cwd +endfunction + " vim: set sw=4 sts=4 et fdm=marker: From 1b19089917cc3e0a81d3294fead2424c419d545c Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sun, 31 Jan 2021 00:19:58 -0500 Subject: [PATCH 629/680] Add new FAQ and answer: How to prevent buffers replacing NERDTree. (#1215) * Add new FAQ and answer: How to prevent buffers replacing NERDTree. * Update version number in change log. --- CHANGELOG.md | 1 + README.markdown | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1192d48c..409d631f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) - **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) - **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) - **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) diff --git a/README.markdown b/README.markdown index 7c6ba3c2..843ebe24 100644 --- a/README.markdown +++ b/README.markdown @@ -156,6 +156,14 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr \ quit | endif ``` +### How can I prevent other buffers replacing NERDTree in its window? + +```vim +" If another buffer tries to replace NERDTree, put in the other window, and bring back NERDTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +``` + ### Can I have the same NERDTree on every tab automatically? ```vim From d3becd11492343761a13419abc43720aa19425af Mon Sep 17 00:00:00 2001 From: Daniel E <73450961+gladiator@users.noreply.github.com> Date: Tue, 9 Feb 2021 18:48:36 -0700 Subject: [PATCH 630/680] Removed directory separator from sort key (#1219) * Removed directory separator from sort key Directories had an additional separator appended to them which caused improper comparisons for other directories that shared similar prefixes. * Updated changelog --- CHANGELOG.md | 1 + lib/nerdtree/path.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 409d631f..1472c44c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) - **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) - **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) - **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 26749c61..eec4f330 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -394,7 +394,7 @@ function! s:Path.getSortKey() let self._sortKey = [self.getSortOrderIndex()] + metadata endif - let path = self.getLastPathComponent(1) + let path = self.getLastPathComponent(0) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') endif From 593c16add35a5461f189b8189abe219f7bbbd604 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 9 Feb 2021 21:34:24 -0500 Subject: [PATCH 631/680] Fix {'keepopen':0} in NERDTreeCustomOpenArgs (#1217) * Replace #and() with two more-specific functions. * Push NERDTreeQuitOnOpen checking earlier in the call stack. * Fix bug in `go` key for file bookmarks. It was behaving like `gs`. * Fix the `o` mapping for bookmark nodes and the g:NERDTree reference. * Use get() function to shorten if statement logic. * Update version number in change log. * Remove obsolete reference to MERDTreeQuitOnOpen in comment. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 32 ++++++++++---------------------- autoload/nerdtree/ui_glue.vim | 20 ++++++++++---------- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/nerdtree.vim | 8 -------- lib/nerdtree/opener.vim | 7 +++---- 6 files changed, 25 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1472c44c..070b78a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) - **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) - **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) - **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 983bb621..223f2f4b 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -30,6 +30,16 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +" FUNCTION: nerdtree#closeTreeOnOpen() +function! nerdtree#closeTreeOnOpen() abort + return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3 +endfunction + +" FUNCTION: nerdtree#closeBookmarksOnOpen() +function! nerdtree#closeBookmarksOnOpen() abort + return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3 +endfunction + " FUNCTION: nerdtree#slash() {{{2 " Return the path separator used by the underlying file system. Special " consideration is taken for the use of the 'shellslash' option on Windows @@ -46,28 +56,6 @@ function! nerdtree#slash() abort return '/' endfunction -"FUNCTION: nerdtree#and(x,y) {{{2 -" Implements and() function for Vim <= 7.4 -function! nerdtree#and(x,y) abort - if exists('*and') - return and(a:x, a:y) - else - let l:x = a:x - let l:y = a:y - let l:n = 0 - let l:result = 0 - while l:x > 0 && l:y > 0 - if (l:x % 2) && (l:y % 2) - let l:result += float2nr(pow(2, l:n)) - endif - let l:x = float2nr(l:x / 2) - let l:y = float2nr(l:y / 2) - let l:n += 1 - endwhile - return l:result - endif -endfunction - "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) abort diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 31b58c44..2cf6f454 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -168,13 +168,13 @@ endfunction "FUNCTION: s:activateFileNode() {{{1 "handle the user activating a tree node function! s:activateFileNode(node) abort - call a:node.activate({'reuse': 'all', 'where': 'p'}) + call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction "FUNCTION: s:activateBookmark(bookmark) {{{1 "handle the user activating a bookmark function! s:activateBookmark(bm) abort - call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 @@ -539,24 +539,24 @@ endfunction " FUNCTION: s:openHSplit(target) {{{1 function! s:openHSplit(target) abort - call a:target.activate({'where': 'h'}) + call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction " FUNCTION: s:openVSplit(target) {{{1 function! s:openVSplit(target) abort - call a:target.activate({'where': 'v'}) + call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction "FUNCTION: s:openHSplitBookmark(bookmark) {{{1 "handle the user activating a bookmark function! s:openHSplitBookmark(bm) abort - call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction "FUNCTION: s:openVSplitBookmark(bookmark) {{{1 "handle the user activating a bookmark function! s:openVSplitBookmark(bm) abort - call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction " FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 @@ -576,13 +576,13 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{1 function! s:openInNewTab(target) abort - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()}) call l:opener.open(a:target) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 function! s:openInNewTabSilent(target) abort - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1}) call l:opener.open(a:target) endfunction @@ -596,7 +596,7 @@ endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 function! s:previewBookmark(bookmark) abort - call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'p', 'keepopen': 1} : {}) endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 @@ -621,7 +621,7 @@ function! nerdtree#ui_glue#revealBookmark(name) abort let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) catch /^NERDTree.BookmarkNotFoundError/ - call nerdtree#echo('Bookmark isnt cached under the current root') + call nerdtree#echo('Bookmark isn''t cached under the current root') endtry endfunction diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 248bb074..37be451c 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -256,7 +256,7 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} - if nerdtree#and(g:NERDTreeQuitOnOpen,2) + if nerdtree#closeBookmarksOnOpen() call a:nerdtree.ui.toggleShowBookmarks() endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index db9e2b55..61a11a96 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -65,14 +65,6 @@ function! s:NERDTree.Close() endif endfunction -"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 -"Closes the NERD tree window if the close on open option is set -function! s:NERDTree.CloseIfQuitOnOpen() - if nerdtree#and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() - call s:NERDTree.Close() - endif -endfunction - "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "Places the cursor at the top of the bookmarks table function! s:NERDTree.CursorToBookmarkTable() diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index 9c62b723..27993ac7 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -33,8 +33,7 @@ function! s:Opener._bufInWindows(bnum) endfunction " FUNCTION: Opener._checkToCloseTree(newtab) {{{1 -" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see -" if the tree should be closed now. +" Check the class options to see if the tree should be closed now. " " Args: " a:newtab - boolean. If set, only close the tree now if we are opening the @@ -46,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab) endif if (a:newtab && self._where ==# 't') || !a:newtab - call g:NERDTree.CloseIfQuitOnOpen() + call g:NERDTree.Close() endif endfunction @@ -218,7 +217,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !nerdtree#and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + if !self._stay && self._keepopen && get(b:, 'NERDTreeZoomed', 0) call b:NERDTree.ui.toggleZoom() endif From 1d46d6df3e581984d4b31d30d362cb94bc993e1d Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 9 Feb 2021 21:50:35 -0500 Subject: [PATCH 632/680] Update README.markdown --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 843ebe24..dc160ee6 100644 --- a/README.markdown +++ b/README.markdown @@ -159,7 +159,7 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr ### How can I prevent other buffers replacing NERDTree in its window? ```vim -" If another buffer tries to replace NERDTree, put in the other window, and bring back NERDTree. +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif ``` From d3f9fc44caaa5688b65ccc508af6fac7defa120f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 10 Feb 2021 16:38:41 -0500 Subject: [PATCH 633/680] Update README.markdown Add the missing slashes in the names of two of the mentioned plugin managers. --- README.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index dc160ee6..135f41ad 100644 --- a/README.markdown +++ b/README.markdown @@ -8,7 +8,7 @@ The NERDTree is a file system explorer for the Vim editor. Using this plugin, us ## Installation -Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVimVundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunnvim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** +Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g). @@ -183,4 +183,3 @@ let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. - From 3a9d533f3de86a43b69f6c47d3394c0d866fdb08 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 10 Feb 2021 22:20:04 -0500 Subject: [PATCH 634/680] Restore the default behavior of the key. (#1221) * Restore 's default behavior to be the same as o's. * Remove the dictionary validation, and simplify initCustomOpenArgs(). There was a bug in the validation logic that caused a valid integer value of 'keepopen' to always be overwritten with the defaultOpenArgs' value. It was always comparing its type to the type of a string. I fixed this by removing all the type validation, and wrapping the code with a try-catch block. If NERDTreeCustomOpenArgs is not a dictionary, an error message will print and the defaults will be used instead. * Add fold markers to new functions. * Update version number in change log. --- CHANGELOG.md | 1 + autoload/nerdtree.vim | 4 ++-- autoload/nerdtree/ui_glue.vim | 44 ++++++++--------------------------- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 070b78a3..8b84bfb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.6**: Restore the default behavior of the key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) - **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) - **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 223f2f4b..e6f687a0 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -30,12 +30,12 @@ endfunction " SECTION: General Functions {{{1 "============================================================ -" FUNCTION: nerdtree#closeTreeOnOpen() +" FUNCTION: nerdtree#closeTreeOnOpen() {{{2 function! nerdtree#closeTreeOnOpen() abort return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3 endfunction -" FUNCTION: nerdtree#closeBookmarksOnOpen() +" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2 function! nerdtree#closeBookmarksOnOpen() abort return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3 endfunction diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2cf6f454..1231e5eb 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -109,40 +109,16 @@ endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 function! s:initCustomOpenArgs() abort - let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} - let l:customOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) - - if !s:validateType(l:customOpenArgs, type({})) || empty(l:customOpenArgs) - let g:NERDTreeCustomOpenArgs = l:customOpenArgs - return l:defaultOpenArgs - endif - - for l:typeKey in keys(l:defaultOpenArgs) - if !s:validateType(get(l:customOpenArgs, l:typeKey, {}), type({})) - \ || !has_key(l:customOpenArgs, l:typeKey) - let l:customOpenArgs[l:typeKey] = l:defaultOpenArgs[l:typeKey] - continue - endif - - for l:optionName in keys(l:defaultOpenArgs[l:typeKey]) - if s:validateType(get(l:customOpenArgs[l:typeKey], l:optionName, v:null), type('')) - continue - endif - let l:customOpenArgs[l:typeKey][l:optionName] = l:defaultOpenArgs[l:typeKey][l:optionName] - endfor - endfor - - let g:NERDTreeCustomOpenArgs = l:customOpenArgs - - return extend(l:customOpenArgs, l:defaultOpenArgs, 'keep') -endfunction - -function! s:validateType(variable, type) abort - if type(a:variable) == a:type - return v:true - endif - - return v:false + let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}} + try + let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep') + catch /^Vim(\a\+):E712:/ + call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.') + let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs + finally + return g:NERDTreeCustomOpenArgs + endtry endfunction "FUNCTION: s:activateAll() {{{1 From a1fa4a33bf16b6661e502080fc97788bb98afd35 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 12 Feb 2021 23:14:26 -0500 Subject: [PATCH 635/680] Fix mouse-clicking a file to open it, which was broken in 6.10.5. (#1225) * Fix mouse-clicking a file to open it, which was broken in 6.10.5. * Update version number in change log. --- CHANGELOG.md | 1 + autoload/nerdtree/ui_glue.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b84bfb9..8b9d83cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) - **.6**: Restore the default behavior of the key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) - **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 1231e5eb..c6df0028 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -373,7 +373,7 @@ function! s:handleLeftClick() abort if currentNode.path.isDirectory call currentNode.activate() else - call currentNode.activate({'reuse': 'all', 'where': 'p'}) + call currentNode.activate({'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}) endif return endif From f63fb6984f9cd07cf723c3e2e20f6ccc0aad48c2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 1 Mar 2021 09:34:54 -0500 Subject: [PATCH 636/680] Put `Callback` function variables in local scope. (#1230) * Put `Callback` function variables in local scope. This change prevents conflict with other `Callback` functions that are defined elsewhere in global scope. * Update version number in change log. --- CHANGELOG.md | 1 + lib/nerdtree/key_map.vim | 6 +++--- lib/nerdtree/notifier.vim | 4 ++-- lib/nerdtree/path.vim | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b9d83cc..3138e6ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.8**: Put `Callback` function variables in local scope. [#1230](https://github.com/preservim/nerdtree/pull/1230) - **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) - **.6**: Restore the default behavior of the key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim index e6afb824..ed791677 100644 --- a/lib/nerdtree/key_map.vim +++ b/lib/nerdtree/key_map.vim @@ -66,11 +66,11 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) + let l:Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) if a:0 - call Callback(a:1) + call l:Callback(a:1) else - call Callback() + call l:Callback() endif endfunction diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim index fc3155d7..ffa2853a 100644 --- a/lib/nerdtree/notifier.vim +++ b/lib/nerdtree/notifier.vim @@ -15,8 +15,8 @@ function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) for Listener in s:Notifier.GetListenersForEvent(a:event) - let Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) - call Callback(event) + let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) + call l:Callback(event) endfor endfunction diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index eec4f330..997abf37 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -459,10 +459,10 @@ function! s:Path.ignore(nerdtree) endif endfor - for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback) - if Callback({'path': self, 'nerdtree': a:nerdtree}) - return 1 + for l:Callback in g:NERDTree.PathFilters() + let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback) + if l:Callback({'path': self, 'nerdtree': a:nerdtree}) + return 1 endif endfor endif From 81f3eaba295b3fceb2d032db57e5eae99ae480f8 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 24 Mar 2021 23:41:15 -0400 Subject: [PATCH 637/680] `go` on a bookmark directory will NERDTreeFind it. (#1236) * `go` on a bookmark directory will NERDTreeFind it. This leaves the root unchanged if possible. * Update version number in change log. --- CHANGELOG.md | 3 ++- autoload/nerdtree/ui_glue.vim | 6 +++++- doc/NERDTree.txt | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3138e6ec..2681b67f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 -- **.8**: Put `Callback` function variables in local scope. [#1230](https://github.com/preservim/nerdtree/pull/1230) +- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) +- **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) - **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) - **.6**: Restore the default behavior of the key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index c6df0028..fc22f216 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -572,7 +572,11 @@ endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 function! s:previewBookmark(bookmark) abort - call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'p', 'keepopen': 1} : {}) + if a:bookmark.path.isDirectory + execute 'NERDTreeFind '.a:bookmark.path.str() + else + call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1}) + endif endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 95742a30..4e75ad13 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -249,7 +249,7 @@ Key Description help-tag~ o........Open files, directories and bookmarks......................|NERDTree-o| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| - Open selected bookmark directory in current NERDTree + Find selected bookmark directory in current NERDTree t........Open selected node/bookmark in a new tab...................|NERDTree-t| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| i........Open selected file in a split window.......................|NERDTree-i| From de0e2edeac61039d8c9fb01a43b0305baad0a28b Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 13 Jul 2021 14:28:29 -0400 Subject: [PATCH 638/680] Improve F.A.Q. Answers and Issue Templates (#1249) * Update the issue templates, making them simpler to use. * Update FAQ answers. Closes #1246. - Add an if statement to the autocommand to prevent its running in the Command Window. Closes #1248. - Add a new answer to show closing a tab when only NERDTree remains. * Update the Bug issue template. * Update version number in change log. --- .github/ISSUE_TEMPLATE/bug.md | 57 +++++++++++++++--------------- .github/ISSUE_TEMPLATE/question.md | 21 +++-------- CHANGELOG.md | 3 +- README.markdown | 14 +++++--- 4 files changed, 45 insertions(+), 50 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index dd351350..e2ce07b9 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -5,41 +5,42 @@ labels: bug --- +Keep in mind that others may have the same question in the future. The better your information, +the more likely they'll be able to help themselves. +--> #### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. - -#### Environment (for bug reports) -- [ ] Operating System: -- [ ] Vim/Neovim version `:echo v:version`: -- [ ] NERDTree version, found on 1st line in NERDTree quickhelp `?`: -- [ ] vimrc settings - - [ ] NERDTree variables - ```vim - ``` - - Other NERDTree-dependent Plugins - - [ ] jistr/vim-nerdtree-tabs - - [ ] ryanoasis/vim-devicons - - [ ] tiagofumo/vim-nerdtree-syntax-highlight - - [ ] Xuyuanp/nerdtree-git-plugin - - [ ] Others (specify): - - [ ] I've verified the issue occurs with only NERDTree installed. +Before creating an issue, take some time to search these resources for an answer. It's possible that someone else has already seen and solved your issue. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resources: , , etc. + +#### Environment +- Operating System: +- Vim/Neovim version `:version`: +- NERDTree version, found on first line of quickhelp `?`: +- Are you using any of these NERDTree-dependent plugins? + - [ ] [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin) + - [ ] [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons) + - [ ] [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight) + - [ ] [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin) + - [ ] [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops) + - [ ] [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection) + - [ ] [jistr/vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + - [ ] Others (specify): +- Provide a minimal **.vimrc** file that will reproduce the issue. +```vim +``` #### Steps to Reproduce the Issue 1. -#### Current Result (Include screenshots where appropriate.) +#### Current Behavior (Include screenshots where appropriate.) #### Expected Result diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 25f15b02..0ca45bf8 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -3,22 +3,11 @@ name: "General Question" about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." labels: "general question" --- - - -#### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. +Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/scrooloose/nerdtree/wiki) +- Other resource: , , etc. #### State Your Question diff --git a/CHANGELOG.md b/CHANGELOG.md index 2681b67f..8bbc8f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,11 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) - **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) - **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) - **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) -- **.6**: Restore the default behavior of the key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) +- **.6**: Restore the default behavior of the `` key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) - **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) - **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) diff --git a/README.markdown b/README.markdown index 135f41ad..ea10c119 100644 --- a/README.markdown +++ b/README.markdown @@ -148,12 +148,16 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif ``` -### How can I close Vim automatically when NERDTree is the last window? +### How can I close Vim or a tab automatically when NERDTree is the last window? ```vim -" Exit Vim if NERDTree is the only window left. -autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | - \ quit | endif +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +``` +--- +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif ``` ### How can I prevent other buffers replacing NERDTree in its window? @@ -168,7 +172,7 @@ autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_ ```vim " Open the existing NERDTree on each new tab. -autocmd BufWinEnter * silent NERDTreeMirror +autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif ``` or change your NERDTree-launching shortcut key like so: ```vim From 2c14ed0e153cdcd0a1c7d1eabec6820bb6b3f8a2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 15 Jul 2021 08:31:01 -0400 Subject: [PATCH 639/680] Update Wiki link in General Question issue template --- .github/ISSUE_TEMPLATE/question.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 0ca45bf8..7e13b7ac 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -6,7 +6,7 @@ labels: "general question" Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer. - [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) - NERDTree documentation - `:h NERDTree` -- [NERDTree Wiki](https://github.com/scrooloose/nerdtree/wiki) +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) - Other resource: , , etc. #### State Your Question From 0e71462f90fb4bd09121eeba829512cc24ab5c97 Mon Sep 17 00:00:00 2001 From: Sharla Kew Date: Fri, 13 Aug 2021 00:18:53 +0100 Subject: [PATCH 640/680] Trim filenames created via the fs_menu (#1243) The default when naming a file in the command line is that extra white space will be stripped away. It seems logical for file naming via the fs_menu in nerdtree to follow that convention. I have left the defaults of `trim` because they seem sensible. Co-authored-by: Phil Runninger --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bbc8f2c..d8a23414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) - **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) - **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) - **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 09cb69b5..33ff6674 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -169,7 +169,7 @@ endfunction function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() let prompt = s:inputPrompt('add') - let newNodeName = input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file') + let newNodeName = trim(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file')) if newNodeName ==# '' call nerdtree#echo('Node Creation Aborted.') @@ -206,7 +206,7 @@ function! NERDTreeMoveNode() let newNodePath = input(prompt, curNode.path.str(), 'file') while filereadable(newNodePath) call nerdtree#echoWarning('This destination already exists. Try again.') - let newNodePath = input(prompt, curNode.path.str(), 'file') + let newNodePath = trim(input(prompt, curNode.path.str(), 'file')) endwhile @@ -337,7 +337,7 @@ endfunction function! NERDTreeCopyNode() let currentNode = g:NERDTreeFileNode.GetSelected() let prompt = s:inputPrompt('copy') - let newNodePath = input(prompt, currentNode.path.str(), 'file') + let newNodePath = trim(input(prompt, currentNode.path.str(), 'file')) if newNodePath !=# '' "strip trailing slash From e5f24e2b8bc09ce6fc3488215d69ddb7cadc5f8d Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 7 Sep 2021 10:14:36 -0400 Subject: [PATCH 641/680] Answer the question about accessing files over scp or ftp. (#1259) * Answer the question about accessing files over scp or ftp. * Minor formatting change to README. * Update version number in Change Log. --- CHANGELOG.md | 1 + README.markdown | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a23414..87e0f783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) - **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) - **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) - **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) diff --git a/README.markdown b/README.markdown index ea10c119..2de10d6c 100644 --- a/README.markdown +++ b/README.markdown @@ -187,3 +187,35 @@ let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. + +### Can NERDTree access remote files via scp or ftp? + +Short answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression. + +```vim +" Function to open the file or NERDTree or netrw. +" Returns: 1 if either file explorer was opened; otherwise, 0. +function! s:OpenFileOrExplorer(...) + if a:0 == 0 || a:1 == '' + NERDTree + elseif filereadable(a:1) + execute 'edit '.a:1 + return 0 + elseif a:1 =~? '^\(scp\|ftp\)://' " Add other protocols as needed. + execute 'Vexplore '.a:1 + elseif isdirectory(a:1) + execute 'NERDTree '.a:1 + endif + return 1 +endfunction + +" Auto commands to handle OS commandline arguments +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc()==1 && !exists('s:std_in') | if OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif + +" Command to call the OpenFileOrExplorer function. +command! -n=? -complete=file -bar Edit :call OpenFileOrExplorer('') + +" Command-mode abbreviation to replace the :edit Vim command. +cnoreabbrev e Edit +``` From aa7e97b7ff2ace7ed434b09bd33f3ad449d294e9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Sat, 11 Sep 2021 11:31:39 -0400 Subject: [PATCH 642/680] Change highlighting of bookmarks in the tree. (#1261) * Change highlighting of bookmarks in the tree. The bookmark names in the tree now have the same syntax highlighting as the bookmark names in the list of bookmarks above the tree. * Change version number in change log. --- CHANGELOG.md | 1 + syntax/nerdtree.vim | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e0f783..a21b7b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) - **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) - **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) - **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index bf523d15..c4197eef 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -36,23 +36,23 @@ if g:NERDTreeDirArrowExpandable !=# '' exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' - exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' - exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' else exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' - exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' - exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' endif "highlighting for readonly files -exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmarkName,NERDTreeFile' exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' syn match NERDTreeCWD #^[# From 7eee457efae1bf9b96d7a266ac097639720a68fe Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 14 Sep 2021 22:34:57 -0400 Subject: [PATCH 643/680] Replace trim() with a version-compatible alternative. (#1265) * Replace trim() with a version-compatible alternative. * Update version number in change log. --- CHANGELOG.md | 1 + nerdtree_plugin/fs_menu.vim | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a21b7b5c..48204fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) - **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) - **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) - **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 33ff6674..05bee60d 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -169,7 +169,7 @@ endfunction function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() let prompt = s:inputPrompt('add') - let newNodeName = trim(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file')) + let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g') if newNodeName ==# '' call nerdtree#echo('Node Creation Aborted.') @@ -206,7 +206,7 @@ function! NERDTreeMoveNode() let newNodePath = input(prompt, curNode.path.str(), 'file') while filereadable(newNodePath) call nerdtree#echoWarning('This destination already exists. Try again.') - let newNodePath = trim(input(prompt, curNode.path.str(), 'file')) + let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') endwhile @@ -337,7 +337,7 @@ endfunction function! NERDTreeCopyNode() let currentNode = g:NERDTreeFileNode.GetSelected() let prompt = s:inputPrompt('copy') - let newNodePath = trim(input(prompt, currentNode.path.str(), 'file')) + let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') if newNodePath !=# '' "strip trailing slash From e731b845590017493224dfcb7403c2332105b700 Mon Sep 17 00:00:00 2001 From: lifecrisis Date: Mon, 20 Sep 2021 15:01:21 -0400 Subject: [PATCH 644/680] Ensure backward compatible testing of types (#1266) - Use "type(0)" instead of "v:t_number" - Use "==" instead of "==#" since we are comparing numbers - Make use of the "+=" operator - Update the "CHANGELOG.md" file The only real issue here is that we should prefer "type(0)" over the special variable. I run into this problem enough on older systems that it frustrates me. Let's have it fixed! --- CHANGELOG.md | 3 ++- autoload/nerdtree.vim | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48204fe4..f2cfd978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 -- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) +- **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266) +- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) - **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) - **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) - **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index e6f687a0..ba708711 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -112,18 +112,18 @@ function! nerdtree#compareNodePaths(p1, p2) abort " Compare chunks upto common length. " If chunks have different type, the one which has " integer type is the lesser. - if type(sortKey1[i]) ==# type(sortKey2[i]) + if type(sortKey1[i]) == type(sortKey2[i]) if sortKey1[i] <# sortKey2[i] return - 1 elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif type(sortKey1[i]) ==# v:t_number + elseif type(sortKey1[i]) == type(0) return -1 - elseif type(sortKey2[i]) ==# v:t_number + elseif type(sortKey2[i]) == type(0) return 1 endif - let i = i + 1 + let i += 1 endwhile " Keys are identical upto common length. From 9310f91476a94ee9c2f3a587171893743a343e26 Mon Sep 17 00:00:00 2001 From: lifecrisis Date: Tue, 28 Sep 2021 00:43:04 +0000 Subject: [PATCH 645/680] Fix documentation errors (#1269) * Fix a typo: "NERDTree_*" -> "NERD_Tree_*" * Format text * Use the proper abbreviation for the BEL character * Format text * Make the documentation match the code The syntax file sets 'conceallevel' to 2, not 3. * Update the "CHANGELOG.md" file --- CHANGELOG.md | 1 + doc/NERDTree.txt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2cfd978..6e6893a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> #### 6.10 +- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269) - **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266) - **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) - **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 4e75ad13..55c25cd1 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1256,10 +1256,10 @@ responsible pull request: https://github.com/preservim/nerdtree/pull/868. The default value of this variable depends on the features compiled into your vim and the values of |NERDTreeDirArrowCollapsible| and |NERDTreeDirArrowExpandable|. - * If your vim is compiled with the +conceal feature, it is the "\x07" (BELL) - character, and it is hidden by setting 'conceallevel' to 3. If you use - autocommands, make sure none of them change that setting in the NERDTree_* - buffers. + * If your vim is compiled with the +conceal feature, it is the "\x07" + (BEL) character, and it is hidden by setting 'conceallevel' to 2. If you + use autocommands, make sure none of them change that setting in the + NERD_Tree_* buffers. * If your vim does NOT have the +conceal feature and you're using "\u00a0" (non-breaking space) to hide the directory arrows, "\u00b7" (middle dot) is used as the default delimiter. From eed488b1cd1867bd25f19f90e10440c5cc7d6424 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Fri, 29 Oct 2021 00:16:03 -0400 Subject: [PATCH 646/680] Help Wanted Announcement --- README.markdown | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 2de10d6c..6b5d366b 100644 --- a/README.markdown +++ b/README.markdown @@ -1,3 +1,9 @@ +![Help Wanted](http://blog.ncce.org/wp-content/uploads/2013/12/help-wanted.jpg) + +**NERDTree** is on the lookout for a new maintainer. See [issue #1280](https://github.com/preservim/nerdtree/issues/1280) to submit your name for consideration. + +--- + # The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) ## Introduction @@ -183,8 +189,8 @@ nnoremap :NERDTreeMirror:NERDTreeFocus ### How can I change the default arrows? ```vim -let g:NERDTreeDirArrowExpandable = '▸' -let g:NERDTreeDirArrowCollapsible = '▾' +let g:NERDTreeDirArrowExpandable = '?' +let g:NERDTreeDirArrowCollapsible = '?' ``` The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. From fc85a6f07c2cd694be93496ffad75be126240068 Mon Sep 17 00:00:00 2001 From: Rod Elias Date: Mon, 13 Jun 2022 07:10:46 -0300 Subject: [PATCH 647/680] Fix typo in docs (#1306) --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 6b5d366b..27aa3148 100644 --- a/README.markdown +++ b/README.markdown @@ -90,7 +90,7 @@ vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`. ## NERDTree Plugins -NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API and are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. +NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. * [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree. * [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders, From c46e12a886b4a6618a9e834c90f6245952567115 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 Jun 2023 10:30:25 +0300 Subject: [PATCH 648/680] ci: Update vimscript linter workflow with latest GH Action --- .github/workflows/vint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml index 36d72580..68351b1c 100644 --- a/.github/workflows/vint.yml +++ b/.github/workflows/vint.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Run vint with reviewdog - uses: reviewdog/action-vint@v1.0.1 + uses: reviewdog/action-vint@v1 with: github_token: ${{ secrets.github_token }} reporter: github-pr-review From 6895e5259eea5af37556139dd9f7a974e5001041 Mon Sep 17 00:00:00 2001 From: Nick Jensen Date: Sun, 3 Sep 2023 15:29:01 +1200 Subject: [PATCH 649/680] Fix README autocmd suggestion (#1330) --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 27aa3148..2f97d073 100644 --- a/README.markdown +++ b/README.markdown @@ -178,7 +178,7 @@ autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_ ```vim " Open the existing NERDTree on each new tab. -autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif +autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif ``` or change your NERDTree-launching shortcut key like so: ```vim From 1f2e28d4766e661435e423f6dbae62b61a69b7ce Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Sun, 3 Sep 2023 07:15:35 +0330 Subject: [PATCH 650/680] Add horizontal position options to `g:NERDTreeWinPos` (#1363) --- doc/NERDTree.txt | 9 ++++++++- lib/nerdtree/creator.vim | 9 +++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 55c25cd1..a2a7a469 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1128,7 +1128,7 @@ setting is used. ------------------------------------------------------------------------------ *NERDTreeWinPos* -Values: "left" or "right" +Values: "left", "right", "top" or "bottom" Default: "left". This setting is used to determine where NERDTree window is placed on the @@ -1138,6 +1138,13 @@ This setting makes it possible to use two different explorer plugins simultaneously. For example, you could have the taglist plugin on the left of the window and the NERDTree on the right. +When setting this variable to "top" or "bottom" make sure to also change the +|NERDTreeWinSize| to a more reasonable size. + +For example: +> + let g:NERDTreeWinSize = 15 +< ------------------------------------------------------------------------------ *NERDTreeWinSize* Values: a positive integer. diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index b9d45dc9..4dd7a310 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -182,16 +182,17 @@ endfunction " Initialize the NERDTree window. Open the window, size it properly, set all " local options, etc. function! s:Creator._createTreeWin() - let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright ' + let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright ' + let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : '' let l:splitSize = g:NERDTreeWinSize if !g:NERDTree.ExistsForTab() let t:NERDTreeBufName = self._nextBufferName() - silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' + silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new' silent! execute 'edit ' . t:NERDTreeBufName - silent! execute 'vertical resize '. l:splitSize + silent! execute l:splitDirection . ' resize '. l:splitSize else - silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' + silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split' silent! execute 'buffer ' . t:NERDTreeBufName endif From aedd0653adf8ad4088666b0edc56b6b47db1cf37 Mon Sep 17 00:00:00 2001 From: Rafael Monico Date: Fri, 8 Oct 2021 19:47:20 -0300 Subject: [PATCH 651/680] Warn about invalid files not loaded on-load Co-authored-by: rzvxa --- lib/nerdtree/tree_dir_node.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index f5f76829..05d93627 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -421,6 +421,7 @@ function! s:TreeDirNode._initChildren(silent) endif let invalidFilesFound = 0 + let invalidFiles = [] for i in files try let path = g:NERDTreePath.New(i) @@ -428,6 +429,7 @@ function! s:TreeDirNode._initChildren(silent) call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ let invalidFilesFound += 1 + let invalidFiles += [i] endtry endfor @@ -437,7 +439,7 @@ function! s:TreeDirNode._initChildren(silent) call nerdtree#echo('') if invalidFilesFound - call nerdtree#echoWarning(invalidFilesFound . ' file(s) could not be loaded into the NERD tree') + call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', ')) endif return self.getChildCount() endfunction From 32168889bdbc1e7d1d313e3e41c1cc794b38eac5 Mon Sep 17 00:00:00 2001 From: rzvxa Date: Sun, 3 Sep 2023 03:01:39 +0330 Subject: [PATCH 652/680] Warn about invalid files not loaded on-refresh --- lib/nerdtree/tree_dir_node.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 05d93627..6ed1ea84 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -566,6 +566,7 @@ function! s:TreeDirNode.refresh() let files = self._glob('*', 1) + self._glob('.*', 0) let newChildNodes = [] let invalidFilesFound = 0 + let invalidFiles = [] for i in files try "create a new path and see if it exists in this nodes children @@ -582,7 +583,8 @@ function! s:TreeDirNode.refresh() call add(newChildNodes, newNode) endif catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound = 1 + let invalidFilesFound += 1 + let invalidFiles += [i] endtry endfor @@ -591,7 +593,7 @@ function! s:TreeDirNode.refresh() call self.sortChildren() if invalidFilesFound - call nerdtree#echoWarning('some files could not be loaded into the NERD tree') + call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', ')) endif endif endfunction From b1f5bb60df2c78f926ca02bd555c17318e7311b2 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:28:11 +0330 Subject: [PATCH 653/680] Updated CHANGELOG.md, bumped the version to 7.0.0 (#1379) --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e6893a4..2fa753d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,21 @@ PATCH versions are listed from newest to oldest under their respective MAJOR.MINOR version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) + or + - **.PATCH**: + - Pull Request Title 1 (PR Author) [PR Number](Link to PR) + - Pull Request Title 2 (PR Author) [PR Number](Link to PR) + . + . + . + - Pull Request Title n (PR Author) [PR Number](Link to PR) --> +#### 7.0 +- **.0**: + - Now we warn about invalid files instead of ignoring them silently. (rmonico) [#1365](https://github.com/preservim/nerdtree/pull/1365) + - New g:NERDTreeWinPos options for top and bottom. (rzvxa) [#1363](https://github.com/preservim/nerdtree/pull/1363) + - Fix error in README. (nickspoons) [#1330](https://github.com/preservim/nerdtree/pull/1330) + - Fix typo in the documentation. (chapeupreto) [#1306](https://github.com/preservim/nerdtree/pull/1306) #### 6.10 - **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269) - **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266) From 3a66272486083bbafb1b764009a1ba5e4ee684da Mon Sep 17 00:00:00 2001 From: SandeshPyakurel <85491057+SandeshPyakurel@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:39:52 +0545 Subject: [PATCH 654/680] Fixed typo in nerdtree.vim file (#1380) --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index c4197eef..6aae6f28 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -28,7 +28,7 @@ else hi! link NERDTreeNodeDelimiters Ignore endif -"highlighing for directory nodes and file nodes +"highlighting for directory nodes and file nodes syn match NERDTreeDirSlash #/# containedin=NERDTreeDir if g:NERDTreeDirArrowExpandable !=# '' From d69b68bf31fcbd9cb34c275dbc58a79c40dedeae Mon Sep 17 00:00:00 2001 From: Bubu <50858626+BubuDavid@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:48:25 -0600 Subject: [PATCH 655/680] Fix documentation error (#1372) --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2f97d073..eaf401a3 100644 --- a/README.markdown +++ b/README.markdown @@ -170,7 +170,7 @@ autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTa ```vim " If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. -autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | +autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif ``` From c99395a323238cb22c002be239f34fe2b21e7e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=2E=20Kl=C3=B6ckner?= Date: Thu, 19 Oct 2023 09:33:38 -0300 Subject: [PATCH 656/680] New menu command: Change selected node permissions (#1348) --- nerdtree_plugin/fs_menu.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 05bee60d..9f32bf39 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -45,6 +45,7 @@ call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':' if has('unix') || has('osx') call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) + call NERDTreeAddMenuItem({'text': '(C)hange node permissions', 'shortcut':'C', 'callback': 'NERDTreeChangePermissions'}) else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif @@ -333,6 +334,29 @@ function! NERDTreeListNodeWin32() call nerdtree#echo('node not recognized') endfunction +" FUNCTION: NERDTreeChangePermissions() {{{1 +function! NERDTreeChangePermissions() + let l:node = g:NERDTreeFileNode.GetSelected() + let l:prompt = "change node permissions: " + let l:newNodePerm = input(l:prompt) + + if !empty(l:node) + let l:path = l:node.path.str() + let l:cmd = 'chmod ' .. newNodePerm .. ' ' .. path + let l:error = split(system(l:cmd), '\n') + + if !empty(l:error) + call nerdtree#echo(l:error[0]) + endif + + call b:NERDTree.root.refresh() + call b:NERDTree.render() + return + endif + + call nerdtree#echo('node not recognized') +endfunction + " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() let currentNode = g:NERDTreeFileNode.GetSelected() From ea4833da8a2cba8778f3fd88af7b5f7d75878d7b Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:47:01 +0330 Subject: [PATCH 657/680] Added Case Sensitive Move Operation via newly introduced flag `NERDTreeCaseSensitiveFS` (#1375) * Added NERDTreeCaseInsensitiveFS option. * check against g:NERDTreeCaseInsensitiveFS with path.equals method * Fixed issues in comments and added nerdtree#runningMac * Using nerdtree#runningMac instead of manual checks for mac * Better implementation * Updated documentation * Added notice about the flag * Updated the documentation * Added support for g:NERDTreeCaseSensitiveFS = 3 * Better comments * Exported caseSensitiveFS check as a function --- autoload/nerdtree.vim | 38 +++++++++++++++++++++++-- doc/NERDTree.txt | 23 ++++++++++++++++ lib/nerdtree/path.vim | 6 +--- nerdtree_plugin/fs_menu.vim | 55 +++++++++++++++++++++++++++++++------ plugin/NERD_tree.vim | 2 ++ 5 files changed, 108 insertions(+), 16 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index ba708711..1c10ec80 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -198,16 +198,42 @@ function! nerdtree#postSourceActions() abort runtime! nerdtree_plugin/**/*.vim endfunction -"FUNCTION: nerdtree#runningWindows(dir) {{{2 +"FUNCTION: nerdtree#runningWindows() {{{2 function! nerdtree#runningWindows() abort return has('win16') || has('win32') || has('win64') endfunction -"FUNCTION: nerdtree#runningCygwin(dir) {{{2 +"FUNCTION: nerdtree#runningCygwin() {{{2 function! nerdtree#runningCygwin() abort return has('win32unix') endfunction +"FUNCTION: nerdtree#runningMac() {{{2 +function! nerdtree#runningMac() abort + return has('gui_mac') || has('gui_macvim') || has('mac') || has('osx') +endfunction + +" FUNCTION: nerdtree#osDefaultCaseSensitiveFS() {{{2 +function! nerdtree#osDefaultCaseSensitiveFS() abort + return s:osDefaultCaseSensitiveFS +endfunction + +" FUNCTION: nerdtree#caseSensitiveFS() {{{2 +function! nerdtree#caseSensitiveFS() abort + return g:NERDTreeCaseSensitiveFS == 1 || + \((g:NERDTreeCaseSensitiveFS == 2 || g:NERDTreeCaseSensitiveFS == 3) && + \nerdtree#osDefaultCaseSensitiveFS()) +endfunction + +"FUNCTION: nerdtree#pathEquals(lhs, rhs) {{{2 +function! nerdtree#pathEquals(lhs, rhs) abort + if nerdtree#caseSensitiveFS() + return a:lhs ==# a:rhs + else + return a:lhs ==? a:rhs + endif +endfunction + " SECTION: View Functions {{{1 "============================================================ @@ -246,4 +272,12 @@ function! nerdtree#renderView() abort call b:NERDTree.render() endfunction +if nerdtree#runningWindows() + let s:osDefaultCaseSensitiveFS = 0 +elseif nerdtree#runningMac() + let s:osDefaultCaseSensitiveFS = 0 +else + let s:osDefaultCaseSensitiveFS = 1 +endif + " vim: set sw=4 sts=4 et fdm=marker: diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index a2a7a469..161d71d8 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -673,6 +673,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`. |NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. +|NERDTreeCaseSensitiveFS| Tells the NERDTree whether or not it is + running in on a case sensitive file system. + |NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case sensitive or not when sorting nodes. @@ -808,6 +811,26 @@ Default: 3 This setting controls the "sensitivity" of the NERDTree auto centering. See |NERDTreeAutoCenter| for details. +------------------------------------------------------------------------------ + *NERDTreeCaseSensitiveFS* +Values: 0, 1, 2 or 3. +Default: 2. + +If set to 0, the NERDTree will interact with the file system without case +sensitivity. + +If set to 1, the NERDTree will interact with the file system in a case-sensitive +manner. + +If set to 2, the NERDTree assumes its case sensitivity from the OS it is +running on. It Will default to case-insensitive on Windows and macOS +machines and case-sensitive on everything else. Since it's not a foolproof +way of detection, NERDTree won't proceed with any write actions when +the destination is ambiguous. + +Setting it to 3 will perform just like 2, but without suppressing write +actions. + ------------------------------------------------------------------------------ *NERDTreeCaseSensitiveSort* Values: 0 or 1. diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 997abf37..2165c57a 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -554,11 +554,7 @@ endfunction " Args: " path: the other path obj to compare this with function! s:Path.equals(path) - if nerdtree#runningWindows() - return self.str() ==? a:path.str() - else - return self.str() ==# a:path.str() - endif + return nerdtree#pathEquals(self.str(), a:path.str()) endfunction " FUNCTION: Path.New(pathStr) {{{1 diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 9f32bf39..1059b403 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -23,7 +23,7 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if has('gui_mac') || has('gui_macvim') || has('mac') +if nerdtree#runningMac() call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) @@ -149,18 +149,38 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory) let quotedFileName = fnameescape(a:newNodeName) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) endif - " 1. ensure that a new buffer is loaded - call nerdtree#exec('badd ' . quotedFileName, 0) - " 2. ensure that all windows which display the just deleted filename - " display a buffer for a new filename. let s:originalTabNumber = tabpagenr() let s:originalWindowNumber = winnr() - call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 0) + let l:tempBufferName = 'NERDTreeRenameTempBuffer' + + " 1. swap deleted file buffer with a temporary one + " this step is needed to compensate for case insensitive filesystems + + " 1.1. create an intermediate(temporary) buffer + call nerdtree#exec('badd ' . l:tempBufferName, 0) + let l:tempBufNum = bufnr(l:tempBufferName) + " 1.2. ensure that all windows which display the just deleted filename + " display the new temp buffer. + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . l:tempBufferName . "' | endif", 0) + " 1.3. We don't need the deleted file buffer anymore + try + call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) + catch + " This happens when answering Cancel if confirmation is needed. Do nothing. + endtry + + " 2. swap temporary buffer with the new filename buffer + " 2.1. create the actual new file buffer + call nerdtree#exec('badd ' . quotedFileName, 0) + + " 2.2. ensure that all windows which display the temporary buffer + " display a buffer for the new filename. + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . l:tempBufNum . " | exec ':e! " . editStr . "' | endif", 0) call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) - " 3. We don't need a previous buffer anymore + " 2.3. We don't need the temporary buffer anymore try - call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) + call nerdtree#exec('confirm bwipeout ' . l:tempBufNum, 0) catch " This happens when answering Cancel if confirmation is needed. Do nothing. endtry @@ -206,7 +226,24 @@ function! NERDTreeMoveNode() let prompt = s:inputPrompt('move') let newNodePath = input(prompt, curNode.path.str(), 'file') while filereadable(newNodePath) - call nerdtree#echoWarning('This destination already exists. Try again.') + " allow renames with different casing when g:NERDTreeCaseSensitiveFS + " is set to either 0 or 3 and the 2 paths are equal + if (g:NERDTreeCaseSensitiveFS == 0 || g:NERDTreeCaseSensitiveFS == 3) && + \nerdtree#pathEquals(curNode.path.str(), newNodePath) + break + endif + + call nerdtree#echoWarning('This destination already exists, Try again.') + + " inform the user about the flag if we think it is a false positive + " when g:NERDTreeCaseSensitiveFS is set to 2 + if g:NERDTreeCaseSensitiveFS == 2 && + \!nerdtree#osDefaultCaseSensitiveFS() && + \nerdtree#pathEquals(curNode.path.str(), newNodePath) + echon "\n(If it is a false positive please consider assigning NERDTreeCaseSensitiveFS's value)" + endif + + " prompt the user again let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') endwhile diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index ef60cca1..c26842a0 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -29,6 +29,7 @@ set cpoptions&vim "SECTION: Initialize variable calls and other random constants {{{2 let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1) let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3) +let g:NERDTreeCaseSensitiveFS = get(g:, 'NERDTreeCaseSensitiveFS', 2) let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0) let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0) let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1) @@ -53,6 +54,7 @@ let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0 let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0) let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1) + if !nerdtree#runningWindows() && !nerdtree#runningCygwin() let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸') let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾') From 9184ec05bd9def72de1ace14c9421b97f4f858dd Mon Sep 17 00:00:00 2001 From: Kai <57713705+kai-patel@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:28:09 +0100 Subject: [PATCH 658/680] fix: escape directories containing brackets([...]) for globbing (#1359) --- lib/nerdtree/tree_dir_node.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 6ed1ea84..7edc50fa 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -278,6 +278,10 @@ function! s:TreeDirNode._glob(pattern, all) else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') + if nerdtree#runningWindows() + let l:pathSpec = substitute(l:pathSpec, "\\[\\(.*\\]\\)", "[[]\\1", "g") + endif + " On Windows, the drive letter may be removed by "fnamemodify()". if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash() let l:pathSpec = self.path.drive . l:pathSpec From 334542c361bfd250042c6a1ecd147ffcbcc8049a Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:06:13 +0330 Subject: [PATCH 659/680] Added reveal functionality for Windows platform in fs_menu (#1366) * Added reveal functionality for Windows platform * Removed an unnecessary check --- nerdtree_plugin/fs_menu.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 1059b403..2da4c865 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -24,7 +24,7 @@ call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'c call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) if nerdtree#runningMac() - call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Finder', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) endif @@ -35,6 +35,7 @@ if executable('xdg-open') endif if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Explorer', 'shortcut': 'r', 'callback': 'NERDTreeRevealInExplorer'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) endif @@ -514,6 +515,17 @@ function! NERDTreeExecuteFileLinux() call system('xdg-open ' . shellescape(l:node.path.str())) endfunction +" FUNCTION: NERDTreeRevealInExplorer() {{{1 +function! NERDTreeRevealInExplorer() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c explorer /select, ' . shellescape(l:node.path.str())) +endfunction + " FUNCTION: NERDTreeExecuteFileWindows() {{{1 function! NERDTreeExecuteFileWindows() let l:node = g:NERDTreeFileNode.GetSelected() From edc94608596c49279d03f18b58b3de6bc8e9f804 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:13:24 +0330 Subject: [PATCH 660/680] Clarified the NERDTreeChangePermissions prompt (#1381) Co-authored-by: Caleb Maclennan --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 2da4c865..45126dde 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -375,7 +375,7 @@ endfunction " FUNCTION: NERDTreeChangePermissions() {{{1 function! NERDTreeChangePermissions() let l:node = g:NERDTreeFileNode.GetSelected() - let l:prompt = "change node permissions: " + let l:prompt = "change node permissions (chmod args): " let l:newNodePerm = input(l:prompt) if !empty(l:node) From 79f6f912f4e8d1442948e743592bf10e678d0e33 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 24 Oct 2023 22:59:41 +0300 Subject: [PATCH 661/680] chore: Drop over-urgent help wanted poster from readme Help is still welcome and the related issue still pinned, but we have an active contributer with some maintenence priviledges already. Having watched the issue for a while I don't think the 'throw your name in for consideration' is really helping because it attracts people who want the attention but aren't interested in actually jumping in and doing tho *hard* parts of maintaining a project. The glamorious bits are mostly done for this project and the long tail of issue triage and small bug fixes and improvements is long underway. Anyone is welcome to jump into those things, but advertising it as an opening is a) turning people off from using the plugin and b) attracting the wrong kind of applicants. --- README.markdown | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.markdown b/README.markdown index eaf401a3..6312960f 100644 --- a/README.markdown +++ b/README.markdown @@ -1,9 +1,3 @@ -![Help Wanted](http://blog.ncce.org/wp-content/uploads/2013/12/help-wanted.jpg) - -**NERDTree** is on the lookout for a new maintainer. See [issue #1280](https://github.com/preservim/nerdtree/issues/1280) to submit your name for consideration. - ---- - # The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) ## Introduction From ff002d2132dcce9cd514101a166d59d2ebd08f8d Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:20:57 +0330 Subject: [PATCH 662/680] Added case sensivity for refreshing nodes (#1382) --- lib/nerdtree/tree_dir_node.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 7edc50fa..cfda3c42 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -576,7 +576,7 @@ function! s:TreeDirNode.refresh() "create a new path and see if it exists in this nodes children let path = g:NERDTreePath.New(i) let newNode = self.getChild(path) - if newNode !=# {} + if newNode !=# {} && path.str() ==# newNode.path.str() call newNode.refresh() call add(newChildNodes, newNode) From 4c588f182090e01edadeecb127a353cb08d1e39f Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:24:05 +0330 Subject: [PATCH 663/680] Update GitHub PR template (#1383) --- .github/PULL_REQUEST_TEMPLATE.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d2e3b7d4..911f4598 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,18 +5,3 @@ Closes # #### 7.0 +- **.1**: + - Fix NERDTreeFind to handle directory case sensitivity. (dangibson) [#1387](https://github.com/preservim/nerdtree/pull/1387) + - New Show file lines toggle. (hsnks100) [#1384](https://github.com/preservim/nerdtree/pull/1384) + - Add case sensitivity for refreshing nodes. (rzvxa) [#1382](https://github.com/preservim/nerdtree/pull/1382) + - Clarified the NERDTreeChangePermissions prompt. (rzvxa) [#1381](https://github.com/preservim/nerdtree/pull/1381) + - New reveal functionality for Windows. (rzvxa) [#1366](https://github.com/preservim/nerdtree/pull/1366) + - Fix bracket escaping in path names. (kai-patel) [#1359](https://github.com/preservim/nerdtree/pull/1359) + - Fix Case Sensitive Move Operation. (rzvxa) [#1375](https://github.com/preservim/nerdtree/pull/1375) + - New menu command for changing selected node permissions. (mjkloeckner) [#1348](https://github.com/preservim/nerdtree/pull/1348) + - Fix documentation errors. (BubuDavid) [#1372](https://github.com/preservim/nerdtree/pull/1372) + - Fix typo in nerdtree.vim file. (SandeshPyakurel) [#1380](https://github.com/preservim/nerdtree/pull/1380) - **.0**: - Now we warn about invalid files instead of ignoring them silently. (rmonico) [#1365](https://github.com/preservim/nerdtree/pull/1365) - New g:NERDTreeWinPos options for top and bottom. (rzvxa) [#1363](https://github.com/preservim/nerdtree/pull/1363) From a9546618241e61e785aa4c21b3de0cb657f3b828 Mon Sep 17 00:00:00 2001 From: Leo Chung Date: Wed, 20 Dec 2023 23:25:39 +0800 Subject: [PATCH 667/680] fix: typo in nerdtree.txt (#1390) Signed-off-by: Leo Chung --- doc/NERDTree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index fc599767..8393766a 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -605,7 +605,7 @@ Toggles whether the bookmarks table is displayed. ------------------------------------------------------------------------------ *NERDTree-L* Default key: L -Map setting: *NERDTreeMapToggleFileLiness* +Map setting: *NERDTreeMapToggleFileLines* Applies to: no restrictions. Toggles whether the number of lines in files is displayed. From fefea5d3824ce98ff3fc76c2e78c4bc85c7fb516 Mon Sep 17 00:00:00 2001 From: msibal6 <20745877+msibal6@users.noreply.github.com> Date: Fri, 22 Dec 2023 16:17:43 -0800 Subject: [PATCH 668/680] feat: add NERDTreeExplore command. (#1389) * create a explorer command that opens a window tree at specified directory * update CHANGELOG.md * Update CHANGELOG.md * revert CHANGELOG.md * CreateExplorerTree matches :Explore command * prevent empty split when calling NERDTreeExplorer with invalid arg from modified buffer * NERDTreeExplore/CreateExploreTree checks for hidden and autowriteall settings --- autoload/nerdtree/ui_glue.vim | 1 + lib/nerdtree/creator.vim | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index eae817cf..1610d098 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -642,6 +642,7 @@ endfunction function! nerdtree#ui_glue#setupCommands() abort command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') + command! -n=? -complete=dir -bar NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('') command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 4dd7a310..7e1940b8 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -38,6 +38,29 @@ function! s:Creator.BufNamePrefix() return 'NERD_tree_' endfunction +" FUNCTION: s:Creator.CreateExploreTree(dir) {{{1 +function! s:Creator.CreateExploreTree(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('Invalid directory name:' . a:dir) + return + endtry + + let creator = s:Creator.New() + if getbufinfo('%')[0].changed && !&hidden && !&autowriteall + let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright ' + let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : '' + silent! execute l:splitLocation . l:splitDirection . ' new' + else + silent! execute 'enew' + endif + + call creator.createWindowTree(a:dir) + "we want windowTree buffer to disappear after moving to any other buffer + setlocal bufhidden=wipe +endfunction + " FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 function! s:Creator.CreateTabTree(name) let creator = s:Creator.New() From ff9469a14a55d3f40f3c72ea4618a1cc432e49cf Mon Sep 17 00:00:00 2001 From: Rocco Mao Date: Tue, 26 Dec 2023 09:08:17 +0800 Subject: [PATCH 669/680] fix: mapping description in NERDTree.txt (#1393) --- doc/NERDTree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 8393766a..9b8b6ba8 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -287,7 +287,7 @@ I........Toggle whether hidden files displayed......................|NERDTree-I| f........Toggle whether the file filters are used...................|NERDTree-f| F........Toggle whether files are displayed.........................|NERDTree-F| B........Toggle whether the bookmark table is displayed.............|NERDTree-B| -L........Toggle whether the bookmark table is displayed.............|NERDTree-L| +L........Toggle whether the number of lines in files is displayed...|NERDTree-L| q........Close the NERDTree window..................................|NERDTree-q| A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A| From e5599272a95c362bede206ab2dc95bf6dde2b556 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Sun, 31 Dec 2023 12:06:39 +0330 Subject: [PATCH 670/680] chore: bump version to 7.1.0 (#1391) --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5381e59f..fc3edbed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ . - Pull Request Title n (PR Author) [PR Number](Link to PR) --> +#### 7.1 +- **.0**: + - fix: typo in the docs. (bl4kraven) [#1390](https://github.com/preservim/nerdtree/pull/1390) + - feat: add NERDTreeExplore command. (msibal6) [#1389](https://github.com/preservim/nerdtree/pull/1389) + - fix: mapping description in NERDTree.txt. (roccomao) [#1393](https://github.com/preservim/nerdtree/pull/1393) #### 7.0 - **.1**: - Fix NERDTreeFind to handle directory case sensitivity. (dangibson) [#1387](https://github.com/preservim/nerdtree/pull/1387) From aa29fbe481a4603e92240e6b0622aca97348532b Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Mon, 1 Jan 2024 06:37:44 +0330 Subject: [PATCH 671/680] fix: toggle zoom resizing (#1395) Co-authored-by: Daniel Schreck --- lib/nerdtree/ui.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 358a948b..dffdecde 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -532,6 +532,9 @@ endfunction " zoom (maximize/minimize) the NERDTree window function! s:UI.toggleZoom() if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + setlocal nowinfixwidth + wincmd = + setlocal winfixwidth call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1) let b:NERDTreeZoomed = 0 else From 6acfc48d80f83b7c23c4e6f9faa93c3defdb150b Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:55:55 +0330 Subject: [PATCH 672/680] fix: change default binding of filelines to `FL`. (#1400) --- doc/NERDTree.txt | 8 ++++---- plugin/NERD_tree.vim | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 9b8b6ba8..5c0344a7 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -287,7 +287,7 @@ I........Toggle whether hidden files displayed......................|NERDTree-I| f........Toggle whether the file filters are used...................|NERDTree-f| F........Toggle whether files are displayed.........................|NERDTree-F| B........Toggle whether the bookmark table is displayed.............|NERDTree-B| -L........Toggle whether the number of lines in files is displayed...|NERDTree-L| +L........Toggle whether the number of lines in files is displayed..|NERDTree-FL| q........Close the NERDTree window..................................|NERDTree-q| A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A| @@ -603,8 +603,8 @@ Applies to: no restrictions. Toggles whether the bookmarks table is displayed. ------------------------------------------------------------------------------ - *NERDTree-L* -Default key: L + *NERDTree-FL* +Default key: FL Map setting: *NERDTreeMapToggleFileLines* Applies to: no restrictions. @@ -1080,7 +1080,7 @@ Default: 0. If this setting is set to 1 then the NERDTree shows number of lines for each file. -This setting can be toggled dynamically, per tree, with the |NERDTree-L| +This setting can be toggled dynamically, per tree, with the |NERDTree-FL| mapping. Use one of the follow lines for this setting: > let NERDTreeShowFilesLines=0 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a4276701..3e0c9e0f 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -131,7 +131,7 @@ let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B') let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F') let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f') let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I') -let g:NERDTreeMapToggleFileLines = get(g:, 'NERDTreeMapToggleFileLines', 'L') +let g:NERDTreeMapToggleFileLines = get(g:, 'NERDTreeMapToggleFileLines', 'FL') let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') From bc606c43e2d8ef0987d6d3d1ec8c17360a2e29d5 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Tue, 9 Jan 2024 16:53:16 +0330 Subject: [PATCH 673/680] chore: bump version to 7.1.1 (#1401) --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3edbed..ef25435a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ - Pull Request Title n (PR Author) [PR Number](Link to PR) --> #### 7.1 +- **.1**: + - fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400) + - fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395) - **.0**: - fix: typo in the docs. (bl4kraven) [#1390](https://github.com/preservim/nerdtree/pull/1390) - feat: add NERDTreeExplore command. (msibal6) [#1389](https://github.com/preservim/nerdtree/pull/1389) From 60b5e602e95384e6f6d5ba47975b4903c12e2c59 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:07:25 +0330 Subject: [PATCH 674/680] fix: session restore for nerdtree buffers. (#1405) --- autoload/nerdtree.vim | 32 ++++++++++++++++++++++++++++++++ lib/nerdtree/creator.vim | 24 ++++++++++++++++++------ plugin/NERD_tree.vim | 2 +- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 1c10ec80..d7246dc5 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -234,6 +234,38 @@ function! nerdtree#pathEquals(lhs, rhs) abort endif endfunction +"FUNCTION: nerdtree#onBufLeave() {{{2 +" used for handling the nerdtree BufLeave/WinLeave events. +function! nerdtree#onBufLeave() abort + " detect whether we are in the middle of sourcing a session. + " if it is a buffer from the sourced session we need to restore it. + if exists('g:SessionLoad') && !exists('b:NERDTree') + let bname = bufname('%') + " is the buffer for a tab tree? + if bname =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'tab_\d\+$' + " rename loaded buffer and mark it as trash to prevent this event + " getting fired again + exec 'file TRASH_' . bname + " delete the trash buffer + exec 'bwipeout!' + " rescue the tab tree at the current working directory + call g:NERDTreeCreator.CreateTabTree(getcwd()) + " is the buffer for a window tree? + elseif bname =~# '^' . g:NERDTreeCreator.BufNamePrefix(). 'win_\d\+$' + " rescue the window tree at the current working directory + call g:NERDTreeCreator.CreateWindowTree(getcwd()) + else " unknown buffer type + " rename buffer to mark it as broken. + exec 'file BROKEN_' . bname + call nerdtree#echoError('Failed to restore "' . bname . '" from session. Is this session created with an older version of NERDTree?') + endif + else + if g:NERDTree.IsOpen() + call b:NERDTree.ui.saveScreenState() + endif + endif +endfunction + " SECTION: View Functions {{{1 "============================================================ diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 7e1940b8..e794e0d9 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -118,7 +118,7 @@ function! s:Creator.createWindowTree(dir) "we need a unique name for each window tree buffer to ensure they are "all independent - exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName() + exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName('win') call self._createNERDTree(path, 'window') let b:NERDTree._previousBuf = bufnr(previousBuf) @@ -210,7 +210,7 @@ function! s:Creator._createTreeWin() let l:splitSize = g:NERDTreeWinSize if !g:NERDTree.ExistsForTab() - let t:NERDTreeBufName = self._nextBufferName() + let t:NERDTreeBufName = self._nextBufferName('tab') silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new' silent! execute 'edit ' . t:NERDTreeBufName silent! execute l:splitDirection . ' resize '. l:splitSize @@ -244,10 +244,22 @@ function! s:Creator.New() return newCreator endfunction -" FUNCTION: s:Creator._nextBufferName() {{{1 -" returns the buffer name for the next nerd tree -function! s:Creator._nextBufferName() - let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() +" FUNCTION: s:Creator._nextBufferName(type='') {{{1 +" gets an optional buffer type of either 'tab' or 'win'. +" returns the buffer name for the next nerd tree of such type. +function! s:Creator._nextBufferName(...) + if a:0 > 0 + let type = a:1 + else + let type = '' + end + let name = s:Creator.BufNamePrefix() + if type ==# 'tab' + let name = name . 'tab_' + elseif type ==# 'win' + let name = name . 'win_' + endif + let name = name . self._nextBufferNumber() return name endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 3e0c9e0f..73085d01 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -151,7 +151,7 @@ call nerdtree#ui_glue#setupCommands() "============================================================ augroup NERDTree "Save the cursor position whenever we close the nerd tree - exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif' + exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* call nerdtree#onBufLeave()' "disallow insert mode in the NERDTree exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert' From bdf81a086dd271571104a11f555b79e5cdff5dc5 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:27:41 +0330 Subject: [PATCH 675/680] fix: GetWinNum regex pattern. (#1409) --- lib/nerdtree/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index 61a11a96..1af5346a 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -144,7 +144,7 @@ function! s:NERDTree.GetWinNum() " If WindowTree, there is no t:NERDTreeBufName variable. Search all windows. for w in range(1,winnr('$')) - if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'win_\d\+$' return w endif endfor From f3a4d8eaa8ac10305e3d53851c976756ea9dc8e8 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:20:59 +0330 Subject: [PATCH 676/680] chore: bump version to 7.1.2. (#1410) --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef25435a..791c9bf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ - Pull Request Title n (PR Author) [PR Number](Link to PR) --> #### 7.1 +- **.2**: + - fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409) + - fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405) - **.1**: - fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400) - fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395) From 6ad85ec29b4b0f890ff5733f66d8d4acbdf16a00 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Mon, 13 May 2024 11:52:13 +0330 Subject: [PATCH 677/680] feat: jump to bookmark table shortcut. (#1394) Co-authored-by: Daniel Schreck --- autoload/nerdtree/ui_glue.vim | 16 ++++++++++++++++ lib/nerdtree/ui.vim | 15 +++++++++++---- plugin/NERD_tree.vim | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 1610d098..c5c96181 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -70,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' }) @@ -496,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort call b:NERDTree.ui.centerView() endfunction +" FUNCTION: s:jumpToBookmarks() {{{1 +" moves the cursor to the bookmark table +function! s:jumpToBookmarks() abort + try + if b:NERDTree.ui.getShowBookmarks() + call g:NERDTree.CursorToBookmarkTable() + else + call b:NERDTree.ui.setShowBookmarks(1) + endif + catch /^NERDTree/ + call nerdtree#echoError('Failed to jump to the bookmark table') + return + endtry +endfunction + " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 " Open the Bookmark that has the specified name. This function provides the " implementation for the :OpenBookmark command. diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index dffdecde..867e04b1 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -62,6 +62,7 @@ function! s:UI._dumpHelp() let help .= "\"\n\" ----------------------------\n" let help .= "\" Bookmark table mappings~\n" let help .= "\" double-click,\n" + let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n" let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n" let help .= '" '. g:NERDTreeMapPreview .": preview file\n" let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" @@ -482,10 +483,10 @@ function! s:UI.toggleIgnoreFilter() call self.centerView() endfunction -" FUNCTION: s:UI.toggleShowBookmarks() {{{1 -" Toggle the visibility of the Bookmark table. -function! s:UI.toggleShowBookmarks() - let self._showBookmarks = !self._showBookmarks +" FUNCTION: s:UI.setShowBookmarks() {{{1 +" Sets the visibility of the Bookmark table. +function! s:UI.setShowBookmarks(value) + let self._showBookmarks = a:value if self.getShowBookmarks() call self.nerdtree.render() @@ -503,6 +504,12 @@ function! s:UI.toggleShowBookmarks() call self.centerView() endfunction +" FUNCTION: s:UI.toggleShowBookmarks() {{{1 +" Toggle the visibility of the Bookmark table. +function! s:UI.toggleShowBookmarks() + call self.setShowBookmarks(!self._showBookmarks) +endfunction + " FUNCTION: s:UI.toggleShowFiles() {{{1 " toggles the display of hidden files function! s:UI.toggleShowFiles() diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 73085d01..84c04fda 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -101,6 +101,7 @@ endif "SECTION: Init variable calls for key mappings {{{2 let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '') +let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb') let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o') let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C') let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd') From fbb71fcd90602e3ec77f40b864b5f9b437c496c5 Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Tue, 14 May 2024 19:09:02 +0330 Subject: [PATCH 678/680] docs: update FAQ snippets containing `quit` command. (#1417) --- README.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.markdown b/README.markdown index 210ec312..93a844a5 100644 --- a/README.markdown +++ b/README.markdown @@ -150,6 +150,24 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in ### How can I close Vim or a tab automatically when NERDTree is the last window? +Because of the changes in how Vim handles its `autocmd` and layout locking `quit` command is no longer available in Vim9 auto commands, Depending on which version you're running select one of these solutions. + +__NeoVim users should be able to choose either one of them!__ + +#### Vim9 + +```vim +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\:\") | endif +``` +--- +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\:\") | endif +``` + +#### Vim8 or older + ```vim " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif From 09aec2cfca93c34fd4871bc6ebf7bd499abe55bf Mon Sep 17 00:00:00 2001 From: Lothar Droppelmann <48971777+lothardp@users.noreply.github.com> Date: Sat, 20 Jul 2024 00:50:24 -0400 Subject: [PATCH 679/680] fix: typo in docs for show file lines setting (#1426) Co-authored-by: Lothar Droppelmann --- doc/NERDTree.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 5c0344a7..f8a1fdc1 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -1073,7 +1073,7 @@ mapping and is useful for drastically shrinking the tree when you are navigating to a different part of the tree. ------------------------------------------------------------------------------ - *NERDTreeShowFilesLines* + *NERDTreeFileLines* Values: 0 or 1. Default: 0. @@ -1083,8 +1083,8 @@ file. This setting can be toggled dynamically, per tree, with the |NERDTree-FL| mapping. Use one of the follow lines for this setting: > - let NERDTreeShowFilesLines=0 - let NERDTreeShowFilesLines=1 + let NERDTreeFileLines=0 + let NERDTreeFileLines=1 < ------------------------------------------------------------------------------ *NERDTreeShowHidden* From 9b465acb2745beb988eff3c1e4aa75f349738230 Mon Sep 17 00:00:00 2001 From: rzvxa <3788964+rzvxa@users.noreply.github.com> Date: Sat, 20 Jul 2024 08:31:16 +0330 Subject: [PATCH 680/680] chore: bump version to 7.1.3. (#1414) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 791c9bf4..ba25bf16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ - Pull Request Title n (PR Author) [PR Number](Link to PR) --> #### 7.1 +- **.3**: + - docs: update FAQ snippets containing quit command. (rzvxa) [#1417](https://github.com/preservim/nerdtree/pull/1417) + - feat: jump to bookmark table shortcut. (ds2606, rzvxa) [#1394](https://github.com/preservim/nerdtree/pull/1394) + - fix: typo in docs for show file lines setting. (lothardp) [#1426](https://github.com/preservim/nerdtree/pull/1426) - **.2**: - fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409) - fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405)