Compare commits

...

23 Commits
5.2.8 ... 6.2.0

Author SHA1 Message Date
Phil Runninger
371feb7e54 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.
2019-10-16 13:26:20 -04:00
Farid Ahmadian
4245517689 Add VIM built-in package management to readme (#1049) 2019-10-14 09:13:20 -04:00
Phil Runninger
926ff0ec03 Update version number instructions in PR template and change log. 2019-10-11 10:44:25 -04:00
Phil Runninger
53eef21ad6 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.
2019-10-11 01:04:06 -04:00
Phil Runninger
4fe24d3156 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.
2019-10-08 14:01:50 -04:00
Phil Runninger
2d639b70e7 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.
2019-10-01 09:17:32 -04:00
Phil Runninger
6318406f66 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.
2019-09-29 11:28:59 -04:00
Phil Runninger
496b61ead1 Give @dragonxlwang proper credit on PR #1035. 2019-09-26 08:48:57 -04:00
Phil Runninger
5af6859846 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)
2019-09-26 08:47:36 -04:00
Phil Runninger
bd744eab8d 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.
2019-09-24 01:19:27 -04:00
Phil Runninger
9193962ad8 Update version number in change log. 2019-09-15 14:44:09 -04:00
Chris Patuzzo
2eaedd8bf4 Fix (p)ath not displaying in the minimal menu (#1038)
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 ‘(’
2019-09-15 14:41:27 -04:00
Phil Runninger
60ec10b477 Enable events when closing NerdTree window. (#1037)
* Enable events when closing NT window. Triggers updates in Airline.

* Update version number in change log.
2019-09-13 10:49:26 -04:00
Phil Runninger (mac)
51fc75efdb Fix version number. I was on the wrong branch. 2019-09-09 09:40:18 -04:00
Phil Runninger (mac)
79ef87b009 Update version number in change log. 2019-09-09 05:27:48 -04:00
Phil Runninger
3d508aedce 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.
2019-08-27 20:53:23 -04:00
Phil Runninger (mac)
9afab6257b Condense code: ternary operators vs. if-then-else blocks. 2019-08-19 14:39:17 -04:00
Phil Runninger (mac)
877f41e243 Update PR template with instructions to tag the release. 2019-08-19 09:36:50 -04:00
Phil Runninger
c4a7ca084e 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.
2019-08-19 03:51:34 -04:00
Phil Runninger (mac)
184fbb6ffe Better spacing of comment in issue templates. 2019-08-09 10:27:47 -04:00
Phil Runninger (mac)
03073bb1c8 Update issue templates, moving some text into comments. 2019-08-09 10:07:14 -04:00
Phil Runninger (mac)
858b3c0004 Update PR template, moving some text into a comment. 2019-08-09 09:45:46 -04:00
Phil Runninger
ae1c0004ec 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.
2019-08-08 22:00:35 -04:00
18 changed files with 243 additions and 172 deletions

View File

@@ -3,18 +3,18 @@ name: "Bug Report"
about: "NERDTree is misbehaving? Tell us about it." about: "NERDTree is misbehaving? Tell us about it."
labels: bug labels: bug
--- ---
<!-- Attention! Please Read!
# 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.
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. -->
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 #### Self-Diagnosis
<!-- Check the boxes after creating the issue, or use [x]. -->
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. - [ ] 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 NERDTree documentation. `:h NERDTree`
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). - [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).

View File

@@ -3,18 +3,18 @@ name: "General Question"
about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here."
labels: "general question" labels: "general question"
--- ---
<!-- Attention! Please Read!
# 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.
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. -->
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 #### Self-Diagnosis
<!-- Check the boxes after creating the issue, or use [x]. -->
- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. - [ ] 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 NERDTree documentation. `:h NERDTree`
- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). - [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki).

View File

@@ -5,16 +5,12 @@ Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
--- ---
### New Version Info ### New Version Info
- [ ] Derive a new version number. Increment the: #### Author's Instructions
- [ ] `MAJOR` version when you make incompatible API changes - [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the:
- [ ] `MINOR` version when you add functionality in a backwards-compatible manner - `MAJOR` version when you make incompatible API changes
- [ ] `PATCH` version when you make backwards-compatible bug fixes - `MINOR` version when you add functionality in a backwards-compatible manner
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following this format/example: - `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.
#### MAJOR.MINOR... #### Collaborator's Instructions
- **.PATCH**: PR Title (Author) [#PR Number](link to PR) - [ ] 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`
#### 5.1...
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
- **.0**: Too many changes for one patch...
```

View File

@@ -1,16 +1,41 @@
# Change Log # NERDTree Change Log
#### 5.2... <!--
Introduce a new MAJOR.MINOR version with a 4-hash header.
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)
-->
#### 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)
- **.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
- **.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
- **.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 (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) - **.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) - **.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. [#1017](https://github.com/scrooloose/nerdtree/pull/1017) - **.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) - **.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) - **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/scrooloose/nerdtree/pull/1015)
- **.3**: Fix `<CR>` key map on the bookmark (lkebin) [#1014](https://github.com/scrooloose/nerdtree/pull/1014) - **.3**: Fix `<CR>` 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) - **.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) - **.1**: Fix nerdtree#version() on Windows. (PhilRunninger)
- **.0**: Expand functionality of `<CR>` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011) - **.0**: Expand functionality of `<CR>` 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) - **.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) - **.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) - **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)

View File

@@ -17,6 +17,13 @@ included documentation.
Installation 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) #### [pathogen.vim](https://github.com/tpope/vim-pathogen)
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree

View File

@@ -4,24 +4,33 @@ endif
let g:loaded_nerdtree_autoload = 1 let g:loaded_nerdtree_autoload = 1
let s:rootNERDTreePath = resolve(expand("<sfile>:p:h:h")) let s:rootNERDTreePath = resolve(expand("<sfile>: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(...) function! nerdtree#version(...)
let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
let l:text = 'Unknown' let l:text = 'Unknown'
let l:line = 0 try
while l:line <= len(l:changelog) let l:changelog = readfile(join([s:rootNERDTreePath, "CHANGELOG.md"], nerdtree#slash()))
if l:changelog[l:line] =~ '\d\+\.\d\+' let l:line = 0
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') while l:line <= len(l:changelog)
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') if l:changelog[l:line] =~ '\d\+\.\d\+'
break let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
endif let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
let l:line += 1 break
endwhile endif
let l:line += 1
endwhile
catch
endtry
return l:text return l:text
endfunction endfunction
" SECTION: General Functions {{{1 " SECTION: General Functions {{{1
"============================================================ "============================================================
"FUNCTION: nerdtree#slash() {{{2
function! nerdtree#slash() function! nerdtree#slash()
if nerdtree#runningWindows() if nerdtree#runningWindows()
@@ -49,7 +58,6 @@ function! nerdtree#and(x,y)
if (l:x % 2) && (l:y % 2) if (l:x % 2) && (l:y % 2)
let l:result += float2nr(pow(2, l:n)) let l:result += float2nr(pow(2, l:n))
endif endif
echomsg l:x . ", " . l:y . " => " l:result
let l:x = float2nr(l:x / 2) let l:x = float2nr(l:x / 2)
let l:y = float2nr(l:y / 2) let l:y = float2nr(l:y / 2)
let l:n += 1 let l:n += 1
@@ -154,13 +162,13 @@ function! nerdtree#deprecated(func, ...)
endif endif
endfunction endfunction
" FUNCTION: nerdtree#exec(cmd) {{{2 " FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2
" Same as :exec cmd but with eventignore set for the duration " Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration
" to disable the autocommands used by NERDTree (BufEnter, function! nerdtree#exec(cmd, ignoreAll)
" BufLeave and VimEnter)
function! nerdtree#exec(cmd)
let old_ei = &ei let old_ei = &ei
set ei=BufEnter,BufLeave,VimEnter if a:ignoreAll
set ei=all
endif
exec a:cmd exec a:cmd
let &ei = old_ei let &ei = old_ei
endfunction endfunction

View File

@@ -72,6 +72,7 @@ function! nerdtree#ui_glue#createDefaultBindings()
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) 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': "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 endfunction
@@ -283,6 +284,9 @@ endfunction
" FUNCTION: s:findAndRevealPath(pathStr) {{{1 " FUNCTION: s:findAndRevealPath(pathStr) {{{1
function! s:findAndRevealPath(pathStr) function! s:findAndRevealPath(pathStr)
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: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')
@@ -574,11 +578,11 @@ function! s:refreshRoot()
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() 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.root.refresh()
call b:NERDTree.render() call b:NERDTree.render()
redraw redraw
call nerdtree#exec(l:curWin . "wincmd w") call nerdtree#exec(l:curWin . "wincmd w", 1)
call nerdtree#echo("") call nerdtree#echo("")
endfunction endfunction

View File

@@ -849,9 +849,17 @@ above nodes would then be sorted like this: >
z110.txt z110.txt
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTreeChDirMode* *NERDTreeUseTCD*
Values: 0 or 1.
Default: 0.
Values: 0, 1 or 2. 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.
------------------------------------------------------------------------------
*NERDTreeChDirMode*
Values: 0, 1, 2, or 3.
Default: 0. Default: 0.
Use this setting 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
@@ -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 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. 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* *NERDTreeHighlightCursorline*
Values: 0 or 1. Values: 0 or 1.
@@ -980,7 +991,6 @@ then (to single click activate it) you must click somewhere in
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTreeQuitOnOpen* *NERDTreeQuitOnOpen*
Values: 0,1,2 or 3. Values: 0,1,2 or 3.
Default: 0 Default: 0
@@ -1043,28 +1053,31 @@ window. Use one of the follow lines for this setting: >
Values: a list of regular expressions. Values: a list of regular expressions.
Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$']
This setting is a list of regular expressions which are used to specify the This setting is a list of regular expressions which are used to group or sort
order of nodes under their parent. the nodes under their parent.
For example, if the setting is: > For example, if the setting is: >
['\.vim$', '\.c$', '\.h$', '*', 'foobar'] ['\.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 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 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. 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. appended to the end of the list.
The regex '\/$' should be used to match directory nodes. The regex '\/$' should be used to match directory nodes.
A special flag can be used to sort by the modification timestamps of files and Files can also be sorted by 1) the modification timestamp, 2) the size, or 3)
directories. It is either '[[timestamp]]' for ascending, or '[[-timestamp]]' the extension. Directories are always sorted by name. To accomplish this, the
for descending. If placed at the beginning of the list, files and directories following special flags are used:
are sorted by timestamp, and then by the remaining items in the sort order [[timestamp]] [[-timestamp]] [[size]] [[-size]] [[extension]]
list. If this flag is in any other position of the list, timestamp sorting is The hyphen specifies a descending sort; extensions are sorted in ascending
done secondarily. See examples 4, 5, and 6 below. 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. After this sorting is done, the files in each group are sorted alphabetically.
@@ -1072,20 +1085,20 @@ Examples: >
(1) ['*', '\/$'] (1) ['*', '\/$']
(2) [] (2) []
(3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$']
(4) ['[[timestamp]]'] (4) ['[[-size]]']
(5) ['\/$', '*', '[[-timestamp]]'] (5) ['\/$', '*', '[[timestamp]]']
(6) ['\.md$', '\.c$', '[[-timestamp]]', '*'] (6) ['foo','\/$','[[extension]]']
< <
1. Directories will appear last, everything else will appear above. 1. Directories will appear last, everything else will appear above.
2. Everything will simply appear in alphabetical order. 2. Everything will simply appear in alphabetical order.
3. Dirs will appear first, then ruby and php. Swap files, bak files and vim 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. backup files will appear last with everything else preceding them.
4. All files and directories are sorted by timestamp, oldest first. If any 4. Everything is sorted by size, largest to smallest, with directories
files have identical timestamps, they are sorted alphabetically. considered to have size 0 bytes.
5. Directories are first, newest to oldest, then everything else, newest to 5. Directories will appear first alphabetically, followed by files, sorted by
oldest. timestamp, oldest first.
6. Markdown files first, followed by C source files, then everything else. 6. Files and directories matching 'foo' first, followed by other directories,
Each group is shown newest to oldest. then all other files. Each section of files is sorted by file extension.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTreeStatusline* *NERDTreeStatusline*

View File

@@ -159,8 +159,8 @@ endfunction
" FUNCTION: s:Edit() {{{1 " FUNCTION: s:Edit() {{{1
" opens the NERDTreeBookmarks file for manual editing " opens the NERDTreeBookmarks file for manual editing
function! s:Bookmark.Edit() function! s:Bookmark.Edit()
execute "wincmd w" call nerdtree#exec("wincmd w", 1)
execute "edit ".g:NERDTreeBookmarksFile call nerdtree#exec("edit ".g:NERDTreeBookmarksFile, 1)
endfunction endfunction
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1

View File

@@ -62,9 +62,10 @@ 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 shortcuts = map(copy(self.menuItems), "v:val['shortcut']") 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): " echo "Menu: [" . join(shortcuts, ",") . "] (" . navHelp . " or shortcut): "
else else

View File

@@ -20,7 +20,7 @@ function! s:NERDTree.changeRoot(node)
call self.root.open() call self.root.open()
"change dir to the dir of the new root if instructed to "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() call self.root.path.changeToDir()
endif endif
@@ -44,19 +44,19 @@ function! s:NERDTree.Close()
let l:useWinId = exists('*win_getid') && exists('*win_gotoid') let l:useWinId = exists('*win_getid') && exists('*win_gotoid')
if winnr() == s:NERDTree.GetWinNum() if winnr() == s:NERDTree.GetWinNum()
call nerdtree#exec("wincmd p") call nerdtree#exec("wincmd p", 1)
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
call nerdtree#exec("wincmd p") call nerdtree#exec("wincmd p", 1)
else else
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("") let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
endif endif
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w") call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w", 1)
close call nerdtree#exec("close", 0)
if l:useWinId if l:useWinId
call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")") call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")", 0)
else else
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w") call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w", 0)
endif endif
else else
close close
@@ -98,7 +98,7 @@ endfunction
"Places the cursor in the nerd tree window "Places the cursor in the nerd tree window
function! s:NERDTree.CursorToTreeWin() function! s:NERDTree.CursorToTreeWin()
call g:NERDTree.MustBeOpen() call g:NERDTree.MustBeOpen()
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w", 1)
endfunction endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1 " Function: s:NERDTree.ExistsForBuffer() {{{1
@@ -148,12 +148,19 @@ function! s:NERDTree.GetWinNum()
return bufwinnr(t:NERDTreeBufName) return bufwinnr(t:NERDTreeBufName)
endif 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 return -1
endfunction endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1 "FUNCTION: s:NERDTree.IsOpen() {{{1
function! s:NERDTree.IsOpen() function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1 || bufname('%') =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' return s:NERDTree.GetWinNum() != -1
endfunction endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1 "FUNCTION: s:NERDTree.isTabTree() {{{1

View File

@@ -71,9 +71,9 @@ endfunction
function! s:Opener._gotoTargetWin() function! s:Opener._gotoTargetWin()
if b:NERDTree.isWinTree() if b:NERDTree.isWinTree()
if self._where == 'v' if self._where == 'v'
vsplit call self._newVSplit()
elseif self._where == 'h' elseif self._where == 'h'
split call self._newSplit()
elseif self._where == 't' elseif self._where == 't'
tabnew tabnew
endif endif
@@ -107,10 +107,10 @@ function! s:Opener._isWindowUsable(winnumber)
endif endif
let oldwinnr = winnr() 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 specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
let modified = &modified 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 "if its a special window e.g. quickfix or another explorer plugin then we
"have to split "have to split
@@ -153,44 +153,18 @@ endfunction
" FUNCTION: Opener._newSplit() {{{1 " FUNCTION: Opener._newSplit() {{{1
function! s:Opener._newSplit() 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) let onlyOneWin = (winnr("$") ==# 1)
let savesplitright = &splitright
" If no adjacent window, set splitright and splitbelow appropriately
if onlyOneWin if onlyOneWin
let &splitright=right let &splitright = (g:NERDTreeWinPos ==# "left")
let &splitbelow=below
else
" found adjacent window - invert split direction
let &splitright=!right
let &splitbelow=!below
endif endif
" If only one window (ie. NERDTree), split vertically instead.
let splitMode = onlyOneWin ? "vertical" : "" let splitMode = onlyOneWin ? "vertical" : ""
" Open the new window " Open the new window
try try
exec(splitMode." sp ") call nerdtree#exec('wincmd p', 1)
call nerdtree#exec(splitMode . " split",1)
catch /^Vim\%((\a\+)\)\=:E37/ catch /^Vim\%((\a\+)\)\=:E37/
call g:NERDTree.CursorToTreeWin() 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."
@@ -200,14 +174,12 @@ function! s:Opener._newSplit()
"resize the tree window if no other window was open before "resize the tree window if no other window was open before
if onlyOneWin if onlyOneWin
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
call nerdtree#exec(there) call nerdtree#exec('wincmd p', 1)
exec("silent ". splitMode ." resize ". size) call nerdtree#exec('silent '. splitMode .' resize '. size, 1)
call nerdtree#exec('wincmd p') call nerdtree#exec('wincmd p', 0)
endif endif
" Restore splitmode settings
let &splitbelow=savesplitbelow
let &splitright=savesplitright let &splitright=savesplitright
endfunction endfunction
@@ -215,12 +187,15 @@ endfunction
function! s:Opener._newVSplit() function! s:Opener._newVSplit()
let l:winwidth = winwidth('.') 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 let l:winwidth = g:NERDTreeWinSize
endif endif
call nerdtree#exec('wincmd p') call nerdtree#exec('wincmd p', 1)
vnew call nerdtree#exec('vnew', 1)
let l:currentWindowNumber = winnr() let l:currentWindowNumber = winnr()
@@ -228,7 +203,8 @@ function! s:Opener._newVSplit()
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin()
execute 'silent vertical resize ' . l:winwidth execute 'silent vertical resize ' . l:winwidth
call nerdtree#exec(l:currentWindowNumber . 'wincmd w') call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0)
let &splitright=savesplitright
endfunction endfunction
" FUNCTION: Opener.open(target) {{{1 " FUNCTION: Opener.open(target) {{{1
@@ -290,9 +266,9 @@ function! s:Opener._previousWindow()
else else
try try
if !self._isWindowUsable(winnr("#")) if !self._isWindowUsable(winnr("#"))
call nerdtree#exec(self._firstUsableWindow() . "wincmd w") call nerdtree#exec(self._firstUsableWindow() . "wincmd w", 1)
else else
call nerdtree#exec('wincmd p') call nerdtree#exec('wincmd p', 1)
endif endif
catch /^Vim\%((\a\+)\)\=:E37/ catch /^Vim\%((\a\+)\)\=:E37/
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin()
@@ -305,8 +281,8 @@ endfunction
" FUNCTION: Opener._restoreCursorPos() {{{1 " FUNCTION: Opener._restoreCursorPos() {{{1
function! s:Opener._restoreCursorPos() function! s:Opener._restoreCursorPos()
call nerdtree#exec(self._tabnr . 'tabnext') call nerdtree#exec(self._tabnr . 'tabnext', 1)
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w', 1)
endfunction endfunction
" FUNCTION: Opener._reuseWindow() {{{1 " FUNCTION: Opener._reuseWindow() {{{1
@@ -321,7 +297,7 @@ function! s:Opener._reuseWindow()
"check the current tab for the window "check the current tab for the window
let winnr = bufwinnr('^' . self._path.str() . '$') let winnr = bufwinnr('^' . self._path.str() . '$')
if winnr != -1 if winnr != -1
call nerdtree#exec(winnr . "wincmd w") call nerdtree#exec(winnr . "wincmd w", 0)
call self._checkToCloseTree(0) call self._checkToCloseTree(0)
return 1 return 1
endif endif
@@ -334,9 +310,9 @@ function! s:Opener._reuseWindow()
let tabnr = self._path.tabnr() let tabnr = self._path.tabnr()
if tabnr if tabnr
call self._checkToCloseTree(1) call self._checkToCloseTree(1)
call nerdtree#exec(tabnr . 'tabnext') call nerdtree#exec(tabnr . 'tabnext', 1)
let winnr = bufwinnr('^' . self._path.str() . '$') let winnr = bufwinnr('^' . self._path.str() . '$')
call nerdtree#exec(winnr . "wincmd w") call nerdtree#exec(winnr . "wincmd w", 0)
return 1 return 1
endif endif

View File

@@ -87,8 +87,13 @@ function! s:Path.changeToDir()
endif endif
try try
execute "cd " . dir if g:NERDTreeUseTCD && exists(":tcd") == 2
call nerdtree#echo("CWD is now: " . getcwd()) 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 catch
throw "NERDTree.PathChangeError: cannot change CWD to " . dir throw "NERDTree.PathChangeError: cannot change CWD to " . dir
endtry endtry
@@ -380,7 +385,8 @@ endfunction
function! s:Path.getSortOrderIndex() function! s:Path.getSortOrderIndex()
let i = 0 let i = 0
while i < len(g:NERDTreeSortOrder) 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 return i
endif endif
let i = i + 1 let i = i + 1
@@ -407,15 +413,26 @@ endfunction
" FUNCTION: Path.getSortKey() {{{1 " FUNCTION: Path.getSortKey() {{{1
" returns a key used in compare function for sorting " returns a key used in compare function for sorting
function! s:Path.getSortKey() function! s:Path.getSortKey()
let l:ascending = index(g:NERDTreeSortOrder,'[[timestamp]]') if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder
let l:descending = index(g:NERDTreeSortOrder,'[[-timestamp]]') " Look for file metadata tags: [[timestamp]], [[extension]], [[size]]
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder || l:ascending >= 0 || l:descending >= 0 let metadata = []
let self._sortKey = [self.getSortOrderIndex()] for tag in g:NERDTreeSortOrder
if tag =~? '\[\[-\?timestamp\]\]'
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)]
elseif tag =~? '\[\[extension\]\]'
let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$')
let metadata += [self.isDirectory ? '' : (extension == '' ? nr2char(str2nr('0x10ffff',16)) : extension)]
endif
endfor
if l:descending >= 0 if g:NERDTreeSortOrder[0] =~ '\[\[.*\]\]'
call insert(self._sortKey, -getftime(self.str()), l:descending == 0 ? 0 : len(self._sortKey)) " Apply tags' sorting first if specified first.
elseif l:ascending >= 0 let self._sortKey = metadata + [self.getSortOrderIndex()]
call insert(self._sortKey, getftime(self.str()), l:ascending == 0 ? 0 : len(self._sortKey)) else
" Otherwise, do regex grouping first.
let self._sortKey = [self.getSortOrderIndex()] + metadata
endif endif
let path = self.getLastPathComponent(1) let path = self.getLastPathComponent(1)

View File

@@ -523,7 +523,8 @@ endfunction
" Open an explorer window for this node in the previous window. The explorer " Open an explorer window for this node in the previous window. The explorer
" can be a NERDTree window or a netrw window. " can be a NERDTree window or a netrw window.
function! s:TreeDirNode.openExplorer() function! s:TreeDirNode.openExplorer()
call self.open({'where': 'p'}) execute "wincmd p"
execute "edit ".self.path.str({'format':'Edit'})
endfunction endfunction
" FUNCTION: TreeDirNode.openInNewTab(options) {{{1 " FUNCTION: TreeDirNode.openInNewTab(options) {{{1

View File

@@ -246,6 +246,12 @@ function! s:TreeFileNode.openInNewTab(options)
call self.open(extend({'where': 't'}, a:options)) call self.open(extend({'where': 't'}, a:options))
endfunction 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 " FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1
" Places the cursor on the line number this node is rendered on " Places the cursor on the line number this node is rendered on
" "

View File

@@ -340,7 +340,7 @@ function! s:UI.restoreScreenState()
if !has_key(self, '_screenState') if !has_key(self, '_screenState')
return return
endif endif
exec("silent vertical resize " . self._screenState['oldWindowSize']) call nerdtree#exec("silent vertical resize " . self._screenState['oldWindowSize'], 1)
let old_scrolloff=&scrolloff let old_scrolloff=&scrolloff
let &scrolloff=0 let &scrolloff=0
@@ -355,12 +355,15 @@ endfunction
" scroll position " scroll position
function! s:UI.saveScreenState() function! s:UI.saveScreenState()
let win = winnr() let win = winnr()
call g:NERDTree.CursorToTreeWin()
let self._screenState = {} let self._screenState = {}
let self._screenState['oldPos'] = getpos(".") try
let self._screenState['oldTopLine'] = line("w0") call g:NERDTree.CursorToTreeWin()
let self._screenState['oldWindowSize']= winwidth("") let self._screenState['oldPos'] = getpos(".")
call nerdtree#exec(win . "wincmd w") let self._screenState['oldTopLine'] = line("w0")
let self._screenState['oldWindowSize']= winwidth("")
call nerdtree#exec(win . "wincmd w", 1)
catch
endtry
endfunction endfunction
" FUNCTION: s:UI.setShowHidden(val) {{{1 " FUNCTION: s:UI.setShowHidden(val) {{{1
@@ -506,10 +509,10 @@ endfunction
function! s:UI.toggleZoom() function! s:UI.toggleZoom()
if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize 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 let b:NERDTreeZoomed = 0
else else
exec "vertical resize ". get(g:, 'NERDTreeWinSizeMax', '') call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''), 1)
let b:NERDTreeZoomed = 1 let b:NERDTreeZoomed = 1
endif endif
endfunction endfunction

View File

@@ -114,14 +114,14 @@ function! s:promptToDelBuffer(bufnum, msg)
let l:listedBufferCount = 0 let l:listedBufferCount = 0
endif endif
if l:listedBufferCount > 1 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 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 endif
exec "tabnext " . s:originalTabNumber call nerdtree#exec("tabnext " . s:originalTabNumber, 1)
exec s:originalWindowNumber . "wincmd w" 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
exec "bwipeout! " . a:bufnum call nerdtree#exec("bwipeout! " . a:bufnum, 0)
endif endif
endfunction endfunction
@@ -141,17 +141,17 @@ 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
exec "badd " . quotedFileName call nerdtree#exec("badd " . quotedFileName, 1)
" 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()
exec "tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif" call nerdtree#exec("tabdo windo if winbufnr(0) == " . a:bufNum . " | exec ':e! " . editStr . "' | endif", 1)
exec "tabnext " . s:originalTabNumber call nerdtree#exec("tabnext " . s:originalTabNumber, 1)
exec s:originalWindowNumber . "wincmd w" 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
try try
exec "confirm bwipeout " . a:bufNum call nerdtree#exec("confirm bwipeout " . a:bufNum, 0)
catch catch
" This happens when answering Cancel if confirmation is needed. Do nothing. " This happens when answering Cancel if confirmation is needed. Do nothing.
endtry endtry

View File

@@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
call s:initVariable("g:NERDTreeNaturalSort", 0) call s:initVariable("g:NERDTreeNaturalSort", 0)
call s:initVariable("g:NERDTreeSortHiddenFirst", 1) call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
call s:initVariable("g:NERDTreeUseTCD", 0)
call s:initVariable("g:NERDTreeChDirMode", 0) call s:initVariable("g:NERDTreeChDirMode", 0)
call s:initVariable("g:NERDTreeCreatePrefix", "silent") call s:initVariable("g:NERDTreeCreatePrefix", "silent")
call s:initVariable("g:NERDTreeMinimalUI", 0) call s:initVariable("g:NERDTreeMinimalUI", 0)
@@ -170,10 +171,10 @@ call nerdtree#ui_glue#setupCommands()
"============================================================ "============================================================
augroup NERDTree augroup NERDTree
"Save the cursor position whenever we close the nerd tree "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 "disallow insert mode in the NERDTree
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert" exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
augroup END augroup END
if g:NERDTreeHijackNetrw if g:NERDTreeHijackNetrw
@@ -183,6 +184,12 @@ if g:NERDTreeHijackNetrw
augroup END augroup END
endif 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 " SECTION: Public API {{{1
"============================================================ "============================================================
function! NERDTreeAddMenuItem(options) function! NERDTreeAddMenuItem(options)