Commit Graph

248 Commits

Author SHA1 Message Date
Phil Runninger
e3e600608a
On Windows, do a case-insensitive comparison of paths. (#967) 2019-03-25 22:32:07 -04:00
Phil Runninger
0efbdfbc5a
Remove the "Please wait... DONE" messages. (#966) 2019-03-25 22:29:21 -04:00
Chris Patuzzo
84737f2ebe Add a NERDTreeMinimalMenu feature (#938)
* Extract the menu action prompts to a function

* Add a NERDTreeMinimalMenu configuration option

If this option is set, Vim’s command line displays
a single-line version of the menu:

Which action? (a*/m/d/r/o/q/c/l):

Pressing ‘a’ will call the ‘add child node’ menu
item as that is its shortcut.

The * denotes the position of the currently
selected menu item which can be changed with
NERDTreeMenuDown and Up in the usual way.

The user may wish to set these to <left>, <right>
or h, l if they prefer.

* Minimise the text once a menu item is chosen

If NERDTreeMinimalMenu is set, then echo a single
line prompt after the menu item is chosen. This
reduces noise for users who are already familiar
with how the menu works and prevents Vim scrolling
down to accommodate the menu text.

If the directory is non-empty we display
‘Delete directory?’ instead of ‘Delete?’ and the
user must still type ‘yes’ to confirm, rather than
just pressing ‘y’.

* Document the new NERDTreeMinimalMenu feature

* Tweak the format for the minimal menu prompt

As per @PhilRunninger’s suggestions:

- The menu now shows the ‘j/k/enter’ help text
- The first word of the selected item is shown*
- Use commas between menu items so that it’s
  visually distinct from the ‘j/k/enter’ text

* I tried displaying the full menuItem text, but
this can be quite long, e.g.

> (o)pen the current node with system editor

This causes the menu to jump around a lot. We
could add another minimal versions of these, but
I think the first word seems ok for now.
2019-02-24 18:01:12 -05: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
9eda9ce6a1
Add new value to NERDTreeQuitOnOpen to close bookmark table (#955)
* Update documentation for new NERDTreeQuitOnOpen values.

* Modify use of NERDTreeQuitOnOpen, keeping current behavior.

* If applicable, close the bookmarks table before opening the target.
2019-02-21 07:47:15 -05:00
Phil Runninger
2e0b101d57
Add an :EditBookmarks command to edit the bookmarks file (#954)
* Add a new NERDTree buffer command to edit the bookmarks file.

* Update the mini-help panel with missing bookmark commands.

* Update the help file with the new :EditBookmarks command.
2019-02-20 23:57:51 -05:00
Phil Runninger
c05615fd80
Set a maximum window size when zooming. (#950) 2019-02-15 03:10:28 -05:00
Phil Runninger
74be22deb7
Escape a backslash so it can be used in a key mapping. (#948) 2019-02-14 15:28:30 -05:00
zcodes
8cc154d4b0 fixed root path error for windows (#935)
* fixed root path error for windows

* simplify condition check
2019-02-01 07:50:55 -05:00
Phil Runninger
72c3656799
Add new command to open NERDTree in the root of a VCS repository. (#872)
* Add new command to open NERDTree in the root of a VCS repository.

* Add another example to the help file.

* Refactor and make NERDTreeVCS work on Windows.

* Don't crash when NERDTreeVCS is given a nonexistent folder.

* Move VCS code to a plugin script.

* Add some documentation to the top of vcs.vim.
2018-12-12 13:30:13 -05:00
Phil Runninger
a4dd4e1dce
Restore getDirChildren for use in nerdtree-project-plugin. (#929)
This function was added to support a separate plugin:
https://github.com/scrooloose/nerdtree-project-plugin.git. It was
subsequently removed without recognizing its contribution to the
external plugin. This commit restores that function so NERDTree projects
will work.
2018-12-11 22:44:55 -05:00
Arvid Gerstmann
c905a5d7b8 Allow modification of menu keybindings (#923) 2018-11-29 09:17:39 -05:00
Phil Runninger
370eb5bcb4
Add two more disqualifications for isCascadable(). (#914)
* Add two more disqualifications for isCascadable().

A directory that is bookmarked or that is a symlink to another location
has trailing text indicating so. This extra text causes problem when
cascading with a directory underneath it, so disable it in this case.

* Add comments to explain the new exclusions for bookmarks and symlinks.
2018-11-20 13:33:23 -05:00
Phil Runninger (mac)
8d005db94f Use substitute() for backward compatibility. Change conceallevel to 3. 2018-10-31 08:45:43 -04:00
Phil Runninger
91e0f2253f
Support unusual characters in file and directory names (#868)
* Use a delimiter in node to separate file/dir name from the rest.

* Switch warning message to use nerdtree#deprecated function.

* Compress the space between the tree symbols and the node.

* Include the delimiter when calculating indent or getting filename.

* Don't need to strip leading delimiter. It will already be gone.

* Simplify the way the delimiter is being used.

I don't know what I was thinking. The delimiter doesn't need to be used
to separate every indicator on the node's text, ie.

Bad:    Tree|GenericFlags|Filename|ExecutableFlag|Link|ReadonlyFlag
Better: Tree GenericFlags|Filename|ExecutableFlag Link ReadonlyFlag

This was unnecessary, given that we're only interested in the filename.
So, just one pair of delimiters is all we need. That greatly simplifies
the _stripMarkup function, and restores a bunch of other statements to
what they already are in the master branch.

* Add syntax highlighting to conceal the delimiter

* Put a if has("conceal") check around the syntax statement using it.

* Make concealment work correctly for LinkFile and readonly files.

* Use highlight Ignore if conceal isn't available.

This is probably the best we can do, especially if some other character
must be used in place of nbsp.

* Make the regex better match the original, but more compact.

It was allowing 2+ spaces, instead of only 1+.

* Fix the syntax highlighing of delimiters around NERDTreeExecFile.

* Bug fix: Parse . and .. from path string with trailing slash.

* Fix unresponsive cascaded directories.

Using ':' as a more visible delimiter, when directories are cascaded,
the line appears in NERDTree like so:

▾ :lib/::nerdtree/:

Before this commit, the s:UI._stripMarkup function was leaving the
internal delimiters in place (lib/::nerdtree/). Now they are removed,
resulting in a valid path (lib/nerdtree/).

* Use .= to shorten statement. Use clearer substitutes to get node name.

* Remove node delimiters that terminate the line.

* If flags are needed after the node name, then put another delimiter
before them.
* When joining directory nodes for cascaded display, strip off the
delimiter from the child node(s).
* Remove the unnecessary substitution of doubled intermediate
delimiters, since they're not in there anymore.

* DRY up the addition of the 2nd delimiter, and use only 1 for all tags.
2018-10-24 22:41:13 -04:00
Phil Runninger
388623e702
Support sorting files and directories by modification time. (#901)
* Introduce a flag to to sort by the node's modification time.

This flag is part of the NERDTreeSortOrder list. '[[timestamp]]' sorts
oldest to newest, while '[[-timestamp]]' sorts newest to oldest. Its
position in the array determines whether it is the primary sort (first
position) or secondary sort (any other position). The remaining elements
in the array describe the other sort level following all prior rules. If
needed, a tertiary sort is done alphabetically on the filename.

Examples:

['[[timestamp]]']            - oldest to newest
['\/$','*','[[-timestamp]]'] - dirs, then files, each newest first.

When using this flag, performance is slowed a little because the sortKey
is always recalculated with every sort. Why? Because if a file is saved
(either in vim or by an outside program), NERDTree needs to go back out
to the shell to get the new modification time.

* Update NERDTreeSortOrder documentation.

The new `[[timestamp]]' and '[[-timestamp]]' flags are added to support
sorting by modification time.

* Fix the inequality. Must be >= to force recalculation of _sortKey.

* Move `let path=` closer to where it's used.
2018-10-24 22:18:18 -04:00
Phil Runninger
92a20c0736
Bug fix: Parse . and .. from path string with trailing slash. (#899) 2018-10-24 22:14:18 -04:00
Phil Runninger
820955e773
Catch all errors, not just NERDTree errors. (#894)
When middle-clicking, the s:TreeFileNode.GetSelected() function is
called along the way. If this is done outside of the NERDTree window,
there is not "b:NERDTree" variable, and the "E121: Undefined variable"
exception is thrown. This function was trying to catch only the NERDTree
specific errors; thus, it let the Undefined variable exception slip by.
This commit causes the function to catch all errors.
2018-10-18 11:35:00 -04:00
Jason Franklin
599238ad99
Make NERDTreeCreator set the 'nolist' option (#889) 2018-09-17 08:13:07 -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
e9d3f72d9c
Function "s:UI.getLineNum()" doesn't always work on cascades. (#882)
This PR is a rewrite of the "s:UI.getLineNum()" function.  This change
improves the logic and clarity of this function, and it fixes the function's
ability to work with cascades.

Fixes #529.
2018-09-13 08:39:09 -04:00
Phil Runninger
b3804dcd71
Merge pull request #871 from scrooloose/trap_bad_bookmark_path
Make sure the path to the bookmarks file exists before writing it.
2018-09-10 17:34:06 -04:00
Phil Runninger
129a241b22
Merge pull request #870 from scrooloose/undo_zoom_on_open
Unzoom NERDTree when opening a file
2018-09-10 06:34:05 -04:00
Phil Runninger (mac)
f78cf63627 Instead of creating the bookmark file path, show error message.
This change puts the burden on the user to make sure
g:NERDTreeBookmarksFile is correctly set and the path it contains is
present and has the proper permissions. If this is not the case, an
error message is displayed. This is a better solution than to blindly
create the path, when it may actually be impossible to do so.
2018-09-09 21:29:20 -04:00
Phil Runninger (home)
808f5b225b Escape commas in the globpath() function's path argument.
If not escaped, commas will cause globpath() to search in multiple
directories, none of which really exist.
2018-08-25 09:52:55 -04:00
Jason Franklin
b8cc044760
Merge pull request #875 from scrooloose/open_differently_cased_files
Force a case-sensitive comparison of new and existing buffers.
2018-08-25 09:36:57 -04:00
Phil Runninger (mac)
39a89f5e50 Use <count>tabnext instead of <count>gt to allow users to remap gt. 2018-08-22 09:16:33 -04:00
Phil Runninger (mac)
026bfaf35e Do a case sensitive comparison of new/existing buffers.
When NERTDtree opens a file, it compares this new file to all open
buffers to see if it's already open. If the user has 'ignorecase' turned
on then the comparison of "file" and "File" says they're the same, and
NERDTree won't reopen the file. This commit forces a case sensitive
comparison by using the ==# operator.
2018-08-15 13:22:06 +00:00
Phil Runninger (mac)
7d9a3f0e8b Make sure the path to the bookmarks file exists before writing it. 2018-08-07 18:13:40 -04:00
Phil Runninger (mac)
b6978ecd70 Unzoom only when user want NERDTree to stay open. 2018-08-07 10:01:09 -04:00
Phil Runninger (mac)
192b07ce1f If the NERDTree is zoomed when 'o'pening a file, unzoom it.
'go' does not trigger this new behavior, because focus remains in the
NERDTree.
2018-08-07 09:00:39 -04:00
Jason Franklin
456367ab07 Put cursor on root when closing bookmark table
If the cursor is not already positioned on a node when the bookmark
table is closed, then the resulting position of the cursor is not
determined.  Here, we default to positioning the cursor on the
root when the bookmark table is closed.
2018-08-02 09:17:18 -04:00
Phil Runninger (mac)
e99a7a0313 Restore the cached _sortKey for faster processing.
Also add a new global variable to track when the g:NERDTreeSortOrder
changes. If it has been changed, or when the cached _sortKey value is
uninitialized, then calculate the sort key. This improves processing
speed over the previous commit, and allows on-the-fly changes to the
sort order, (without required vim to be restarted.)
2018-07-27 08:46:50 -04:00
Phil Runninger (mac)
1e2b7ef98d Remove AddDefaultGroupToSortOrder check from startup.
The call to AddDefaultGroupToSortOrder in NERD_tree.vim is redundant
because it's also done every time sortChildren is called. And since the
check is done only once, there's no need for a function either.
sortChildren now just contains the needed if statement.
2018-07-02 09:06:09 -04:00
Phil Runninger (mac)
6ef3213cd0 Fix indentation. 2018-07-02 08:55:32 -04:00
Phil Runninger (mac)
a053925279 Recalculate the node's sortkey every time.
The cached _sortkey wasn't being recalculated after changing the
NERDTreeSortOrder, resulting in incorrect sort orders.
2018-07-01 19:57:02 -04:00
mnussbaum
eb048a3070 Bugfix - ensure keymaps dictionary exists before using it
The s:KeyMap._all function isn't necessary if we initialize the
s:keyMaps dictionary at file load time.
2018-06-12 13:46:14 -07:00
mnussbaum
657be6b24d Mark private function with leading underscore 2018-06-12 08:28:04 -07:00
mnussbaum
c6d757f198 Decrease startup-time by avoiding iteration over maps
This commit makes adding, removing and finding key maps an O(1)
operation instead of O(n), where n is the number of pre-existing maps.

In my testing, averaged over 100 iterations, this reduces the time spent
initializing NERDTree at Vim startup from ~73ms to ~9.7ms. That's with
only the default included key maps.
2018-06-10 23:55:04 -07:00
Jason Franklin
57c825a169 Add code to sort mappings in quickhelp 2018-06-06 09:02:25 -04:00
Jason Franklin
80ee0897ff Add a call to ":clearjumps" to "_createTreeWin()"
Using the ":clearjumps" command wipes out the jump list for the
current window.  This means that the user can't inadvertently jump
out of the NERDTree buffer while using the NERDTree window (i.e., by
using "<C-O>").
2018-05-26 08:43:27 -04:00
Phil Runninger (mac)
c4f8a0f370 Like m-c did before, create parent directories if needed on m-m. 2018-05-16 13:09:20 -04:00
Phil Runninger (mac)
2c38519733 Make the NERDTree buffer writable when rendering it. 2018-05-06 11:34:24 -04:00
bravestarr
abf200397f
Merge branch 'master' into fix-multibyte-path 2018-04-26 21:20:33 +08:00
bravestarr
b45f2c27ea Replace strcharpart() with substitute() for backward compatibility 2018-04-26 17:13:06 +08:00
hav4ik
0972cda243 Fixed bug 'unknown function strcharpart' for older versions of Vim 2018-04-25 03:04:18 +03:00
Phil Runninger
d3a7cd20ae
Merge pull request #830 from bravestarr/fix-multibyte-path
Display a path with multi-byte characters correctly when it is truncated
2018-04-24 14:19:36 -04:00
bravestarr
6aff1b6cd3 Display a path with multi-byte characters correctly when it is truncated
When a path is rendered in the Bookmarks area or as the header line of the
tree, it is truncated if there is no enough space for it.  But if a path
contains multi-byte characters, it should be truncated by characters, not
bytes, otherwise the path may be truncated between the bytes of a
multi-byte character.  To deal with multi-byte characters, use
strdisplaywidth() instead of len() to get the number of display cells, and
use strcharpart() instead of strpart() to truncate a path.
2018-04-23 03:09:49 +08:00
Jason Franklin
164131762f Refine the internals of the "showMenu()" function 2018-04-22 10:23:16 -04:00
Jason Franklin
38d4d2288a Clean up a function comment 2018-04-22 10:21:16 -04:00