From 26333ceeabaa6770475fd0d80c47c0ff585c898f Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 3 Feb 2020 01:58:00 -0500 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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