Commit Graph

76 Commits

Author SHA1 Message Date
Ali Rezvani
60b5e602e9
fix: session restore for nerdtree buffers. (#1405) 2024-02-07 15:07:25 +03:30
Ali Rezvani
ea4833da8a
Added Case Sensitive Move Operation via newly introduced flag NERDTreeCaseSensitiveFS (#1375)
* Added NERDTreeCaseInsensitiveFS option.

* check against g:NERDTreeCaseInsensitiveFS with path.equals method

* Fixed issues in comments and added nerdtree#runningMac

* Using nerdtree#runningMac instead of manual checks for mac

* Better implementation

* Updated documentation

* Added notice about the flag

* Updated the documentation

* Added support for g:NERDTreeCaseSensitiveFS = 3

* Better comments

* Exported caseSensitiveFS check as a function
2023-10-22 15:47:01 +03:30
lifecrisis
e731b84559
Ensure backward compatible testing of types (#1266)
- Use "type(0)" instead of "v:t_number"
- Use "==" instead of "==#" since we are comparing numbers
- Make use of the "+=" operator
- Update the "CHANGELOG.md" file

The only real issue here is that we should prefer "type(0)" over the
special variable.  I run into this problem enough on older systems
that it frustrates me.  Let's have it fixed!
2021-09-20 15:01:21 -04:00
Phil Runninger
3a9d533f3d
Restore the default behavior of the <CR> key. (#1221)
* Restore <CR>'s default behavior to be the same as o's.

* Remove the dictionary validation, and simplify initCustomOpenArgs().

There was a bug in the validation logic that caused a valid integer
value of 'keepopen' to always be overwritten with the defaultOpenArgs'
value. It was always comparing its type to the type of a string.

I fixed this by removing all the type validation, and wrapping the code
with a try-catch block. If NERDTreeCustomOpenArgs is not a dictionary,
an error message will print and the defaults will be used instead.

* Add fold markers to new functions.

* Update version number in change log.
2021-02-10 22:20:04 -05:00
Phil Runninger
593c16add3
Fix {'keepopen':0} in NERDTreeCustomOpenArgs (#1217)
* Replace #and() with two more-specific functions.

* Push NERDTreeQuitOnOpen checking earlier in the call stack.

* Fix bug in `go` key for file bookmarks. It was behaving like `gs`.

* Fix the `o` mapping for bookmark nodes and the g:NERDTree reference.

* Use get() function to shorten if statement logic.

* Update version number in change log.

* Remove obsolete reference to MERDTreeQuitOnOpen in comment.
2021-02-09 21:34:24 -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
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
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
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
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
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
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 (mac)
703e1ef4fe Correctly check the type of the sort key's value. Fixes #842. 2018-07-01 19:55:26 -04:00
Alexey Shumkin
cb9f4db6ff fixed: directory navigation does not work on Cygwin
Directory tree navigation is broken because of directory signs which is
shown in UTF-8.

Cygwin is a Windows application, so it uses ASCII codepages and so
directory signs must be in ASCII, but if to modify
"nerdtree#runningWindows" function there are many other functions break
that convert paths, e.g.

So, the quick and reliable solution is to add a
separate function "nerdtree#runningCygwin" and use it in a specific
place.
2017-10-27 10:06:51 +03:00
Phil Runninger
626e80f6e4 Merge pull request #536 from satori/master
Add support for natural sorting order.
2017-06-21 11:33:47 -04:00
Jason Franklin
0b65089122 Reimplement the bookmark comparison method
Sorting the list of user bookmarks requires care to ensure that Vim's
builtin sort function is called correctly. Previously, this function was
called incorrectly. This is why the sorting of bookmarks never worked.

The offending functions have been removed here and replaced with
"s:Bookmark.CompareBookmarksByName". To understand the necessity for
this change, read ":h sort()" for the requirements of the function
reference argument (esp., note that it must return -1, 0, or 1).

In addition to fixing this problem, the new comparison function will
inspect the "g:NERDTreeBookmarksSort" setting to determine whether
case-sensitivity is preferred in the sort. The documentation has been
modified to accurately reflect this adjustment. The change is also made
in such a way as not to break any existing configurations.

Fixes #361 ("My bookmarks aren't sorted").
2017-05-26 13:23:05 -04:00
Phil Runninger
d99967cadd Revert "Determine if we're running in Cygwin on Windows." 2017-05-23 07:15:35 -04:00
Phil Runninger
fce10d1b10 Merge pull request #626 from scrooloose/win32unix
Determine if we're running in Cygwin on Windows.
2017-05-20 03:25:38 -04:00
Greg Hurrell
0c0bde3106 Update stale comments
@lifecrisis pointed out this stale comment here:

https://github.com/scrooloose/nerdtree/pull/578#issuecomment-302392831

Closes: #640
2017-05-18 07:02:02 -07:00
Phil Runninger
45f4d61f04 Merge pull request #578 from wincent/eventignore
Suppress autocmds less aggressively
2017-04-12 09:50:28 -04:00
Martin Grenfell
eee431dbd4 really fix the previous buffer issue when closing a tree win
So :bprev was failing to jump back to the right buffer. I dont fully
understand this yet, but I'm fairly sure this is because there is a
magic <directory> buffer that we delete when creating a wintree :-/

Anyway, we are explicitly storing the prev buffer again - and updating
it when reusing treewins. It's worky, but there may be a superior way...
2016-10-21 14:48:05 +01:00
Phil Runninger
4477078170 Unlet! the nt variable before letting it.
Some will have a "NERDTree" buffer variable and others will not. In the
ones that do, getbufvar will return a dictionary. getbufvar will return
an empty string from the other buffers. When looping through the buffers,
let will throw an error if nt already exists and is a different type than
what is trying to be put into it. This easily can be illustrated by these
two statements:

:let x = ""
:let x = {}
E706: Variable type mismatch for: x

This commit gets rid of the variable before setting it so that the
mismatch cannot occur.
2016-10-17 10:30:33 -04:00
Martin Grenfell
84e7a77a7e reuse win trees when editing the same dir again
If you do

```
:edit some/dir/
```

then do the same thing at a later point, then the same nerdtree buffer
will be loaded/shown the second time.
2016-10-14 16:34:08 +01:00
Phil Runninger
a9a5aec9c0 Determine if we're running in Cygwin on Windows. 2016-10-06 17:51:22 -04:00
Greg Hurrell
35b04fa3df Suppress autocmds less aggressively
This is the counterpart to a PR I just submitted to undotree
(https://github.com/mbbill/undotree/pull/61).

I noticed that my statusline doesn't update properly when using NERDTree to move
between revisions of a file with `go` or `gi`
(https://github.com/wincent/wincent/issues/16). I established that this was
because it was using `'eventignore'` to suppress all autocmds, which in turn
prevents the statusline from updating.

Commenting out the `set eventignore=all` line makes the failure to update go
away, at the cost of firing more autocmds.

I considered adding an option for opting out of this behavior (eg. `let
g:NERDTreeEventignore=0` or something), or rearchitecting my statusline to use
an approach like vim-airline does based on CursorMoved autocmds (see
https://github.com/vim-airline/vim-airline/issues/82; see also
30f078daf5/plugin/airline.vim (L36-L50)
for current implementation), but then realized that a simpler fix is to have
NERDTree just disable only the autocmds that it uses instead of disabling all of
them.

This is probably not enough to unbreak every bit of code in the world that
depends on those autocmds, but it does at least unbreak my use case, because it
allows my `WinLeave` autocmd to run and update the statusline.
2016-05-05 09:35:16 -07:00
Maxim Bublis
6251ab1e63 Add support for natural sorting order. 2016-01-19 00:21:13 -08:00
Martin Grenfell
4ebbb533c3 silence bookmark errors on startup
Just disable the warning for now. The bookmark system will be replaced
with the project system soon - so no sense putting much effort into
this.

Closes #168
2015-12-02 21:17:22 +00:00
Martin Grenfell
848857d18b rename "primary" and "secondary" trees to "tab" and "window" trees
This is much more accurate and descriptive.
2015-11-14 11:50:01 +00:00
Martin Grenfell
4dada8c04f update version number to 5.0.0 2015-11-13 16:57:21 +00:00
toiffel
93c9726c6d Fixed case-sensitive sorting of tree nodes when 'ignorecase' option is on 2015-07-13 03:03:14 +06:00
Vincent Tsang
80e184df56 Refactor code to use getSortKey() and replace regular expression with
simple string comparison in tree_dir_node.vim
2015-05-11 11:56:08 +08:00
Vincent Tsang
57d5bd7731 Speed up sortChildren() by using sorting token
This improves the sorting functions from 12 seconds to 0.66 seconds for
~4000 objects
2015-05-09 22:47:33 +08:00
Martin Grenfell
8b189cb263 move some rendering and cursor moving functions out of autoload 2015-05-02 15:24:59 +01:00
Martin Grenfell
b0114d202b move dumpHelp out of autoload 2015-05-02 15:05:28 +01:00
Martin Grenfell
53d2de86eb move the closeTree functions out of autoload
Remove `closeTreeIfOpen` and just make `closeTree` fail silently.
2015-05-02 15:03:54 +01:00
Martin Grenfell
0d88ce946f move isTreeOpen() out of autoload 2015-05-02 14:44:32 +01:00
Martin Grenfell
8270b6d717 move nerdtree#getTreeWinNum out of autoload 2015-05-02 14:32:21 +01:00