mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7886fb6c4 | ||
|
|
82b1649f2e | ||
|
|
8d9b8dae67 | ||
|
|
960fda6299 | ||
|
|
fec3e57ad2 | ||
|
|
371feb7e54 | ||
|
|
4245517689 | ||
|
|
926ff0ec03 | ||
|
|
53eef21ad6 |
13
.github/PULL_REQUEST_TEMPLATE.md
vendored
13
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -5,9 +5,12 @@ Closes # <!-- Issue number this PR addresses. If none, remove this line. -->
|
|||||||
---
|
---
|
||||||
### New Version Info
|
### New Version Info
|
||||||
|
|
||||||
- [ ] Derive a new version number. Increment the:
|
#### Author's Instructions
|
||||||
- [ ] `MAJOR` version when you make incompatible API changes
|
- [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the:
|
||||||
- [ ] `MINOR` version when you add functionality in a backwards-compatible manner
|
- `MAJOR` version when you make incompatible API changes
|
||||||
- [ ] `PATCH` version when you make backwards-compatible bug fixes
|
- `MINOR` version when you add functionality in a backwards-compatible manner
|
||||||
|
- `PATCH` version when you make backwards-compatible bug fixes
|
||||||
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern.
|
- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern.
|
||||||
- [ ] Tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags`
|
#### Collaborator's Instructions
|
||||||
|
- [ ] 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`
|
||||||
|
|||||||
28
CHANGELOG.md
28
CHANGELOG.md
@@ -1,18 +1,34 @@
|
|||||||
# Change Log
|
# NERDTree Change Log
|
||||||
|
|
||||||
#### 6.1...
|
<!--
|
||||||
|
Introduce a new MAJOR.MINOR version with a 4-hash header.
|
||||||
|
|
||||||
|
PATCH versions are listed from newest to oldest under their respective MAJOR.MINOR version
|
||||||
|
in an unordered list. The format is:
|
||||||
|
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||||
|
-->
|
||||||
|
#### 6.4
|
||||||
|
- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/scrooloose/nerdtree/pull/1067)
|
||||||
|
#### 6.3
|
||||||
|
- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/scrooloose/nerdtree/pull/1060)
|
||||||
|
#### 6.2
|
||||||
|
- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/scrooloose/nerdtree/pull/1056)
|
||||||
|
- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/scrooloose/nerdtree/pull/1032)
|
||||||
|
#### 6.1
|
||||||
|
- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/scrooloose/nerdtree/pull/1049)
|
||||||
|
- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/scrooloose/nerdtree/pull/1048)
|
||||||
- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047)
|
- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/scrooloose/nerdtree/pull/1047)
|
||||||
- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045)
|
- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/scrooloose/nerdtree/pull/1045)
|
||||||
- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043)
|
- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/scrooloose/nerdtree/pull/1043)
|
||||||
#### 6.0...
|
#### 6.0
|
||||||
- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040)
|
- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/scrooloose/nerdtree/pull/1040)
|
||||||
- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035)
|
- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/scrooloose/nerdtree/pull/1035)
|
||||||
#### 5.3...
|
#### 5.3
|
||||||
- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038)
|
- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/scrooloose/nerdtree/pull/1038)
|
||||||
- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037)
|
- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/scrooloose/nerdtree/pull/1037)
|
||||||
- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031)
|
- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/scrooloose/nerdtree/pull/1031)
|
||||||
- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029)
|
- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/scrooloose/nerdtree/pull/1029)
|
||||||
#### 5.2...
|
#### 5.2
|
||||||
- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026)
|
- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/scrooloose/nerdtree/pull/1026)
|
||||||
- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021)
|
- **.8**: Revert [#1019](https://github.com/scrooloose/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/scrooloose/nerdtree/pull/1021)
|
||||||
- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019)
|
- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/scrooloose/nerdtree/pull/1019)
|
||||||
@@ -23,7 +39,7 @@
|
|||||||
- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013)
|
- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/scrooloose/nerdtree/pull/1013)
|
||||||
- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger)
|
- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger)
|
||||||
- **.0**: Expand functionality of `<CR>` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011)
|
- **.0**: Expand functionality of `<CR>` mapping. (PhilRunninger) [#1011](https://github.com/scrooloose/nerdtree/pull/1011)
|
||||||
#### 5.1...
|
#### 5.1
|
||||||
- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009)
|
- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/scrooloose/nerdtree/pull/1009)
|
||||||
- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008)
|
- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/scrooloose/nerdtree/pull/1008)
|
||||||
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
|
- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
|
||||||
|
|||||||
@@ -17,27 +17,62 @@ included documentation.
|
|||||||
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.
|
||||||
|
|
||||||
|
#### Vim 8+ packages
|
||||||
|
|
||||||
|
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
|
||||||
|
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
|
||||||
|
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
|
||||||
|
```
|
||||||
|
|
||||||
|
Otherwise, these are some of the 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.
|
||||||
|
|
||||||
#### [pathogen.vim](https://github.com/tpope/vim-pathogen)
|
#### [pathogen.vim](https://github.com/tpope/vim-pathogen)
|
||||||
|
|
||||||
|
In the terminal,
|
||||||
|
```bash
|
||||||
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
|
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
|
||||||
|
```
|
||||||
|
In your vimrc,
|
||||||
|
```vim
|
||||||
|
call pathogen#infect()
|
||||||
|
syntax on
|
||||||
|
filetype plugin indent on
|
||||||
|
```
|
||||||
|
|
||||||
Then reload Vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`, and check out `:help NERDTree.txt`.
|
Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`.
|
||||||
|
|
||||||
|
#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim)
|
||||||
|
```vim
|
||||||
|
call vundle#begin()
|
||||||
|
Plugin 'scrooloose/nerdtree'
|
||||||
|
call vundle#end()
|
||||||
|
```
|
||||||
|
|
||||||
|
#### [vim-plug](https://github.com/junegunn/vim-plug)
|
||||||
|
```vim
|
||||||
|
call plug#begin()
|
||||||
|
Plug 'scrooloose/nerdtree'
|
||||||
|
call plug#end()
|
||||||
|
```
|
||||||
|
|
||||||
#### [apt-vim](https://github.com/egalpin/apt-vim)
|
#### [apt-vim](https://github.com/egalpin/apt-vim)
|
||||||
|
```bash
|
||||||
apt-vim install -y https://github.com/scrooloose/nerdtree.git
|
apt-vim install -y https://github.com/scrooloose/nerdtree.git
|
||||||
|
```
|
||||||
|
|
||||||
F.A.Q.
|
F.A.Q. (here, and in the [Wiki](https://github.com/scrooloose/nerdtree/wiki))
|
||||||
------
|
------
|
||||||
|
|
||||||
> Is there any support for `git` flags?
|
#### Is there any support for `git` flags?
|
||||||
|
|
||||||
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
|
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
#### Can I have the nerdtree on every tab automatically?
|
||||||
> 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
|
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
|
buffers as they were intended to be used. Read this
|
||||||
@@ -46,53 +81,65 @@ 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)
|
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?
|
#### How can I open a NERDTree automatically when vim starts up?
|
||||||
|
|
||||||
Stick this in your vimrc: `autocmd vimenter * NERDTree`
|
Stick this in your vimrc: `autocmd vimenter * NERDTree`
|
||||||
|
|
||||||
---
|
---
|
||||||
> How can I open a NERDTree automatically when vim starts up if no files were specified?
|
#### How can I open a NERDTree automatically when vim starts up if no files were specified?
|
||||||
|
|
||||||
Stick this in your vimrc:
|
Stick this in your vimrc:
|
||||||
|
```vim
|
||||||
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 .`
|
Note: Now start vim with plain `vim`, not `vim .`
|
||||||
|
|
||||||
---
|
---
|
||||||
> How can I open NERDTree automatically when vim starts up on opening a directory?
|
#### 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
|
||||||
|
autocmd StdinReadPre * let s:std_in=1
|
||||||
|
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### How can I open NERDTree automatically when vim starts up on opening a directory?
|
||||||
|
```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() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | 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.
|
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`
|
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?
|
#### 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):
|
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
|
||||||
|
```vim
|
||||||
map <C-n> :NERDTreeToggle<CR>
|
map <C-n> :NERDTreeToggle<CR>
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
> How can I close vim if the only window left open is a NERDTree?
|
#### How can I close vim if the only window left open is a NERDTree?
|
||||||
|
|
||||||
Stick this in your vimrc:
|
Stick this in your vimrc:
|
||||||
|
```vim
|
||||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
> Can I have different highlighting for different file extensions?
|
#### Can I have different highlighting for different file extensions?
|
||||||
|
|
||||||
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
|
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
|
||||||
|
|
||||||
---
|
---
|
||||||
> How can I change default arrows?
|
#### How can I change default arrows?
|
||||||
|
|
||||||
Use these variables in your vimrc. Note that below are default arrow symbols
|
Use these variables in your vimrc. Note that below are default arrow symbols
|
||||||
|
```vim
|
||||||
let g:NERDTreeDirArrowExpandable = '▸'
|
let g:NERDTreeDirArrowExpandable = '▸'
|
||||||
let g:NERDTreeDirArrowCollapsible = '▾'
|
let g:NERDTreeDirArrowCollapsible = '▾'
|
||||||
|
```
|
||||||
|
|||||||
@@ -125,6 +125,14 @@ The following features and functionality are provided by the NERDTree:
|
|||||||
again. If no NERDTree exists for this tab then this command acts the
|
again. If no NERDTree exists for this tab then this command acts the
|
||||||
same as the |:NERDTree| command.
|
same as the |:NERDTree| command.
|
||||||
|
|
||||||
|
:NERDTreeToggleVCS [<start-directory> | <bookmark>] *:NERDTreeToggleVCS*
|
||||||
|
Like |:NERDTreeToggle|, but searches up the directory tree to find the top of
|
||||||
|
the version control system repository, and roots the NERDTree there. It
|
||||||
|
works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A
|
||||||
|
couple of examples: >
|
||||||
|
:NERDTreeToggleVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree)
|
||||||
|
:NERDTreeToggleVCS (opens root of repository containing CWD)
|
||||||
|
|
||||||
:NERDTreeFocus *:NERDTreeFocus*
|
:NERDTreeFocus *:NERDTreeFocus*
|
||||||
Opens (or reopens) the NERDTree if it is not currently visible;
|
Opens (or reopens) the NERDTree if it is not currently visible;
|
||||||
otherwise, the cursor is moved to the already-open NERDTree.
|
otherwise, the cursor is moved to the already-open NERDTree.
|
||||||
@@ -849,9 +857,17 @@ above nodes would then be sorted like this: >
|
|||||||
z110.txt
|
z110.txt
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeChDirMode*
|
*NERDTreeUseTCD*
|
||||||
|
Values: 0 or 1.
|
||||||
|
Default: 0.
|
||||||
|
|
||||||
Values: 0, 1 or 2.
|
By default, NERDTree will use the `:cd` command to change the current working
|
||||||
|
directory. If this setting is turned on, and the `:tcd` command is available, it
|
||||||
|
will be used instead.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTreeChDirMode*
|
||||||
|
Values: 0, 1, 2, or 3.
|
||||||
Default: 0.
|
Default: 0.
|
||||||
|
|
||||||
Use this setting to tell the script when (if at all) to change the current
|
Use this setting to tell the script when (if at all) to change the current
|
||||||
@@ -871,6 +887,9 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD
|
|||||||
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
||||||
root then the CWD will become /home/marty/foobar/baz.
|
root then the CWD will become /home/marty/foobar/baz.
|
||||||
|
|
||||||
|
If the set to 3, then it behaves the same as if set to 2, and the CWD is
|
||||||
|
changed whenever changing tabs to whatever the tree root is on that tab.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeHighlightCursorline*
|
*NERDTreeHighlightCursorline*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
@@ -980,7 +999,6 @@ then (to single click activate it) you must click somewhere in
|
|||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeQuitOnOpen*
|
*NERDTreeQuitOnOpen*
|
||||||
|
|
||||||
Values: 0,1,2 or 3.
|
Values: 0,1,2 or 3.
|
||||||
Default: 0
|
Default: 0
|
||||||
|
|
||||||
@@ -1297,6 +1315,10 @@ following code conventions are used:
|
|||||||
See this blog post for more details:
|
See this blog post for more details:
|
||||||
http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
|
http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
|
||||||
|
|
||||||
|
A number of API functions take a callback argument to call. The callback can
|
||||||
|
be either a string with the name of a function to call, or a |Funcref| object
|
||||||
|
which will be called directly.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
4.1. Key map API *NERDTreeKeymapAPI*
|
4.1. Key map API *NERDTreeKeymapAPI*
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ endfunction
|
|||||||
"FUNCTION: KeyMap.invoke() {{{1
|
"FUNCTION: KeyMap.invoke() {{{1
|
||||||
"Call the KeyMaps callback function
|
"Call the KeyMaps callback function
|
||||||
function! s:KeyMap.invoke(...)
|
function! s:KeyMap.invoke(...)
|
||||||
let Callback = function(self.callback)
|
let Callback = type(self.callback) == v:t_func ? self.callback : function(self.callback)
|
||||||
if a:0
|
if a:0
|
||||||
call Callback(a:1)
|
call Callback(a:1)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ endfunction
|
|||||||
"specified
|
"specified
|
||||||
function! s:MenuItem.enabled()
|
function! s:MenuItem.enabled()
|
||||||
if self.isActiveCallback != -1
|
if self.isActiveCallback != -1
|
||||||
return {self.isActiveCallback}()
|
return type(self.isActiveCallback) == v:t_func ? self.isActiveCallback() : {self.isActiveCallback}()
|
||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
@@ -94,9 +94,13 @@ function! s:MenuItem.execute()
|
|||||||
call mc.showMenu()
|
call mc.showMenu()
|
||||||
else
|
else
|
||||||
if self.callback != -1
|
if self.callback != -1
|
||||||
|
if type(self.callback) == v:t_func
|
||||||
|
call self.callback()
|
||||||
|
else
|
||||||
call {self.callback}()
|
call {self.callback}()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.isSeparator() {{{1
|
"FUNCTION: MenuItem.isSeparator() {{{1
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function! s:NERDTree.changeRoot(node)
|
|||||||
call self.root.open()
|
call self.root.open()
|
||||||
|
|
||||||
"change dir to the dir of the new root if instructed to
|
"change dir to the dir of the new root if instructed to
|
||||||
if g:NERDTreeChDirMode ==# 2
|
if g:NERDTreeChDirMode >= 2
|
||||||
call self.root.path.changeToDir()
|
call self.root.path.changeToDir()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ endfunction
|
|||||||
function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
|
function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
|
||||||
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
|
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
|
||||||
|
|
||||||
for listener in s:Notifier.GetListenersForEvent(a:event)
|
for Listener in s:Notifier.GetListenersForEvent(a:event)
|
||||||
call {listener}(event)
|
let Callback = type(Listener) == v:t_func ? Listener : function(Listener)
|
||||||
|
call Callback(event)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,13 @@ function! s:Path.changeToDir()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
try
|
||||||
|
if g:NERDTreeUseTCD && exists(":tcd") == 2
|
||||||
|
execute "tcd " . dir
|
||||||
|
call nerdtree#echo("Tab's CWD is now: " . getcwd())
|
||||||
|
else
|
||||||
execute "cd " . dir
|
execute "cd " . dir
|
||||||
call nerdtree#echo("CWD is now: " . getcwd())
|
call nerdtree#echo("CWD is now: " . getcwd())
|
||||||
|
endif
|
||||||
catch
|
catch
|
||||||
throw "NERDTree.PathChangeError: cannot change CWD to " . dir
|
throw "NERDTree.PathChangeError: cannot change CWD to " . dir
|
||||||
endtry
|
endtry
|
||||||
@@ -495,8 +500,9 @@ function! s:Path.ignore(nerdtree)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for callback in g:NERDTree.PathFilters()
|
for Callback in g:NERDTree.PathFilters()
|
||||||
if {callback}({'path': self, 'nerdtree': a:nerdtree})
|
let Callback = type(Callback) == v:t_func ? Callback : function(Callback)
|
||||||
|
if Callback({'path': self, 'nerdtree': a:nerdtree})
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -369,7 +369,11 @@ endfunction
|
|||||||
function! NERDTreeCopyPath()
|
function! NERDTreeCopyPath()
|
||||||
let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
|
let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
|
||||||
if has("clipboard")
|
if has("clipboard")
|
||||||
|
if &clipboard == "unnamedplus"
|
||||||
|
let @+ = l:nodePath
|
||||||
|
else
|
||||||
let @* = l:nodePath
|
let @* = l:nodePath
|
||||||
|
endif
|
||||||
call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.")
|
call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.")
|
||||||
else
|
else
|
||||||
call nerdtree#echo("The full path is: " . l:nodePath)
|
call nerdtree#echo("The full path is: " . l:nodePath)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"
|
"
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
command! -n=? -complete=dir -bar NERDTreeVCS :call <SID>CreateTabTreeVCS('<args>')
|
command! -n=? -complete=dir -bar NERDTreeVCS :call <SID>CreateTabTreeVCS('<args>')
|
||||||
|
command! -n=? -complete=dir -bar NERDTreeToggleVCS :call <SID>ToggleTabTreeVCS('<args>')
|
||||||
|
|
||||||
" FUNCTION: s:CreateTabTreeVCS(a:name) {{{1
|
" FUNCTION: s:CreateTabTreeVCS(a:name) {{{1
|
||||||
function! s:CreateTabTreeVCS(name)
|
function! s:CreateTabTreeVCS(name)
|
||||||
@@ -19,6 +20,14 @@ function! s:CreateTabTreeVCS(name)
|
|||||||
call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str())
|
call g:NERDTreeCreator.createTabTree(empty(l:path) ? "" : l:path._str())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1
|
||||||
|
" Behaves the same as ToggleTabTree except roots directory at VCS root
|
||||||
|
function! s:ToggleTabTreeVCS(name)
|
||||||
|
let l:path = g:NERDTreeCreator._pathForString(a:name)
|
||||||
|
let l:path = s:FindParentVCSRoot(l:path)
|
||||||
|
call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? "" : l:path._str())
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:FindParentVCSRoot(a:path) {{{1
|
" FUNCTION: s:FindParentVCSRoot(a:path) {{{1
|
||||||
" Finds the root version control system folder of the given path. If a:path is
|
" Finds the root version control system folder of the given path. If a:path is
|
||||||
" not part of a repository, return the original path.
|
" not part of a repository, return the original path.
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
|||||||
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||||
call s:initVariable("g:NERDTreeNaturalSort", 0)
|
call s:initVariable("g:NERDTreeNaturalSort", 0)
|
||||||
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
|
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
|
||||||
|
call s:initVariable("g:NERDTreeUseTCD", 0)
|
||||||
call s:initVariable("g:NERDTreeChDirMode", 0)
|
call s:initVariable("g:NERDTreeChDirMode", 0)
|
||||||
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
|
call s:initVariable("g:NERDTreeCreatePrefix", "silent")
|
||||||
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
||||||
@@ -170,10 +171,10 @@ call nerdtree#ui_glue#setupCommands()
|
|||||||
"============================================================
|
"============================================================
|
||||||
augroup NERDTree
|
augroup NERDTree
|
||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
|
exec "autocmd BufLeave,WinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif"
|
||||||
|
|
||||||
"disallow insert mode in the NERDTree
|
"disallow insert mode in the NERDTree
|
||||||
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
exec "autocmd BufEnter,WinEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
if g:NERDTreeHijackNetrw
|
if g:NERDTreeHijackNetrw
|
||||||
@@ -183,6 +184,12 @@ if g:NERDTreeHijackNetrw
|
|||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if g:NERDTreeChDirMode == 3
|
||||||
|
augroup NERDTreeChDirOnTabSwitch
|
||||||
|
autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
" SECTION: Public API {{{1
|
" SECTION: Public API {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
function! NERDTreeAddMenuItem(options)
|
function! NERDTreeAddMenuItem(options)
|
||||||
|
|||||||
Reference in New Issue
Block a user