Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/preservim/nerdtree into B…
Browse files Browse the repository at this point in the history
…ookmarkJump
  • Loading branch information
rzvxa committed Dec 26, 2023
2 parents b153732 + ff9469a commit c067f94
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 56 deletions.
15 changes: 0 additions & 15 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,3 @@ Closes # <!-- Enter the issue number this PR addresses. If none, remove this
---
### 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 changes: 2 additions & 2 deletions .github/workflows/vint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v3
- name: Run vint with reviewdog
uses: reviewdog/action-vint@v1.0.1
uses: reviewdog/action-vint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,32 @@
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)
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.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
- **.17**: Add 'b' binding to to jump to bookmark table. (ds2606) [#1305](https://github.com/preservim/nerdtree/pull/1305)
- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269)
Expand Down
34 changes: 25 additions & 9 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
![Help Wanted](http://blog.ncce.org/wp-content/uploads/2013/12/help-wanted.jpg)

**NERDTree** is on the lookout for a new maintainer. See [issue #1280](https://github.com/preservim/nerdtree/issues/1280) to submit your name for consideration.

---

# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint)

## Introduction
Expand Down Expand Up @@ -90,7 +84,7 @@ 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`.
## 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.
* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders,
Expand Down Expand Up @@ -170,15 +164,15 @@ autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTa
```vim
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
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
```
### Can I have the same NERDTree on every tab automatically?
```vim
" 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:
```vim
Expand All @@ -194,6 +188,28 @@ 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.
### 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?
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.
Expand Down
38 changes: 36 additions & 2 deletions autoload/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,42 @@ function! nerdtree#postSourceActions() abort
runtime! nerdtree_plugin/**/*.vim
endfunction

"FUNCTION: nerdtree#runningWindows(dir) {{{2
"FUNCTION: nerdtree#runningWindows() {{{2
function! nerdtree#runningWindows() abort
return has('win16') || has('win32') || has('win64')
endfunction

"FUNCTION: nerdtree#runningCygwin(dir) {{{2
"FUNCTION: nerdtree#runningCygwin() {{{2
function! nerdtree#runningCygwin() abort
return has('win32unix')
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

" SECTION: View Functions {{{1
"============================================================

Expand Down Expand Up @@ -246,4 +272,12 @@ function! nerdtree#renderView() abort
call b:NERDTree.render()
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:
8 changes: 8 additions & 0 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' })
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:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' })
Expand Down Expand Up @@ -653,6 +654,7 @@ endfunction
function! nerdtree#ui_glue#setupCommands() abort
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 NERDTreeExplore :call g:NERDTreeCreator.CreateExploreTree('<args>')
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=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
Expand Down Expand Up @@ -697,6 +699,12 @@ function! s:toggleShowHidden() abort
call b:NERDTree.ui.toggleShowHidden()
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() abort
call b:NERDTree.ui.toggleZoom()
Expand Down
55 changes: 54 additions & 1 deletion doc/NERDTree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 files are displayed.........................|NERDTree-F|
B........Toggle whether the bookmark table is displayed.............|NERDTree-B|
L........Toggle whether the number of lines in files is displayed...|NERDTree-L|

q........Close the NERDTree window..................................|NERDTree-q|
A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A|
Expand Down Expand Up @@ -601,6 +602,14 @@ Applies to: no restrictions.

Toggles whether the bookmarks table is displayed.

------------------------------------------------------------------------------
*NERDTree-L*
Default key: L
Map setting: *NERDTreeMapToggleFileLines*
Applies to: no restrictions.

Toggles whether the number of lines in files is displayed.

------------------------------------------------------------------------------
*NERDTree-q*
Default key: q
Expand Down Expand Up @@ -673,6 +682,9 @@ the NERDTree. These settings should be set in your vimrc, using `:let`.

|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
sensitive or not when sorting nodes.

Expand Down Expand Up @@ -808,6 +820,26 @@ Default: 3
This setting controls the "sensitivity" of the NERDTree auto centering. See
|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*
Values: 0 or 1.
Expand Down Expand Up @@ -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
navigating to a different part of the tree.

------------------------------------------------------------------------------
*NERDTreeShowFilesLines*
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-L|
mapping.
Use one of the follow lines for this setting: >
let NERDTreeShowFilesLines=0
let NERDTreeShowFilesLines=1
<
------------------------------------------------------------------------------
*NERDTreeShowHidden*
Values: 0 or 1.
Expand Down Expand Up @@ -1128,7 +1174,7 @@ setting is used.

------------------------------------------------------------------------------
*NERDTreeWinPos*
Values: "left" or "right"
Values: "left", "right", "top" or "bottom"
Default: "left".

This setting is used to determine where NERDTree window is placed on the
Expand All @@ -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
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*
Values: a positive integer.
Expand Down
32 changes: 28 additions & 4 deletions lib/nerdtree/creator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
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(name)
let creator = s:Creator.New()
Expand Down Expand Up @@ -182,16 +205,17 @@ endfunction
" Initialize the NERDTree window. Open the window, size it properly, set all
" local options, etc.
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

if !g:NERDTree.ExistsForTab()
let t:NERDTreeBufName = self._nextBufferName()
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
silent! execute 'edit ' . t:NERDTreeBufName
silent! execute 'vertical resize '. l:splitSize
silent! execute l:splitDirection . ' resize '. l:splitSize
else
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split'
silent! execute 'buffer ' . t:NERDTreeBufName
endif

Expand Down
Loading

0 comments on commit c067f94

Please sign in to comment.