Commit Graph

129 Commits

Author SHA1 Message Date
Phil Runninger
a7eb011e47 Revert #1200, due to bug (#1205) it introduced. 2021-01-17 22:16:38 -05:00
Tomasz N
7e1713853a
Respect NERDTreeCustomOpenArgs when opening bookmark (#1200)
* Respect NERDTreeCustomOpenArgs when opening bookmark

* Update CHANGELOG

* Do not duplicate s:initCustomOpenArgs()

* Restore missing assignment

* fixup! Restore missing assignment

* fixup! Do not duplicate s:initCustomOpenArgs()

* Simplify loop iteration
2021-01-17 20:00:17 -05:00
Phil Runninger
23000acd7f
Refactor sort comparison functions, removing redundancy (#1166)
* Add a function to compare path objects.

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

* Remove the compareTo function in the Path object.

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

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

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

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

* Fix fold marker.

* Update version number in change log.

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

Co-authored-by: Phil Runninger <prunninger@vhtcx.com>
2020-07-14 08:53:00 -04:00
Phil Runninger
aa37cb40da
Fix the scope of several key mappings (#1151)
* Limit opening or previewing into a split window to only file nodes.

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

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

* Update version number in change log.

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

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

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

* Handle previewing directory bookmarks properly.

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

* Update version number in change log.
2020-06-23 10:40:30 -04:00
Phil Runninger
f63132cade
Use backward-compatible nerdtree#and() in one place that was missed. (#1134)
* Use backward-compatible nerdtree#and() in one place that was missed.

* Update version number in change log.
2020-05-25 11:33:20 -04:00
Bouke van der Bijl
5249b30fbf Use single-quoted string to comply with styleguide 2020-02-20 10:50:15 +01:00
Bouke van der Bijl
6224d20698 Open the parent directory when revealing a non-existent file
Right now it just reveals the directory but leaves it closed.

Related to #1043
2020-02-20 10:45:09 +01:00
andys8
881c265438 [BUGFIX] Shows error for empty filenames (vim-startify)
There was a fix in #1043 which improves the behavior for non saved
filenames. Those are not on disk, but also not empty. This lead to an
issue #1059 where actual "empty files" like created with vim-startify or
stdin lead to an error. This change fixes this by adapting the order of
the tests. It'll print "no file for the current buffer" for empty files.

Solves #1059
2020-01-20 15:05:47 +01:00
Phil Runninger
5fbf0d7dba Put the eventignore reset inside a finally block to ensure it's called. 2020-01-16 10:51:12 -05:00
Caleb Maclennan
907587f7a3 Fix lint warnings: use the full option name 2019-12-31 10:30:00 +03:00
Caleb Maclennan
38b1e5e7aa
Fix lint warnings: use the abort attribute for functions in autoload 2019-12-31 09:42:19 +03:00
Caleb Maclennan
a722613f36
Fix lint warnings: use robust operators 2019-12-31 09:42:19 +03:00
Caleb Maclennan
45e33f2502
Fix lint warnings: prefer single quoted strings 2019-12-31 09:42:14 +03:00
Phil Runninger
2d639b70e7
Catch errors when trying to read CHANGELOG.md. (#1045)
* Catch errors when trying to read CHANGELOG.md.

The ArchLinux package
(https://www.archlinux.org/packages/community/any/vim-nerdtree/) puts
this file in the wrong location.

* Update version number in change log.
2019-10-01 09:17:32 -04:00
Phil Runninger
6318406f66
If file path doesn't exist, :NERDTreeFind its parent directory instead. (#1043)
* If file path doesn't exist, :NERDTreeFind its parent directory instead.

This happens in the following scenario:
```
:edit path/new_file
:NERDTreeFind
```
Instead of an error message about an **invalid path**, this change will
now find the parent directory instead. It will not work if the new file
is **path/new_folder/new_file**, and that's OK because even vim itself
cannot handle both the new folder and the new file; `:w` won't create
the new folder.

* Update version number in change log.

* Change version change from PATCH to MINOR.
2019-09-29 11:28:59 -04:00
Phil Runninger
bd744eab8d
Make the behavior of window splits consistent (#1035)
* add option to spawn split from previous window

* Update some comments and remove debugging statement.

* Simplify the code, and make it respect NERDTreeWinPos and 'splitbelow'.

* Better logic for getting NERDTree window number when not active window.

* Use common functions for splitting windows. Make splitting respect user.

The placement of split windows now respects the user's choices for the
splitright and splitbelow settings, and the g:NERDTreeWinPos variable.

* Update version number in change log.
2019-09-24 01:19:27 -04:00
Phil Runninger
3d508aedce
Fix the e key mapping to use netrw if desired (#1031)
* Use :edit in openExplorer to allow NERDTreeHijackNetrw to do its thing.

* Remove commented-out code.

* Make `e` work on file nodes, opening a new NERDTree or netrw buffer.

* Update change log.
2019-08-27 20:53:23 -04:00
Phil Runninger
ae1c0004ec
Suppress events for intermediate window/tab/buffer changes (#1026)
* Add an optional parameter to neredtree#exec to suppress all events.

The value doesn't matter, but 1 is a good choice. Its presence is an
indicator that tells NERDTree to tell Vim to ignore all events. I'm not
yet sure if there needs to be an else section to that if block. It may
be OK to allow all events to fire in the right situations.

* Supress events in all intermediate nerdtree#exec calls.

Finding all the right function calls is the key here.

* Make ignoreAll a required parameter to nerdtree#exec().

* Put required ignoreAll argument (==0) in where it's now needed.

* Ignore events when creating a new vertical split.

* Ignore events when closing NERDTree. This may need to be reverted.

* Remove debugging statment and commented-out code.

* Wrap remaining buffer/window-switching commands in nerdtree#exec().

* Update version number.

* Add a space between arguments in nerdtree#exec() calls.
2019-08-08 22:00:35 -04:00
Phil Runninger
63c59208c1
Revert #1019 to fix nvim artifacts and flickering. (#1021)
* Revert "Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)"

This reverts commit 4ac07f52a3.

* If not Neovim, use `:redraw!` as was done before.

* Update version number.

* Fix punctuation in NERDTree Menu instructions.
2019-07-14 15:17:56 -04:00
Phil Runninger
4ac07f52a3
Use :mode only in neovim. MacVim still needs to use :redraw! (#1019)
* Use :mode only in neovim. MacVim still needs to use :redraw!

* Make nerdtree#redraw do both redraw and redraw! based on a parameter.

* Make bang a required parameter.

* Replace all redraw statments with call nerdtree#redraw function calls.

* Update version in change log.
2019-07-10 09:45:58 -04:00
Kebin Liu
aef6baf6e2 Update ui_glue.vim (#1014)
Fix `<CR>` key map on the bookmark
2019-07-03 11:11:25 -04:00
Phil Runninger
06c9d9c963
Make Enter work on the .. ( up a dir ) line (#1013)
* Make Enter work on the `.. ( up a dir )` line.

* Simpler instructions for getting bug info.

* Update changelog.
2019-07-02 15:45:36 -04:00
Phil Runninger
ca16df25fa Fix nerdtree#version() on Windows. 2019-07-01 23:29:56 -04:00
Phil Runninger
cce6fb373f
Expand functionality of <CR> mapping (#1011)
* Define default values for new variables governing new "Default Open".

"Default Open" means to open a file with the Enter key (which of course
can be changed.) The key can be changed in the vimrc, and there is a
variable for specifying the Opener parameters for opening the node. This
lets the user decide whether Enter (or another key) will open a file in
the current tab or a new one, and whether or not to open the file again
in the tab or jump to a window where the file is already open.

* Remove the old mapping for <CR>, a duplicate of 'o'.

<CR> will be defined like all the other keys, in plugin/NERD_tree.vim

* Assign functions to the new <CR> key mapping.

Three separate functions handle directories, files, and bookmarks.

* Rename variables: NERDTreeCustomOpen and NERDTreeCustomOpenArgs

* Add documentation for NERDTreeCustomOpenArgs and NERDTree-<CR>.

* Make key mapping variables be indexed in the Vim help

* Remove angle brackets from <CR> to see if help navigation improves.

* Rename functions from defaultOpen... to customOpen...

* Use separate options for file and directory nodes.

* Update documentation for separate file/directory options.

* Update version number and change log.

* Change CR to <CR> in help tags.

* Fix missing backtick in patch number.

* Update the quickhelp text.

* Update Pull Request template.

* Update change log with simpler formatting of patch number.

* Get NERDTree version number directly from CHANGELOG.md

* Reformat the lists of contributors in the Change Log.

* Initialize the version text, just in case the while loop finds nothing.
2019-07-01 22:13:20 -04:00
Phil Runninger
1c803b36f6
Remove @mentions from PR template and change log. They weren't working. (#1009)
* Remove @mentions from PR template and change log. They weren't working.

* Update version number and change log.
2019-06-27 08:03:50 -04:00
Phil Runninger
2cbc76bbfd
Fix NERDTree opening with the wrong size. (#1008)
* Fix NERDTree opening with the wrong size.

There were two commands that seemed to be causing the NERDTree window to
open in exactly half the screen width. They are:

- silent! execute 'edit ' . t:NERDTreeBufName        in _createTreeWin()
- setlocal nobuflisted                         in _setCommonBufOptions()

These commands were reseting the width of NERDTree. The solution I chose
was to resize the window after creating the new window, and then to set
winfixwidth before setting the other common buffer options.

* Update change log and version number.
2019-06-27 01:34:10 -04:00
Phil Runninger
347a58b0b0
Update Changelog and create PR Template (#1007)
* Update CHANGELOG and change it to Markdown format.

* Add PR template with checklist for advancing the version number.

* Update version number.

* Change PR number in change log and PR template.
2019-06-27 01:28:45 -04:00
Phil Runninger
28eb47e267
Fix refreshroot (#999)
* Set t:NERDTreeBufName when creating a window tree.

* Change folding markers.
2019-06-07 21:41:47 -04:00
Phil Runninger
a3f0e66793
Change minimum vim (#991)
* Add a new function to implement and() from vim 7.4.

* Change minimum required version of vim to 7.3.
2019-05-09 10:12:25 -04:00
Phil Runninger
e126b8745d
Remove redraw! while still clearing last message empty string. (#979) 2019-04-16 09:55:20 -04:00
Phil Runninger
0efbdfbc5a
Remove the "Please wait... DONE" messages. (#966) 2019-03-25 22:29:21 -04:00
Phil Runninger
b6cde142dd
Preview bookmarks (#956)
* Add function to preview bookmarks.

File bookmarks are previewed like regular file nodes.
Directory bookmarks are located with NERDTreeFind in the current tree.

* Update help doc to include the new bookmark preview functionality.
2019-02-22 08:21:20 -05:00
Phil Runninger
52151fb307
Call Resolve on the file's path when calling :NERDTreeFind. (#896)
When :NERDTreeFind creates a tree, it resolves the file's path, and
makes that its root. See :h resolve() for more info; it basically
tracks down links to their ultimate source. Then :NERDTreeFind
tries to find the file under that root, so it can be revealed. The
problem is that it compares the file's unresolved path against the
resolved path in the root. Here is the scenario:

/tmp/ is a link to /private/tmp/
:e /tmp/foo will open the file as expected
:NERDTreeFind will first create a tree with a root of /private/tmp/
Then it tries to find /tmp/foo, but it can't, because the path
names don't match.

This commit resolves /tmp/foo to the actual location of
/private/tmp/foo; thus, it is able to find the file in the tree.
2018-10-24 22:13:42 -04:00
Werner Hofstra
5381197747 Add NERDTreeRefreshRoot command (#897)
* Add NERDTreeRefreshRoot command

* Document NERDTreeRefreshRoot
2018-10-16 11:08:23 -04:00
Jason Franklin
cd1f2c803e Fix the <C-J>, <C-K>, J, and K default mappings (#886)
These mappings currently fail on cascades.  This pull request fixes
this problem.
2018-09-15 10:20:13 -04:00
Jason Franklin
7e00a9971e Check for error; remove code duplication 2018-09-10 08:46:42 -04:00
Phil Runninger (mac)
703e1ef4fe Correctly check the type of the sort key's value. Fixes #842. 2018-07-01 19:55:26 -04:00
Jason Franklin
f9e83ad8bd Fix a bug with the 'u' mapping
This commit refactors the "nerdtree#ui_glue#UpDir()" function to fix
a bug in the behavior of the 'u' mapping.  To reproduce the bug:

  1. Open a bookmarked directory with 'o'
  2. Press 'u' twice, observing normal behavior
  3. Open the same bookmark again with 'o'
  4. Press 'u' again, observe the new root is closed

The reason for this bug is that the parent node already existed and
was closed by the second 'u' press in step two above.

This commit fixes this bug by being careful to always open the new
root and transplant the child node properly.  Also, the internals of
the function in question were refactored to make use of valuable
NERDTree functions that ultimately help to reduce the amount of code
needed for this operation.
2018-05-06 12:19:19 -04:00
Jason Franklin
2437b75479 Remove unsupported bookmark table mappings
The definitions for certain bookmark mappings reference callbacks
that don't actually support operation on bookmarks.  Furthermore,
the mappings that are defined are not documented anywhere.  Removing
them seems reasonable since they serve no real purpose.
2018-04-28 09:17:29 -04:00
Jason Franklin
0ff697eb40 Implement the "isHiddenUnder()" method for Path 2017-12-22 10:28:31 -05:00
Jason Franklin
01b011d38e Have "finAndRevealPath()" fail on no file
If a file does not exist for the current buffer, this function
should fail with a clear warning message.

Here, I improved the messages that this function prints so that it
fails gracefully when no path can be determined in the calling
context.
2017-12-22 08:45:57 -05:00
Jason Franklin
344119439e Refresh children of directory nodes on "reveal()"
The ":NERDTreeFind" command calls the "reveal()" method on the
NERDTree root node.  The "reveal()" method would, in turn, call the
node's "open()" method.  Since the "open()" method would only
initialize the child nodes of the root (i.e., read them from disk)
when the list of child nodes was empty, new paths would not be
included in the list.

This commit will result in the refreshing of the child node list
whenever "reveal()" is called on a directory node (unless it is the
first time the node is being opened... the most efficient option).

The result is that ":NERDTreeFind" will discover newly created paths
that exist on disk but are not cached in the NERDTree.

A stray debugging message is also removed.

Fixes issue #779.
2017-12-21 10:36:16 -05:00
Jason Franklin
90d08dc626 Add a debugging message 2017-12-21 09:26:26 -05:00
Jason Franklin
5301dd24fb Improve variable naming in "findAndRevealPath" 2017-12-21 08:43:15 -05:00
Jason Franklin
496d9a17d8 Remove code duplication in "findAndRevealPath" 2017-12-21 08:28:28 -05:00
Jason Franklin
b4b99c39fa Change the type of completion used by NERDTreeFind
This command should complete file names, not directories.

Fixes #780.
2017-12-12 08:24:18 -05:00
Jason Franklin
2129740419 Add style improvements
Function-local variables, instead of script-local variables, should
be used here.  In addition, "empty()" is a better choice for testing
for the absence of an argument.  Finally, the use of "else" is
removed.

The docstring is also updated to include the new argument.
2017-12-09 11:09:10 -05:00
zhenyangze
12960b966f change NERDTreeFind with args 2017-12-09 16:58:18 +08:00