From 862ce06a78909438f39b3b71081629ce054d4bb9 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 5 Jul 2018 01:18:24 -0400 Subject: [PATCH 01/17] Use a delimiter in node to separate file/dir name from the rest. --- lib/nerdtree/path.vim | 8 ++++---- lib/nerdtree/tree_dir_node.vim | 2 +- lib/nerdtree/tree_file_node.vim | 2 +- lib/nerdtree/ui.vim | 13 ++++++++----- plugin/NERD_tree.vim | 3 +++ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2d8de23c..74840c4b 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -46,7 +46,7 @@ function! s:Path.cacheDisplayString() abort let self.cachedDisplayString = self.getLastPathComponent(1) if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . '*' + let self.cachedDisplayString = self.cachedDisplayString . g:NERDTreeNodeDelimiter.'*' endif let self._bookmarkNames = [] @@ -56,15 +56,15 @@ function! s:Path.cacheDisplayString() abort endif endfor if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 - let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' + let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'{' . join(self._bookmarkNames) . '}' endif if self.isSymLink - let self.cachedDisplayString .= ' -> ' . self.symLinkDest + let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'-> ' . self.symLinkDest endif if self.isReadOnly - let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' + let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'['.g:NERDTreeGlyphReadOnly.']' endif endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 03c3545b..3f5aa59c 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -111,7 +111,7 @@ function! s:TreeDirNode.displayString() let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . l:label + let l:result = l:symbol . ' ' . l:flags . g:NERDTreeNodeDelimiter . l:label return l:result endfunction diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 3ad9fcb6..ffef0343 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -86,7 +86,7 @@ endfunction " 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() + return self.path.flagSet.renderToString() . g:NERDTreeNodeDelimiter . self.path.displayString() endfunction " FUNCTION: TreeFileNode.equals(treenode) {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 68a72b68..fd204f4c 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -372,18 +372,21 @@ function! s:UI._stripMarkup(line) let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","") " strip off any read only flag - let line = substitute (line, ' \['.g:NERDTreeGlyphReadOnly.'\]', "","") + let line = substitute (line, g:NERDTreeNodeDelimiter.'\['.g:NERDTreeGlyphReadOnly.'\]', "","") " strip off any bookmark flags - let line = substitute (line, ' {[^}]*}', "","") + let line = substitute (line, g:NERDTreeNodeDelimiter.'{[^}]*}', "","") " strip off any executable flags - let line = substitute (line, '*\ze\($\| \)', "","") + let line = substitute (line, '*\ze\('.g:NERDTreeNodeDelimiter.'$\| \)', "","") " strip off any generic flags - let line = substitute (line, '\[[^]]*\]', "","") + let line = substitute (line, '\[[^]]*\]'.g:NERDTreeNodeDelimiter, "","") - let line = substitute (line,' -> .*',"","") " remove link to + let line = substitute (line,g:NERDTreeNodeDelimiter.'-> .*',"","") " remove link to + + " strip off any leading delimiter + let line = substitute (line, '^'.g:NERDTreeNodeDelimiter, "","") return line endfunction diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 35b47c38..c4031d9a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -90,6 +90,9 @@ endif 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 From 2e55ceaf1d20e8a546f9d3b1b42c82cd4d0ab323 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 30 Jul 2018 09:18:45 -0400 Subject: [PATCH 02/17] Switch warning message to use nerdtree#deprecated function. --- 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 ffef0343..79affe55 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -270,7 +270,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 From a5ed6e2ca7ebba845859a2e054d87245966044c3 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 30 Jul 2018 09:19:47 -0400 Subject: [PATCH 03/17] Compress the space between the tree symbols and the node. --- 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 3f5aa59c..be61c9d8 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -111,7 +111,7 @@ function! s:TreeDirNode.displayString() let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . g:NERDTreeNodeDelimiter . l:label + let l:result = l:symbol . l:flags . g:NERDTreeNodeDelimiter . l:label return l:result endfunction From 0c4834bcff0b2274e05532a20055c365681144f1 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 30 Jul 2018 09:21:27 -0400 Subject: [PATCH 04/17] Include the delimiter when calculating indent or getting filename. --- lib/nerdtree/ui.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index fd204f4c..6bba7005 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -275,7 +275,7 @@ 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.']') + let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.g:NERDTreeNodeDelimiter.']') " 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')) @@ -299,7 +299,9 @@ endfunction " FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() - return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)' + return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']'.g:NERDTreeNodeDelimiter. + \ '\| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']'.g:NERDTreeNodeDelimiter. + \ '\| \+'.g:NERDTreeNodeDelimiter.'\?\)' endfunction " FUNCTION: s:UI._renderBookmarks {{{1 From 0aa80e14e6ae394b06d486aa462fb49d5670ffb9 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 30 Jul 2018 09:23:33 -0400 Subject: [PATCH 05/17] Don't need to strip leading delimiter. It will already be gone. --- lib/nerdtree/ui.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 6bba7005..5c6dc0c4 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -385,10 +385,8 @@ function! s:UI._stripMarkup(line) " strip off any generic flags let line = substitute (line, '\[[^]]*\]'.g:NERDTreeNodeDelimiter, "","") - let line = substitute (line,g:NERDTreeNodeDelimiter.'-> .*',"","") " remove link to - - " strip off any leading delimiter - let line = substitute (line, '^'.g:NERDTreeNodeDelimiter, "","") + " strip off link to target file + let line = substitute (line,g:NERDTreeNodeDelimiter.'-> .*',"","") return line endfunction From e44edbcbff345a74fa338cf43ff0e8e1c4c9365d Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sat, 4 Aug 2018 13:44:03 -0400 Subject: [PATCH 06/17] 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. --- lib/nerdtree/path.vim | 10 +++++----- lib/nerdtree/tree_dir_node.vim | 2 +- lib/nerdtree/tree_file_node.vim | 2 +- lib/nerdtree/ui.vim | 29 ++++------------------------- plugin/NERD_tree.vim | 2 +- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 74840c4b..31ac2a95 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -43,10 +43,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) . g:NERDTreeNodeDelimiter if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . g:NERDTreeNodeDelimiter.'*' + let self.cachedDisplayString = self.cachedDisplayString . '*' endif let self._bookmarkNames = [] @@ -56,15 +56,15 @@ function! s:Path.cacheDisplayString() abort endif endfor if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 - let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'{' . join(self._bookmarkNames) . '}' + let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' endif if self.isSymLink - let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'-> ' . self.symLinkDest + let self.cachedDisplayString .= ' -> ' . self.symLinkDest endif if self.isReadOnly - let self.cachedDisplayString .= g:NERDTreeNodeDelimiter.'['.g:NERDTreeGlyphReadOnly.']' + let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' endif endfunction diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index be61c9d8..03c3545b 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -111,7 +111,7 @@ function! s:TreeDirNode.displayString() let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . l:flags . g:NERDTreeNodeDelimiter . l:label + let l:result = l:symbol . ' ' . l:flags . l:label return l:result endfunction diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index 79affe55..194a48c9 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -86,7 +86,7 @@ endfunction " Return: " a string that can be used in the view to represent this node function! s:TreeFileNode.displayString() - return self.path.flagSet.renderToString() . g:NERDTreeNodeDelimiter . self.path.displayString() + return self.path.flagSet.renderToString() . self.path.displayString() endfunction " FUNCTION: TreeFileNode.equals(treenode) {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5c6dc0c4..02e66469 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -275,7 +275,7 @@ 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.g:NERDTreeNodeDelimiter.']') + 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')) @@ -299,9 +299,7 @@ endfunction " FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() - return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']'.g:NERDTreeNodeDelimiter. - \ '\| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']'.g:NERDTreeNodeDelimiter. - \ '\| \+'.g:NERDTreeNodeDelimiter.'\?\)' + return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.' ] ' endfunction " FUNCTION: s:UI._renderBookmarks {{{1 @@ -364,31 +362,12 @@ 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:NERDTreeNodeDelimiter.'\['.g:NERDTreeGlyphReadOnly.'\]', "","") - - " strip off any bookmark flags - let line = substitute (line, g:NERDTreeNodeDelimiter.'{[^}]*}', "","") - - " strip off any executable flags - let line = substitute (line, '*\ze\('.g:NERDTreeNodeDelimiter.'$\| \)', "","") - - " strip off any generic flags - let line = substitute (line, '\[[^]]*\]'.g:NERDTreeNodeDelimiter, "","") - - " strip off link to target file - let line = substitute (line,g:NERDTreeNodeDelimiter.'-> .*',"","") - - return line + return substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter . '\(.*\)' . g:NERDTreeNodeDelimiter . '.*', '\1', '') endfunction " FUNCTION: s:UI.render() {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index c4031d9a..595a8bbb 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -91,7 +91,7 @@ endif 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") +call s:initVariable("g:NERDTreeNodeDelimiter", "\u00a0") if !exists('g:NERDTreeStatusline') From 682ab859d9890845ee7561b899c70c97d293dce2 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Sat, 4 Aug 2018 13:58:09 -0400 Subject: [PATCH 07/17] Add syntax highlighting to conceal the delimiter --- syntax/nerdtree.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7c80605c..a703bb45 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -35,6 +35,8 @@ exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir +exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeDir' +setlocal conceallevel=2 concealcursor=nvic syn match NERDTreeCWD #^[ Date: Sat, 4 Aug 2018 14:00:42 -0400 Subject: [PATCH 08/17] Put a if has("conceal") check around the syntax statement using it. --- syntax/nerdtree.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index a703bb45..73e9c63f 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -35,8 +35,12 @@ exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir -exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeDir' -setlocal conceallevel=2 concealcursor=nvic + +"highlighing to conceal the delimiter around the file/dir name +if has("conceal") + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeDir' + setlocal conceallevel=2 concealcursor=nvic +endif syn match NERDTreeCWD #^[ Date: Sat, 4 Aug 2018 17:52:19 -0400 Subject: [PATCH 09/17] Make concealment work correctly for LinkFile and readonly files. --- syntax/nerdtree.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 73e9c63f..f79228c7 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -38,7 +38,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,NERDTreeDir' + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' setlocal conceallevel=2 concealcursor=nvic endif From 0af0ac42c0174cdb32c26ec4c406eb3d5e833af6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 6 Aug 2018 21:50:24 -0400 Subject: [PATCH 10/17] 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. --- syntax/nerdtree.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index f79228c7..a1540558 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -40,6 +40,9 @@ syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir if has("conceal") exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# conceal containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' setlocal conceallevel=2 concealcursor=nvic +else + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' + hi! link NERDTreeNodeDelimiters Ignore endif syn match NERDTreeCWD #^[ Date: Wed, 8 Aug 2018 09:59:31 -0400 Subject: [PATCH 11/17] Make the regex better match the original, but more compact. It was allowing 2+ spaces, instead of only 1+. --- 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 e42fce54..43683112 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -299,7 +299,7 @@ endfunction " FUNCTION: s:UI.MarkupReg() {{{1 function! s:UI.MarkupReg() - return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.' ] ' + return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']\? ' endfunction " FUNCTION: s:UI._renderBookmarks {{{1 From 8cf55d94f36b13233bc0cff3c16cc4ca6db9e231 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 20 Aug 2018 09:34:54 -0400 Subject: [PATCH 12/17] Fix the syntax highlighing of delimiters around NERDTreeExecFile. --- syntax/nerdtree.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index a1540558..dddce6d3 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,NERDTreeRO,NERDTreeDir' + 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,NERDTreeRO,NERDTreeDir' + exec 'syn match NERDTreeNodeDelimiters #' . g:NERDTreeNodeDelimiter . '# containedin=NERDTreeFile,NERDTreeLinkFile,NERDTreeExecFile,NERDTreeRO,NERDTreeDir' hi! link NERDTreeNodeDelimiters Ignore endif From c5cbe60c449cc86c224dea875bc77f1c3cc12a6f Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 20 Aug 2018 10:18:34 -0400 Subject: [PATCH 13/17] Bug fix: Parse . and .. from path string with trailing slash. --- 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 30db853f..25138116 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -278,9 +278,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 e1af7a314bb7877d11d758953320aa959004eb68 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 10 Sep 2018 07:11:57 -0400 Subject: [PATCH 14/17] Fix unresponsive cascaded directories. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/). --- 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 43683112..042742fe 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -367,7 +367,8 @@ endfunction " Args: " line: the subject line function! s:UI._stripMarkup(line) - return substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter . '\(.*\)' . g:NERDTreeNodeDelimiter . '.*', '\1', '') + let line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter . '\(.*\)' . g:NERDTreeNodeDelimiter . '.*', '\1', '') + return substitute(line, g:NERDTreeNodeDelimiter, '', 'g') endfunction " FUNCTION: s:UI.render() {{{1 From d64fb3b3a1a57baad16fd7247fe690fea32e4448 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 18 Oct 2018 09:33:15 -0400 Subject: [PATCH 15/17] Use .= to shorten statement. Use clearer substitutes to get node name. --- lib/nerdtree/path.vim | 2 +- lib/nerdtree/ui.vim | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index fce96189..2a2c10dc 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -42,7 +42,7 @@ function! s:Path.cacheDisplayString() abort let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) . g:NERDTreeNodeDelimiter if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . '*' + let self.cachedDisplayString .= '*' endif let self._bookmarkNames = [] diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index b1983a19..cb78cc79 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -368,8 +368,9 @@ endfunction " Args: " line: the subject line function! s:UI._stripMarkup(line) - let line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter . '\(.*\)' . g:NERDTreeNodeDelimiter . '.*', '\1', '') - return substitute(line, g:NERDTreeNodeDelimiter, '', 'g') + let l:line = substitute(a:line, g:NERDTreeNodeDelimiter . '\{2}', '', '') + let l:line = substitute(l:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '') + return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '') endfunction " FUNCTION: s:UI.render() {{{1 From 18a148e83806e9be273fadbf21c68c23b34241e6 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 18 Oct 2018 19:18:37 -0400 Subject: [PATCH 16/17] 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. --- lib/nerdtree/path.vim | 10 +++++----- lib/nerdtree/tree_dir_node.vim | 3 ++- lib/nerdtree/ui.vim | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 2a2c10dc..db77725c 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 = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) . g:NERDTreeNodeDelimiter + let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) if self.isExecutable - let self.cachedDisplayString .= '*' + let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . '*' endif let self._bookmarkNames = [] @@ -52,15 +52,15 @@ function! s:Path.cacheDisplayString() abort endif endfor if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks == 1 - let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' + let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' {' . join(self._bookmarkNames) . '}' endif if self.isSymLink - let self.cachedDisplayString .= ' -> ' . self.symLinkDest + let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' -> ' . self.symLinkDest endif if self.isReadOnly - let self.cachedDisplayString .= ' ['.g:NERDTreeGlyphReadOnly.']' + let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' ['.g:NERDTreeGlyphReadOnly.']' 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/ui.vim b/lib/nerdtree/ui.vim index cb78cc79..32d96d9b 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -368,8 +368,7 @@ endfunction " Args: " line: the subject line function! s:UI._stripMarkup(line) - let l:line = substitute(a:line, g:NERDTreeNodeDelimiter . '\{2}', '', '') - let l:line = substitute(l:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '') + let l:line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '') return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '') endfunction From e37ba2ba76b63ebdbe64b3cf0303eb86122ec602 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Thu, 18 Oct 2018 23:18:50 -0400 Subject: [PATCH 17/17] DRY up the addition of the 2nd delimiter, and use only 1 for all tags. --- lib/nerdtree/path.vim | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index db77725c..20d7b681 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -42,7 +42,7 @@ function! s:Path.cacheDisplayString() abort let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) if self.isExecutable - let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . '*' + 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 .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' {' . join(self._bookmarkNames) . '}' + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' endif if self.isSymLink - let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' -> ' . self.symLinkDest + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest endif if self.isReadOnly - let self.cachedDisplayString .= (self.cachedDisplayString =~ g:NERDTreeNodeDelimiter.'$' ? '' : g:NERDTreeNodeDelimiter) . ' ['.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