Commit Graph

98 Commits

Author SHA1 Message Date
Ali Rezvani
edc9460859
Clarified the NERDTreeChangePermissions prompt (#1381)
Co-authored-by: Caleb Maclennan <caleb@alerque.com>
2023-10-24 23:13:24 +03:30
Ali Rezvani
334542c361
Added reveal functionality for Windows platform in fs_menu (#1366)
* Added reveal functionality for Windows platform

* Removed an unnecessary check
2023-10-23 19:06:13 +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
Martin J. Klöckner
c99395a323
New menu command: Change selected node permissions (#1348) 2023-10-19 16:03:38 +03:30
Phil Runninger
7eee457efa
Replace trim() with a version-compatible alternative. (#1265)
* Replace trim() with a version-compatible alternative.

* Update version number in change log.
2021-09-14 22:34:57 -04:00
Sharla Kew
0e71462f90
Trim filenames created via the fs_menu (#1243)
The default when naming a file in the command line is that extra white
space will be stripped away. It seems logical for file naming via the
fs_menu in nerdtree to follow that convention.

I have left the defaults of `trim` because they seem sensible.

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
2021-08-12 19:18:53 -04:00
Phil Runninger
c8be9458dd
New menu command: Run a system command in this directory. (#1214)
* New menu command: Run system command in this directory.

* Echo the output from the system command.

* Update version number in change log.

* Address Vim linter message: change "\n" to nr2char(10)

* Use single quoted strings.

* Use system() instead of systemlist() for greater version compatibility.

systemlist() was introduced sometime in Vim 8+, so I switched to
system() for 7.4 compatibility.
2021-01-30 23:45:56 -05: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
Jordi Altayó
2e9d43b6f8
cmd.exe /c start "" <filename> for windows default viewer support (#1130)
* support for default viewer in Windows

* updated changelog

* Update nerdtree_plugin/fs_menu.vim

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>

* Update nerdtree_plugin/fs_menu.vim

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>

Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
2020-05-22 08:57:19 -04:00
lifecrisis
f767dd34a0
Add missing calls to the shellescape() function (#1099)
* Improve "g:NERDTreeQuickLook()"

The following improvements were made...

  - Use variable sigils
  - Shorten a local variable name
  - Prefer an early return over testing for a negative
  - Switch to single quotes
  - Call "shellescape()" to pass a command argument [IMPORTANT!]

The final change is a critical fix for the security and reliability
of this function (see ":h system()").

Similar fixes for the other functions in this script will follow.

* Improve "g:NERDTreeRevealInFinder()"

This commit makes several style improvements and adds a missing call
to the "shellescape()" function.

See also: 56cfbcff1e

* Improve "g:NERDTreeExecuteFile()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeRevealFileLinux()"

Refer to: 56cfbcff1e

* Improve "g:NERDTreeExecuteFileLinux()"

Refer to: 56cfbcff1e

* Properly reveal "/" on Linux

This commit handles the edge case where a user invokes the "reveal"
function on "/" on a Linux box.  There is nothing to do but open the
root directory itself since "/" has no parent.

* Update the "CHANGELOG.md" file

* Add final missing "shellescape()" calls

I initially thought that there were several more locations where
a call to "shellescape()" was required but omitted.  However, there
are only two.  I suppose I should have taken the time to look.

Fixing these was easy.  I would be surprised if this change breaks
anything on the user side.

* Update the "CHANGELOG.md" file (again)

Use a more fitting description of the change...
2020-04-09 21:37:55 -04:00
Eugenij
343508e9fd
Fix infinity loop in FindParentVCSRoot (#1095)
* Fix infinity loop in FindParentVCSRoot (on windows os with 'set shellslash' in vimrc and no VCS in path)

* update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: Phil Runninger <PhilRunninger@users.noreply.github.com>

Co-authored-by: evgenij.vidershpan <evgenij.vidershpan@yandex.ru>
Co-authored-by: Phil Runninger <PhilRunninger@users.noreply.github.com>
2020-03-26 16:33:11 -04:00
Phil Runninger
495b4e781a
File Move: Escape existing directory name when looking for open files. (#1094)
* File Move: Escape existing directory name when looking for open files.

* Update version number in change log.

Co-authored-by: Phil Runninger <prunninger@vhtcx.com>
2020-03-24 15:08:06 -04:00
Phil Runninger
3a3636b7cb Don't ignore events when opening renamed files. 2020-01-16 11:17:33 -05:00
Phil Runninger
97e4b47aa3 Prevent overwriting existing files/dirs on node move. (m-m) 2020-01-15 19:51:39 -05: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
William Findlay
82b1649f2e Add a NERDTreeToggleVCS command to the vcs plugin (#1060)
* NERDTreeToggleVCS

* nerdtree toggle vcs documentation

* fix function documentation

* changelog

* Update CHANGELOG.md

* Update CHANGELOG.md

* simplify toggletreevcs

* Update CHANGELOG.md
2019-11-22 11:26:25 -05:00
jhzn
960fda6299 Menu option, 'copy path to clipboard' is aware of VIM clipboard option (#1056)
VIM noob here, so code might not be optimal.

My setup is as follows.
NVIM v0.5.0-95-g2e14dffbb, Linux Mint 19.2.

I have this in init.vim
```vim
set clipboard=unnamedplus
```
This enables me to share clipboard between VIM and X clipboard.

The problem is that the menu option in NERDTree copies the file path to the "* register.
This means I can't access the value in the X clipboard.
2019-11-13 08:58:42 -05: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
12dea6ccb2
Add a "copy path to clipboard" menu option (#1002)
* Add menu item to copy the node's path to the clipboard.

It works on Mac. Check Windows later.

* Handle case where clipboard is not a compiled feature of Vim.

* Change menu text if clipboard is unavailable.
2019-06-13 09:17:19 -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
842f5cabaa Before deleting, turn off &shellslash. Restore after delete is done. 2019-02-17 22:03:49 -05:00
Phil Runninger
cce52fb9c5
Before copying, turn off &shellslash. Restore after copy is finished. (#952) 2019-02-17 18:30:10 -05:00
Phil Runninger
5e8aa9e721
Confirm the wipeout of a unsaved buffer whose file has been renamed. (#949) 2019-02-14 17:44:31 -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
c372911c4a
Refresh buffers after m, m operation on a folder (#888)
* WIP: Wow! That's an ugly diff. I'm not done yet, though.

* Fix the ugliness of the previous commit, and finish the work.

If the node being renamed is a directory, get a list of all open buffers
whose file lives in the old directory. If that list is not empty, ask
the user if he wants to replace the old buffers with the new files. The
logic to handle renaming a file node stays the same, although the code
has been refactored a bit.
2018-10-24 22:20:59 -04:00
Phil Runninger
f98078d3ae
Force sort to recalculate the cached sortKey. (#898)
* Force sort to recalculate the cached sortKey.

The problem in issue #880 was caused by the sort using the old sortKey.
For example, given nodes A, B, and C, if B were renamed to D, the sort
was still using B as its sortKey, thus not moving it.

It's a bit of a hack, but if we set g:NERDTreeOldSortOrder to an empty
list, the cached sortKey will be recalculated. I did the same thing for
both the Copy and Add functions as well.

* Add a comment to explain the let ... = [] statement.
2018-10-18 16:13:15 -04:00
Phil Runninger
6b6cadf86c
Use a better arg for FINDSTR when using the m,l command in Windows. (#887)
* Use a better arg for FINDSTR when using the m,l command in Windows.

* Remove trailing spaces.

* Use vim getf...() functions in place of DOS commands.

* Remove unnecessary variable.

* Put labels in the text of the file/dir listing.
2018-10-10 22:19:18 -04:00
Andrew Flockhart
9e9d16a38a Reword renamed-buffer prompt to be more clear 2018-08-04 01:16:46 -04:00
Bubba
08db3a0eea Do not need to check for unix os here. 2018-06-15 12:02:58 -04:00
Bubba
a053179d6a Use the case-insensitive regex 2018-06-15 11:29:09 -04:00
Bubba
c0d87db309 Better OSX detection 2018-06-15 10:43:20 -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
Hieu Nguyen
435861ee69 Support revealing file and executing file with xdg-open for Linux 2018-04-09 19:08:09 +02:00
Phil Runninger (mac)
b37495fa98 If node isn't open, count children on disk before deleting.
Fixes #821. If a node isn't opened in NERDTree, it's children aren't
known yet, so when deleting the node (with `m`, `d`), the user isn't
properly asked to confirm the delete. It was going to the less strict
`Y`/`n` confirmation, instead of the `yes` confirmation for non-empty
directories.

This change checks to see if the node is opened already. If it is, the
existing getChildCount() function is used; otherwise, the disk is read
to get the number of children there.
2018-04-02 09:26:34 -04:00
Jason Franklin
9f985514f0 Add modelines 2017-12-17 08:43:43 -05:00
Phil Runninger
97433edd43 Merge pull request #754 from branch comma-separated-file-size
This change will display the file size (printed with the "ml"
command) in an easy-to-read format, while still displaying its
precise value.  It uses the "stat" command (with the correct
switches for Unix and OSX) to get the file size, "sed" to add the
commas, and "sed" again to replace the original size with the
modified number.
2017-11-02 08:36:07 -04:00
Mohamed Boughaba
a8c6245057 Merge pull request #756 from mboughaba/master
Previously, deleting a file in the NERDTree with "md" would cause
a new buffer to be created to fill the window(s) occupied by
a buffer on the file.  This pull request makes it so that a new
buffer is not created.  Instead, the next buffer in the buffer list
fills the window.

Fixes #755.
2017-11-02 08:26:48 -04:00
Jason Franklin
876283b07c Improve display of shell output from menu command
This small change reverts to the previous method of breaking shell
output into lines.  The reason for this is to avoid the printing of
trailing carriage return characters on Windows.
2017-08-19 09:39:25 -04:00
Jason Franklin
f4ff6dcf84 Fix a menu command that breaks under 'shellslash'
The (l) menu command breaks on Windows systems when 'shellslash' is
set.  This is due to the fact that the menu item uses a hard coded
shell command, thus relying on the use of the default Windows shell
without the 'shellslash' setting.

The pattern used for the fix is localized to the problem function.
However, this technique could easily be abstracted into its own
function to execute Windows shell commands with the default shell
throughout the NERDTree codebase.
2017-08-19 08:58:57 -04:00
Dan Schaub
682a7b64db Fix typo in argument usage in promptToRenameBuffer 2016-10-03 18:04:50 -04:00
Phil Runninger
f640646f2c Change confirmation prompt when deleting non-empty directory. 2016-09-22 16:42:17 -04:00
Phil Runninger
1a6c502f19 Merge pull request #530 from mikeperri/delete-empty-directory
Don't require user to type 'yes' to delete an empty directory
2016-09-22 16:40:25 -04:00
Zachary Voase
916f6b8f8f Use fnameescape to quote filenames for :badd. 2016-06-30 16:21:13 -07:00
Mike Perri
d2509d279e Don't require user to type 'yes' to delete an empty directory 2016-06-27 11:28:47 -05:00
Martin Grenfell
665f326577 remove dependency on b:NERDTree from classes that dont need it
Inject it where needed.
2015-11-20 01:44:12 +00:00
Martin Grenfell
d36b793656 dont use b:NERDTreeRoot internally, but leave the var there for compat
Use b:NERDTree.root instead. I will eventually remove  b:NERDTreeRoot
altogether - but this will break some other plugins so leave it for now.
2015-11-16 11:28:24 +00:00
Martin Grenfell
be8f18914c remove some unneeded header comments 2015-11-13 16:54:47 +00:00