Compare commits

...

81 Commits

Author SHA1 Message Date
Phil Runninger
3a9d533f3d Restore the default behavior of the <CR> key. (#1221)
* Restore <CR>'s default behavior to be the same as o's.

* Remove the dictionary validation, and simplify initCustomOpenArgs().

There was a bug in the validation logic that caused a valid integer
value of 'keepopen' to always be overwritten with the defaultOpenArgs'
value. It was always comparing its type to the type of a string.

I fixed this by removing all the type validation, and wrapping the code
with a try-catch block. If NERDTreeCustomOpenArgs is not a dictionary,
an error message will print and the defaults will be used instead.

* Add fold markers to new functions.

* Update version number in change log.
2021-02-10 22:20:04 -05:00
Phil Runninger
d3f9fc44ca Update README.markdown
Add the missing slashes in the names of two of the mentioned plugin managers.
2021-02-10 16:38:41 -05:00
Phil Runninger
1d46d6df3e Update README.markdown 2021-02-09 21:50:35 -05:00
Phil Runninger
593c16add3 Fix {'keepopen':0} in NERDTreeCustomOpenArgs (#1217)
* Replace #and() with two more-specific functions.

* Push NERDTreeQuitOnOpen checking earlier in the call stack.

* Fix bug in `go` key for file bookmarks. It was behaving like `gs`.

* Fix the `o` mapping for bookmark nodes and the g:NERDTree reference.

* Use get() function to shorten if statement logic.

* Update version number in change log.

* Remove obsolete reference to MERDTreeQuitOnOpen in comment.
2021-02-09 21:34:24 -05:00
Daniel E
d3becd1149 Removed directory separator from sort key (#1219)
* Removed directory separator from sort key

Directories had an additional separator appended to them which caused improper comparisons for other directories that shared similar prefixes.

* Updated changelog
2021-02-09 20:48:36 -05:00
Phil Runninger
1b19089917 Add new FAQ and answer: How to prevent buffers replacing NERDTree. (#1215)
* Add new FAQ and answer: How to prevent buffers replacing NERDTree.

* Update version number in change log.
2021-01-31 00:19:58 -05:00
Phil Runninger
c8be9458dd New menu command: Run a system command in this directory. (#1214)
* New menu command: Run system command in this directory.

* Echo the output from the system command.

* Update version number in change log.

* Address Vim linter message: change "\n" to nr2char(10)

* Use single quoted strings.

* Use system() instead of systemlist() for greater version compatibility.

systemlist() was introduced sometime in Vim 8+, so I switched to
system() for 7.4 compatibility.
2021-01-30 23:45:56 -05:00
Phil Runninger
628098fff1 Escape quotation marks so they can be used in key mappings. (#1213)
* Escape quotation marks so they can be used in key mappings.

* Update version number in change log.
2021-01-30 23:43:29 -05:00
Phil Runninger
b134f6518b Enable full path specifications for NERDTreeIgnore (#1207)
* Add ability to specify a path to be ignored.

This ignore expression compares itself against the whole path of the
node, instead of just the tail component of the node.

* Remove debug statements and make it work on Windows.

* Restore the original self.str() to get OS-specific paths for comparing.

Using the UI-formatted path had two problems.
1. It always appended a forward slash at the end of the path, which was
   unnecessary and made patterns like '/tmp/cache$[[path]]' not work as
   expected.
2. It always used forward slashes to join the path components. I thought
   this would be a good thing, but there's no reason to force Windows
   users to use that syntax. They'll just need to remember to escape the
   backslashes, like so: '\\Temp\\cache$[[path]]'

* Add documentation for the new [[path]] tag for NERDTreeIgnore.

* Replace the abbreviation 'dir' with the full word 'directory'.

* Update version number in change log.
2021-01-19 20:07:26 -05:00
Tomasz N
7099f638ed Fix missing key case, add BC type checking (#1206)
* Fix missing key case, add BC type checking

Resolves #1205

* Assign g:NERDTreeCustomOpenArgs also before quick return

* Fix syntax to be compatibile with Vim 7.3
2021-01-18 21:23:52 -05:00
Phil Runninger
a7eb011e47 Revert #1200, due to bug (#1205) it introduced. 2021-01-17 22:16:38 -05:00
Tomasz N
7e1713853a Respect NERDTreeCustomOpenArgs when opening bookmark (#1200)
* Respect NERDTreeCustomOpenArgs when opening bookmark

* Update CHANGELOG

* Do not duplicate s:initCustomOpenArgs()

* Restore missing assignment

* fixup! Restore missing assignment

* fixup! Do not duplicate s:initCustomOpenArgs()

* Simplify loop iteration
2021-01-17 20:00:17 -05:00
Phil Runninger
aaa946fb6b Provide alternate way to mirror the NERDTree on all tabs. 2020-12-19 20:28:15 -05:00
Phil Runninger
2406c456ee Revamp the README file (#1193)
* Revamp the README to improve clarity and provide more information.

* Verify correct behavior of suggested auto commands.

* Add my tribute to Norm Abrams. Be careful with those plugin managers.

* Other minor formatting and cleanup.

* Fix typos, reorder some sections, and tidy up the README.

* Give a better answer to the single NERDTree for all tabs question.

* More reformatting of text.

* Add basic installation instructions. Switch to single quotes.

* Update version number in CHANGELOG.
2020-12-18 15:03:38 -05:00
buncis
474d735b7d readme update add script for automatically open NERDTree and focus on file (#1192)
* update readme for auto startup NERDTree and focus on file

* readme update

add how to open NERDTree automatically and focus on file
2020-12-18 00:36:10 -05:00
Phil Runninger
14af89743a Open a mirrored NERDTree with correct width (#1177)
* Make sure a mirrored NERDTree is displayed at correct width.

* Remove references to unused variables.

b:NERDTreeOldWindowSize was referenced, but never set anywhere. No need
to keep it around.

* Refactor: Initialize variables a different way.

Using the get() function allows us to "let" variables more directly,
without using the execute command or requiring strings to be escaped.
This also eliminates the s:initVariable function. The new format is
shown below, and defines a default value if the user didn't provide a
value in the vimrc file.

  let g:var = get(g: 'var', 'default value')

* Update version number in change log.

* Fix alignment of `let g:var = get(g:, 'var', <default>)` statements.
2020-10-14 18:08:18 -04:00
Yosef Herskovitz
577ddc73f0 Updated Readme (#1167)
* Updated Readme

Fixed typo in readme

* Updated Changelog
2020-08-18 11:14:05 -04:00
Phil Runninger
23000acd7f Refactor sort comparison functions, removing redundancy (#1166)
* Add a function to compare path objects.

* Remove redundant node comparison function, and rename the ones left.

* Remove the compareTo function in the Path object.

Use nerdtree#compareNodePaths(p1,p2) instead. There was no need for two
comparison functions that do the same thing. They were a little
different in their details, but that shouldn't be the case. Having only
one such function makes better sense and is easier to maintain.

* Update version number in change log.
2020-08-14 18:06:03 -04:00
Phil Runninger
6b5d70e5bf Fix argument of exists() function calls checking for autocommands. (#1165)
* Fix syntax of exists function calls checking for autocommands.

* Update version number in change log.
2020-08-09 07:07:55 -04:00
Phil Runninger
373a4b28e4 Don't use silent when raising User events (#1164)
* Remove silent from doautocmd. Prevent errors with exists('#...').

* Update version number in change log.
2020-08-07 00:37:56 -04:00
Yeri Pratama
4a32dd0be3 fix highlight for file node (#1157)
* fix #960 953 highlight for file node

* update changelog
2020-07-24 11:14:54 -04:00
Phil Runninger
e571d3e95b Make sure symbolic links' flags are highlighted correctly. (#1156)
* Make sure symbolic links' flags are higlighted correctly.

* Update version number in change log.
2020-07-17 14:11:08 -04:00
Phil Runninger
96e247ba74 Respect user's &shellslash setting in CopyNode and RemoveNode functions (#1150)
* Replace s:Path.Slash() with nerdtree#slash().

* Check the value of &shell when determining the slash under Windows.

* Leave &shellslash unchanged when forming copy/delete commands.

* Fix fold marker.

* Update version number in change log.

* Add abort attribute to nerdtree#slash() to satisfy Vim style guide.

Co-authored-by: Phil Runninger <prunninger@vhtcx.com>
2020-07-14 08:53:00 -04:00
Phil Runninger
2af10e3589 Update PULL_REQUEST_TEMPLATE.md
Use a shorter command to display the recent patches: replace `| head -2` with `-m2` grep switch; replace a `sed` with `cut` to get the line numbers.
2020-07-14 08:49:44 -04:00
Phil Runninger
42a5a2c106 Update PULL_REQUEST_TEMPLATE.md
Make the tag creation process semi-automatic by making bash do more of the legwork. The included bash commands will:

1. Make sure your master branch is up to date
2. Display all the patch releases in the current MAJOR.MINOR version
3. Ask for a version number to use as the tag (one of the ones previously displayed, presumably)
4. Get the latest commit's subject line, and use it in the tag's message field.
5. Create the tag, and push all tags to the origin.
2020-07-14 08:32:29 -04:00
Phil Runninger
f8aa749985 Fix new NERDTrees' width when previous one was in the only window. (#1153)
* Fix new NERDTrees' width when previous one was in the only window.

When leaving a NERDTree buffer, its window's width is remembered so that
that width can be used when showing the buffer again in a new window. If
NERDTree is the only window when leaving the buffer, it remembers the
whole width of the editor. When a new NERDTree window is created, it is
sized such that there is only a very small window for files to be opened
into.

To fix this, if NERDTree is the ONLY window, remember its width as the
value of g:NERDTreeWinSize, not the width of the editor.

* Update version number in change log.
2020-07-14 07:20:48 -04:00
Phil Runninger
aa37cb40da Fix the scope of several key mappings (#1151)
* Limit opening or previewing into a split window to only file nodes.

* Prevent previwing directory nodes, which would create another NERDTree.

* Refactor the previewBookmark code to open directories a better way.

* Update version number in change log.

* Update documentation.
2020-07-12 10:03:24 -04:00
Phil Runninger
6571452857 Enable opening bookmarks in split windows. (#1144)
* Add open/preview in split/vsplit to bookmarks.

* Make preview split/vsplit bookmark work only on file nodes.

* Add quickhelp text for split/vsplit commands on bookmarks.

* Handle previewing directory bookmarks properly.

* Update documentation: bookmarks can be opened in a split/vsplit.

* Update version number in change log.
2020-06-23 10:40:30 -04:00
Phil Runninger
d48ab70721 Merge branch 'master' of github.com:preservim/nerdtree 2020-06-01 02:09:39 -04:00
Phil Runninger
9de5b3e785 Allow concealed characters to show another character. (#1138)
* Closes #1136. Allow concealed characters to show another character.

conceallevel=3 always hides the character, but conceallevel=2 allows an
alternate character to be displayed instead.

* Update version number in changelog.
2020-06-01 02:08:13 -04:00
Phil Runninger
635071dcc8 Closes #1136. Allow concealed characters to show another character.
conceallevel=3 always hides the character, but conceallevel=2 allows an
alternate character to be displayed instead.
2020-06-01 01:51:27 -04:00
Phil Runninger
052b1f00a0 Add curly braces to the list of characters to be escaped. (#1128)
* Add curly braces to the list of characters to be escaped.

* Update version number in change log.
2020-05-26 00:15:17 -04:00
Phil Runninger
f63132cade Use backward-compatible nerdtree#and() in one place that was missed. (#1134)
* Use backward-compatible nerdtree#and() in one place that was missed.

* Update version number in change log.
2020-05-25 11:33:20 -04:00
Phil Runninger
484dc84b47 Update title of pull request. Add PR authors where missing. 2020-05-22 09:02:39 -04:00
Jordi Altayó
2e9d43b6f8 cmd.exe /c start "" <filename> for windows default viewer support (#1130)
* support for default viewer in Windows

* updated changelog

* Update nerdtree_plugin/fs_menu.vim

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>

* Update nerdtree_plugin/fs_menu.vim

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
2020-05-22 08:57:19 -04:00
Eugenij
10eaa3a2f4 Fixed a bug that caused the file-tree construction to slow down significantly. (#1126)
Co-authored-by: evgenij.vidershpan <evgenij.vidershpan@yandex.ru>
2020-05-21 02:23:35 -04:00
Eugenij
e2670f0d19 * fix duplicated slash in s:Path.isUnder() (on windows OS) (#1122)
* * fix duplicated slash in s:Path.isUnder() (on windows OS, for root directory on drive Path.str() return path with [back]slash)

* * Rewrite NERDTreePath.isUnder() and NERDTreePath.isAncestor() for direct comparison of paths without transformations

* Remove trailing slash, so we don't end up with two on root folder.

The str() function returns "C:\" on the root folder and "C:\temp" on
non-root folders, one with and one without a trailing backslash. This
inconsistency needs to be handled so the stridx() function will work
correctly.

* Make sure the change also works in a non-windows file system.

This commit handles an edge case that can be triggered with these
commands:
    :cd /home/me
    :e /foobar.txt  (an existing file)
    :NERDTreeFind
What happened was the root directory name '/' was being Resolved(), and
the trailing (and only) slash was being removed. The NERDTree was then
created in the current working directory, instead of the root directory.
:NERDTreeFind then wasn't able to find foobar.txt, and printed an error.

* Remove degugging statements.

* * ambiguity issue fix

Co-authored-by: Phil Runninger <philrunninger@gmail.com>
2020-05-14 14:24:36 -04:00
lifecrisis
4cc6097ecb Do not consider the tree root to be "cascadable" (#1120)
* Do not consider the tree root to be "cascadable"

* Update "CHANGELOG.md"
2020-05-06 23:24:01 -04:00
Phil Runninger
30ad6da984 Force NERDTreeFocus to allow events to be fired when switching windows. (#1118) 2020-05-04 08:14:22 -04:00
Phil Runninger
3005a0e9c0 Update version number in change log. 2020-05-04 08:11:49 -04:00
Phil Runninger
a7d585f7af Force NERDTreeFocus to allow events to be fired when switching windows. 2020-05-04 07:59:25 -04:00
Phil Runninger
5e77fb2fef Fix example code for the NERDTreeAddKeyMap function. (#1116)
* Fix example code for the NERDTreeAddKeyMap function.

The quickhelpText didn't match what the statement in the callback
function actually did.

* Update version number in change log.
2020-05-03 01:21:34 -04:00
Phil Runninger
29a321d061 Put '%' argument in bufname() for backwards compatibility. (#1105)
* Put '%' argument in bufname() for backwards compatibility.

* Update version number in change log.
2020-04-15 08:58:07 -04:00
Phil Runninger
0257d64248 If a file's already open in the window, don't edit it again. (#1103)
* If a file's already open in the window, don't edit it again.

* Update version number in change log.

* Make only one call to self.str().
2020-04-15 00:55:13 -04:00
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
20 changed files with 649 additions and 514 deletions

View File

@@ -1,5 +1,5 @@
### Description of Changes ### Description of Changes
Closes # <!-- Issue number this PR addresses. If none, remove this line. --> Closes # <!-- Enter the issue number this PR addresses. If none, remove this line. -->
--- ---
@@ -13,4 +13,10 @@ Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern.
#### Collaborator's Instructions #### Collaborator's Instructions
- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. - [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary.
- [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` - [ ] After merging, tag the commit using these (Mac-compatible) bash commands:
```bash
git checkout master
git pull
sed -n "$(grep -n -m2 '####' CHANGELOG.md | cut -f1 -d: | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d'
git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags
```

View File

@@ -1,13 +1,60 @@
# 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.10
- **.6**: Restore the default behavior of the <CR> key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221)
- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217)
- **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219)
- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215)
- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214)
- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213)
- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207)
#### 6.9
- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200)
- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193)
- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177)
- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167)
- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166)
- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165)
- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164)
- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157)
- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156)
- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153)
- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151)
- **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150)
- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144)
#### 6.8
- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138)
#### 6.7
- **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128)
- **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134)
- **.13**: `cmd.exe /c start "" <filename>` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130)
- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126)
- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122)
- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120)
- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118)
- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116)
- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105)
- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103)
- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] <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

@@ -1,145 +1,185 @@
The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) # The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint)
=============
Introduction ## Introduction
------------
The NERDTree is a file system explorer for the Vim editor. Using this plugin, The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations.
users can visually browse complex directory hierarchies, quickly open files for
reading or editing, and perform basic file system operations.
This plugin can also be extended with custom mappings using a special API. The
details of this API and of other NERDTree features are described in the
included documentation.
![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) ![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png)
Installation ## Installation
------------
Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them. Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.**
#### Vim 8+ packages If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g).
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: <details>
<summary>Pathogen</summary>
Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim.
1. In the terminal,
```bash
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree
```
1. In your `vimrc`,
```vim
call pathogen#infect()
syntax on
filetype plugin indent on
```
1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`.
</details>
<details>
<summary>Vundle</summary>
1. Install Vundle, according to its instructions.
1. Add the following text to your `vimrc`.
```vim
call vundle#begin()
Plugin 'preservim/nerdtree'
call vundle#end()
```
1. Restart Vim, and run the `:PluginInstall` statement to install your plugins.
</details>
<details>
<summary>Vim-Plug</summary>
1. Install Vim-Plug, according to its instructions.
1. Add the following text to your `vimrc`.
```vim
call plug#begin()
Plug 'preservim/nerdtree'
call plug#end()
```
1. Restart Vim, and run the `:PlugInstall` statement to install your plugins.
</details>
<details>
<summary>Dein</summary>
1. Install Dein, according to its instructions.
1. Add the following text to your `vimrc`.
```vim
call dein#begin()
call dein#add('preservim/nerdtree')
call dein#end()
```
1. Restart Vim, and run the `:call dein#install()` statement to install your plugins.
</details>
<details>
<summary>Vim 8+ packages</summary>
If you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal:
```bash ```bash
git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
``` ```
</details>
Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take. ## Getting Started
After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`.
#### [pathogen.vim](https://github.com/tpope/vim-pathogen) ## NERDTree Plugins
NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API and are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible.
In the terminal, * [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree.
```bash * [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders,
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree * [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype.
``` * [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions.
In your vimrc, * [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree.
* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once.
If any others should be listed, mention them in an issue or pull request.
## Frequently Asked Questions
In the answers to these questions, you will see code blocks that you can put in your `vimrc` file.
### How can I map a specific key or shortcut to open NERDTree?
NERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples.
```vim ```vim
call pathogen#infect() nnoremap <leader>n :NERDTreeFocus<CR>
syntax on nnoremap <C-n> :NERDTree<CR>
filetype plugin indent on nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
``` ```
Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. ### How do I open NERDTree automatically when Vim starts?
Each code block below is slightly different, as described in the `" Comment lines`.
#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim)
```vim ```vim
call vundle#begin() " Start NERDTree and leave the cursor in it.
Plugin 'preservim/nerdtree' autocmd VimEnter * NERDTree
call vundle#end()
``` ```
#### [vim-plug](https://github.com/junegunn/vim-plug)
```vim
call plug#begin()
Plug 'preservim/nerdtree'
call plug#end()
```
#### [apt-vim](https://github.com/egalpin/apt-vim)
```bash
apt-vim install -y https://github.com/preservim/nerdtree.git
```
F.A.Q. (here, and in the [Wiki](https://github.com/preservim/nerdtree/wiki))
------
#### Is there any support for `git` flags?
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
--- ---
#### Can I have the nerdtree on every tab automatically?
Nope. If this is something you want then chances are you aren't using tabs and
buffers as they were intended to be used. Read this
http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
---
#### How can I open a NERDTree automatically when vim starts up?
Stick this in your vimrc: `autocmd vimenter * NERDTree`
---
#### How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc:
```vim ```vim
" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p
```
---
```vim
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1 autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
``` ```
Note: Now start vim with plain `vim`, not `vim .`
--- ---
#### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario.
```vim ```vim
" Start NERDTree. If a file is specified, move the cursor to its window.
autocmd StdinReadPre * let s:std_in=1 autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
``` ```
--- ---
#### How can I open NERDTree automatically when vim starts up on opening a directory?
```vim ```vim
" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim.
autocmd StdinReadPre * let s:std_in=1 autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif
``` ```
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory`
--- ---
#### How can I map a specific key or shortcut to open NERDTree?
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
```vim ```vim
map <C-n> :NERDTreeToggle<CR> " Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
``` ```
--- ### How can I close Vim automatically when NERDTree is the last window?
#### How can I close vim if the only window left open is a NERDTree?
Stick this in your vimrc:
```vim ```vim
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
``` ```
--- ### How can I prevent other buffers replacing NERDTree in its window?
#### Can I have different highlighting for different file extensions?
See here: https://github.com/preservim/nerdtree/issues/433#issuecomment-92590696 ```vim
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
```
--- ### Can I have the same NERDTree on every tab automatically?
#### How can I change default arrows?
```vim
" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * silent NERDTreeMirror
```
or change your NERDTree-launching shortcut key like so:
```vim
" Mirror the NERDTree before showing it. This makes it the same on all tabs.
nnoremap <C-n> :NERDTreeMirror<CR>:NERDTreeFocus<CR>
```
### How can I change the default arrows?
Use these variables in your vimrc. Note that below are default arrow symbols
```vim ```vim
let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾' let g:NERDTreeDirArrowCollapsible = '▾'
``` ```
The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details.

View File

@@ -30,9 +30,21 @@ endfunction
" SECTION: General Functions {{{1 " SECTION: General Functions {{{1
"============================================================ "============================================================
"FUNCTION: nerdtree#slash() {{{2 " FUNCTION: nerdtree#closeTreeOnOpen() {{{2
function! nerdtree#slash() abort function! nerdtree#closeTreeOnOpen() abort
return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3
endfunction
" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2
function! nerdtree#closeBookmarksOnOpen() abort
return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3
endfunction
" FUNCTION: nerdtree#slash() {{{2
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! nerdtree#slash() abort
if nerdtree#runningWindows() if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash if exists('+shellslash') && &shellslash
return '/' return '/'
@@ -44,28 +56,6 @@ function! nerdtree#slash() abort
return '/' return '/'
endfunction endfunction
"FUNCTION: nerdtree#and(x,y) {{{2
" Implements and() function for Vim <= 7.2
function! nerdtree#and(x,y) abort
if exists('*and')
return and(a:x, a:y)
else
let l:x = a:x
let l:y = a:y
let l:n = 0
let l:result = 0
while l:x > 0 && l:y > 0
if (l:x % 2) && (l:y % 2)
let l:result += float2nr(pow(2, l:n))
endif
let l:x = float2nr(l:x / 2)
let l:y = float2nr(l:y / 2)
let l:n += 1
endwhile
return l:result
endif
endfunction
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a window tree in the current buffer if appropriate "inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir) abort function! nerdtree#checkForBrowse(dir) abort
@@ -108,15 +98,15 @@ function! nerdtree#completeBookmarks(A,L,P) abort
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
endfunction endfunction
"FUNCTION: nerdtree#compareNodes(dir) {{{2 "FUNCTION: nerdtree#compareNodes(n1, n2) {{{2
function! nerdtree#compareNodes(n1, n2) abort function! nerdtree#compareNodes(n1, n2) abort
return a:n1.path.compareTo(a:n2.path) return nerdtree#compareNodePaths(a:n1.path, a:n2.path)
endfunction endfunction
"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 "FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2
function! nerdtree#compareNodesBySortKey(n1, n2) abort function! nerdtree#compareNodePaths(p1, p2) abort
let sortKey1 = a:n1.path.getSortKey() let sortKey1 = a:p1.getSortKey()
let sortKey2 = a:n2.path.getSortKey() let sortKey2 = a:p2.getSortKey()
let i = 0 let i = 0
while i < min([len(sortKey1), len(sortKey2)]) while i < min([len(sortKey1), len(sortKey2)])
" Compare chunks upto common length. " Compare chunks upto common length.
@@ -169,8 +159,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

@@ -25,12 +25,16 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Node', 'callback': s.'openHSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'FileNode', 'callback': s.'openHSplit' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Node', 'callback': s.'openVSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'FileNode', 'callback': s.'openVSplit' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Node', 'callback': s.'previewNodeCurrent' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'FileNode', 'callback': s.'previewNodeCurrent' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'FileNode', 'callback': s.'previewNodeHSplit' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Node', 'callback': s.'previewNodeHSplit' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'FileNode', 'callback': s.'previewNodeVSplit' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' })
@@ -104,10 +108,17 @@ function! s:customOpenBookmark(node) abort
endfunction endfunction
"FUNCTION: s:initCustomOpenArgs() {{{1 "FUNCTION: s:initCustomOpenArgs() {{{1
" Make sure NERDTreeCustomOpenArgs has needed keys
function! s:initCustomOpenArgs() abort function! s:initCustomOpenArgs() abort
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}}
return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') try
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep')
catch /^Vim(\a\+):E712:/
call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.')
let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs
finally
return g:NERDTreeCustomOpenArgs
endtry
endfunction endfunction
"FUNCTION: s:activateAll() {{{1 "FUNCTION: s:activateAll() {{{1
@@ -133,13 +144,13 @@ endfunction
"FUNCTION: s:activateFileNode() {{{1 "FUNCTION: s:activateFileNode() {{{1
"handle the user activating a tree node "handle the user activating a tree node
function! s:activateFileNode(node) abort function! s:activateFileNode(node) abort
call a:node.activate({'reuse': 'all', 'where': 'p'}) call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()})
endfunction endfunction
"FUNCTION: s:activateBookmark(bookmark) {{{1 "FUNCTION: s:activateBookmark(bookmark) {{{1
"handle the user activating a bookmark "handle the user activating a bookmark
function! s:activateBookmark(bm) abort function! s:activateBookmark(bm) abort
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
endfunction endfunction
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
@@ -284,15 +295,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 +340,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
@@ -493,19 +507,42 @@ function! nerdtree#ui_glue#openBookmark(name) abort
endtry endtry
if l:bookmark.path.isDirectory if l:bookmark.path.isDirectory
call l:bookmark.open(b:NERDTree) call l:bookmark.open(b:NERDTree)
else return
call l:bookmark.open(b:NERDTree, {'where': 'p'})
endif endif
call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file)
endfunction endfunction
" FUNCTION: s:openHSplit(target) {{{1 " FUNCTION: s:openHSplit(target) {{{1
function! s:openHSplit(target) abort function! s:openHSplit(target) abort
call a:target.activate({'where': 'h'}) call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()})
endfunction endfunction
" FUNCTION: s:openVSplit(target) {{{1 " FUNCTION: s:openVSplit(target) {{{1
function! s:openVSplit(target) abort function! s:openVSplit(target) abort
call a:target.activate({'where': 'v'}) call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()})
endfunction
"FUNCTION: s:openHSplitBookmark(bookmark) {{{1
"handle the user activating a bookmark
function! s:openHSplitBookmark(bm) abort
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
endfunction
"FUNCTION: s:openVSplitBookmark(bookmark) {{{1
"handle the user activating a bookmark
function! s:openVSplitBookmark(bm) abort
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {})
endfunction
" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1
function! s:previewNodeHSplitBookmark(bookmark) abort
call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {})
endfunction
" FUNCTION: s:previewVSplitBookmark(bookmark) {{{1
function! s:previewNodeVSplitBookmark(bookmark) abort
call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'v', 'keepopen': 1} : {})
endfunction endfunction
" FUNCTION: s:openExplorer(node) {{{1 " FUNCTION: s:openExplorer(node) {{{1
@@ -515,13 +552,13 @@ endfunction
" FUNCTION: s:openInNewTab(target) {{{1 " FUNCTION: s:openInNewTab(target) {{{1
function! s:openInNewTab(target) abort function! s:openInNewTab(target) abort
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()})
call l:opener.open(a:target) call l:opener.open(a:target)
endfunction endfunction
" FUNCTION: s:openInNewTabSilent(target) {{{1 " FUNCTION: s:openInNewTabSilent(target) {{{1
function! s:openInNewTabSilent(target) abort function! s:openInNewTabSilent(target) abort
let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1})
call l:opener.open(a:target) call l:opener.open(a:target)
endfunction endfunction
@@ -535,11 +572,7 @@ endfunction
" FUNCTION: s:previewBookmark(bookmark) {{{1 " FUNCTION: s:previewBookmark(bookmark) {{{1
function! s:previewBookmark(bookmark) abort function! s:previewBookmark(bookmark) abort
if a:bookmark.path.isDirectory call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'p', 'keepopen': 1} : {})
execute 'NERDTreeFind '.a:bookmark.path.str()
else
call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1})
endif
endfunction endfunction
"FUNCTION: s:previewNodeCurrent(node) {{{1 "FUNCTION: s:previewNodeCurrent(node) {{{1
@@ -564,7 +597,7 @@ function! nerdtree#ui_glue#revealBookmark(name) abort
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1) call targetNode.putCursorHere(0, 1)
catch /^NERDTree.BookmarkNotFoundError/ catch /^NERDTree.BookmarkNotFoundError/
call nerdtree#echo('Bookmark isnt cached under the current root') call nerdtree#echo('Bookmark isn''t cached under the current root')
endtry endtry
endfunction endfunction

View File

@@ -116,16 +116,17 @@ The following features and functionality are provided by the NERDTree:
:NERDTreeVCS (opens root of repository containing CWD) :NERDTreeVCS (opens root of repository containing CWD)
< <
:NERDTreeFromBookmark <bookmark> *:NERDTreeFromBookmark* :NERDTreeFromBookmark <bookmark> *:NERDTreeFromBookmark*
Opens a fresh NERDTree with the root initialized to the dir for Opens a fresh NERDTree with the root initialized to the directory for
<bookmark>. The only reason to use this command over :NERDTree is for <bookmark>. The only reason to use this command over :NERDTree is for
the completion (which is for bookmarks rather than directories). the completion (which is for bookmarks rather than directories).
: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
the version control system repository, and roots the NERDTree there. It the version control system repository, and roots the NERDTree there. It
works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A
@@ -248,7 +249,7 @@ Key Description help-tag~
o........Open files, directories and bookmarks......................|NERDTree-o| o........Open files, directories and bookmarks......................|NERDTree-o|
go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go|
Open selected bookmark dir in current NERDTree Open selected bookmark directory in current NERDTree
t........Open selected node/bookmark in a new tab...................|NERDTree-t| t........Open selected node/bookmark in a new tab...................|NERDTree-t|
T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T|
i........Open selected file in a split window.......................|NERDTree-i| i........Open selected file in a split window.......................|NERDTree-i|
@@ -259,10 +260,10 @@ gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs|
O........Recursively open the selected directory....................|NERDTree-O| O........Recursively open the selected directory....................|NERDTree-O|
x........Close the current nodes parent.............................|NERDTree-x| x........Close the current nodes parent.............................|NERDTree-x|
X........Recursively close all children of the current node.........|NERDTree-X| X........Recursively close all children of the current node.........|NERDTree-X|
e........Edit the current dir.......................................|NERDTree-e| e........Edit the current directory.................................|NERDTree-e|
double-click....same as |NERDTree-o|. double-click....same as |NERDTree-o|.
middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for directories.
D........Delete the current bookmark ...............................|NERDTree-D| D........Delete the current bookmark ...............................|NERDTree-D|
@@ -273,13 +274,13 @@ J........Jump down inside directories at the current tree depth.....|NERDTree-J|
<C-J>....Jump down to next sibling of the current directory.......|NERDTree-C-J| <C-J>....Jump down to next sibling of the current directory.......|NERDTree-C-J|
<C-K>....Jump up to previous sibling of the current directory.....|NERDTree-C-K| <C-K>....Jump up to previous sibling of the current directory.....|NERDTree-C-K|
C........Change the tree root to the selected dir...................|NERDTree-C| C........Change the tree root to the selected directory.............|NERDTree-C|
u........Move the tree root up one directory........................|NERDTree-u| u........Move the tree root up one directory........................|NERDTree-u|
U........Same as 'u' except the old root node is left open..........|NERDTree-U| U........Same as 'u' except the old root node is left open..........|NERDTree-U|
r........Recursively refresh the current directory..................|NERDTree-r| r........Recursively refresh the current directory..................|NERDTree-r|
R........Recursively refresh the current root.......................|NERDTree-R| R........Recursively refresh the current root.......................|NERDTree-R|
m........Display the NERDTree menu..................................|NERDTree-m| m........Display the NERDTree menu..................................|NERDTree-m|
cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| cd.......Change the CWD to the directory of the selected node......|NERDTree-cd|
CD.......Change tree root to the CWD...............................|NERDTree-CD| CD.......Change tree root to the CWD...............................|NERDTree-CD|
I........Toggle whether hidden files displayed......................|NERDTree-I| I........Toggle whether hidden files displayed......................|NERDTree-I|
@@ -317,9 +318,8 @@ Applies to: files.
If a file node or a bookmark that links to a file is selected, it is opened in If a file node or a bookmark that links to a file is selected, it is opened in
the previous window, but the cursor does not move. the previous window, but the cursor does not move.
If a bookmark that links to a directory is selected, that directory is found If a bookmark that links to a directory is selected then that directory
in the current NERDTree. If the directory couldn't be found, a new NERDTree is becomes the new root.
created.
The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see
|NERDTree-o|). |NERDTree-o|).
@@ -349,7 +349,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab.
*NERDTree-i* *NERDTree-i*
Default key: i Default key: i
Map setting: *NERDTreeMapOpenSplit* Map setting: *NERDTreeMapOpenSplit*
Applies to: files. Applies to: files, and bookmarks pointing to files.
Opens the selected file in a new split window and puts the cursor in the new Opens the selected file in a new split window and puts the cursor in the new
window. window.
@@ -358,7 +358,7 @@ window.
*NERDTree-gi* *NERDTree-gi*
Default key: gi Default key: gi
Map setting: *NERDTreeMapPreviewSplit* Map setting: *NERDTreeMapPreviewSplit*
Applies to: files. Applies to: files, and bookmarks pointing to files.
The same as |NERDTree-i| except that the cursor is not moved. The same as |NERDTree-i| except that the cursor is not moved.
@@ -369,7 +369,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see
*NERDTree-s* *NERDTree-s*
Default key: s Default key: s
Map setting: *NERDTreeMapOpenVSplit* Map setting: *NERDTreeMapOpenVSplit*
Applies to: files. Applies to: files, and bookmarks pointing to files.
Opens the selected file in a new vertically split window and puts the cursor Opens the selected file in a new vertically split window and puts the cursor
in the new window. in the new window.
@@ -378,7 +378,7 @@ in the new window.
*NERDTree-gs* *NERDTree-gs*
Default key: gs Default key: gs
Map setting: *NERDTreeMapPreviewVSplit* Map setting: *NERDTreeMapPreviewVSplit*
Applies to: files. Applies to: files, and bookmarks pointing to files.
The same as |NERDTree-s| except that the cursor is not moved. The same as |NERDTree-s| except that the cursor is not moved.
@@ -469,7 +469,7 @@ Jump to the first child of the current nodes parent.
If the cursor is already on the first node then do the following: If the cursor is already on the first node then do the following:
* loop back thru the siblings of the current nodes parent until we find an * loop back thru the siblings of the current nodes parent until we find an
open dir with children open directory with children
* go to the first child of that node * go to the first child of that node
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@@ -482,7 +482,7 @@ Jump to the last child of the current nodes parent.
If the cursor is already on the last node then do the following: If the cursor is already on the last node then do the following:
* loop forward thru the siblings of the current nodes parent until we find * loop forward thru the siblings of the current nodes parent until we find
an open dir with children an open directory with children
* go to the last child of that node * go to the last child of that node
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@@ -516,7 +516,7 @@ Default key: u
Map setting: *NERDTreeMapUpdir* Map setting: *NERDTreeMapUpdir*
Applies to: no restrictions. Applies to: no restrictions.
Move the tree root up a dir (like doing a "cd .."). Move the tree root up a directory (like doing a "cd ..").
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*NERDTree-U* *NERDTree-U*
@@ -532,8 +532,8 @@ Default key: r
Map setting: *NERDTreeMapRefresh* Map setting: *NERDTreeMapRefresh*
Applies to: files and directories. Applies to: files and directories.
If a dir is selected, recursively refresh that dir, i.e. scan the filesystem If a directory is selected, recursively refresh that directory, i.e. scan the
for changes and represent them in the tree. filesystem for changes and represent them in the tree.
If a file node is selected then the above is done on it's parent. If a file node is selected then the above is done on it's parent.
@@ -634,8 +634,8 @@ file explorers have.
The script comes with two default menu plugins: exec_menuitem.vim and The script comes with two default menu plugins: exec_menuitem.vim and
fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for
creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a creating/deleting/moving/copying files and directories. exec_menuitem.vim
menu item to execute executable files. provides a menu item to execute executable files.
Related tags: |NERDTree-m| |NERDTreeApi| Related tags: |NERDTree-m| |NERDTreeApi|
@@ -921,7 +921,7 @@ Default: ['\~$'].
This setting is used to specify which files the NERDTree should ignore. It This setting is used to specify which files the NERDTree should ignore. It
must be a list of regular expressions. When the NERDTree is rendered, any must be a list of regular expressions. When the NERDTree is rendered, any
files/dirs that match any of the regex's in NERDTreeIgnore won't be files/directories that match any of the regex's in NERDTreeIgnore won't be
displayed. displayed.
For example if you put the following line in your vimrc: > For example if you put the following line in your vimrc: >
@@ -929,13 +929,18 @@ For example if you put the following line in your vimrc: >
< <
then all files ending in .vim or ~ will be ignored. then all files ending in .vim or ~ will be ignored.
There are 2 magic flags that can be appended to the end of each regular There are 3 magic flags that can be appended to the end of each regular
expression to specify that the regex should match only files or only dirs. expression to specify that the regex should match only filenames, only lowest
These flags are "[[dir]]" and "[[file]]". Example: > level directories, or a full path. These flags are "[[dir]]", "[[file]]", and
let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]'] "[[path]]". Example: >
let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]', 'tmp/cache$[[path]]']
< <
This will cause all dirs ending in ".d" to be ignored and all files ending in This will cause all directories ending in ".d" to be ignored, all files ending
".o" to be ignored. in ".o" to be ignored, and the "cache" subdirectory of any "tmp" directory to
be ignored. All other "cache" directories will be displayed.
When using the "[[path]]" tag on Windows, make sure you use escaped
backslashes for the separators in the regex, eg. 'Temp\\cache$[[path]]'
Note: to tell the NERDTree not to ignore any files you must use the following Note: to tell the NERDTree not to ignore any files you must use the following
line: > line: >
@@ -1099,8 +1104,8 @@ Examples: >
< <
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. Directories will appear first, then ruby and php. Swap files, bak files
backup files will appear last with everything else preceding them. and vim backup files will appear last with everything else preceding them.
4. Everything is sorted by size, largest to smallest, with directories 4. Everything is sorted by size, largest to smallest, with directories
considered to have size 0 bytes. considered to have size 0 bytes.
5. Directories will appear first alphabetically, followed by files, sorted by 5. Directories will appear first alphabetically, followed by files, sorted by
@@ -1174,8 +1179,9 @@ Use one of the following lines for this setting: >
Values: 0 or 1 Values: 0 or 1
Default: 1. Default: 1.
When displaying dir nodes, this setting tells NERDTree to collapse dirs that When displaying directory nodes, this setting tells NERDTree to collapse
have only one child. Use one of the following lines for this setting: > directories that have only one child. Use one of the following lines for this
setting: >
let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=0
let NERDTreeCascadeSingleChildDir=1 let NERDTreeCascadeSingleChildDir=1
< <
@@ -1184,11 +1190,12 @@ have only one child. Use one of the following lines for this setting: >
Values: 0 or 1 Values: 0 or 1
Default: 1. Default: 1.
When opening dir nodes, this setting tells NERDTree to recursively open dirs When opening directory nodes, this setting tells NERDTree to recursively open
that have only one child which is also a dir. NERDTree will stop when it finds directories that have only one child which is also a directory. NERDTree will
a dir that contains anything but another single dir. This setting also causes stop when it finds a directory that contains anything but another single
the |NERDTree-x| mapping to close dirs in the same manner. This setting may be directory. This setting also causes the |NERDTree-x| mapping to close
useful for Java projects. Use one of the following lines for this setting: > directories in the same manner. This setting may be useful for Java projects.
Use one of the following lines for this setting: >
let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=0
let NERDTreeCascadeOpenSingleChildDir=1 let NERDTreeCascadeOpenSingleChildDir=1
< <
@@ -1222,13 +1229,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.
@@ -1346,18 +1359,18 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
Example: > Example: >
call NERDTreeAddKeyMap({ call NERDTreeAddKeyMap({
\ 'key': 'foo', \ 'key': 'foo',
\ 'callback': 'NERDTreeCDHandler', \ 'callback': 'NERDTreeEchoPathHandler',
\ 'quickhelpText': 'echo full path of current node', \ 'quickhelpText': 'echo full path of current node',
\ 'scope': 'DirNode' }) \ 'scope': 'DirNode' })
function! NERDTreeCDHandler(dirnode) function! NERDTreeEchoPathHandler(dirnode)
call a:dirnode.changeToDir() echo a:dirnode.path.str()
endfunction endfunction
< <
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of
the current dir node. Note this mapping will only fire when the cursor is the current directory node. Note this mapping will only fire when the
on a directory node. cursor is on a directory node.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
4.2. Menu API *NERDTreeMenuAPI* 4.2. Menu API *NERDTreeMenuAPI*

View File

@@ -256,7 +256,7 @@ endfunction
function! s:Bookmark.open(nerdtree, ...) function! s:Bookmark.open(nerdtree, ...)
let opts = a:0 ? a:1 : {} let opts = a:0 ? a:1 : {}
if nerdtree#and(g:NERDTreeQuitOnOpen,2) if nerdtree#closeBookmarksOnOpen()
call a:nerdtree.ui.toggleShowBookmarks() call a:nerdtree.ui.toggleShowBookmarks()
endif endif

View File

@@ -28,7 +28,9 @@ endfunction
" FUNCTION: s:Creator._broadcastInitEvent() {{{1 " FUNCTION: s:Creator._broadcastInitEvent() {{{1
function! s:Creator._broadcastInitEvent() function! s:Creator._broadcastInitEvent()
silent doautocmd User NERDTreeInit if exists('#User#NERDTreeInit')
doautocmd User NERDTreeInit
endif
endfunction endfunction
" FUNCTION: s:Creator.BufNamePrefix() {{{1 " FUNCTION: s:Creator.BufNamePrefix() {{{1
@@ -170,6 +172,7 @@ function! s:Creator.createMirror()
let t:NERDTreeBufName = bufferName let t:NERDTreeBufName = bufferName
call self._createTreeWin() call self._createTreeWin()
exec 'buffer ' . bufferName exec 'buffer ' . bufferName
call b:NERDTree.ui.restoreScreenState()
if !&hidden if !&hidden
call b:NERDTree.render() call b:NERDTree.render()
endif endif
@@ -247,9 +250,13 @@ function! s:Creator._pathForString(str)
"hack to get an absolute path if a relative path is given "hack to get an absolute path if a relative path is given
if dir =~# '^\.' if dir =~# '^\.'
let dir = getcwd() . g:NERDTreePath.Slash() . dir let dir = getcwd() . nerdtree#slash() . dir
endif
"hack to prevent removing slash if dir is the root of the file system.
if dir !=# '/'
let dir = g:NERDTreePath.Resolve(dir)
endif endif
let dir = g:NERDTreePath.Resolve(dir)
try try
let path = g:NERDTreePath.New(dir) let path = g:NERDTreePath.New(dir)
@@ -333,14 +340,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 +362,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

@@ -51,7 +51,7 @@ function! s:KeyMap.bind()
else else
let keymapInvokeString = self.key let keymapInvokeString = self.key
endif endif
let keymapInvokeString = escape(keymapInvokeString, '\') let keymapInvokeString = escape(keymapInvokeString, '\"')
let premap = self.key ==# '<LeftRelease>' ? ' <LeftRelease>' : ' ' let premap = self.key ==# '<LeftRelease>' ? ' <LeftRelease>' : ' '

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

@@ -27,7 +27,9 @@ function! s:NERDTree.changeRoot(node)
call self.render() call self.render()
call self.root.putCursorHere(0, 0) call self.root.putCursorHere(0, 0)
silent doautocmd User NERDTreeNewRoot if exists('#User#NERDTreeNewRoot')
doautocmd User NERDTreeNewRoot
endif
endfunction endfunction
"FUNCTION: s:NERDTree.Close() {{{1 "FUNCTION: s:NERDTree.Close() {{{1
@@ -63,14 +65,6 @@ function! s:NERDTree.Close()
endif endif
endfunction endfunction
"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1
"Closes the NERD tree window if the close on open option is set
function! s:NERDTree.CloseIfQuitOnOpen()
if nerdtree#and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen()
call s:NERDTree.Close()
endif
endfunction
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
"Places the cursor at the top of the bookmarks table "Places the cursor at the top of the bookmarks table
function! s:NERDTree.CursorToBookmarkTable() function! s:NERDTree.CursorToBookmarkTable()
@@ -96,9 +90,9 @@ endfunction
"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 "FUNCTION: s:NERDTree.CursorToTreeWin(){{{1
"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', 1) call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1)
endfunction endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1 " Function: s:NERDTree.ExistsForBuffer() {{{1

View File

@@ -33,8 +33,7 @@ function! s:Opener._bufInWindows(bnum)
endfunction endfunction
" FUNCTION: Opener._checkToCloseTree(newtab) {{{1 " FUNCTION: Opener._checkToCloseTree(newtab) {{{1
" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see " Check the class options to see if the tree should be closed now.
" if the tree should be closed now.
" "
" Args: " Args:
" a:newtab - boolean. If set, only close the tree now if we are opening the " a:newtab - boolean. If set, only close the tree now if we are opening the
@@ -46,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab)
endif endif
if (a:newtab && self._where ==# 't') || !a:newtab if (a:newtab && self._where ==# 't') || !a:newtab
call g:NERDTree.CloseIfQuitOnOpen() call g:NERDTree.Close()
endif endif
endfunction endfunction
@@ -174,9 +173,8 @@ 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
call nerdtree#exec('wincmd p', 1) call nerdtree#exec('wincmd p', 1)
call nerdtree#exec('silent '. splitMode .' resize '. size, 1) call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1)
call nerdtree#exec('wincmd p', 0) call nerdtree#exec('wincmd p', 0)
endif endif
@@ -195,7 +193,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()
@@ -219,7 +217,7 @@ endfunction
" FUNCTION: Opener._openFile() {{{1 " FUNCTION: Opener._openFile() {{{1
function! s:Opener._openFile() function! s:Opener._openFile()
if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed if !self._stay && self._keepopen && get(b:, 'NERDTreeZoomed', 0)
call b:NERDTree.ui.toggleZoom() call b:NERDTree.ui.toggleZoom()
endif endif

View File

@@ -25,10 +25,10 @@ function! s:Path.AbsolutePathFor(pathStr)
if l:prependWorkingDir if l:prependWorkingDir
let l:result = getcwd() let l:result = getcwd()
if l:result[-1:] ==# s:Path.Slash() if l:result[-1:] == nerdtree#slash()
let l:result = l:result . a:pathStr let l:result = l:result . a:pathStr
else else
let l:result = l:result . s:Path.Slash() . a:pathStr let l:result = l:result . nerdtree#slash() . a:pathStr
endif endif
endif endif
@@ -99,50 +99,6 @@ function! s:Path.changeToDir()
endtry endtry
endfunction endfunction
" FUNCTION: Path.compareTo() {{{1
"
" Compares this Path to the given path and returns 0 if they are equal, -1 if
" this Path is 'less than' the given path, or 1 if it is 'greater'.
"
" Args:
" path: the path object to compare this to
"
" Return:
" 1, -1 or 0
function! s:Path.compareTo(path)
let thisPath = self.getLastPathComponent(1)
let thatPath = a:path.getLastPathComponent(1)
"if the paths are the same then clearly we return 0
if thisPath ==# thatPath
return 0
endif
let thisSS = self.getSortOrderIndex()
let thatSS = a:path.getSortOrderIndex()
"compare the sort sequences, if they are different then the return
"value is easy
if thisSS < thatSS
return -1
elseif thisSS > thatSS
return 1
else
if !g:NERDTreeSortHiddenFirst
let thisPath = substitute(thisPath, '^[._]', '', '')
let thatPath = substitute(thatPath, '^[._]', '', '')
endif
"if the sort sequences are the same then compare the paths
"alphabetically
let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
if pathCompare
return -1
else
return 1
endif
endif
endfunction
" FUNCTION: Path.Create(fullpath) {{{1 " FUNCTION: Path.Create(fullpath) {{{1
" "
" Factory method. " Factory method.
@@ -199,7 +155,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 . "'"
@@ -295,7 +251,10 @@ endfunction
" FUNCTION: Path.edit() {{{1 " FUNCTION: Path.edit() {{{1
function! s:Path.edit() function! s:Path.edit()
exec 'edit ' . self.str({'format': 'Edit'}) let l:bufname = self.str({'format': 'Edit'})
if bufname('%') !=# l:bufname
exec 'edit ' . l:bufname
endif
endfunction endfunction
" FUNCTION: Path.extractDriveLetter(fullpath) {{{1 " FUNCTION: Path.extractDriveLetter(fullpath) {{{1
@@ -329,7 +288,7 @@ function! s:Path._escChars()
return " `\|\"#%&,?()\*^<>$" return " `\|\"#%&,?()\*^<>$"
endif endif
return " \\`\|\"#%&,?()\*^<>[]$" return " \\`\|\"#%&,?()\*^<>[]{}$"
endfunction endfunction
" FUNCTION: Path.getDir() {{{1 " FUNCTION: Path.getDir() {{{1
@@ -435,7 +394,7 @@ function! s:Path.getSortKey()
let self._sortKey = [self.getSortOrderIndex()] + metadata let self._sortKey = [self.getSortOrderIndex()] + metadata
endif endif
let path = self.getLastPathComponent(1) let path = self.getLastPathComponent(0)
if !g:NERDTreeSortHiddenFirst if !g:NERDTreeSortHiddenFirst
let path = substitute(path, '^[._]', '', '') let path = substitute(path, '^[._]', '', '')
endif endif
@@ -524,7 +483,10 @@ endfunction
" returns true if this path matches the given ignore pattern " returns true if this path matches the given ignore pattern
function! s:Path._ignorePatternMatches(pattern) function! s:Path._ignorePatternMatches(pattern)
let pat = a:pattern let pat = a:pattern
if strpart(pat,len(pat)-7) ==# '[[dir]]' if strpart(pat,len(pat)-8) ==# '[[path]]'
let pat = strpart(pat,0, len(pat)-8)
return self.str() =~# pat
elseif strpart(pat,len(pat)-7) ==# '[[dir]]'
if !self.isDirectory if !self.isDirectory
return 0 return 0
endif endif
@@ -543,26 +505,36 @@ endfunction
" return 1 if this path is somewhere above the given path in the filesystem. " return 1 if this path is somewhere above the given path in the filesystem.
" "
" a:path should be a dir " a:path should be a dir
function! s:Path.isAncestor(path) function! s:Path.isAncestor(child)
if !self.isDirectory return a:child.isUnder(self)
return 0
endif
let this = self.str()
let that = a:path.str()
return stridx(that, this) ==# 0
endfunction endfunction
" FUNCTION: Path.isUnder(path) {{{1 " FUNCTION: Path.isUnder(path) {{{1
" return 1 if this path is somewhere under the given path in the filesystem. " return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path) function! s:Path.isUnder(parent)
if a:path.isDirectory ==# 0 if a:parent.isDirectory ==# 0
return 0 return 0
endif endif
if nerdtree#runningWindows() && a:parent.drive !=# self.drive
let this = self.str() return 0
let that = a:path.str() endif
return stridx(this, that . s:Path.Slash()) ==# 0 let l:this_count = len(self.pathSegments)
if l:this_count ==# 0
return 0
endif
let l:that_count = len(a:parent.pathSegments)
if l:that_count ==# 0
return 1
endif
if l:that_count >= l:this_count
return 0
endif
for i in range(0, l:that_count-1)
if self.pathSegments[i] !=# a:parent.pathSegments[i]
return 0
endif
endfor
return 1
endfunction endfunction
" FUNCTION: Path.JoinPathStrings(...) {{{1 " FUNCTION: Path.JoinPathStrings(...) {{{1
@@ -601,23 +573,6 @@ function! s:Path.New(pathStr)
return l:newPath return l:newPath
endfunction endfunction
" FUNCTION: Path.Slash() {{{1
" Return the path separator used by the underlying file system. Special
" consideration is taken for the use of the 'shellslash' option on Windows
" systems.
function! s:Path.Slash()
if nerdtree#runningWindows()
if exists('+shellslash') && &shellslash
return '/'
endif
return '\'
endif
return '/'
endfunction
" FUNCTION: Path.Resolve() {{{1 " FUNCTION: Path.Resolve() {{{1
" Invoke the vim resolve() function and return the result " Invoke the vim resolve() function and return the result
" This is necessary because in some versions of vim resolve() removes trailing " This is necessary because in some versions of vim resolve() removes trailing
@@ -802,7 +757,7 @@ function! s:Path._strForEdit()
" On Windows, the drive letter may be removed by "fnamemodify()". Add it " On Windows, the drive letter may be removed by "fnamemodify()". Add it
" back, if necessary. " back, if necessary.
if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash() if nerdtree#runningWindows() && l:result[0] == nerdtree#slash()
let l:result = self.drive . l:result let l:result = self.drive . l:result
endif endif
@@ -817,14 +772,14 @@ endfunction
" FUNCTION: Path._strForGlob() {{{1 " FUNCTION: Path._strForGlob() {{{1
function! s:Path._strForGlob() function! s:Path._strForGlob()
let lead = s:Path.Slash() let lead = nerdtree#slash()
"if we are running windows then slap a drive letter on the front "if we are running windows then slap a drive letter on the front
if nerdtree#runningWindows() if nerdtree#runningWindows()
let lead = self.drive . '\' let lead = self.drive . '\'
endif endif
let toReturn = lead . join(self.pathSegments, s:Path.Slash()) let toReturn = lead . join(self.pathSegments, nerdtree#slash())
if !nerdtree#runningWindows() if !nerdtree#runningWindows()
let toReturn = escape(toReturn, self._escChars()) let toReturn = escape(toReturn, self._escChars())
@@ -836,7 +791,7 @@ endfunction
" Return the absolute pathname associated with this Path object. The pathname " Return the absolute pathname associated with this Path object. The pathname
" returned is appropriate for the underlying file system. " returned is appropriate for the underlying file system.
function! s:Path._str() function! s:Path._str()
let l:separator = s:Path.Slash() let l:separator = nerdtree#slash()
let l:leader = l:separator let l:leader = l:separator
if nerdtree#runningWindows() if nerdtree#runningWindows()

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
@@ -241,7 +236,7 @@ function! s:TreeDirNode.getChildIndex(path)
let z = self.getChildCount() let z = self.getChildCount()
while a < z while a < z
let mid = (a+z)/2 let mid = (a+z)/2
let diff = a:path.compareTo(self.children[mid].path) let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path)
if diff ==# -1 if diff ==# -1
let z = mid let z = mid
@@ -283,8 +278,8 @@ function! s:TreeDirNode._glob(pattern, all)
else else
let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',')
" On Windows, the drive letter may be removed by fnamemodify(). " On Windows, the drive letter may be removed by "fnamemodify()".
if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash() if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash()
let l:pathSpec = self.path.drive . l:pathSpec let l:pathSpec = self.path.drive . l:pathSpec
endif endif
endif endif
@@ -382,11 +377,17 @@ endfunction
" 1. If cascaded, we don't know which dir is bookmarked or is a symlink. " 1. If cascaded, we don't know which dir is bookmarked or is a symlink.
" 2. If the parent is a symlink or is bookmarked, you end up with unparsable " 2. If the parent is a symlink or is bookmarked, you end up with unparsable
" text, and NERDTree cannot get the path of any child node. " text, and NERDTree cannot get the path of any child node.
" Also, return false if this directory is the tree root, which should never be
" part of a cascade.
function! s:TreeDirNode.isCascadable() function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir ==# 0 if g:NERDTreeCascadeSingleChildDir ==# 0
return 0 return 0
endif endif
if self.isRoot()
return 0
endif
if self.path.isSymLink if self.path.isSymLink
return 0 return 0
endif endif
@@ -430,6 +431,7 @@ function! s:TreeDirNode._initChildren(silent)
endtry endtry
endfor endfor
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
call self.sortChildren() call self.sortChildren()
call nerdtree#echo('') call nerdtree#echo('')
@@ -664,7 +666,7 @@ function! s:TreeDirNode.sortChildren()
if count(g:NERDTreeSortOrder, '*') < 1 if count(g:NERDTreeSortOrder, '*') < 1
call add(g:NERDTreeSortOrder, '*') call add(g:NERDTreeSortOrder, '*')
endif endif
let CompareFunc = function('nerdtree#compareNodesBySortKey') let CompareFunc = function('nerdtree#compareNodes')
call sort(self.children, CompareFunc) call sort(self.children, CompareFunc)
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
endfunction endfunction

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

@@ -67,6 +67,10 @@ function! s:UI._dumpHelp()
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n"
let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n"
let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n"
let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n"
let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n"
let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
@@ -284,7 +288,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
@@ -360,7 +368,7 @@ function! s:UI.saveScreenState()
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin()
let self._screenState['oldPos'] = getpos('.') let self._screenState['oldPos'] = getpos('.')
let self._screenState['oldTopLine'] = line('w0') let self._screenState['oldTopLine'] = line('w0')
let self._screenState['oldWindowSize']= winwidth('') let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('')
call nerdtree#exec(win . 'wincmd w', 1) call nerdtree#exec(win . 'wincmd w', 1)
catch catch
endtry endtry
@@ -508,8 +516,7 @@ endfunction
" zoom (maximize/minimize) the NERDTree window " zoom (maximize/minimize) the NERDTree window
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 call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1)
call nerdtree#exec('silent vertical resize '. size, 1)
let b:NERDTreeZoomed = 0 let b:NERDTreeZoomed = 0
else else
call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1)

View File

@@ -34,6 +34,10 @@ if executable('xdg-open')
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'})
endif endif
if nerdtree#runningWindows()
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'})
endif
if g:NERDTreePath.CopyingSupported() if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif endif
@@ -45,6 +49,10 @@ else
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
endif endif
if exists('*system')
call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'})
endif
"FUNCTION: s:inputPrompt(action){{{1 "FUNCTION: s:inputPrompt(action){{{1
"returns the string that should be prompted to the user for the given action "returns the string that should be prompted to the user for the given action
" "
@@ -141,12 +149,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
@@ -161,7 +169,7 @@ endfunction
function! NERDTreeAddNode() function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected() let curDirNode = g:NERDTreeDirNode.GetSelected()
let prompt = s:inputPrompt('add') let prompt = s:inputPrompt('add')
let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), 'file') let newNodeName = input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file')
if newNodeName ==# '' if newNodeName ==# ''
call nerdtree#echo('Node Creation Aborted.') call nerdtree#echo('Node Creation Aborted.')
@@ -196,6 +204,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 +217,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
@@ -242,8 +256,6 @@ endfunction
" FUNCTION: NERDTreeDeleteNode() {{{1 " FUNCTION: NERDTreeDeleteNode() {{{1
function! NERDTreeDeleteNode() function! NERDTreeDeleteNode()
let l:shellslash = &shellslash
let &shellslash = 0
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0 let confirmed = 0
@@ -279,7 +291,6 @@ function! NERDTreeDeleteNode()
else else
call nerdtree#echo('delete aborted') call nerdtree#echo('delete aborted')
endif endif
let &shellslash = l:shellslash
endfunction endfunction
" FUNCTION: NERDTreeListNode() {{{1 " FUNCTION: NERDTreeListNode() {{{1
@@ -324,8 +335,6 @@ endfunction
" FUNCTION: NERDTreeCopyNode() {{{1 " FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode() function! NERDTreeCopyNode()
let l:shellslash = &shellslash
let &shellslash = 0
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
let prompt = s:inputPrompt('copy') let prompt = s:inputPrompt('copy')
let newNodePath = input(prompt, currentNode.path.str(), 'file') let newNodePath = input(prompt, currentNode.path.str(), 'file')
@@ -361,7 +370,6 @@ function! NERDTreeCopyNode()
else else
call nerdtree#echo('Copy aborted.') call nerdtree#echo('Copy aborted.')
endif endif
let &shellslash = l:shellslash
redraw! redraw!
endfunction endfunction
@@ -382,44 +390,95 @@ 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
" FUNCTION: NERDTreeExecuteFileWindows() {{{1
function! NERDTreeExecuteFileWindows()
let l:node = g:NERDTreeFileNode.GetSelected()
if empty(l:node)
return
endif
call system('cmd.exe /c start "" ' . shellescape(l:node.path.str()))
endfunction
" FUNCTION: NERDTreeSystemCommand() {{{1
function! NERDTreeSystemCommand()
let l:node = g:NERDTreeFileNode.GetSelected()
if empty(l:node)
return
endif
let l:cwd = getcwd()
let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str()
execute 'cd '.l:directory
let l:nl = nr2char(10)
echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ ')))
execute 'cd '.l:cwd
endfunction 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

@@ -26,141 +26,114 @@ let loaded_nerd_tree = 1
let s:old_cpo = &cpoptions let s:old_cpo = &cpoptions
set cpoptions&vim set cpoptions&vim
"Function: s:initVariable() function {{{2 "SECTION: Initialize variable calls and other random constants {{{2
"This function is used to initialise a given variable to a given value. The let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1)
"variable is only initialised if it does not exist prior let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3)
" let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0)
"Args: let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0)
"var: the name of the var to be initialised let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1)
"value: the value to initialise var to let g:NERDTreeUseTCD = get(g:, 'NERDTreeUseTCD', 0)
" let g:NERDTreeChDirMode = get(g:, 'NERDTreeChDirMode', 0)
"Returns: let g:NERDTreeCreatePrefix = get(g:, 'NERDTreeCreatePrefix', 'silent')
"1 if the var is set, 0 otherwise let g:NERDTreeMinimalUI = get(g:, 'NERDTreeMinimalUI', 0)
function! s:initVariable(var, value) let g:NERDTreeMinimalMenu = get(g:, 'NERDTreeMinimalMenu', 0)
if !exists(a:var) let g:NERDTreeIgnore = get(g:, 'NERDTreeIgnore', ['\~$'])
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", 'g') . "'" let g:NERDTreeBookmarksFile = get(g:, 'NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks')
return 1 let g:NERDTreeBookmarksSort = get(g:, 'NERDTreeBookmarksSort', 1)
endif let g:NERDTreeHighlightCursorline = get(g:, 'NERDTreeHighlightCursorline', 1)
return 0 let g:NERDTreeHijackNetrw = get(g:, 'NERDTreeHijackNetrw', 1)
endfunction let g:NERDTreeMarkBookmarks = get(g:, 'NERDTreeMarkBookmarks', 1)
let g:NERDTreeMouseMode = get(g:, 'NERDTreeMouseMode', 1)
"SECTION: Init variable calls and other random constants {{{2 let g:NERDTreeNotificationThreshold = get(g:, 'NERDTreeNotificationThreshold', 100)
call s:initVariable('g:NERDTreeAutoCenter', 1) let g:NERDTreeQuitOnOpen = get(g:, 'NERDTreeQuitOnOpen', 0)
call s:initVariable('g:NERDTreeAutoCenterThreshold', 3) let g:NERDTreeRespectWildIgnore = get(g:, 'NERDTreeRespectWildIgnore', 0)
call s:initVariable('g:NERDTreeCaseSensitiveSort', 0) let g:NERDTreeShowBookmarks = get(g:, 'NERDTreeShowBookmarks', 0)
call s:initVariable('g:NERDTreeNaturalSort', 0) let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1)
call s:initVariable('g:NERDTreeSortHiddenFirst', 1) let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0)
call s:initVariable('g:NERDTreeUseTCD', 0) let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0)
call s:initVariable('g:NERDTreeChDirMode', 0) let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1)
call s:initVariable('g:NERDTreeCreatePrefix', 'silent')
call s:initVariable('g:NERDTreeMinimalUI', 0)
call s:initVariable('g:NERDTreeMinimalMenu', 0)
if !exists('g:NERDTreeIgnore')
let g:NERDTreeIgnore = ['\~$']
endif
call s:initVariable('g:NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks')
call s:initVariable('g:NERDTreeBookmarksSort', 1)
call s:initVariable('g:NERDTreeHighlightCursorline', 1)
call s:initVariable('g:NERDTreeHijackNetrw', 1)
call s:initVariable('g:NERDTreeMarkBookmarks', 1)
call s:initVariable('g:NERDTreeMouseMode', 1)
call s:initVariable('g:NERDTreeNotificationThreshold', 100)
call s:initVariable('g:NERDTreeQuitOnOpen', 0)
call s:initVariable('g:NERDTreeRespectWildIgnore', 0)
call s:initVariable('g:NERDTreeShowBookmarks', 0)
call s:initVariable('g:NERDTreeShowFiles', 1)
call s:initVariable('g:NERDTreeShowHidden', 0)
call s:initVariable('g:NERDTreeShowLineNumbers', 0)
call s:initVariable('g:NERDTreeSortDirs', 1)
if !nerdtree#runningWindows() && !nerdtree#runningCygwin() if !nerdtree#runningWindows() && !nerdtree#runningCygwin()
call s:initVariable('g:NERDTreeDirArrowExpandable', '▸') let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸')
call s:initVariable('g:NERDTreeDirArrowCollapsible', '▾') let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾')
else else
call s:initVariable('g:NERDTreeDirArrowExpandable', '+') let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '+')
call s:initVariable('g:NERDTreeDirArrowCollapsible', '~') let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '~')
endif endif
call s:initVariable('g:NERDTreeCascadeOpenSingleChildDir', 1) let g:NERDTreeCascadeOpenSingleChildDir = get(g:, 'NERDTreeCascadeOpenSingleChildDir', 1)
call s:initVariable('g:NERDTreeCascadeSingleChildDir', 1) let g:NERDTreeCascadeSingleChildDir = get(g:, 'NERDTreeCascadeSingleChildDir', 1)
if !exists('g:NERDTreeSortOrder') let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$', '\.bak$', '\~$'])
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
endif
let g:NERDTreeOldSortOrder = [] let g:NERDTreeOldSortOrder = []
call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO')
if has('conceal') if has('conceal')
call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07")
elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0")
call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00b7")
else else
call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00a0")
endif endif
if !exists('g:NERDTreeStatusline') "the exists() crap here is a hack to stop vim spazzing out when
"loading a session that was created with an open nerd tree. It spazzes
"because it doesnt store b:NERDTree(its a b: var, and its a hash)
let g:NERDTreeStatusline = get(g:, 'NERDTreeStatusline', "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}")
"the exists() crap here is a hack to stop vim spazzing out when let g:NERDTreeWinPos = get(g:, 'NERDTreeWinPos', 'left')
"loading a session that was created with an open nerd tree. It spazzes let g:NERDTreeWinSize = get(g:, 'NERDTreeWinSize', 31)
"because it doesnt store b:NERDTree(its a b: var, and its a hash)
let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}"
endif
call s:initVariable('g:NERDTreeWinPos', 'left')
call s:initVariable('g:NERDTreeWinSize', 31)
"init the shell commands that will be used to copy nodes, and remove dir trees "init the shell commands that will be used to copy nodes, and remove dir trees
"
"Note: the space after the command is important "Note: the space after the command is important
if nerdtree#runningWindows() if nerdtree#runningWindows()
call s:initVariable('g:NERDTreeRemoveDirCmd', 'rmdir /s /q ') let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rmdir /s /q ')
call s:initVariable('g:NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') let g:NERDTreeCopyDirCmd = get(g:, 'NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ')
call s:initVariable('g:NERDTreeCopyFileCmd', 'copy /y ') let g:NERDTreeCopyFileCmd = get(g:, 'NERDTreeCopyFileCmd', 'copy /y ')
else else
call s:initVariable('g:NERDTreeRemoveDirCmd', 'rm -rf ') let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rm -rf ')
call s:initVariable('g:NERDTreeCopyCmd', 'cp -r ') let g:NERDTreeCopyCmd = get(g:, 'NERDTreeCopyCmd', 'cp -r ')
endif endif
"SECTION: Init variable calls for key mappings {{{2 "SECTION: Init variable calls for key mappings {{{2
call s:initVariable('g:NERDTreeMapCustomOpen', '<CR>') let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
call s:initVariable('g:NERDTreeMapActivateNode', 'o') let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
call s:initVariable('g:NERDTreeMapChangeRoot', 'C') let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
call s:initVariable('g:NERDTreeMapChdir', 'cd') let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
call s:initVariable('g:NERDTreeMapCloseChildren', 'X') let g:NERDTreeMapCloseChildren = get(g:, 'NERDTreeMapCloseChildren', 'X')
call s:initVariable('g:NERDTreeMapCloseDir', 'x') let g:NERDTreeMapCloseDir = get(g:, 'NERDTreeMapCloseDir', 'x')
call s:initVariable('g:NERDTreeMapDeleteBookmark', 'D') let g:NERDTreeMapDeleteBookmark = get(g:, 'NERDTreeMapDeleteBookmark', 'D')
call s:initVariable('g:NERDTreeMapMenu', 'm') let g:NERDTreeMapMenu = get(g:, 'NERDTreeMapMenu', 'm')
call s:initVariable('g:NERDTreeMapHelp', '?') let g:NERDTreeMapHelp = get(g:, 'NERDTreeMapHelp', '?')
call s:initVariable('g:NERDTreeMapJumpFirstChild', 'K') let g:NERDTreeMapJumpFirstChild = get(g:, 'NERDTreeMapJumpFirstChild', 'K')
call s:initVariable('g:NERDTreeMapJumpLastChild', 'J') let g:NERDTreeMapJumpLastChild = get(g:, 'NERDTreeMapJumpLastChild', 'J')
call s:initVariable('g:NERDTreeMapJumpNextSibling', '<C-j>') let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '<C-j>')
call s:initVariable('g:NERDTreeMapJumpParent', 'p') let g:NERDTreeMapJumpParent = get(g:, 'NERDTreeMapJumpParent', 'p')
call s:initVariable('g:NERDTreeMapJumpPrevSibling', '<C-k>') let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '<C-k>')
call s:initVariable('g:NERDTreeMapJumpRoot', 'P') let g:NERDTreeMapJumpRoot = get(g:, 'NERDTreeMapJumpRoot', 'P')
call s:initVariable('g:NERDTreeMapOpenExpl', 'e') let g:NERDTreeMapOpenExpl = get(g:, 'NERDTreeMapOpenExpl', 'e')
call s:initVariable('g:NERDTreeMapOpenInTab', 't') let g:NERDTreeMapOpenInTab = get(g:, 'NERDTreeMapOpenInTab', 't')
call s:initVariable('g:NERDTreeMapOpenInTabSilent', 'T') let g:NERDTreeMapOpenInTabSilent = get(g:, 'NERDTreeMapOpenInTabSilent', 'T')
call s:initVariable('g:NERDTreeMapOpenRecursively', 'O') let g:NERDTreeMapOpenRecursively = get(g:, 'NERDTreeMapOpenRecursively', 'O')
call s:initVariable('g:NERDTreeMapOpenSplit', 'i') let g:NERDTreeMapOpenSplit = get(g:, 'NERDTreeMapOpenSplit', 'i')
call s:initVariable('g:NERDTreeMapOpenVSplit', 's') let g:NERDTreeMapOpenVSplit = get(g:, 'NERDTreeMapOpenVSplit', 's')
call s:initVariable('g:NERDTreeMapPreview', 'g' . NERDTreeMapActivateNode) let g:NERDTreeMapPreview = get(g:, 'NERDTreeMapPreview', 'g'.NERDTreeMapActivateNode)
call s:initVariable('g:NERDTreeMapPreviewSplit', 'g' . NERDTreeMapOpenSplit) let g:NERDTreeMapPreviewSplit = get(g:, 'NERDTreeMapPreviewSplit', 'g'.NERDTreeMapOpenSplit)
call s:initVariable('g:NERDTreeMapPreviewVSplit', 'g' . NERDTreeMapOpenVSplit) let g:NERDTreeMapPreviewVSplit = get(g:, 'NERDTreeMapPreviewVSplit', 'g'.NERDTreeMapOpenVSplit)
call s:initVariable('g:NERDTreeMapQuit', 'q') let g:NERDTreeMapQuit = get(g:, 'NERDTreeMapQuit', 'q')
call s:initVariable('g:NERDTreeMapRefresh', 'r') let g:NERDTreeMapRefresh = get(g:, 'NERDTreeMapRefresh', 'r')
call s:initVariable('g:NERDTreeMapRefreshRoot', 'R') let g:NERDTreeMapRefreshRoot = get(g:, 'NERDTreeMapRefreshRoot', 'R')
call s:initVariable('g:NERDTreeMapToggleBookmarks', 'B') let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B')
call s:initVariable('g:NERDTreeMapToggleFiles', 'F') let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F')
call s:initVariable('g:NERDTreeMapToggleFilters', 'f') let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f')
call s:initVariable('g:NERDTreeMapToggleHidden', 'I') let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I')
call s:initVariable('g:NERDTreeMapToggleZoom', 'A') let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A')
call s:initVariable('g:NERDTreeMapUpdir', 'u') let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u')
call s:initVariable('g:NERDTreeMapUpdirKeepOpen', 'U') let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U')
call s:initVariable('g:NERDTreeMapCWD', 'CD') let g:NERDTreeMapCWD = get(g:, 'NERDTreeMapCWD', 'CD')
call s:initVariable('g:NERDTreeMenuDown', 'j') let g:NERDTreeMenuDown = get(g:, 'NERDTreeMenuDown', 'j')
call s:initVariable('g:NERDTreeMenuUp', 'k') let g:NERDTreeMenuUp = get(g:, 'NERDTreeMenuUp', 'k')
"SECTION: Load class files{{{2 "SECTION: Load class files{{{2
call nerdtree#loadClassFiles() call nerdtree#loadClassFiles()
@@ -217,7 +190,7 @@ endfunction
function! NERDTreeFocus() function! NERDTreeFocus()
if g:NERDTree.IsOpen() if g:NERDTree.IsOpen()
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin(0)
else else
call g:NERDTreeCreator.ToggleTabTree('') call g:NERDTreeCreator.ToggleTabTree('')
endif endif

View File

@@ -19,32 +19,36 @@ 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=2 concealcursor=nvic
else else
exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL'
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,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir'
syn match NERDTreeCWD #^[</].*$# syn match NERDTreeCWD #^[</].*$#
"highlighting for bookmarks "highlighting for bookmarks
@@ -89,3 +93,5 @@ hi def link NERDTreeBookmark Statement
hi def link NERDTreeFlags Number hi def link NERDTreeFlags Number
hi def link NERDTreeCurrentNode Search hi def link NERDTreeCurrentNode Search
hi NERDTreeFile ctermbg=NONE guibg=NONE