Compare commits

...

37 Commits
6.4.2 ... 6.7.5

Author SHA1 Message Date
Phil Runninger
2d7cb043d4 Prevent unneeded tree creation in :NERDTreeToggle[VCS] <path> (#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.
2020-04-13 17:05:27 -04:00
lifecrisis
f767dd34a0 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: 56cfbcff1e

* Improve "g:NERDTreeExecuteFile()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeRevealFileLinux()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeExecuteFileLinux()"

Refer to: 56cfbcff1e

* 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...
2020-04-09 21:37:55 -04:00
Rolando
832bbaa729 Fix vsplit to not open empty buffer (#1098)
* Fix vsplit to not open empty buffer

* Add changelog entry
2020-04-01 01:21:37 -04:00
Eugenij
343508e9fd 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 <PhilRunninger@users.noreply.github.com>

Co-authored-by: evgenij.vidershpan <evgenij.vidershpan@yandex.ru>
Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
2020-03-26 16:33:11 -04:00
Phil Runninger
495b4e781a 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 <prunninger@vhtcx.com>
2020-03-24 15:08:06 -04:00
Phil Runninger
e67324fdea Merge pull request #1090 from bouk/open-on-find-unsaved-file
Open the parent directory when revealing a non-existent file
2020-02-20 09:10:19 -05:00
Bouke van der Bijl
5249b30fbf Use single-quoted string to comply with styleguide 2020-02-20 10:50:15 +01:00
Bouke van der Bijl
09b165cfac Add changelog entry 2020-02-20 10:49:03 +01:00
Bouke van der Bijl
6224d20698 Open the parent directory when revealing a non-existent file
Right now it just reveals the directory but leaves it closed.

Related to #1043
2020-02-20 10:45:09 +01:00
Phil Runninger
07612557eb Give kazukazuinaina proper credit. 2020-02-07 14:11:00 -05:00
Phil Runninger
7a0312f492 Merge pull request #1087 from kazukazuinaina/add_dein_in_README
[add] How to install using dein.vim
2020-02-07 14:00:12 -05:00
kazukazuinaina
41a44be8d5 [add] How to install using dein.vim
update changelog
2020-02-08 03:45:28 +09:00
Phil Runninger
85103aa607 Merge pull request #1085 from preservim/i1064
Add the ability to turn off directory arrows
2020-02-06 18:21:00 -05:00
Phil Runninger
1f5018dc45 Update version number in change log. 2020-02-06 17:43:46 -05:00
Phil Runninger
d706f40ae7 Update the documentation/README. 2020-02-06 13:01:04 -05:00
Phil Runninger
e41dd019d9 Reorder syntax statements to fix highlighting. 2020-02-05 15:09:24 -05:00
Phil Runninger
2388af7754 WIP: A better regex for NERDTreeExecFile. Still not all right. 2020-02-04 02:08:08 -05:00
Phil Runninger
c3d7c141bb Simplify and make similar statements more similarer 2020-02-03 09:30:08 -05:00
Phil Runninger
450abd1820 Fix indentLevelFor(), which was getting the right answer the wrong way. 2020-02-03 08:00:06 -05:00
Phil Runninger
6d3743549c Fix vint errors: Use robust operators ==# and !=# 2020-02-03 02:28:53 -05:00
Phil Runninger
961c3571c4 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.
2020-02-03 01:59:41 -05:00
Phil Runninger
26333ceeab If arrows are empty strings, don't print their trailing spaces. 2020-02-03 01:58:00 -05:00
Phil Runninger
8c48845d11 Merge pull request #1083 from preservim/1076
NERDTree <start-directory> always sets NERDTree root.
2020-01-28 03:59:24 -05:00
Phil Runninger
b16553ac54 Update pull request number in change log. 2020-01-28 03:57:50 -05:00
Phil Runninger
e48b5728f9 NERDTree <start-directory> always sets NERDTree root. 2020-01-28 03:55:58 -05:00
Phil Runninger
f7b09634ba Fix typo in version number. 2020-01-28 03:20:07 -05:00
Phil Runninger
c2c4a6564f Merge pull request #1081 from andys8/bugfix/1059-fails-with-vim-startify
[BUGFIX] Shows error for empty filenames (vim-startify)
2020-01-27 20:37:47 -05:00
andys8
881c265438 [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
2020-01-20 15:05:47 +01:00
Phil Runninger
26740d1157 Merge pull request #1080 from preservim/restore_eventignore_in_finally_block
Ensure events are (or aren't) being ignored correctly.
2020-01-16 13:29:33 -05:00
Phil Runninger
6d5e185cef Update version in change log. 2020-01-16 13:25:57 -05:00
Phil Runninger
3a3636b7cb Don't ignore events when opening renamed files. 2020-01-16 11:17:33 -05:00
Phil Runninger
5fbf0d7dba Put the eventignore reset inside a finally block to ensure it's called. 2020-01-16 10:51:12 -05:00
Phil Runninger
901aba632b Merge pull request #1079 from preservim/1078
Prevent overwriting existing files/dirs on node move. (m-m)
2020-01-15 19:55:31 -05:00
Phil Runninger
a046ba5c5b Update version number in change log. 2020-01-15 19:54:06 -05:00
Phil Runninger
97e4b47aa3 Prevent overwriting existing files/dirs on node move. (m-m) 2020-01-15 19:51:39 -05:00
Phil Runninger
ee79ecfb67 Merge pull request #1075 from preservim/1073
Fix regex that finds keyword for minimal menu.
2020-01-06 09:21:11 -05:00
Phil Runninger
b579c7751d Fix regex that finds keyword for minimal menu. 2020-01-06 09:19:25 -05:00
15 changed files with 159 additions and 87 deletions

View File

@@ -1,13 +1,26 @@
# NERDTree Change Log # NERDTree Change Log
<!-- Introduce a new MAJOR or MINOR version with a 4-hash header.
<!-- PATCH versions are listed from newest to oldest under their respective MAJOR.MINOR
Introduce a new MAJOR.MINOR version with a 4-hash header. version in an unordered list. The format is:
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) - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
--> -->
#### 6.7
- **.5**: Prevent unneeded tree creation in :NERDTreeToggle[VCS] <path> (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)
- **.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)
- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085)
#### 6.5
- **.0**: `NERDTreeToggle <start-directory>` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083)
#### 6.4 #### 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)
- **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) - **.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) - **.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) - **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/preservim/nerdtree/pull/1067)

View File

@@ -59,6 +59,13 @@ Plug 'preservim/nerdtree'
call plug#end() 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) #### [apt-vim](https://github.com/egalpin/apt-vim)
```bash ```bash
apt-vim install -y https://github.com/preservim/nerdtree.git apt-vim install -y https://github.com/preservim/nerdtree.git
@@ -143,3 +150,8 @@ Use these variables in your vimrc. Note that below are default arrow symbols
let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾' 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 = ''
```

View File

@@ -169,8 +169,11 @@ function! nerdtree#exec(cmd, ignoreAll) abort
if a:ignoreAll if a:ignoreAll
set eventignore=all set eventignore=all
endif endif
exec a:cmd try
let &eventignore = old_ei exec a:cmd
finally
let &eventignore = old_ei
endtry
endfunction endfunction
" FUNCTION: nerdtree#has_opt(options, name) {{{2 " FUNCTION: nerdtree#has_opt(options, name) {{{2

View File

@@ -284,15 +284,18 @@ endfunction
" FUNCTION: s:findAndRevealPath(pathStr) {{{1 " FUNCTION: s:findAndRevealPath(pathStr) {{{1
function! s:findAndRevealPath(pathStr) abort function! s:findAndRevealPath(pathStr) abort
let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p')
if !filereadable(l:pathStr) let l:revealOpts = {}
let l:pathStr = fnamemodify(l:pathStr, ':h')
endif
if empty(l:pathStr) if empty(l:pathStr)
call nerdtree#echoWarning('no file for the current buffer') call nerdtree#echoWarning('no file for the current buffer')
return return
endif endif
if !filereadable(l:pathStr)
let l:pathStr = fnamemodify(l:pathStr, ':h')
let l:revealOpts['open'] = 1
endif
try try
let l:pathStr = g:NERDTreePath.Resolve(l:pathStr) let l:pathStr = g:NERDTreePath.Resolve(l:pathStr)
let l:pathObj = g:NERDTreePath.New(l:pathStr) let l:pathObj = g:NERDTreePath.New(l:pathStr)
@@ -326,7 +329,7 @@ function! s:findAndRevealPath(pathStr) abort
call b:NERDTree.ui.setShowHidden(1) call b:NERDTree.ui.setShowHidden(1)
endif 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 b:NERDTree.render()
call l:node.putCursorHere(1, 0) call l:node.putCursorHere(1, 0)
endfunction endfunction

View File

@@ -122,8 +122,9 @@ The following features and functionality are provided by the NERDTree:
:NERDTreeToggle [<start-directory> | <bookmark>] *:NERDTreeToggle* :NERDTreeToggle [<start-directory> | <bookmark>] *:NERDTreeToggle*
If a NERDTree already exists for this tab, it is reopened and rendered 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 again. If <start-directory> or <bookmark> is given, the root of NERDTree
same as the |:NERDTree| command. is set to that path. If no NERDTree exists for this tab then this command
acts the same as the |:NERDTree| command.
:NERDTreeToggleVCS [<start-directory> | <bookmark>] *:NERDTreeToggleVCS* :NERDTreeToggleVCS [<start-directory> | <bookmark>] *:NERDTreeToggleVCS*
Like |:NERDTreeToggle|, but searches up the directory tree to find the top of Like |:NERDTreeToggle|, but searches up the directory tree to find the top of
@@ -1222,13 +1223,19 @@ Values: Any single character.
Defaults: Windows: ~ and + Others: ▾ and ▸ Defaults: Windows: ~ and + Others: ▾ and ▸
These characters indicate whether a directory is collapsible or expandable. These characters indicate whether a directory is collapsible or expandable.
Example: >
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 NERDTreeDirArrowExpandable=">"
let NERDTreeDirArrowCollapsible="v" 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* *NERDTreeNodeDelimiter*
Values: Any single character. Values: Any single character.

View File

@@ -333,14 +333,17 @@ function! s:Creator._tabpagevar(tabnr, var)
let old_ei = &eventignore let old_ei = &eventignore
set eventignore=all set eventignore=all
exec 'tabnext ' . a:tabnr try
let v = -1 exec 'tabnext ' . a:tabnr
if exists('t:' . a:var) let v = -1
exec 'let v = t:' . a:var if exists('t:' . a:var)
endif exec 'let v = t:' . a:var
exec 'tabnext ' . currentTab endif
exec 'tabnext ' . currentTab
let &eventignore = old_ei finally
let &eventignore = old_ei
endtry
return v return v
endfunction endfunction
@@ -352,17 +355,20 @@ function! s:Creator.ToggleTabTree(dir)
endfunction endfunction
" FUNCTION: s:Creator.toggleTabTree(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 " 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 it doesnt exist) " closed, it is restored or initialized. If dir is not empty, it will be set
" as the new root.
" "
" Args: " Args:
" dir: the full path for the root node (is only used if the NERD tree is being " dir: the full path for the root node (is used if the NERD tree is being
" initialized. " initialized, or to change the root to a new dir.)
function! s:Creator.toggleTabTree(dir) function! s:Creator.toggleTabTree(dir)
if g:NERDTree.ExistsForTab() if g:NERDTree.ExistsForTab()
if !g:NERDTree.IsOpen() if !g:NERDTree.IsOpen()
call self._createTreeWin() call self._createTreeWin()
if !&hidden if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str()
call self.createTabTree(a:dir)
elseif !&hidden
call b:NERDTree.render() call b:NERDTree.render()
endif endif
call b:NERDTree.ui.restoreScreenState() call b:NERDTree.ui.restoreScreenState()

View File

@@ -62,7 +62,7 @@ function! s:MenuController._echoPrompt()
if self.isMinimal() if self.isMinimal()
let selection = self.menuItems[self.selection].text 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 = map(copy(self.menuItems), "v:val['shortcut']")
let shortcuts[self.selection] = ' ' . keyword . ' ' let shortcuts[self.selection] = ' ' . keyword . ' '

View File

@@ -195,7 +195,7 @@ function! s:Opener._newVSplit()
endif endif
call nerdtree#exec('wincmd p', 1) call nerdtree#exec('wincmd p', 1)
call nerdtree#exec('vnew', 1) call nerdtree#exec('vsplit', 1)
let l:currentWindowNumber = winnr() let l:currentWindowNumber = winnr()

View File

@@ -199,7 +199,7 @@ function! s:Path.copy(dest)
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
endif 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) 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 . "'" throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'"

View File

@@ -104,16 +104,11 @@ function! s:TreeDirNode.displayString()
endfor endfor
" Select the appropriate open/closed status indicator symbol. " Select the appropriate open/closed status indicator symbol.
if l:cascade[-1].isOpen let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable )
let l:symbol = g:NERDTreeDirArrowCollapsible let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ')
else
let l:symbol = g:NERDTreeDirArrowExpandable
endif
let l:flags = l:cascade[-1].path.flagSet.renderToString() let l:flags = l:cascade[-1].path.flagSet.renderToString()
let l:result = l:symbol . ' ' . l:flags . l:label return l:symbol . l:flags . l:label
return l:result
endfunction endfunction
" FUNCTION: TreeDirNode.findNode(path) {{{1 " FUNCTION: TreeDirNode.findNode(path) {{{1

View File

@@ -321,13 +321,9 @@ function! s:TreeFileNode._renderToString(depth, drawText)
if a:drawText ==# 1 if a:drawText ==# 1
let treeParts = repeat(' ', a:depth - 1) let treeParts = repeat(' ', a:depth - 1)
let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ')
if !self.path.isDirectory
let treeParts = treeParts . ' '
endif
let line = treeParts . self.displayString() let line = treeParts . self.displayString()
let output = output . line . "\n" let output = output . line . "\n"
endif endif

View File

@@ -284,7 +284,11 @@ endfunction
function! s:UI._indentLevelFor(line) function! s:UI._indentLevelFor(line)
" Replace multi-character DirArrows with a single space so the " Replace multi-character DirArrows with a single space so the
" indentation calculation doesn't get messed up. " 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\[^ ]') let leadChars = match(l:line, '\M\[^ ]')
return leadChars / s:UI.IndentWid() return leadChars / s:UI.IndentWid()
endfunction endfunction

View File

@@ -141,12 +141,12 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'})
endif endif
" 1. ensure that a new buffer is loaded " 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 " 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:originalTabNumber = tabpagenr()
let s:originalWindowNumber = winnr() 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('tabnext ' . s:originalTabNumber, 1)
call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1)
" 3. We don't need a previous buffer anymore " 3. We don't need a previous buffer anymore
@@ -196,6 +196,11 @@ function! NERDTreeMoveNode()
let curNode = g:NERDTreeFileNode.GetSelected() let curNode = g:NERDTreeFileNode.GetSelected()
let prompt = s:inputPrompt('move') let prompt = s:inputPrompt('move')
let newNodePath = input(prompt, curNode.path.str(), 'file') 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 ==# '' if newNodePath ==# ''
call nerdtree#echo('Node Renaming Aborted.') call nerdtree#echo('Node Renaming Aborted.')
@@ -204,7 +209,8 @@ function! NERDTreeMoveNode()
try try
if curNode.path.isDirectory 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 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 endif
@@ -382,44 +388,67 @@ endfunction
" FUNCTION: NERDTreeQuickLook() {{{1 " FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook() function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected() let l:node = g:NERDTreeFileNode.GetSelected()
if treenode !=# {}
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") if empty(l:node)
return
endif endif
call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str()))
endfunction endfunction
" FUNCTION: NERDTreeRevealInFinder() {{{1 " FUNCTION: NERDTreeRevealInFinder() {{{1
function! NERDTreeRevealInFinder() function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected() let l:node = g:NERDTreeFileNode.GetSelected()
if treenode !=# {}
call system("open -R '" . treenode.path.str() . "'") if empty(l:node)
return
endif endif
call system('open -R ' . shellescape(l:node.path.str()))
endfunction endfunction
" FUNCTION: NERDTreeExecuteFile() {{{1 " FUNCTION: NERDTreeExecuteFile() {{{1
function! NERDTreeExecuteFile() function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected() let l:node = g:NERDTreeFileNode.GetSelected()
if treenode !=# {}
call system("open '" . treenode.path.str() . "'") if empty(l:node)
return
endif endif
call system('open ' . shellescape(l:node.path.str()))
endfunction endfunction
" FUNCTION: NERDTreeRevealFileLinux() {{{1 " FUNCTION: NERDTreeRevealFileLinux() {{{1
function! NERDTreeRevealFileLinux() function! NERDTreeRevealFileLinux()
let treenode = g:NERDTreeFileNode.GetSelected() let l:node = g:NERDTreeFileNode.GetSelected()
let parentnode = treenode.parent
if parentnode !=# {} if empty(l:node)
call system("xdg-open '" . parentnode.path.str() . "' &") return
endif 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 endfunction
" FUNCTION: NERDTreeExecuteFileLinux() {{{1 " FUNCTION: NERDTreeExecuteFileLinux() {{{1
function! NERDTreeExecuteFileLinux() function! NERDTreeExecuteFileLinux()
let treenode = g:NERDTreeFileNode.GetSelected() let l:node = g:NERDTreeFileNode.GetSelected()
if treenode !=# {}
call system("xdg-open '" . treenode.path.str() . "' &") if empty(l:node)
return
endif endif
call system('xdg-open ' . shellescape(l:node.path.str()))
endfunction endfunction
" vim: set sw=4 sts=4 et fdm=marker: " vim: set sw=4 sts=4 et fdm=marker:

View File

@@ -34,7 +34,7 @@ endfunction
function! s:FindParentVCSRoot(path) function! s:FindParentVCSRoot(path)
let l:path = a:path let l:path = a:path
while !empty(l:path) && while !empty(l:path) &&
\ l:path._str() !~# '^\(\a:\\\|\/\)$' && \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' &&
\ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.git') &&
\ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.svn') &&
\ !isdirectory(l:path._str() . '/.hg') && \ !isdirectory(l:path._str() . '/.hg') &&
@@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path)
\ !isdirectory(l:path._str() . '/_darcs') \ !isdirectory(l:path._str() . '/_darcs')
let l:path = l:path.getParent() let l:path = l:path.getParent()
endwhile 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 endfunction

View File

@@ -19,24 +19,7 @@ syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile
syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile
syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir
"highlighing for directory nodes and file nodes "highlighting to conceal the delimiter around the file/dir name
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'
"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
"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' exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL'
setlocal conceallevel=3 concealcursor=nvic setlocal conceallevel=3 concealcursor=nvic
@@ -45,6 +28,27 @@ else
hi! link NERDTreeNodeDelimiters Ignore hi! link NERDTreeNodeDelimiters Ignore
endif endif
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
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 #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile'
exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeDir'
syn match NERDTreeCWD #^[</].*$# syn match NERDTreeCWD #^[</].*$#
"highlighting for bookmarks "highlighting for bookmarks