mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
43 Commits
6.10.12
...
690d061b59
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690d061b59 | ||
|
|
0b3c1dc0fa | ||
|
|
915f64b3be | ||
|
|
b4b4130f3c | ||
|
|
9b465acb27 | ||
|
|
09aec2cfca | ||
|
|
fbb71fcd90 | ||
|
|
6ad85ec29b | ||
|
|
f3a4d8eaa8 | ||
|
|
bdf81a086d | ||
|
|
60b5e602e9 | ||
|
|
bc606c43e2 | ||
|
|
6acfc48d80 | ||
|
|
aa29fbe481 | ||
|
|
e5599272a9 | ||
|
|
ff9469a14a | ||
|
|
fefea5d382 | ||
|
|
a954661824 | ||
|
|
9ec27d45a8 | ||
|
|
50a394b2bf | ||
|
|
0cb04e9245 | ||
|
|
4c588f1820 | ||
|
|
ff002d2132 | ||
|
|
79f6f912f4 | ||
|
|
edc9460859 | ||
|
|
334542c361 | ||
|
|
9184ec05bd | ||
|
|
ea4833da8a | ||
|
|
c99395a323 | ||
|
|
d69b68bf31 | ||
|
|
3a66272486 | ||
|
|
b1f5bb60df | ||
|
|
32168889bd | ||
|
|
aedd0653ad | ||
|
|
1f2e28d476 | ||
|
|
6895e5259e | ||
|
|
c46e12a886 | ||
|
|
fc85a6f07c | ||
|
|
eed488b1cd | ||
|
|
9310f91476 | ||
|
|
e731b84559 | ||
|
|
7eee457efa | ||
|
|
aa7e97b7ff |
15
.github/PULL_REQUEST_TEMPLATE.md
vendored
15
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -5,18 +5,3 @@ Closes # <!-- Enter the issue number this PR addresses. If none, remove this
|
|||||||
---
|
---
|
||||||
### New Version Info
|
### New Version Info
|
||||||
|
|
||||||
#### Author's Instructions
|
|
||||||
- [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the:
|
|
||||||
- `MAJOR` version when you make incompatible API changes
|
|
||||||
- `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.
|
|
||||||
#### Collaborator's Instructions
|
|
||||||
- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary.
|
|
||||||
- [ ] 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
|
|
||||||
```
|
|
||||||
|
|||||||
4
.github/workflows/vint.yml
vendored
4
.github/workflows/vint.yml
vendored
@@ -7,9 +7,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v3
|
||||||
- name: Run vint with reviewdog
|
- name: Run vint with reviewdog
|
||||||
uses: reviewdog/action-vint@v1.0.1
|
uses: reviewdog/action-vint@v1
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.github_token }}
|
github_token: ${{ secrets.github_token }}
|
||||||
reporter: github-pr-review
|
reporter: github-pr-review
|
||||||
|
|||||||
44
CHANGELOG.md
44
CHANGELOG.md
@@ -3,8 +3,52 @@
|
|||||||
PATCH versions are listed from newest to oldest under their respective MAJOR.MINOR
|
PATCH versions are listed from newest to oldest under their respective MAJOR.MINOR
|
||||||
version in an unordered list. The format is:
|
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)
|
||||||
|
or
|
||||||
|
- **.PATCH**:
|
||||||
|
- Pull Request Title 1 (PR Author) [PR Number](Link to PR)
|
||||||
|
- Pull Request Title 2 (PR Author) [PR Number](Link to PR)
|
||||||
|
.
|
||||||
|
.
|
||||||
|
.
|
||||||
|
- Pull Request Title n (PR Author) [PR Number](Link to PR)
|
||||||
-->
|
-->
|
||||||
|
#### 7.1
|
||||||
|
- **.3**:
|
||||||
|
- docs: update FAQ snippets containing quit command. (rzvxa) [#1417](https://github.com/preservim/nerdtree/pull/1417)
|
||||||
|
- feat: jump to bookmark table shortcut. (ds2606, rzvxa) [#1394](https://github.com/preservim/nerdtree/pull/1394)
|
||||||
|
- fix: typo in docs for show file lines setting. (lothardp) [#1426](https://github.com/preservim/nerdtree/pull/1426)
|
||||||
|
- **.2**:
|
||||||
|
- fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409)
|
||||||
|
- fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405)
|
||||||
|
- **.1**:
|
||||||
|
- fix: change default binding of filelines to `FL`. (rzvxa) [#1400](https://github.com/preservim/nerdtree/pull/1400)
|
||||||
|
- fix: toggle zoom resizing. (ds2606) [#1395](https://github.com/preservim/nerdtree/pull/1395)
|
||||||
|
- **.0**:
|
||||||
|
- fix: typo in the docs. (bl4kraven) [#1390](https://github.com/preservim/nerdtree/pull/1390)
|
||||||
|
- feat: add NERDTreeExplore command. (msibal6) [#1389](https://github.com/preservim/nerdtree/pull/1389)
|
||||||
|
- fix: mapping description in NERDTree.txt. (roccomao) [#1393](https://github.com/preservim/nerdtree/pull/1393)
|
||||||
|
#### 7.0
|
||||||
|
- **.1**:
|
||||||
|
- Fix NERDTreeFind to handle directory case sensitivity. (dangibson) [#1387](https://github.com/preservim/nerdtree/pull/1387)
|
||||||
|
- New Show file lines toggle. (hsnks100) [#1384](https://github.com/preservim/nerdtree/pull/1384)
|
||||||
|
- Add case sensitivity for refreshing nodes. (rzvxa) [#1382](https://github.com/preservim/nerdtree/pull/1382)
|
||||||
|
- Clarified the NERDTreeChangePermissions prompt. (rzvxa) [#1381](https://github.com/preservim/nerdtree/pull/1381)
|
||||||
|
- New reveal functionality for Windows. (rzvxa) [#1366](https://github.com/preservim/nerdtree/pull/1366)
|
||||||
|
- Fix bracket escaping in path names. (kai-patel) [#1359](https://github.com/preservim/nerdtree/pull/1359)
|
||||||
|
- Fix Case Sensitive Move Operation. (rzvxa) [#1375](https://github.com/preservim/nerdtree/pull/1375)
|
||||||
|
- New menu command for changing selected node permissions. (mjkloeckner) [#1348](https://github.com/preservim/nerdtree/pull/1348)
|
||||||
|
- Fix documentation errors. (BubuDavid) [#1372](https://github.com/preservim/nerdtree/pull/1372)
|
||||||
|
- Fix typo in nerdtree.vim file. (SandeshPyakurel) [#1380](https://github.com/preservim/nerdtree/pull/1380)
|
||||||
|
- **.0**:
|
||||||
|
- Now we warn about invalid files instead of ignoring them silently. (rmonico) [#1365](https://github.com/preservim/nerdtree/pull/1365)
|
||||||
|
- New g:NERDTreeWinPos options for top and bottom. (rzvxa) [#1363](https://github.com/preservim/nerdtree/pull/1363)
|
||||||
|
- Fix error in README. (nickspoons) [#1330](https://github.com/preservim/nerdtree/pull/1330)
|
||||||
|
- Fix typo in the documentation. (chapeupreto) [#1306](https://github.com/preservim/nerdtree/pull/1306)
|
||||||
#### 6.10
|
#### 6.10
|
||||||
|
- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269)
|
||||||
|
- **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266)
|
||||||
|
- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265)
|
||||||
|
- **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261)
|
||||||
- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259)
|
- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259)
|
||||||
- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243)
|
- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243)
|
||||||
- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249)
|
- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249)
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
|
|||||||
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`.
|
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`.
|
||||||
|
|
||||||
## NERDTree Plugins
|
## 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.
|
NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API 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.
|
||||||
|
|
||||||
* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree.
|
* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree.
|
||||||
* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders,
|
* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders.
|
||||||
* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype.
|
* [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.
|
* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions.
|
||||||
* [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-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree.
|
||||||
@@ -150,6 +150,24 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in
|
|||||||
|
|
||||||
### How can I close Vim or a tab automatically when NERDTree is the last window?
|
### How can I close Vim or a tab automatically when NERDTree is the last window?
|
||||||
|
|
||||||
|
Because of the changes in how Vim handles its `autocmd` and layout locking `quit` command is no longer available in Vim9 auto commands, Depending on which version you're running select one of these solutions.
|
||||||
|
|
||||||
|
__NeoVim users should be able to choose either one of them!__
|
||||||
|
|
||||||
|
#### Vim9
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||||
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
|
||||||
|
```
|
||||||
|
---
|
||||||
|
```vim
|
||||||
|
" Close the tab if NERDTree is the only window remaining in it.
|
||||||
|
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Vim8 or older
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||||
@@ -164,7 +182,7 @@ autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTa
|
|||||||
|
|
||||||
```vim
|
```vim
|
||||||
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
|
" 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 |
|
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
|
||||||
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
|
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -172,7 +190,7 @@ autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_
|
|||||||
|
|
||||||
```vim
|
```vim
|
||||||
" Open the existing NERDTree on each new tab.
|
" Open the existing NERDTree on each new tab.
|
||||||
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
|
autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif
|
||||||
```
|
```
|
||||||
or change your NERDTree-launching shortcut key like so:
|
or change your NERDTree-launching shortcut key like so:
|
||||||
```vim
|
```vim
|
||||||
@@ -183,11 +201,33 @@ nnoremap <C-n> :NERDTreeMirror<CR>:NERDTreeFocus<CR>
|
|||||||
### How can I change the default arrows?
|
### How can I change the default arrows?
|
||||||
|
|
||||||
```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.
|
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.
|
||||||
|
|
||||||
|
### How can I show lines of files?
|
||||||
|
|
||||||
|
```vim
|
||||||
|
let g:NERDTreeFileLines = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Lines in the file are displayed as shown below.
|
||||||
|
```
|
||||||
|
</pack/packer/start/nerdtree/
|
||||||
|
▸ autoload/
|
||||||
|
▸ doc/
|
||||||
|
▸ lib/
|
||||||
|
▸ nerdtree_plugin/
|
||||||
|
▸ plugin/
|
||||||
|
▸ syntax/
|
||||||
|
_config.yml (1)
|
||||||
|
CHANGELOG.md (307)
|
||||||
|
LICENCE (13)
|
||||||
|
README.markdown (234)
|
||||||
|
screenshot.png (219)
|
||||||
|
```
|
||||||
|
|
||||||
### Can NERDTree access remote files via scp or ftp?
|
### Can NERDTree access remote files via scp or ftp?
|
||||||
|
|
||||||
Short answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression.
|
Short answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression.
|
||||||
|
|||||||
@@ -112,18 +112,18 @@ function! nerdtree#compareNodePaths(p1, p2) abort
|
|||||||
" Compare chunks upto common length.
|
" Compare chunks upto common length.
|
||||||
" If chunks have different type, the one which has
|
" If chunks have different type, the one which has
|
||||||
" integer type is the lesser.
|
" integer type is the lesser.
|
||||||
if type(sortKey1[i]) ==# type(sortKey2[i])
|
if type(sortKey1[i]) == type(sortKey2[i])
|
||||||
if sortKey1[i] <# sortKey2[i]
|
if sortKey1[i] <# sortKey2[i]
|
||||||
return - 1
|
return - 1
|
||||||
elseif sortKey1[i] ># sortKey2[i]
|
elseif sortKey1[i] ># sortKey2[i]
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
elseif type(sortKey1[i]) ==# v:t_number
|
elseif type(sortKey1[i]) == type(0)
|
||||||
return -1
|
return -1
|
||||||
elseif type(sortKey2[i]) ==# v:t_number
|
elseif type(sortKey2[i]) == type(0)
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
let i = i + 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Keys are identical upto common length.
|
" Keys are identical upto common length.
|
||||||
@@ -198,16 +198,74 @@ function! nerdtree#postSourceActions() abort
|
|||||||
runtime! nerdtree_plugin/**/*.vim
|
runtime! nerdtree_plugin/**/*.vim
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: nerdtree#runningWindows(dir) {{{2
|
"FUNCTION: nerdtree#runningWindows() {{{2
|
||||||
function! nerdtree#runningWindows() abort
|
function! nerdtree#runningWindows() abort
|
||||||
return has('win16') || has('win32') || has('win64')
|
return has('win16') || has('win32') || has('win64')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: nerdtree#runningCygwin(dir) {{{2
|
"FUNCTION: nerdtree#runningCygwin() {{{2
|
||||||
function! nerdtree#runningCygwin() abort
|
function! nerdtree#runningCygwin() abort
|
||||||
return has('win32unix')
|
return has('win32unix')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: nerdtree#runningMac() {{{2
|
||||||
|
function! nerdtree#runningMac() abort
|
||||||
|
return has('gui_mac') || has('gui_macvim') || has('mac') || has('osx')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: nerdtree#osDefaultCaseSensitiveFS() {{{2
|
||||||
|
function! nerdtree#osDefaultCaseSensitiveFS() abort
|
||||||
|
return s:osDefaultCaseSensitiveFS
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: nerdtree#caseSensitiveFS() {{{2
|
||||||
|
function! nerdtree#caseSensitiveFS() abort
|
||||||
|
return g:NERDTreeCaseSensitiveFS == 1 ||
|
||||||
|
\((g:NERDTreeCaseSensitiveFS == 2 || g:NERDTreeCaseSensitiveFS == 3) &&
|
||||||
|
\nerdtree#osDefaultCaseSensitiveFS())
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: nerdtree#pathEquals(lhs, rhs) {{{2
|
||||||
|
function! nerdtree#pathEquals(lhs, rhs) abort
|
||||||
|
if nerdtree#caseSensitiveFS()
|
||||||
|
return a:lhs ==# a:rhs
|
||||||
|
else
|
||||||
|
return a:lhs ==? a:rhs
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: nerdtree#onBufLeave() {{{2
|
||||||
|
" used for handling the nerdtree BufLeave/WinLeave events.
|
||||||
|
function! nerdtree#onBufLeave() abort
|
||||||
|
" detect whether we are in the middle of sourcing a session.
|
||||||
|
" if it is a buffer from the sourced session we need to restore it.
|
||||||
|
if exists('g:SessionLoad') && !exists('b:NERDTree')
|
||||||
|
let bname = bufname('%')
|
||||||
|
" is the buffer for a tab tree?
|
||||||
|
if bname =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'tab_\d\+$'
|
||||||
|
" rename loaded buffer and mark it as trash to prevent this event
|
||||||
|
" getting fired again
|
||||||
|
exec 'file TRASH_' . bname
|
||||||
|
" delete the trash buffer
|
||||||
|
exec 'bwipeout!'
|
||||||
|
" rescue the tab tree at the current working directory
|
||||||
|
call g:NERDTreeCreator.CreateTabTree(getcwd())
|
||||||
|
" is the buffer for a window tree?
|
||||||
|
elseif bname =~# '^' . g:NERDTreeCreator.BufNamePrefix(). 'win_\d\+$'
|
||||||
|
" rescue the window tree at the current working directory
|
||||||
|
call g:NERDTreeCreator.CreateWindowTree(getcwd())
|
||||||
|
else " unknown buffer type
|
||||||
|
" rename buffer to mark it as broken.
|
||||||
|
exec 'file BROKEN_' . bname
|
||||||
|
call nerdtree#echoError('Failed to restore "' . bname . '" from session. Is this session created with an older version of NERDTree?')
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if g:NERDTree.IsOpen()
|
||||||
|
call b:NERDTree.ui.saveScreenState()
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" SECTION: View Functions {{{1
|
" SECTION: View Functions {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
|
|
||||||
@@ -246,4 +304,12 @@ function! nerdtree#renderView() abort
|
|||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
if nerdtree#runningWindows()
|
||||||
|
let s:osDefaultCaseSensitiveFS = 0
|
||||||
|
elseif nerdtree#runningMac()
|
||||||
|
let s:osDefaultCaseSensitiveFS = 0
|
||||||
|
else
|
||||||
|
let s:osDefaultCaseSensitiveFS = 1
|
||||||
|
endif
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
|
|||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': 'all', 'callback': s.'toggleShowBookmarks' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': 'all', 'callback': s.'toggleShowBookmarks' })
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFileLines, 'scope': 'all', 'callback': s.'toggleShowFileLines' })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': 'Node', 'callback': s.'closeCurrentDir' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': 'Node', 'callback': s.'closeCurrentDir' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' })
|
||||||
@@ -69,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
|
|||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
||||||
@@ -495,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort
|
|||||||
call b:NERDTree.ui.centerView()
|
call b:NERDTree.ui.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:jumpToBookmarks() {{{1
|
||||||
|
" moves the cursor to the bookmark table
|
||||||
|
function! s:jumpToBookmarks() abort
|
||||||
|
try
|
||||||
|
if b:NERDTree.ui.getShowBookmarks()
|
||||||
|
call g:NERDTree.CursorToBookmarkTable()
|
||||||
|
else
|
||||||
|
call b:NERDTree.ui.setShowBookmarks(1)
|
||||||
|
endif
|
||||||
|
catch /^NERDTree/
|
||||||
|
call nerdtree#echoError('Failed to jump to the bookmark table')
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||||
" Open the Bookmark that has the specified name. This function provides the
|
" Open the Bookmark that has the specified name. This function provides the
|
||||||
" implementation for the :OpenBookmark command.
|
" implementation for the :OpenBookmark command.
|
||||||
@@ -641,6 +658,7 @@ endfunction
|
|||||||
function! nerdtree#ui_glue#setupCommands() abort
|
function! nerdtree#ui_glue#setupCommands() abort
|
||||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
|
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
|
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
|
||||||
|
command! -n=? -complete=dir -bar NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('<args>')
|
||||||
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
|
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
|
||||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
|
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||||
@@ -685,6 +703,12 @@ function! s:toggleShowHidden() abort
|
|||||||
call b:NERDTree.ui.toggleShowHidden()
|
call b:NERDTree.ui.toggleShowHidden()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:toggleShowFileLines() {{{1
|
||||||
|
" toggles the display of hidden files
|
||||||
|
function! s:toggleShowFileLines() abort
|
||||||
|
call b:NERDTree.ui.toggleShowFileLines()
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:toggleZoom() {{{1
|
" FUNCTION: s:toggleZoom() {{{1
|
||||||
function! s:toggleZoom() abort
|
function! s:toggleZoom() abort
|
||||||
call b:NERDTree.ui.toggleZoom()
|
call b:NERDTree.ui.toggleZoom()
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ I........Toggle whether hidden files displayed......................|NERDTree-I|
|
|||||||
f........Toggle whether the file filters are used...................|NERDTree-f|
|
f........Toggle whether the file filters are used...................|NERDTree-f|
|
||||||
F........Toggle whether files are displayed.........................|NERDTree-F|
|
F........Toggle whether files are displayed.........................|NERDTree-F|
|
||||||
B........Toggle whether the bookmark table is displayed.............|NERDTree-B|
|
B........Toggle whether the bookmark table is displayed.............|NERDTree-B|
|
||||||
|
L........Toggle whether the number of lines in files is displayed..|NERDTree-FL|
|
||||||
|
|
||||||
q........Close the NERDTree window..................................|NERDTree-q|
|
q........Close the NERDTree window..................................|NERDTree-q|
|
||||||
A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A|
|
A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A|
|
||||||
@@ -601,6 +602,14 @@ Applies to: no restrictions.
|
|||||||
|
|
||||||
Toggles whether the bookmarks table is displayed.
|
Toggles whether the bookmarks table is displayed.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTree-FL*
|
||||||
|
Default key: FL
|
||||||
|
Map setting: *NERDTreeMapToggleFileLines*
|
||||||
|
Applies to: no restrictions.
|
||||||
|
|
||||||
|
Toggles whether the number of lines in files is displayed.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTree-q*
|
*NERDTree-q*
|
||||||
Default key: q
|
Default key: q
|
||||||
@@ -673,6 +682,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`.
|
|||||||
|
|
||||||
|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering.
|
|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering.
|
||||||
|
|
||||||
|
|NERDTreeCaseSensitiveFS| Tells the NERDTree whether or not it is
|
||||||
|
running in on a case sensitive file system.
|
||||||
|
|
||||||
|NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case
|
|NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case
|
||||||
sensitive or not when sorting nodes.
|
sensitive or not when sorting nodes.
|
||||||
|
|
||||||
@@ -808,6 +820,26 @@ Default: 3
|
|||||||
This setting controls the "sensitivity" of the NERDTree auto centering. See
|
This setting controls the "sensitivity" of the NERDTree auto centering. See
|
||||||
|NERDTreeAutoCenter| for details.
|
|NERDTreeAutoCenter| for details.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTreeCaseSensitiveFS*
|
||||||
|
Values: 0, 1, 2 or 3.
|
||||||
|
Default: 2.
|
||||||
|
|
||||||
|
If set to 0, the NERDTree will interact with the file system without case
|
||||||
|
sensitivity.
|
||||||
|
|
||||||
|
If set to 1, the NERDTree will interact with the file system in a case-sensitive
|
||||||
|
manner.
|
||||||
|
|
||||||
|
If set to 2, the NERDTree assumes its case sensitivity from the OS it is
|
||||||
|
running on. It Will default to case-insensitive on Windows and macOS
|
||||||
|
machines and case-sensitive on everything else. Since it's not a foolproof
|
||||||
|
way of detection, NERDTree won't proceed with any write actions when
|
||||||
|
the destination is ambiguous.
|
||||||
|
|
||||||
|
Setting it to 3 will perform just like 2, but without suppressing write
|
||||||
|
actions.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeCaseSensitiveSort*
|
*NERDTreeCaseSensitiveSort*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
@@ -1040,6 +1072,20 @@ This setting can be toggled dynamically, per tree, with the |NERDTree-F|
|
|||||||
mapping and is useful for drastically shrinking the tree when you are
|
mapping and is useful for drastically shrinking the tree when you are
|
||||||
navigating to a different part of the tree.
|
navigating to a different part of the tree.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*NERDTreeFileLines*
|
||||||
|
Values: 0 or 1.
|
||||||
|
Default: 0.
|
||||||
|
|
||||||
|
If this setting is set to 1 then the NERDTree shows number of lines for each
|
||||||
|
file.
|
||||||
|
|
||||||
|
This setting can be toggled dynamically, per tree, with the |NERDTree-FL|
|
||||||
|
mapping.
|
||||||
|
Use one of the follow lines for this setting: >
|
||||||
|
let NERDTreeFileLines=0
|
||||||
|
let NERDTreeFileLines=1
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeShowHidden*
|
*NERDTreeShowHidden*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
@@ -1128,7 +1174,7 @@ setting is used.
|
|||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeWinPos*
|
*NERDTreeWinPos*
|
||||||
Values: "left" or "right"
|
Values: "left", "right", "top" or "bottom"
|
||||||
Default: "left".
|
Default: "left".
|
||||||
|
|
||||||
This setting is used to determine where NERDTree window is placed on the
|
This setting is used to determine where NERDTree window is placed on the
|
||||||
@@ -1138,6 +1184,13 @@ This setting makes it possible to use two different explorer plugins
|
|||||||
simultaneously. For example, you could have the taglist plugin on the left of
|
simultaneously. For example, you could have the taglist plugin on the left of
|
||||||
the window and the NERDTree on the right.
|
the window and the NERDTree on the right.
|
||||||
|
|
||||||
|
When setting this variable to "top" or "bottom" make sure to also change the
|
||||||
|
|NERDTreeWinSize| to a more reasonable size.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
>
|
||||||
|
let g:NERDTreeWinSize = 15
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeWinSize*
|
*NERDTreeWinSize*
|
||||||
Values: a positive integer.
|
Values: a positive integer.
|
||||||
@@ -1256,10 +1309,10 @@ responsible pull request: https://github.com/preservim/nerdtree/pull/868.
|
|||||||
The default value of this variable depends on the features compiled into your
|
The default value of this variable depends on the features compiled into your
|
||||||
vim and the values of |NERDTreeDirArrowCollapsible| and
|
vim and the values of |NERDTreeDirArrowCollapsible| and
|
||||||
|NERDTreeDirArrowExpandable|.
|
|NERDTreeDirArrowExpandable|.
|
||||||
* If your vim is compiled with the +conceal feature, it is the "\x07" (BELL)
|
* If your vim is compiled with the +conceal feature, it is the "\x07"
|
||||||
character, and it is hidden by setting 'conceallevel' to 3. If you use
|
(BEL) character, and it is hidden by setting 'conceallevel' to 2. If you
|
||||||
autocommands, make sure none of them change that setting in the NERDTree_*
|
use autocommands, make sure none of them change that setting in the
|
||||||
buffers.
|
NERD_Tree_* buffers.
|
||||||
* If your vim does NOT have the +conceal feature and you're using "\u00a0"
|
* If your vim does NOT have the +conceal feature and you're using "\u00a0"
|
||||||
(non-breaking space) to hide the directory arrows, "\u00b7" (middle dot)
|
(non-breaking space) to hide the directory arrows, "\u00b7" (middle dot)
|
||||||
is used as the default delimiter.
|
is used as the default delimiter.
|
||||||
|
|||||||
@@ -38,6 +38,29 @@ function! s:Creator.BufNamePrefix()
|
|||||||
return 'NERD_tree_'
|
return 'NERD_tree_'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:Creator.CreateExploreTree(dir) {{{1
|
||||||
|
function! s:Creator.CreateExploreTree(dir)
|
||||||
|
try
|
||||||
|
let path = g:NERDTreePath.New(a:dir)
|
||||||
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
|
call nerdtree#echo('Invalid directory name:' . a:dir)
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
|
||||||
|
let creator = s:Creator.New()
|
||||||
|
if getbufinfo('%')[0].changed && !&hidden && !&autowriteall
|
||||||
|
let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright '
|
||||||
|
let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : ''
|
||||||
|
silent! execute l:splitLocation . l:splitDirection . ' new'
|
||||||
|
else
|
||||||
|
silent! execute 'enew'
|
||||||
|
endif
|
||||||
|
|
||||||
|
call creator.createWindowTree(a:dir)
|
||||||
|
"we want windowTree buffer to disappear after moving to any other buffer
|
||||||
|
setlocal bufhidden=wipe
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
||||||
function! s:Creator.CreateTabTree(name)
|
function! s:Creator.CreateTabTree(name)
|
||||||
let creator = s:Creator.New()
|
let creator = s:Creator.New()
|
||||||
@@ -95,7 +118,7 @@ function! s:Creator.createWindowTree(dir)
|
|||||||
|
|
||||||
"we need a unique name for each window tree buffer to ensure they are
|
"we need a unique name for each window tree buffer to ensure they are
|
||||||
"all independent
|
"all independent
|
||||||
exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName()
|
exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName('win')
|
||||||
|
|
||||||
call self._createNERDTree(path, 'window')
|
call self._createNERDTree(path, 'window')
|
||||||
let b:NERDTree._previousBuf = bufnr(previousBuf)
|
let b:NERDTree._previousBuf = bufnr(previousBuf)
|
||||||
@@ -182,16 +205,17 @@ endfunction
|
|||||||
" Initialize the NERDTree window. Open the window, size it properly, set all
|
" Initialize the NERDTree window. Open the window, size it properly, set all
|
||||||
" local options, etc.
|
" local options, etc.
|
||||||
function! s:Creator._createTreeWin()
|
function! s:Creator._createTreeWin()
|
||||||
let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright '
|
let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright '
|
||||||
|
let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : ''
|
||||||
let l:splitSize = g:NERDTreeWinSize
|
let l:splitSize = g:NERDTreeWinSize
|
||||||
|
|
||||||
if !g:NERDTree.ExistsForTab()
|
if !g:NERDTree.ExistsForTab()
|
||||||
let t:NERDTreeBufName = self._nextBufferName()
|
let t:NERDTreeBufName = self._nextBufferName('tab')
|
||||||
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
|
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
|
||||||
silent! execute 'edit ' . t:NERDTreeBufName
|
silent! execute 'edit ' . t:NERDTreeBufName
|
||||||
silent! execute 'vertical resize '. l:splitSize
|
silent! execute l:splitDirection . ' resize '. l:splitSize
|
||||||
else
|
else
|
||||||
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
|
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split'
|
||||||
silent! execute 'buffer ' . t:NERDTreeBufName
|
silent! execute 'buffer ' . t:NERDTreeBufName
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -220,10 +244,22 @@ function! s:Creator.New()
|
|||||||
return newCreator
|
return newCreator
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:Creator._nextBufferName() {{{1
|
" FUNCTION: s:Creator._nextBufferName(type='') {{{1
|
||||||
" returns the buffer name for the next nerd tree
|
" gets an optional buffer type of either 'tab' or 'win'.
|
||||||
function! s:Creator._nextBufferName()
|
" returns the buffer name for the next nerd tree of such type.
|
||||||
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
|
function! s:Creator._nextBufferName(...)
|
||||||
|
if a:0 > 0
|
||||||
|
let type = a:1
|
||||||
|
else
|
||||||
|
let type = ''
|
||||||
|
end
|
||||||
|
let name = s:Creator.BufNamePrefix()
|
||||||
|
if type ==# 'tab'
|
||||||
|
let name = name . 'tab_'
|
||||||
|
elseif type ==# 'win'
|
||||||
|
let name = name . 'win_'
|
||||||
|
endif
|
||||||
|
let name = name . self._nextBufferNumber()
|
||||||
return name
|
return name
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ function! s:NERDTree.GetWinNum()
|
|||||||
|
|
||||||
" If WindowTree, there is no t:NERDTreeBufName variable. Search all windows.
|
" If WindowTree, there is no t:NERDTreeBufName variable. Search all windows.
|
||||||
for w in range(1,winnr('$'))
|
for w in range(1,winnr('$'))
|
||||||
if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$'
|
if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . 'win_\d\+$'
|
||||||
return w
|
return w
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -65,6 +65,25 @@ function! s:Path.cacheDisplayString() abort
|
|||||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !self.isDirectory && b:NERDTree.ui.getShowFileLines() != 0
|
||||||
|
let l:bufname = self.str({'format': 'Edit'})
|
||||||
|
let l:lines = 0
|
||||||
|
if executable('wc')
|
||||||
|
let l:lines = split(system('wc -l "'.l:bufname.'"'))[0]
|
||||||
|
elseif nerdtree#runningWindows()
|
||||||
|
let l:lines = substitute(system('type "'.l:bufname.'" | find /c /v ""'), '\n', '', 'g')
|
||||||
|
else
|
||||||
|
let s:lines = readfile(l:bufname)
|
||||||
|
let l:lines = 0
|
||||||
|
for s:line in s:lines
|
||||||
|
let l:lines += 1
|
||||||
|
if l:lines >= 20000
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ('.l:lines.')'
|
||||||
|
endif
|
||||||
if self.isReadOnly
|
if self.isReadOnly
|
||||||
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']'
|
let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']'
|
||||||
endif
|
endif
|
||||||
@@ -343,9 +362,10 @@ endfunction
|
|||||||
" returns the index of the pattern in g:NERDTreeSortOrder that this path matches
|
" returns the index of the pattern in g:NERDTreeSortOrder that this path matches
|
||||||
function! s:Path.getSortOrderIndex()
|
function! s:Path.getSortOrderIndex()
|
||||||
let i = 0
|
let i = 0
|
||||||
|
let l:lpc = self.getLastPathComponent(1)
|
||||||
while i < len(g:NERDTreeSortOrder)
|
while i < len(g:NERDTreeSortOrder)
|
||||||
if g:NERDTreeSortOrder[i] !~? '\[\[-\?\(timestamp\|size\|extension\)\]\]' &&
|
if g:NERDTreeSortOrder[i] !~? '\[\[-\?\(timestamp\|size\|extension\)\]\]' &&
|
||||||
\ self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
|
\ l:lpc =~# g:NERDTreeSortOrder[i]
|
||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
let i = i + 1
|
let i = i + 1
|
||||||
@@ -530,7 +550,7 @@ function! s:Path.isUnder(parent)
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
for i in range(0, l:that_count-1)
|
for i in range(0, l:that_count-1)
|
||||||
if self.pathSegments[i] !=# a:parent.pathSegments[i]
|
if !nerdtree#pathEquals(self.pathSegments[i], a:parent.pathSegments[i])
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -554,11 +574,7 @@ endfunction
|
|||||||
" Args:
|
" Args:
|
||||||
" path: the other path obj to compare this with
|
" path: the other path obj to compare this with
|
||||||
function! s:Path.equals(path)
|
function! s:Path.equals(path)
|
||||||
if nerdtree#runningWindows()
|
return nerdtree#pathEquals(self.str(), a:path.str())
|
||||||
return self.str() ==? a:path.str()
|
|
||||||
else
|
|
||||||
return self.str() ==# a:path.str()
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: Path.New(pathStr) {{{1
|
" FUNCTION: Path.New(pathStr) {{{1
|
||||||
|
|||||||
@@ -121,8 +121,14 @@ function! s:TreeDirNode.findNode(path)
|
|||||||
if a:path.equals(self.path)
|
if a:path.equals(self.path)
|
||||||
return self
|
return self
|
||||||
endif
|
endif
|
||||||
if stridx(a:path.str(), self.path.str(), 0) ==# -1
|
if nerdtree#caseSensitiveFS()
|
||||||
return {}
|
if stridx(a:path.str(), self.path.str(), 0) ==# -1
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if stridx(tolower(a:path.str()), tolower(self.path.str()), 0) ==# -1
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if self.path.isDirectory
|
if self.path.isDirectory
|
||||||
@@ -278,6 +284,10 @@ 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'}), ':.'), ',')
|
||||||
|
|
||||||
|
if nerdtree#runningWindows()
|
||||||
|
let l:pathSpec = substitute(l:pathSpec, "\\[\\(.*\\]\\)", "[[]\\1", "g")
|
||||||
|
endif
|
||||||
|
|
||||||
" 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] == nerdtree#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
|
||||||
@@ -421,6 +431,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let invalidFilesFound = 0
|
let invalidFilesFound = 0
|
||||||
|
let invalidFiles = []
|
||||||
for i in files
|
for i in files
|
||||||
try
|
try
|
||||||
let path = g:NERDTreePath.New(i)
|
let path = g:NERDTreePath.New(i)
|
||||||
@@ -428,6 +439,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
|
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
|
||||||
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
|
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
|
||||||
let invalidFilesFound += 1
|
let invalidFilesFound += 1
|
||||||
|
let invalidFiles += [i]
|
||||||
endtry
|
endtry
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@@ -437,7 +449,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
call nerdtree#echo('')
|
call nerdtree#echo('')
|
||||||
|
|
||||||
if invalidFilesFound
|
if invalidFilesFound
|
||||||
call nerdtree#echoWarning(invalidFilesFound . ' file(s) could not be loaded into the NERD tree')
|
call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', '))
|
||||||
endif
|
endif
|
||||||
return self.getChildCount()
|
return self.getChildCount()
|
||||||
endfunction
|
endfunction
|
||||||
@@ -564,12 +576,13 @@ function! s:TreeDirNode.refresh()
|
|||||||
let files = self._glob('*', 1) + self._glob('.*', 0)
|
let files = self._glob('*', 1) + self._glob('.*', 0)
|
||||||
let newChildNodes = []
|
let newChildNodes = []
|
||||||
let invalidFilesFound = 0
|
let invalidFilesFound = 0
|
||||||
|
let invalidFiles = []
|
||||||
for i in files
|
for i in files
|
||||||
try
|
try
|
||||||
"create a new path and see if it exists in this nodes children
|
"create a new path and see if it exists in this nodes children
|
||||||
let path = g:NERDTreePath.New(i)
|
let path = g:NERDTreePath.New(i)
|
||||||
let newNode = self.getChild(path)
|
let newNode = self.getChild(path)
|
||||||
if newNode !=# {}
|
if newNode !=# {} && path.str() ==# newNode.path.str()
|
||||||
call newNode.refresh()
|
call newNode.refresh()
|
||||||
call add(newChildNodes, newNode)
|
call add(newChildNodes, newNode)
|
||||||
|
|
||||||
@@ -578,9 +591,11 @@ function! s:TreeDirNode.refresh()
|
|||||||
let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree())
|
let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree())
|
||||||
let newNode.parent = self
|
let newNode.parent = self
|
||||||
call add(newChildNodes, newNode)
|
call add(newChildNodes, newNode)
|
||||||
|
call g:NERDTreePathNotifier.NotifyListeners('init', newNode.path, newNode.getNerdtree(), {})
|
||||||
endif
|
endif
|
||||||
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
|
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
|
||||||
let invalidFilesFound = 1
|
let invalidFilesFound += 1
|
||||||
|
let invalidFiles += [i]
|
||||||
endtry
|
endtry
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@@ -589,7 +604,7 @@ function! s:TreeDirNode.refresh()
|
|||||||
call self.sortChildren()
|
call self.sortChildren()
|
||||||
|
|
||||||
if invalidFilesFound
|
if invalidFilesFound
|
||||||
call nerdtree#echoWarning('some files could not be loaded into the NERD tree')
|
call nerdtree#echoWarning(invalidFilesFound . ' Invalid file(s): ' . join(invalidFiles, ', '))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -701,6 +716,7 @@ function! s:TreeDirNode.transplantChild(newNode)
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
call self.refresh()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function! s:UI._dumpHelp()
|
|||||||
let help .= "\"\n\" ----------------------------\n"
|
let help .= "\"\n\" ----------------------------\n"
|
||||||
let help .= "\" Bookmark table mappings~\n"
|
let help .= "\" Bookmark table mappings~\n"
|
||||||
let help .= "\" double-click,\n"
|
let help .= "\" double-click,\n"
|
||||||
|
let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n"
|
||||||
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
||||||
@@ -103,6 +104,7 @@ function! s:UI._dumpHelp()
|
|||||||
let help .= '" '. g:NERDTreeMapToggleFilters .': file filters (' . (self.isIgnoreFilterEnabled() ? 'on' : 'off') . ")\n"
|
let help .= '" '. g:NERDTreeMapToggleFilters .': file filters (' . (self.isIgnoreFilterEnabled() ? 'on' : 'off') . ")\n"
|
||||||
let help .= '" '. g:NERDTreeMapToggleFiles .': files (' . (self.getShowFiles() ? 'on' : 'off') . ")\n"
|
let help .= '" '. g:NERDTreeMapToggleFiles .': files (' . (self.getShowFiles() ? 'on' : 'off') . ")\n"
|
||||||
let help .= '" '. g:NERDTreeMapToggleBookmarks .': bookmarks (' . (self.getShowBookmarks() ? 'on' : 'off') . ")\n"
|
let help .= '" '. g:NERDTreeMapToggleBookmarks .': bookmarks (' . (self.getShowBookmarks() ? 'on' : 'off') . ")\n"
|
||||||
|
let help .= '" '. g:NERDTreeMapToggleFileLines .': files lines (' . (self.getShowFileLines() ? 'on' : 'off') . ")\n"
|
||||||
|
|
||||||
" add quickhelp entries for each custom key map
|
" add quickhelp entries for each custom key map
|
||||||
let help .= "\"\n\" ----------------------------\n"
|
let help .= "\"\n\" ----------------------------\n"
|
||||||
@@ -147,6 +149,7 @@ function! s:UI.New(nerdtree)
|
|||||||
let newObj._showFiles = g:NERDTreeShowFiles
|
let newObj._showFiles = g:NERDTreeShowFiles
|
||||||
let newObj._showHidden = g:NERDTreeShowHidden
|
let newObj._showHidden = g:NERDTreeShowHidden
|
||||||
let newObj._showBookmarks = g:NERDTreeShowBookmarks
|
let newObj._showBookmarks = g:NERDTreeShowBookmarks
|
||||||
|
let newObj._showFileLines = g:NERDTreeFileLines
|
||||||
|
|
||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
@@ -284,6 +287,11 @@ function! s:UI.getShowHidden()
|
|||||||
return self._showHidden
|
return self._showHidden
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:UI.getShowFileLines() {{{1
|
||||||
|
function! s:UI.getShowFileLines()
|
||||||
|
return self._showFileLines
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI._indentLevelFor(line) {{{1
|
" FUNCTION: s:UI._indentLevelFor(line) {{{1
|
||||||
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
|
||||||
@@ -475,10 +483,10 @@ function! s:UI.toggleIgnoreFilter()
|
|||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
" FUNCTION: s:UI.setShowBookmarks() {{{1
|
||||||
" Toggle the visibility of the Bookmark table.
|
" Sets the visibility of the Bookmark table.
|
||||||
function! s:UI.toggleShowBookmarks()
|
function! s:UI.setShowBookmarks(value)
|
||||||
let self._showBookmarks = !self._showBookmarks
|
let self._showBookmarks = a:value
|
||||||
|
|
||||||
if self.getShowBookmarks()
|
if self.getShowBookmarks()
|
||||||
call self.nerdtree.render()
|
call self.nerdtree.render()
|
||||||
@@ -496,6 +504,12 @@ function! s:UI.toggleShowBookmarks()
|
|||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||||
|
" Toggle the visibility of the Bookmark table.
|
||||||
|
function! s:UI.toggleShowBookmarks()
|
||||||
|
call self.setShowBookmarks(!self._showBookmarks)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
||||||
" toggles the display of hidden files
|
" toggles the display of hidden files
|
||||||
function! s:UI.toggleShowFiles()
|
function! s:UI.toggleShowFiles()
|
||||||
@@ -512,10 +526,22 @@ function! s:UI.toggleShowHidden()
|
|||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:UI.toggleShowFileLines() {{{1
|
||||||
|
" toggles the display of file lines
|
||||||
|
function! s:UI.toggleShowFileLines()
|
||||||
|
let self._showFileLines = !self._showFileLines
|
||||||
|
call self.nerdtree.root.refresh()
|
||||||
|
call self.renderViewSavingPosition()
|
||||||
|
call self.centerView()
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleZoom() {{{1
|
" FUNCTION: s:UI.toggleZoom() {{{1
|
||||||
" 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
|
||||||
|
setlocal nowinfixwidth
|
||||||
|
wincmd =
|
||||||
|
setlocal winfixwidth
|
||||||
call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1)
|
call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1)
|
||||||
let b:NERDTreeZoomed = 0
|
let b:NERDTreeZoomed = 0
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac
|
|||||||
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||||
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||||
|
|
||||||
if has('gui_mac') || has('gui_macvim') || has('mac')
|
if nerdtree#runningMac()
|
||||||
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
|
call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Finder', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
|
||||||
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
|
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
|
||||||
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
|
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
|
||||||
endif
|
endif
|
||||||
@@ -35,6 +35,7 @@ if executable('xdg-open')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if nerdtree#runningWindows()
|
if nerdtree#runningWindows()
|
||||||
|
call NERDTreeAddMenuItem({'text': '(r)eveal the current node in the Explorer', 'shortcut': 'r', 'callback': 'NERDTreeRevealInExplorer'})
|
||||||
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'})
|
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'
|
|||||||
|
|
||||||
if has('unix') || has('osx')
|
if has('unix') || has('osx')
|
||||||
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
|
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
|
||||||
|
call NERDTreeAddMenuItem({'text': '(C)hange node permissions', 'shortcut':'C', 'callback': 'NERDTreeChangePermissions'})
|
||||||
else
|
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
|
||||||
@@ -148,28 +150,48 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
|
|||||||
let quotedFileName = fnameescape(a:newNodeName)
|
let quotedFileName = fnameescape(a:newNodeName)
|
||||||
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
|
|
||||||
call nerdtree#exec('badd ' . quotedFileName, 0)
|
|
||||||
" 2. ensure that all windows which display the just deleted 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", 0)
|
let l:tempBufferName = 'NERDTreeRenameTempBuffer'
|
||||||
call nerdtree#exec('tabnext ' . s:originalTabNumber, 1)
|
|
||||||
call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1)
|
" 1. swap deleted file buffer with a temporary one
|
||||||
" 3. We don't need a previous buffer anymore
|
" this step is needed to compensate for case insensitive filesystems
|
||||||
|
|
||||||
|
" 1.1. create an intermediate(temporary) buffer
|
||||||
|
call nerdtree#exec('badd ' . l:tempBufferName, 0)
|
||||||
|
let l:tempBufNum = bufnr(l:tempBufferName)
|
||||||
|
" 1.2. ensure that all windows which display the just deleted filename
|
||||||
|
" display the new temp buffer.
|
||||||
|
call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . l:tempBufferName . "' | endif", 0)
|
||||||
|
" 1.3. We don't need the deleted file buffer anymore
|
||||||
try
|
try
|
||||||
call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0)
|
call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0)
|
||||||
catch
|
catch
|
||||||
" This happens when answering Cancel if confirmation is needed. Do nothing.
|
" This happens when answering Cancel if confirmation is needed. Do nothing.
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
" 2. swap temporary buffer with the new filename buffer
|
||||||
|
" 2.1. create the actual new file buffer
|
||||||
|
call nerdtree#exec('badd ' . quotedFileName, 0)
|
||||||
|
|
||||||
|
" 2.2. ensure that all windows which display the temporary buffer
|
||||||
|
" display a buffer for the new filename.
|
||||||
|
call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . l:tempBufNum . " | exec ':e! " . editStr . "' | endif", 0)
|
||||||
|
call nerdtree#exec('tabnext ' . s:originalTabNumber, 1)
|
||||||
|
call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1)
|
||||||
|
" 2.3. We don't need the temporary buffer anymore
|
||||||
|
try
|
||||||
|
call nerdtree#exec('confirm bwipeout ' . l:tempBufNum, 0)
|
||||||
|
catch
|
||||||
|
" This happens when answering Cancel if confirmation is needed. Do nothing.
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: NERDTreeAddNode(){{{1
|
"FUNCTION: NERDTreeAddNode(){{{1
|
||||||
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 = trim(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'))
|
let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
|
||||||
|
|
||||||
if newNodeName ==# ''
|
if newNodeName ==# ''
|
||||||
call nerdtree#echo('Node Creation Aborted.')
|
call nerdtree#echo('Node Creation Aborted.')
|
||||||
@@ -189,6 +211,7 @@ function! NERDTreeAddNode()
|
|||||||
call b:NERDTree.render()
|
call b:NERDTree.render()
|
||||||
elseif parentNode.isOpen || !empty(parentNode.children)
|
elseif parentNode.isOpen || !empty(parentNode.children)
|
||||||
call parentNode.addChild(newTreeNode, 1)
|
call parentNode.addChild(newTreeNode, 1)
|
||||||
|
call g:NERDTreePathNotifier.NotifyListeners('init', newTreeNode.path, newTreeNode.getNerdtree(), {})
|
||||||
call NERDTreeRender()
|
call NERDTreeRender()
|
||||||
call newTreeNode.putCursorHere(1, 0)
|
call newTreeNode.putCursorHere(1, 0)
|
||||||
endif
|
endif
|
||||||
@@ -205,8 +228,25 @@ function! NERDTreeMoveNode()
|
|||||||
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)
|
while filereadable(newNodePath)
|
||||||
call nerdtree#echoWarning('This destination already exists. Try again.')
|
" allow renames with different casing when g:NERDTreeCaseSensitiveFS
|
||||||
let newNodePath = trim(input(prompt, curNode.path.str(), 'file'))
|
" is set to either 0 or 3 and the 2 paths are equal
|
||||||
|
if (g:NERDTreeCaseSensitiveFS == 0 || g:NERDTreeCaseSensitiveFS == 3) &&
|
||||||
|
\nerdtree#pathEquals(curNode.path.str(), newNodePath)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
call nerdtree#echoWarning('This destination already exists, Try again.')
|
||||||
|
|
||||||
|
" inform the user about the flag if we think it is a false positive
|
||||||
|
" when g:NERDTreeCaseSensitiveFS is set to 2
|
||||||
|
if g:NERDTreeCaseSensitiveFS == 2 &&
|
||||||
|
\!nerdtree#osDefaultCaseSensitiveFS() &&
|
||||||
|
\nerdtree#pathEquals(curNode.path.str(), newNodePath)
|
||||||
|
echon "\n(If it is a false positive please consider assigning NERDTreeCaseSensitiveFS's value)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" prompt the user again
|
||||||
|
let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
|
||||||
@@ -333,11 +373,34 @@ function! NERDTreeListNodeWin32()
|
|||||||
call nerdtree#echo('node not recognized')
|
call nerdtree#echo('node not recognized')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: NERDTreeChangePermissions() {{{1
|
||||||
|
function! NERDTreeChangePermissions()
|
||||||
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
|
let l:prompt = "change node permissions (chmod args): "
|
||||||
|
let l:newNodePerm = input(l:prompt)
|
||||||
|
|
||||||
|
if !empty(l:node)
|
||||||
|
let l:path = l:node.path.str()
|
||||||
|
let l:cmd = 'chmod ' .. newNodePerm .. ' ' .. path
|
||||||
|
let l:error = split(system(l:cmd), '\n')
|
||||||
|
|
||||||
|
if !empty(l:error)
|
||||||
|
call nerdtree#echo(l:error[0])
|
||||||
|
endif
|
||||||
|
|
||||||
|
call b:NERDTree.root.refresh()
|
||||||
|
call b:NERDTree.render()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call nerdtree#echo('node not recognized')
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||||
function! NERDTreeCopyNode()
|
function! NERDTreeCopyNode()
|
||||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||||
let prompt = s:inputPrompt('copy')
|
let prompt = s:inputPrompt('copy')
|
||||||
let newNodePath = trim(input(prompt, currentNode.path.str(), 'file'))
|
let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g')
|
||||||
|
|
||||||
if newNodePath !=# ''
|
if newNodePath !=# ''
|
||||||
"strip trailing slash
|
"strip trailing slash
|
||||||
@@ -453,6 +516,17 @@ function! NERDTreeExecuteFileLinux()
|
|||||||
call system('xdg-open ' . shellescape(l:node.path.str()))
|
call system('xdg-open ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: NERDTreeRevealInExplorer() {{{1
|
||||||
|
function! NERDTreeRevealInExplorer()
|
||||||
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
|
|
||||||
|
if empty(l:node)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call system('cmd.exe /c explorer /select, ' . shellescape(l:node.path.str()))
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeExecuteFileWindows() {{{1
|
" FUNCTION: NERDTreeExecuteFileWindows() {{{1
|
||||||
function! NERDTreeExecuteFileWindows()
|
function! NERDTreeExecuteFileWindows()
|
||||||
let l:node = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ set cpoptions&vim
|
|||||||
"SECTION: Initialize variable calls and other random constants {{{2
|
"SECTION: Initialize variable calls and other random constants {{{2
|
||||||
let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1)
|
let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1)
|
||||||
let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3)
|
let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3)
|
||||||
|
let g:NERDTreeCaseSensitiveFS = get(g:, 'NERDTreeCaseSensitiveFS', 2)
|
||||||
let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0)
|
let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0)
|
||||||
let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0)
|
let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0)
|
||||||
let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1)
|
let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1)
|
||||||
@@ -52,6 +53,8 @@ let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1
|
|||||||
let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0)
|
let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0)
|
||||||
let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0)
|
let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0)
|
||||||
let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1)
|
let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1)
|
||||||
|
let g:NERDTreeFileLines = get(g:, 'NERDTreeFileLines', 0)
|
||||||
|
|
||||||
|
|
||||||
if !nerdtree#runningWindows() && !nerdtree#runningCygwin()
|
if !nerdtree#runningWindows() && !nerdtree#runningCygwin()
|
||||||
let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸')
|
let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸')
|
||||||
@@ -98,6 +101,7 @@ endif
|
|||||||
|
|
||||||
"SECTION: Init variable calls for key mappings {{{2
|
"SECTION: Init variable calls for key mappings {{{2
|
||||||
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
||||||
|
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb')
|
||||||
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
||||||
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
||||||
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
||||||
@@ -128,6 +132,7 @@ let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B')
|
|||||||
let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F')
|
let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F')
|
||||||
let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f')
|
let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f')
|
||||||
let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I')
|
let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I')
|
||||||
|
let g:NERDTreeMapToggleFileLines = get(g:, 'NERDTreeMapToggleFileLines', 'FL')
|
||||||
let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A')
|
let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A')
|
||||||
let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u')
|
let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u')
|
||||||
let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U')
|
let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U')
|
||||||
@@ -142,11 +147,12 @@ call nerdtree#loadClassFiles()
|
|||||||
"============================================================
|
"============================================================
|
||||||
call nerdtree#ui_glue#setupCommands()
|
call nerdtree#ui_glue#setupCommands()
|
||||||
|
|
||||||
|
|
||||||
" SECTION: Auto commands {{{1
|
" SECTION: Auto commands {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
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,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif'
|
exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* call nerdtree#onBufLeave()'
|
||||||
|
|
||||||
"disallow insert mode in the NERDTree
|
"disallow insert mode in the NERDTree
|
||||||
exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert'
|
exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert'
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ else
|
|||||||
hi! link NERDTreeNodeDelimiters Ignore
|
hi! link NERDTreeNodeDelimiters Ignore
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"highlighing for directory nodes and file nodes
|
"highlighting for directory nodes and file nodes
|
||||||
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
|
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
|
||||||
|
|
||||||
if g:NERDTreeDirArrowExpandable !=# ''
|
if g:NERDTreeDirArrowExpandable !=# ''
|
||||||
@@ -36,23 +36,23 @@ if g:NERDTreeDirArrowExpandable !=# ''
|
|||||||
exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
|
exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile'
|
||||||
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
|
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
|
||||||
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'
|
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'
|
||||||
exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark'
|
exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName'
|
||||||
exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile'
|
exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile'
|
||||||
else
|
else
|
||||||
exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#'
|
exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#'
|
||||||
exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark'
|
exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName'
|
||||||
exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile'
|
exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"highlighting for readonly files
|
"highlighting for readonly files
|
||||||
exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile'
|
exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmarkName,NERDTreeFile'
|
||||||
|
|
||||||
exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir'
|
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
|
||||||
syn match NERDTreeBookmark # {.*}#hs=s+1
|
syn match NERDTreeBookmarkName # {.*}#hs=s+2,he=e-1
|
||||||
|
|
||||||
"highlighting for the bookmarks table
|
"highlighting for the bookmarks table
|
||||||
syn match NERDTreeBookmarksLeader #^>#
|
syn match NERDTreeBookmarksLeader #^>#
|
||||||
|
|||||||
Reference in New Issue
Block a user