Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand functionality of <CR> mapping #1011

Merged
merged 19 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ After reading, and before submitting your issue, please remove this introductory
#### Environment (for bug reports)
- [ ] Operating System:
- [ ] Vim/Neovim version `:version`:
- [ ] NERDTree version `git rev-parse --short HEAD`:
- [ ] NERDTree version `:echo nerdtree#version(0)` or `git rev-parse --short HEAD`:
- [ ] A link to my [vimrc](), or
- [ ] vimrc settings
- [ ] NERDTree variables
Expand Down
16 changes: 7 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<!-- Enter the issue number this PR addresses below. If none, remove the line. -->
### Description of Changes
Closes # <!-- Issue number this PR addresses. If none, remove this line. -->

Closes #

---
### New Version Info

- [ ] Derive a new version number. Increment the:
- [ ] `MAJOR` version when you make incompatible API changes,
- [ ] `MINOR` version when you add functionality in a backwards-compatible manner, and
- [ ] `PATCH` version when you make backwards-compatible bug fixes.
- [ ] Update version number in [autoload/nerdtree.vim](https://github.com/scrooloose/nerdtree/blob/master/autoload/nerdtree.vim#L7)
- [ ] Update the ChangeLog, following this format/example:
- [ ] `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 this format/example:
```
MAJOR.MINOR...
#### MAJOR.MINOR...
- **.PATCH**: PR Title (Author) #PR Number

### 5.1...
#### 5.1...
- **.1**: Update Changelog and create PR Template (PhilRunninger) #1007
- **.0**: Too many changes for one patch...
```
104 changes: 36 additions & 68 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Change Log

### 5.1...
- **`.3`**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009
- **`.2`**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008
- **`.1`**: Update Changelog and create PR Template (PhilRunninger) #1007
- **`.0`**: Too many changes for one patch...
#### 5.2...
- **.0**: Expand functionality of `<CR>` mapping. (PhilRunninger) #1011
#### 5.1...
- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) #1009
- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) #1008
- **.1**: Update Changelog and create PR Template (PhilRunninger) #1007
- **.0**: Too many changes for one patch...
- Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) #1005
- Add a "copy path to clipboard" menu option (PhilRunninger) #1002
- Enable root refresh on "vim ." a different way than #999. (PhilRunninger) #1001
Expand Down Expand Up @@ -122,7 +124,7 @@
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.

### 5.0.0
#### 5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods.
Expand All @@ -139,102 +141,68 @@
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
- Many other fixes, doc updates and contributions from:
- @actionshrimp
- @SchDen
- @egalpin
- @cperl82 - many small fixes
- @toiffel
- @WoLpH
- @handcraftedbits
- @devmanhinton
- @xiaodili
- @zhangoose
- @gastropoda
- @mixvin
- @alvan
- @lucascaton
- @kelaban
- @shanesmith
- @staeff
- @pendulm
- @stephenprater
- @franksort
- @agrussellknives
- @AndrewRadev
- @Twinside
- Many other fixes, doc updates and contributions from: **actionshrimp**, **agrussellknives**, **alvan**, **AndrewRadev**, **cperl82** (*many small fixes*), **devmanhinton**, **egalpin**, **franksort**, **gastropoda**, **handcraftedbits**, **kelaban**, **lucascaton**, **mixvin**, **pendulm**, **SchDen**, **shanesmith**, **staeff**, **stephenprater**, **toiffel**, **Twinside**, **WoLpH**, **xiaodili**, **zhangoose**

### 4.2.0
#### 4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung)
- use `file` completion when doing copying, create, and move operations (EvanDotPro)
- lots of misc bug fixes from:
- @paddyoloughlin
- @sdewald
- @camthompson
- @Vitaly
- @Bogdanov
- @AndrewRadev
- @mathias
- @scottstvnsn
- @kml
- @wycats
- me RAWR!
- lots of misc bug fixes from: **AndrewRadev**, **Bogdanov**, **camthompson**, **kml**, **mathias**, **paddyoloughlin**, **scottstvnsn**, **sdewald**, **Vitaly**, **wycats**, me RAWR!

### 4.1.0
#### 4.1.0
- features:
- NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor Gonzalez.
- NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by **Doug McInnes**) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to **Stefan Ritter** and **Rémi Prévost**.
- truncate the root node if wider than the tree window. Thanks to **Victor Gonzalez**.

- bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, jfilip1024, and Chris Chambers
- fix some win32 path escaping issues. Thanks to **Stephan Baumeister**, **Ricky**, **jfilip1024**, and **Chris Chambers**.

### 4.0.0
#### 4.0.0
- add a new programmable menu system (see `:help NERDTreeMenu`).
- add new APIs to add menus/menu-items to the menu system as well as custom key mappings to the NERD tree buffer (see `:help NERDTreeAPI`).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot, thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where secondary nerd trees (netrw hijacked trees) and NERDTreeQuitOnOpen didnt play nicely, thanks to **Curtis Harvey**.
- fix a bug where the script ignored directories whose name ended in a dot, thanks to **Aggelos Orfanakos** for the patch.
- fix a bug when using the x mapping on the tree root, thanks to **Bryan Venteicher** for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to **Richard Hart**.
- fix a bug where NERDTreeMirror would mirror the wrong tree

### 3.1.1
- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to Derek Wyatt and owen1
#### 3.1.1
- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to **Derek Wyatt** and **owen1**
- make `<CR>` behave the same as the `o` mapping
- some helptag fixes in the doc, thanks @strull
- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks @iElectric
- some helptag fixes in the doc, thanks **strull**.
- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks **iElectric**.
- other minor fixes

### 3.1.0
#### 3.1.0
- New features:
- add mappings to open files in a vsplit, see `:help NERDTree-s` and `:help NERDTree-gs`
- make the statusline for the nerd tree window default to something hopefully more useful. See `:help 'NERDTreeStatusline'`
- Bugfixes:
- make the hijack netrw functionality work when vim is started with `vim <some dir>` (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks nach)
- make the hijack netrw functionality work when vim is started with `vim <some dir>` (thanks to **Alf Mikula** for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to **Lucas S. Buchala**)
- add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to **tpope**)
- fix bugs when ignorecase was set (thanks to **nach**)
- fix a bug with the relative path code (thanks to **nach**)
- fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks **nach**)


### 3.0.1
#### 3.0.1
- Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set
- fix a bug where `:NERDTree <path>` would fail if `<path>` was relative and didnt start with a `./` or `../` Thanks to James Kanze.
- make the `q` mapping work with secondary (`:e <dir>` style) trees, thanks to jamessan
- fix a bug where `:NERDTree <path>` would fail if `<path>` was relative and didnt start with a `./` or `../` Thanks to **James Kanze**.
- make the `q` mapping work with secondary (`:e <dir>` style) trees, thanks to **jamessan**
- fix a bunch of small bugs with secondary trees
- More insane refactoring.

### 3.0.0
#### 3.0.0
- hijack netrw so that doing an `:edit <directory>` will put a NERD tree in the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see `:help :NERDTreeMirror`
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
Expand Down
15 changes: 13 additions & 2 deletions autoload/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ if exists("g:loaded_nerdtree_autoload")
endif
let g:loaded_nerdtree_autoload = 1

function! nerdtree#version()
return '5.1.3'
function! nerdtree#version(...)
let l:changelog = readfile(expand("<sfile>:p:h")."/CHANGELOG.md")
let l:text = 'Unknown'
let l:line = 0
while l:line <= len(l:changelog)
if l:changelog[l:line] =~ '\d\+\.\d\+'
let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '')
let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '')
break
endif
let l:line += 1
endwhile
return l:text
endfunction

" SECTION: General Functions {{{1
Expand Down
39 changes: 36 additions & 3 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function! nerdtree#ui_glue#createDefaultBindings()
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" })

call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s."customOpenFile"})
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s."customOpenDir"})
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s."customOpenBookmark"})

call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" })
Expand Down Expand Up @@ -76,6 +79,35 @@ endfunction
"SECTION: Interface bindings {{{1
"============================================================

"FUNCTION: s:customOpenFile() {{{1
" Open file node with the "custom" key, initially <CR>.
function! s:customOpenFile(node)
call a:node.activate(s:initCustomOpenArgs().file)
endfunction

"FUNCTION: s:customOpenDir() {{{1
" Open directory node with the "custom" key, initially <CR>.
function! s:customOpenDir(node)
call s:activateDirNode(a:node, s:initCustomOpenArgs().dir)
endfunction

"FUNCTION: s:customOpenBookmark() {{{1
" Open bookmark node with the "custom" key, initially <CR>.
function! s:customOpenBookmark(node)
if node.isDirectory
call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir)
else
call a:node.activate(b:NERDTree, s:initCustomOpenArgs().file)
endif
endfunction

"FUNCTION: s:initCustomOpenArgs() {{{1
" Make sure NERDTreeCustomOpenArgs has needed keys
function! s:initCustomOpenArgs()
let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {})
return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep')
endfunction

"FUNCTION: s:activateAll() {{{1
"handle the user activating the updir line
function! s:activateAll()
Expand All @@ -84,15 +116,16 @@ function! s:activateAll()
endif
endfunction

" FUNCTION: s:activateDirNode(directoryNode) {{{1
function! s:activateDirNode(directoryNode)
" FUNCTION: s:activateDirNode(directoryNode, options) {{{1
" Open a directory with optional options
function! s:activateDirNode(directoryNode, ...)

if a:directoryNode.isRoot() && a:directoryNode.isOpen
call nerdtree#echo('cannot close tree root')
return
endif

call a:directoryNode.activate()
call a:directoryNode.activate((a:0 > 0) ? a:1 : {})
endfunction

"FUNCTION: s:activateFileNode() {{{1
Expand Down
Loading