mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
153041ac93 | ||
|
|
68cb5fc2eb | ||
|
|
ee7aafb135 | ||
|
|
b047d7f312 | ||
|
|
1537d42706 | ||
|
|
4b566f153f | ||
|
|
f34986d30f | ||
|
|
a713a86f06 | ||
|
|
08bc9870bc | ||
|
|
94e085f1a2 | ||
|
|
241f2e9dfe | ||
|
|
c864c6e463 | ||
|
|
bc55f3dda8 | ||
|
|
39a3a78729 | ||
|
|
31f65b97b1 | ||
|
|
3837ea85e0 | ||
|
|
fedd5f1162 | ||
|
|
dc108f555e | ||
|
|
93a0a422b4 | ||
|
|
e899bed4d7 | ||
|
|
87fbc2e5e4 | ||
|
|
cf61ad3285 | ||
|
|
f772cfdefb | ||
|
|
a1e7bc0b01 | ||
|
|
e5c79fc5c1 | ||
|
|
a3b05e8e38 | ||
|
|
89cfedd39b | ||
|
|
1be18ed53c | ||
|
|
e2265ec3b3 | ||
|
|
5ba3b3a5a8 | ||
|
|
6a513e4340 | ||
|
|
1ea2a0c29b | ||
|
|
3a163fca64 | ||
|
|
36e4402550 | ||
|
|
effb5d4de0 | ||
|
|
a854feeb1e | ||
|
|
cbb0a8698f | ||
|
|
d21b00c767 | ||
|
|
5311777308 | ||
|
|
7a5685af57 | ||
|
|
38e2bcaf85 | ||
|
|
0dda0ce5d7 | ||
|
|
8fc72fd352 | ||
|
|
dc3f1b5edf | ||
|
|
dd38ab8f43 | ||
|
|
7051977808 | ||
|
|
d9f315d63e | ||
|
|
5e9635dfa4 | ||
|
|
f2a9e9a360 | ||
|
|
1080246af9 | ||
|
|
fcb4ec0303 | ||
|
|
8211554efa | ||
|
|
464699215c | ||
|
|
10bb62a728 | ||
|
|
46710bfb25 | ||
|
|
fcb54eee12 | ||
|
|
a686be5c31 | ||
|
|
bd5e5d71b5 | ||
|
|
711c8e3328 | ||
|
|
ec1f7e3e6e | ||
|
|
8535a906be | ||
|
|
eef8a7b280 | ||
|
|
891f0ed3a2 | ||
|
|
e93bf0632b | ||
|
|
31c0ec6d63 | ||
|
|
fc3cb76695 | ||
|
|
389f33ea81 | ||
|
|
abc0cc4c40 | ||
|
|
1654ef820b | ||
|
|
df3485ec64 | ||
|
|
59257d7a3a | ||
|
|
a052a0db65 | ||
|
|
65dd1137da | ||
|
|
236d20946c | ||
|
|
a796715ac1 | ||
|
|
abfd4fef76 | ||
|
|
95acf7dd25 | ||
|
|
02b3cec827 | ||
|
|
c3a2f88b63 | ||
|
|
bc2a628a10 | ||
|
|
6518d1eb4c | ||
|
|
a2ead3545e | ||
|
|
a163f327eb | ||
|
|
e9d6a7209c | ||
|
|
f0290b08dd | ||
|
|
51637ec6d4 | ||
|
|
4d77c3ae45 | ||
|
|
a7f9abe827 | ||
|
|
41029aef24 | ||
|
|
c75a022a23 | ||
|
|
1acf6321a5 | ||
|
|
e164980d84 | ||
|
|
71ebe27a8d |
79
Rakefile
79
Rakefile
@@ -1,18 +1,75 @@
|
||||
desc "Copy the vim/doc files into ~/.vim"
|
||||
task :deploy_local do
|
||||
run "cp plugin/NERD_tree.vim ~/.vim/plugin"
|
||||
run "cp doc/NERD_tree.txt ~/.vim/doc"
|
||||
end
|
||||
# written by travis jeffery <travisjeffery@gmail.com>
|
||||
# contributions by scrooloose <github:scrooloose>
|
||||
|
||||
require 'rake'
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
|
||||
desc "Create a zip archive for release to vim.org"
|
||||
IGNORE = [/\.gitignore$/, /Rakefile$/]
|
||||
|
||||
files = `git ls-files`.split("\n")
|
||||
files.reject! { |f| IGNORE.any? { |re| f.match(re) } }
|
||||
|
||||
desc 'Zip up the project files'
|
||||
task :zip do
|
||||
abort "NERD_tree.zip already exists, aborting" if File.exist?("NERD_tree.zip")
|
||||
run "zip NERD_tree.zip plugin/NERD_tree.vim doc/NERD_tree.txt"
|
||||
zip_name = File.basename(File.dirname(__FILE__))
|
||||
zip_name.gsub!(/ /, '_')
|
||||
zip_name = "#{zip_name}.zip"
|
||||
|
||||
if File.exist?(zip_name)
|
||||
abort("Zip file #{zip_name} already exists. Remove it first.")
|
||||
end
|
||||
|
||||
puts "Creating zip file: #{zip_name}"
|
||||
system("zip #{zip_name} #{files.join(" ")}")
|
||||
end
|
||||
|
||||
def run(cmd)
|
||||
puts "Executing: #{cmd}"
|
||||
system cmd
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts "Installed #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Pulls from origin'
|
||||
task :pull do
|
||||
puts "Updating local repo..."
|
||||
system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull")
|
||||
end
|
||||
|
||||
desc 'Calls pull task and then install task'
|
||||
task :update => ['pull', 'install'] do
|
||||
puts "Update of vim script complete."
|
||||
end
|
||||
|
||||
desc 'Uninstall plugin and documentation'
|
||||
task :uninstall do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.rm target_file
|
||||
|
||||
puts "Uninstalled #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
task :default => ['update']
|
||||
|
||||
@@ -27,11 +27,13 @@ CONTENTS *NERDTree-contents*
|
||||
2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands|
|
||||
2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks|
|
||||
2.3.NERD tree mappings................|NERDTreeMappings|
|
||||
2.4.The filesystem menu...............|NERDTreeFilesysMenu|
|
||||
2.4.The NERD tree menu................|NERDTreeMenu|
|
||||
3.Options.................................|NERDTreeOptions|
|
||||
3.1.Option summary....................|NERDTreeOptionSummary|
|
||||
3.2.Option details....................|NERDTreeOptionDetails|
|
||||
4.Hacking the NERD tree...................|NERDTreeHacking|
|
||||
4.The NERD tree API.......................|NERDTreeAPI|
|
||||
4.1.Key map API.......................|NERDTreeKeymapAPI|
|
||||
4.2.Menu API..........................|NERDTreeMenuAPI|
|
||||
5.About...................................|NERDTreeAbout|
|
||||
6.Changelog...............................|NERDTreeChangelog|
|
||||
7.Credits.................................|NERDTreeCredits|
|
||||
@@ -68,9 +70,6 @@ The following features and functionality are provided by the NERD tree:
|
||||
* custom file filters to prevent e.g. vim backup files being displayed
|
||||
* optional displaying of hidden files (. files)
|
||||
* files can be "turned off" so that only directories are displayed
|
||||
* A textual filesystem menu is provided which allows you to
|
||||
create/delete/move file and directory nodes as well as copy (for
|
||||
supported OSs)
|
||||
* The position and size of the NERD tree window can be customised
|
||||
* The order in which the nodes in the tree are listed can be customised.
|
||||
* A model of your filesystem is created/maintained as you explore it. This
|
||||
@@ -87,6 +86,12 @@ The following features and functionality are provided by the NERD tree:
|
||||
* By default the script overrides the default file browser (netw), so if
|
||||
you :edit a directory a (slighly modified) NERD tree will appear in the
|
||||
current window
|
||||
* A programmable menu system is provided (simulates right clicking on a
|
||||
node)
|
||||
* one default menu plugin is provided to perform basic filesytem
|
||||
operations (create/delete/move/copy files/directories)
|
||||
* There's an API for adding your own keymappings
|
||||
|
||||
|
||||
==============================================================================
|
||||
2. Functionality provided *NERDTreeFunctionality*
|
||||
@@ -123,6 +128,11 @@ The following features and functionality are provided by the NERD tree:
|
||||
:NERDTreeClose *:NERDTreeClose*
|
||||
Close the NERD tree in this tab.
|
||||
|
||||
:NERDTreeFind *:NERDTreeFind*
|
||||
Find the current file in the tree. If no tree exists for the current tab,
|
||||
or the file is not under the current root, then initialize a new tree where
|
||||
the root is the directory of the current file.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2. Bookmarks *NERDTreeBookmarks*
|
||||
|
||||
@@ -205,7 +215,6 @@ i.......Open selected file in a split window.....................|NERDTree-i|
|
||||
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
|
||||
s.......Open selected file in a new vsplit.......................|NERDTree-s|
|
||||
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
|
||||
!.......Execute the current file.................................|NERDTree-!|
|
||||
O.......Recursively open the selected directory..................|NERDTree-O|
|
||||
x.......Close the current nodes parent...........................|NERDTree-x|
|
||||
X.......Recursively close all children of the current node.......|NERDTree-X|
|
||||
@@ -230,7 +239,7 @@ u.......Move the tree root up one directory......................|NERDTree-u|
|
||||
U.......Same as 'u' except the old root node is left open........|NERDTree-U|
|
||||
r.......Recursively refresh the current directory................|NERDTree-r|
|
||||
R.......Recursively refresh the current root.....................|NERDTree-R|
|
||||
m.......Display the filesystem menu..............................|NERDTree-m|
|
||||
m.......Display the NERD tree menu...............................|NERDTree-m|
|
||||
cd......Change the CWD to the dir of the selected node...........|NERDTree-cd|
|
||||
|
||||
I.......Toggle whether hidden files displayed....................|NERDTree-I|
|
||||
@@ -239,6 +248,7 @@ F.......Toggle whether files are displayed.......................|NERDTree-F|
|
||||
B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
|
||||
|
||||
q.......Close the NERDTree window................................|NERDTree-q|
|
||||
A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A|
|
||||
?.......Toggle the display of the quick help.....................|NERDTree-?|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@@ -331,14 +341,6 @@ The same as |NERDTree-s| except that the cursor is not moved.
|
||||
The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see
|
||||
|NERDTree-s|).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-!*
|
||||
Default key: !
|
||||
Map option: NERDTreeMapExecute
|
||||
Applies to: files.
|
||||
|
||||
Executes the selected file, prompting for arguments first.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-O*
|
||||
Default key: O
|
||||
@@ -493,10 +495,10 @@ Recursively refresh the tree root.
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-m*
|
||||
Default key: m
|
||||
Map option: NERDTreeMapFilesystemMenu
|
||||
Map option: NERDTreeMapMenu
|
||||
Applies to: files and directories.
|
||||
|
||||
Display the filesystem menu. See |NERDTreeFilesysMenu| for details.
|
||||
Display the NERD tree menu. See |NERDTreeMenu| for details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-cd*
|
||||
@@ -546,6 +548,14 @@ Applies to: no restrictions.
|
||||
|
||||
Closes the NERDtree window.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-A*
|
||||
Default key: A
|
||||
Map option: NERDTreeMapToggleZoom
|
||||
Applies to: no restrictions.
|
||||
|
||||
Maximize (zoom) and minimize the NERDtree window.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTree-?*
|
||||
Default key: ?
|
||||
@@ -555,44 +565,18 @@ Applies to: no restrictions.
|
||||
Toggles whether the quickhelp is displayed.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3. The filesystem menu *NERDTreeFilesysMenu*
|
||||
2.3. The NERD tree menu *NERDTreeMenu*
|
||||
|
||||
The purpose of the filesystem menu is to allow you to perform basic filesystem
|
||||
operations quickly from the NERD tree rather than the console.
|
||||
The NERD tree has a menu that can be programmed via the an API (see
|
||||
|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most
|
||||
file explorers have.
|
||||
|
||||
The filesystem menu can be accessed with 'm' mapping and has four supported
|
||||
operations: >
|
||||
1. Adding nodes.
|
||||
2. Move nodes.
|
||||
3. Deleting nodes.
|
||||
3. Copying nodes.
|
||||
<
|
||||
1. Adding nodes:
|
||||
To add a node move the cursor onto (or anywhere inside) the directory you wish
|
||||
to create the new node inside. Select the 'add node' option from the
|
||||
filesystem menu and type a filename. If the filename you type ends with a '/'
|
||||
character then a directory will be created. Once the operation is completed,
|
||||
the cursor is placed on the new node.
|
||||
The script comes with two default menu plugins: exec_menuitem.vim and
|
||||
fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for
|
||||
creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a
|
||||
menu item to execute executable files.
|
||||
|
||||
2. Move nodes:
|
||||
To move/rename a node, put the cursor on it and select the 'move' option from
|
||||
the filesystem menu. Enter the new location for the node and it will be
|
||||
moved. If the old file is open in a buffer, you will be asked if you wish to
|
||||
delete that buffer. Once the operation is complete the cursor will be placed
|
||||
on the renamed node.
|
||||
|
||||
3. Deleting nodes:
|
||||
To delete a node put the cursor on it and select the 'delete' option from the
|
||||
filesystem menu. After confirmation the node will be deleted. If a file is
|
||||
deleted but still exists as a buffer you will be given the option to delete
|
||||
that buffer.
|
||||
|
||||
4. Copying nodes:
|
||||
To copy a node put the cursor on it and select the 'copy' option from the
|
||||
filesystem menu. Enter the new location and you're done. Note: copying is
|
||||
currently only supported for *nix operating systems. If someone knows a
|
||||
one line copying command for windows that doesnt require user confirmation
|
||||
then id be grateful if you'd email me.
|
||||
Related tags: |NERDTree-m| |NERDTreeApi|
|
||||
|
||||
==============================================================================
|
||||
3. Customisation *NERDTreeOptions*
|
||||
@@ -824,7 +808,7 @@ Values: 0 or 1.
|
||||
Default: 0
|
||||
|
||||
If set to 1, the NERD tree window will close after opening a file with the
|
||||
|NERDTree-o| or |NERDTree-i| mappings.
|
||||
|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeShowBookmarks'*
|
||||
@@ -938,43 +922,142 @@ Default: 31.
|
||||
This option is used to change the size of the NERD tree when it is loaded.
|
||||
|
||||
==============================================================================
|
||||
4. Hacking the NERD tree *NERDTreeHacking*
|
||||
4. The NERD tree API *NERDTreeAPI*
|
||||
|
||||
Public functions ~
|
||||
The NERD tree script allows you to add custom key mappings and menu items via
|
||||
a set of API calls. Any scripts that use this API should be placed in
|
||||
~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows).
|
||||
|
||||
The script provides 2 public functions for your hacking pleasure. Their
|
||||
signatures are: >
|
||||
function! NERDTreeGetCurrentNode()
|
||||
function! NERDTreeGetCurrentPath()
|
||||
The script exposes some prototype objects that can be used to manipulate the
|
||||
tree and/or get information from it: >
|
||||
g:NERDTreePath
|
||||
g:NERDTreeDirNode
|
||||
g:NERDTreeFileNode
|
||||
g:NERDTreeBookmark
|
||||
<
|
||||
The first returns the node object that the cursor is currently on, while the
|
||||
second returns the corresponding path object.
|
||||
See the code/comments in NERD_tree.vim to find how to use these objects. The
|
||||
following code conventions are used:
|
||||
* class members start with a capital letter
|
||||
* instance members start with a lower case letter
|
||||
* private members start with an underscore
|
||||
|
||||
This is probably a good time to mention that the script implements prototype
|
||||
style OO. To see the functions that each class provides you can read look at
|
||||
the code.
|
||||
See this blog post for more details:
|
||||
http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
|
||||
|
||||
Use the node objects to manipulate the structure of the tree. Use the path
|
||||
objects to access the files/directories the tree nodes represent.
|
||||
------------------------------------------------------------------------------
|
||||
4.1. Key map API *NERDTreeKeymapAPI*
|
||||
|
||||
The NERD tree filetype ~
|
||||
NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
||||
Adds a new keymapping for all NERD tree buffers.
|
||||
{options} must be a dictionary, and must contain the following keys:
|
||||
"key" - the trigger key for the new mapping
|
||||
"callback" - the function the new mapping will be bound to
|
||||
"quickhelpText" - the text that will appear in the quickhelp (see
|
||||
|NERDTree-?|)
|
||||
|
||||
NERD tree buffers have a filetype of "nerdtree". You can use this to hack the
|
||||
NERD tree via autocommands (on |FileType|) or via an ftplugin.
|
||||
Example: >
|
||||
call NERDTreeAddKeyMap({
|
||||
\ 'key': 'b',
|
||||
\ 'callback': 'NERDTreeEchoCurrentNode',
|
||||
\ 'quickhelpText': 'echo full path of current node' })
|
||||
|
||||
For example, putting this code in ~/.vim/ftplugin/nerdtree.vim would override
|
||||
the o mapping, making it open the selected node in a new gvim instance. >
|
||||
|
||||
nnoremap <silent> <buffer> o :call <sid>openInNewVimInstance()<cr>
|
||||
function! s:openInNewVimInstance()
|
||||
let p = NERDTreeGetCurrentPath()
|
||||
if p != {}
|
||||
silent exec "!gvim " . p.strForOS(1) . "&"
|
||||
endif
|
||||
endfunction
|
||||
function! NERDTreeEchoCurrentNode()
|
||||
let n = g:NERDTreeFileNode.GetSelected()
|
||||
if n != {}
|
||||
echomsg 'Current node: ' . n.path.str()
|
||||
endif
|
||||
endfunction
|
||||
<
|
||||
This way you can add new mappings or :commands or override any existing
|
||||
mapping.
|
||||
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
|
||||
It adds a (rather useless) mapping on 'b' which echos the full path to the
|
||||
current node.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
4.2. Menu API *NERDTreeMenuAPI*
|
||||
|
||||
NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()*
|
||||
Creates and returns a new submenu.
|
||||
|
||||
{options} must be a dictionary and must contain the following keys:
|
||||
"text" - the text of the submenu that the user will see
|
||||
"shortcut" - a shortcut key for the submenu (need not be unique)
|
||||
|
||||
The following keys are optional:
|
||||
"isActiveCallback" - a function that will be called to determine whether
|
||||
this submenu item will be displayed or not. The callback function must return
|
||||
0 or 1.
|
||||
"parent" - the parent submenu of the new submenu (returned from a previous
|
||||
invocation of NERDTreeAddSubmenu()). If this key is left out then the new
|
||||
submenu will sit under the top level menu.
|
||||
|
||||
See below for an example.
|
||||
|
||||
NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()*
|
||||
Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|).
|
||||
|
||||
{options} must be a dictionary and must contain the
|
||||
following keys:
|
||||
"text" - the text of the menu item which the user will see
|
||||
"shortcut" - a shortcut key for the menu item (need not be unique)
|
||||
"callback" - the function that will be called when the user activates the
|
||||
menu item.
|
||||
|
||||
The following keys are optional:
|
||||
"isActiveCallback" - a function that will be called to determine whether
|
||||
this menu item will be displayed or not. The callback function must return
|
||||
0 or 1.
|
||||
"parent" - if the menu item belongs under a submenu then this key must be
|
||||
specified. This value for this key will be the object that
|
||||
was returned when the submenu was created with |NERDTreeAddSubmenu()|.
|
||||
|
||||
See below for an example.
|
||||
|
||||
NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()*
|
||||
Adds a menu separator (a row of dashes).
|
||||
|
||||
{options} is an optional dictionary that may contain the following keys:
|
||||
"isActiveCallback" - see description in |NERDTreeAddMenuItem()|.
|
||||
|
||||
Below is an example of the menu API in action. >
|
||||
call NERDTreeAddMenuSeparator()
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': 'a (t)op level menu item',
|
||||
\ 'shortcut': 't',
|
||||
\ 'callback': 'SomeFunction' })
|
||||
|
||||
let submenu = NERDTreeAddSubmenu({
|
||||
\ 'text': 'a (s)ub menu',
|
||||
\ 'shortcut': 's' })
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(n)ested item 1',
|
||||
\ 'shortcut': 'n',
|
||||
\ 'callback': 'SomeFunction',
|
||||
\ 'parent': submenu })
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(n)ested item 2',
|
||||
\ 'shortcut': 'n',
|
||||
\ 'callback': 'SomeFunction',
|
||||
\ 'parent': submenu })
|
||||
<
|
||||
This will create the following menu: >
|
||||
--------------------
|
||||
a (t)op level menu item
|
||||
a (s)ub menu
|
||||
<
|
||||
Where selecting "a (s)ub menu" will lead to a second menu: >
|
||||
(n)ested item 1
|
||||
(n)ested item 2
|
||||
<
|
||||
When any of the 3 concrete menu items are selected the function "SomeFunction"
|
||||
will be called.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
NERDTreeRender() *NERDTreeRender()*
|
||||
Re-renders the NERD tree buffer. Useful if you change the state of the
|
||||
tree and you want to it to be reflected in the UI.
|
||||
|
||||
==============================================================================
|
||||
5. About *NERDTreeAbout*
|
||||
@@ -982,10 +1065,10 @@ mapping.
|
||||
The author of the NERD tree is a terrible terrible monster called Martyzilla
|
||||
who gobbles up small children with milk and sugar for breakfast.
|
||||
|
||||
He can be reached at martin_grenfell at msn.com. He would love to hear from
|
||||
you, so feel free to send him suggestions and/or comments about this plugin.
|
||||
Don't be shy --- the worst he can do is slaughter you and stuff you in the
|
||||
fridge for later ;)
|
||||
He can be reached at martin.grenfell at gmail dot com. He would love to hear
|
||||
from you, so feel free to send him suggestions and/or comments about this
|
||||
plugin. Don't be shy --- the worst he can do is slaughter you and stuff you in
|
||||
the fridge for later ;)
|
||||
|
||||
The latest stable versions can be found at
|
||||
http://www.vim.org/scripts/script.php?script_id=1658
|
||||
@@ -997,6 +1080,39 @@ The latest dev versions are on github
|
||||
==============================================================================
|
||||
6. Changelog *NERDTreeChangelog*
|
||||
|
||||
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.
|
||||
|
||||
bugfixes:
|
||||
- really fix window state restoring
|
||||
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
|
||||
jfilip1024, and Chris Chambers
|
||||
|
||||
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 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
|
||||
@@ -1087,6 +1203,17 @@ just downloaded pr0n instead.
|
||||
Frederic Chanal (nach)
|
||||
Alf Mikula
|
||||
Lucas S. Buchala
|
||||
Curtis Harvey
|
||||
Guillaume Duranceau
|
||||
Richard Hart (hates)
|
||||
Doug McInnes
|
||||
Stefan Ritter
|
||||
Rémi Prévost
|
||||
Victor Gonzalez
|
||||
Stephan Baumeister
|
||||
Ricky
|
||||
jfilip1024
|
||||
Chris Chambers
|
||||
|
||||
==============================================================================
|
||||
8. License *NERDTreeLicense*
|
||||
|
||||
41
nerdtree_plugin/exec_menuitem.vim
Normal file
41
nerdtree_plugin/exec_menuitem.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
" ============================================================================
|
||||
" File: exec_menuitem.vim
|
||||
" Description: plugin for NERD Tree that provides an execute file menu item
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 22 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_exec_menuitem")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_exec_menuitem = 1
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(!)Execute file',
|
||||
\ 'shortcut': '!',
|
||||
\ 'callback': 'NERDTreeExecFile',
|
||||
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
|
||||
|
||||
function! NERDTreeExecFileActive()
|
||||
let node = g:NERDTreeFileNode.GetSelected()
|
||||
return !node.path.isDirectory && node.path.isExecutable
|
||||
endfunction
|
||||
|
||||
function! NERDTreeExecFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
echo "==========================================================\n"
|
||||
echo "Complete the command to execute (add arguments etc):\n"
|
||||
let cmd = treenode.path.str({'escape': 1})
|
||||
let cmd = input(':!', cmd . ' ')
|
||||
|
||||
if cmd != ''
|
||||
exec ':!' . cmd
|
||||
else
|
||||
echo "Aborted"
|
||||
endif
|
||||
endfunction
|
||||
194
nerdtree_plugin/fs_menu.vim
Normal file
194
nerdtree_plugin/fs_menu.vim
Normal file
@@ -0,0 +1,194 @@
|
||||
" ============================================================================
|
||||
" File: fs_menu.vim
|
||||
" Description: plugin for the NERD Tree that provides a file system menu
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 17 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_fs_menu")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_fs_menu = 1
|
||||
|
||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
if g:NERDTreePath.CopyingSupported()
|
||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||
endif
|
||||
|
||||
"FUNCTION: s:echo(msg){{{1
|
||||
function! s:echo(msg)
|
||||
redraw
|
||||
echomsg "NERDTree: " . a:msg
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:echoWarning(msg){{{1
|
||||
function! s:echoWarning(msg)
|
||||
echohl warningmsg
|
||||
call s:echo(a:msg)
|
||||
echohl normal
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
|
||||
"prints out the given msg and, if the user responds by pushing 'y' then the
|
||||
"buffer with the given bufnum is deleted
|
||||
"
|
||||
"Args:
|
||||
"bufnum: the buffer that may be deleted
|
||||
"msg: a message that will be echoed to the user asking them if they wish to
|
||||
" del the buffer
|
||||
function! s:promptToDelBuffer(bufnum, msg)
|
||||
echo a:msg
|
||||
if nr2char(getchar()) ==# 'y'
|
||||
exec "silent bdelete! " . a:bufnum
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeAddNode(){{{1
|
||||
function! NERDTreeAddNode()
|
||||
let curDirNode = g:NERDTreeDirNode.GetSelected()
|
||||
|
||||
let newNodeName = input("Add a childnode\n".
|
||||
\ "==========================================================\n".
|
||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||
\ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash())
|
||||
|
||||
if newNodeName ==# ''
|
||||
call s:echo("Node Creation Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let newPath = g:NERDTreePath.Create(newNodeName)
|
||||
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath)
|
||||
if parentNode.isOpen || !empty(parentNode.children)
|
||||
call parentNode.addChild(newTreeNode, 1)
|
||||
call NERDTreeRender()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Created.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeMoveNode(){{{1
|
||||
function! NERDTreeMoveNode()
|
||||
let curNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Rename the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path for the node: \n" .
|
||||
\ "", curNode.path.str())
|
||||
|
||||
if newNodePath ==# ''
|
||||
call s:echo("Node Renaming Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.str())
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Renamed.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeDeleteNode() {{{1
|
||||
function! NERDTreeDeleteNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let confirmed = 0
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
let choice =input("Delete the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
||||
\ "" . currentNode.path.str() . ": ")
|
||||
let confirmed = choice ==# 'yes'
|
||||
else
|
||||
echo "Delete the current node\n" .
|
||||
\ "==========================================================\n".
|
||||
\ "Are you sure you wish to delete the node:\n" .
|
||||
\ "" . currentNode.path.str() . " (yN):"
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
|
||||
if confirmed
|
||||
try
|
||||
call currentNode.delete()
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
let bufnum = bufnr(currentNode.path.str())
|
||||
if buflisted(bufnum)
|
||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not remove node")
|
||||
endtry
|
||||
else
|
||||
call s:echo("delete aborted")
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||
function! NERDTreeCopyNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Copy the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path to copy the node to: \n" .
|
||||
\ "", currentNode.path.str())
|
||||
|
||||
if newNodePath != ""
|
||||
"strip trailing slash
|
||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
||||
|
||||
let confirmed = 1
|
||||
if currentNode.path.copyingWillOverwrite(newNodePath)
|
||||
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
call NERDTreeRender()
|
||||
call newNode.putCursorHere(0, 0)
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not copy node")
|
||||
endtry
|
||||
endif
|
||||
else
|
||||
call s:echo("Copy aborted.")
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
1358
plugin/NERD_tree.vim
1358
plugin/NERD_tree.vim
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user