mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
205367ab3f | ||
|
|
4bd0def6fb | ||
|
|
4411344f7c | ||
|
|
7ff9def95b | ||
|
|
b3b394c329 | ||
|
|
4dd1bc9ef6 | ||
|
|
1b4dfc8745 | ||
|
|
0747198ee3 | ||
|
|
23d1746bbf | ||
|
|
aa28ae7863 | ||
|
|
02f1d828d9 | ||
|
|
b528910e7a | ||
|
|
dcccd0e532 | ||
|
|
af833e3006 | ||
|
|
82c93a6448 | ||
|
|
49b88757b0 | ||
|
|
30f6bcc30c | ||
|
|
796a40b5d7 | ||
|
|
1c568a4916 | ||
|
|
12f692f436 | ||
|
|
9b5851c36c | ||
|
|
077e330b64 | ||
|
|
86364c2150 | ||
|
|
2dd198c6c4 | ||
|
|
c08d7e9f19 | ||
|
|
5bd641834d | ||
|
|
2fbd578a77 | ||
|
|
04aa45fcd8 | ||
|
|
71d6c1d3c6 | ||
|
|
063e4d0870 | ||
|
|
70ba0d60ec | ||
|
|
1cd50482d2 | ||
|
|
bf73470723 | ||
|
|
2e072fe0e2 | ||
|
|
7f5a8c3aac | ||
|
|
f621df68ae | ||
|
|
6a6ffe2ad6 | ||
|
|
1dd345c56d | ||
|
|
bc0c64ef82 | ||
|
|
702a88956b | ||
|
|
fad6f06ace | ||
|
|
e697444f29 | ||
|
|
d595605ff1 | ||
|
|
b9e970d934 | ||
|
|
999ba49857 | ||
|
|
21bd141866 | ||
|
|
e88f436302 | ||
|
|
2d17132f48 | ||
|
|
8accb0978e | ||
|
|
867de91643 | ||
|
|
1de3c22a44 | ||
|
|
eac32148a4 | ||
|
|
37bfae0d2f | ||
|
|
2504666a72 | ||
|
|
9e415dcc6d | ||
|
|
e4efdb3bd4 | ||
|
|
721ad3ecc2 | ||
|
|
8618929e9a | ||
|
|
b3df8fb1e6 | ||
|
|
492f491056 | ||
|
|
7650cdc662 | ||
|
|
a72cb80337 | ||
|
|
e1abd4d373 | ||
|
|
37859888b5 | ||
|
|
88aaba22b5 | ||
|
|
a997ab3341 |
89
README.markdown
Normal file
89
README.markdown
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
The NERD Tree
|
||||||
|
=============
|
||||||
|
|
||||||
|
Intro
|
||||||
|
-----
|
||||||
|
|
||||||
|
The NERD tree allows you to explore your filesystem and to open files and
|
||||||
|
directories. It presents the filesystem to you in the form of a tree which you
|
||||||
|
manipulate with the keyboard and/or mouse. It also allows you to perform
|
||||||
|
simple filesystem operations.
|
||||||
|
|
||||||
|
The following features and functionality are provided by the NERD tree:
|
||||||
|
|
||||||
|
* Files and directories are displayed in a hierarchical tree structure
|
||||||
|
* Different highlighting is provided for the following types of nodes:
|
||||||
|
* files
|
||||||
|
* directories
|
||||||
|
* sym-links
|
||||||
|
* windows .lnk files
|
||||||
|
* read-only files
|
||||||
|
* executable files
|
||||||
|
* Many (customisable) mappings are provided to manipulate the tree:
|
||||||
|
* Mappings to open/close/explore directory nodes
|
||||||
|
* Mappings to open files in new/existing windows/tabs
|
||||||
|
* Mappings to change the current root of the tree
|
||||||
|
* Mappings to navigate around the tree
|
||||||
|
* ...
|
||||||
|
* Directories and files can be bookmarked.
|
||||||
|
* Most NERD tree navigation can also be done with the mouse
|
||||||
|
* Filtering of tree content (can be toggled at runtime)
|
||||||
|
* 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
|
||||||
|
* 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
|
||||||
|
has several advantages:
|
||||||
|
* All filesystem information is cached and is only re-read on demand
|
||||||
|
* If you revisit a part of the tree that you left earlier in your
|
||||||
|
session, the directory nodes will be opened/closed as you left them
|
||||||
|
* The script remembers the cursor position and window position in the NERD
|
||||||
|
tree so you can toggle it off (or just close the tree window) and then
|
||||||
|
reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
|
||||||
|
as you left it
|
||||||
|
* You can have a separate NERD tree for each tab, share trees across tabs,
|
||||||
|
or a mix of both.
|
||||||
|
* 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
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree.
|
||||||
|
|
||||||
|
cd ~/.vim/bundle
|
||||||
|
git clone https://github.com/scrooloose/nerdtree.git
|
||||||
|
|
||||||
|
Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`.
|
||||||
|
|
||||||
|
|
||||||
|
Faq
|
||||||
|
---
|
||||||
|
|
||||||
|
Q. Can I have the nerdtree on every tab automatically?
|
||||||
|
|
||||||
|
A. Nope. If this is something you want then chances are you aren't using tabs
|
||||||
|
and buffers as they were intended to be used. Read this
|
||||||
|
http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
|
||||||
|
|
||||||
|
If you are interested in this behavour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
4.2.0 (2011-12-28)
|
||||||
|
|
||||||
|
* Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill)
|
||||||
|
* shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas)
|
||||||
|
* Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson)
|
||||||
|
* tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger)
|
||||||
|
* if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung)
|
||||||
|
* use 'file' completion when doing copying, create, and move operations (EvanDotPro)
|
||||||
|
* lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
|
||||||
|
|
||||||
75
Rakefile
75
Rakefile
@@ -1,75 +0,0 @@
|
|||||||
# written by travis jeffery <travisjeffery@gmail.com>
|
|
||||||
# contributions by scrooloose <github:scrooloose>
|
|
||||||
|
|
||||||
require 'rake'
|
|
||||||
require 'find'
|
|
||||||
require 'pathname'
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
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']
|
|
||||||
@@ -129,9 +129,13 @@ The following features and functionality are provided by the NERD tree:
|
|||||||
Close the NERD tree in this tab.
|
Close the NERD tree in this tab.
|
||||||
|
|
||||||
:NERDTreeFind *:NERDTreeFind*
|
:NERDTreeFind *:NERDTreeFind*
|
||||||
Find the current file in the tree. If no tree exists for the current tab,
|
Find the current file in the tree.
|
||||||
or the file is not under the current root, then initialize a new tree where
|
|
||||||
the root is the directory of the current file.
|
If not tree exists and the current file is under vim's CWD, then init a
|
||||||
|
tree at the CWD and reveal the file. Otherwise init a tree in the current
|
||||||
|
file's directory.
|
||||||
|
|
||||||
|
In any case, the current file is revealed and the cursor is placed on it.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2. Bookmarks *NERDTreeBookmarks*
|
2.2. Bookmarks *NERDTreeBookmarks*
|
||||||
@@ -155,6 +159,8 @@ Note that the following commands are only available in the NERD tree buffer.
|
|||||||
:Bookmark <name>
|
:Bookmark <name>
|
||||||
Bookmark the current node as <name>. If there is already a <name>
|
Bookmark the current node as <name>. If there is already a <name>
|
||||||
bookmark, it is overwritten. <name> must not contain spaces.
|
bookmark, it is overwritten. <name> must not contain spaces.
|
||||||
|
If <name> is not provided, it defaults to the file or directory name.
|
||||||
|
For directories, a trailing slash is present.
|
||||||
|
|
||||||
:BookmarkToRoot <bookmark>
|
:BookmarkToRoot <bookmark>
|
||||||
Make the directory corresponding to <bookmark> the new root. If a treenode
|
Make the directory corresponding to <bookmark> the new root. If a treenode
|
||||||
@@ -642,6 +648,12 @@ NERD tree. These options should be set in your vimrc.
|
|||||||
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
||||||
opened.
|
opened.
|
||||||
|
|
||||||
|
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
|
||||||
|
'Press ? for help' text.
|
||||||
|
|
||||||
|
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||||
|
+ ~ chars when displaying directories.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2. Customisation details *NERDTreeOptionDetails*
|
3.2. Customisation details *NERDTreeOptionDetails*
|
||||||
|
|
||||||
@@ -921,6 +933,30 @@ Default: 31.
|
|||||||
|
|
||||||
This option is used to change the size of the NERD tree when it is loaded.
|
This option is used to change the size of the NERD tree when it is loaded.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'NERDTreeMinimalUI'*
|
||||||
|
Values: 0 or 1
|
||||||
|
Default: 0
|
||||||
|
|
||||||
|
This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
|
||||||
|
of the following lines to set this option: >
|
||||||
|
let NERDTreeMinimalUI=0
|
||||||
|
let NERDTreeMinimalUI=1
|
||||||
|
<
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'NERDTreeDirArrows'*
|
||||||
|
Values: 0 or 1
|
||||||
|
Default: 0.
|
||||||
|
|
||||||
|
This option is used to change the default look of directory nodes displayed in
|
||||||
|
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
|
||||||
|
1 it shows right and down arrows. Use one of the follow lines to set this
|
||||||
|
option: >
|
||||||
|
let NERDTreeDirArrows=0
|
||||||
|
let NERDTreeDirArrows=1
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. The NERD tree API *NERDTreeAPI*
|
4. The NERD tree API *NERDTreeAPI*
|
||||||
|
|
||||||
@@ -1080,6 +1116,23 @@ The latest dev versions are on github
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
6. Changelog *NERDTreeChangelog*
|
6. Changelog *NERDTreeChangelog*
|
||||||
|
|
||||||
|
4.2.0
|
||||||
|
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
|
||||||
|
instead of the old +~| chars to define the tree structure (sickill)
|
||||||
|
- shift the syntax highlighting out into its own syntax file (gnap)
|
||||||
|
- add some mac specific options to the filesystem menu - for macvim
|
||||||
|
only (andersonfreitas)
|
||||||
|
- Add NERDTreeMinimalUI option to remove some non functional parts of the
|
||||||
|
nerdtree ui (camthompson)
|
||||||
|
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
|
||||||
|
new behaviour (benjamingeiger)
|
||||||
|
- if no name is given to :Bookmark, make it default to the name of the
|
||||||
|
target file/dir (minyoung)
|
||||||
|
- use 'file' completion when doing copying, create, and move
|
||||||
|
operations (EvanDotPro)
|
||||||
|
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
|
||||||
|
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
|
||||||
|
|
||||||
4.1.0
|
4.1.0
|
||||||
features:
|
features:
|
||||||
- NERDTreeFind to reveal the node for the current buffer in the tree,
|
- NERDTreeFind to reveal the node for the current buffer in the tree,
|
||||||
@@ -1214,6 +1267,22 @@ just downloaded pr0n instead.
|
|||||||
Ricky
|
Ricky
|
||||||
jfilip1024
|
jfilip1024
|
||||||
Chris Chambers
|
Chris Chambers
|
||||||
|
Vitaly Bogdanov
|
||||||
|
Patrick O'Loughlin (paddyoloughlin)
|
||||||
|
Cam Thompson (camthompson)
|
||||||
|
Marcin Kulik (sickill)
|
||||||
|
Steve DeWald (sdewald)
|
||||||
|
Ivan Necas (iNecas)
|
||||||
|
George Ang (gnap)
|
||||||
|
Evan Coury (EvanDotPro)
|
||||||
|
Andrew Radev (AndrewRadev)
|
||||||
|
Matt Gauger (mathias)
|
||||||
|
Scott Stevenson (scottstvnsn)
|
||||||
|
Anderson Freitas (andersonfreitas)
|
||||||
|
Kamil K. Lemański (kml)
|
||||||
|
Yehuda Katz (wycats)
|
||||||
|
Min-Young Wu (minyoung)
|
||||||
|
Benjamin Geiger (benjamingeiger)
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. License *NERDTreeLicense*
|
8. License *NERDTreeLicense*
|
||||||
|
|||||||
@@ -16,8 +16,15 @@ endif
|
|||||||
let g:loaded_nerdtree_fs_menu = 1
|
let g:loaded_nerdtree_fs_menu = 1
|
||||||
|
|
||||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
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': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||||
call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||||
|
|
||||||
|
if has("gui_mac") || has("gui_macvim")
|
||||||
|
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
|
||||||
|
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
|
||||||
|
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
|
||||||
|
endif
|
||||||
|
|
||||||
if g:NERDTreePath.CopyingSupported()
|
if g:NERDTreePath.CopyingSupported()
|
||||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||||
endif
|
endif
|
||||||
@@ -57,7 +64,7 @@ function! NERDTreeAddNode()
|
|||||||
let newNodeName = input("Add a childnode\n".
|
let newNodeName = input("Add a childnode\n".
|
||||||
\ "==========================================================\n".
|
\ "==========================================================\n".
|
||||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||||
\ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash())
|
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
|
||||||
|
|
||||||
if newNodeName ==# ''
|
if newNodeName ==# ''
|
||||||
call s:echo("Node Creation Aborted.")
|
call s:echo("Node Creation Aborted.")
|
||||||
@@ -85,7 +92,7 @@ function! NERDTreeMoveNode()
|
|||||||
let newNodePath = input("Rename the current node\n" .
|
let newNodePath = input("Rename the current node\n" .
|
||||||
\ "==========================================================\n" .
|
\ "==========================================================\n" .
|
||||||
\ "Enter the new path for the node: \n" .
|
\ "Enter the new path for the node: \n" .
|
||||||
\ "", curNode.path.str())
|
\ "", curNode.path.str(), "file")
|
||||||
|
|
||||||
if newNodePath ==# ''
|
if newNodePath ==# ''
|
||||||
call s:echo("Node Renaming Aborted.")
|
call s:echo("Node Renaming Aborted.")
|
||||||
@@ -163,7 +170,7 @@ function! NERDTreeCopyNode()
|
|||||||
let newNodePath = input("Copy the current node\n" .
|
let newNodePath = input("Copy the current node\n" .
|
||||||
\ "==========================================================\n" .
|
\ "==========================================================\n" .
|
||||||
\ "Enter the new path to copy the node to: \n" .
|
\ "Enter the new path to copy the node to: \n" .
|
||||||
\ "", currentNode.path.str())
|
\ "", currentNode.path.str(), "file")
|
||||||
|
|
||||||
if newNodePath != ""
|
if newNodePath != ""
|
||||||
"strip trailing slash
|
"strip trailing slash
|
||||||
@@ -179,8 +186,10 @@ function! NERDTreeCopyNode()
|
|||||||
if confirmed
|
if confirmed
|
||||||
try
|
try
|
||||||
let newNode = currentNode.copy(newNodePath)
|
let newNode = currentNode.copy(newNodePath)
|
||||||
call NERDTreeRender()
|
if !empty(newNode)
|
||||||
call newNode.putCursorHere(0, 0)
|
call NERDTreeRender()
|
||||||
|
call newNode.putCursorHere(0, 0)
|
||||||
|
endif
|
||||||
catch /^NERDTree/
|
catch /^NERDTree/
|
||||||
call s:echoWarning("Could not copy node")
|
call s:echoWarning("Could not copy node")
|
||||||
endtry
|
endtry
|
||||||
@@ -191,4 +200,25 @@ function! NERDTreeCopyNode()
|
|||||||
redraw
|
redraw
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! NERDTreeQuickLook()
|
||||||
|
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||||
|
if treenode != {}
|
||||||
|
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! NERDTreeRevealInFinder()
|
||||||
|
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||||
|
if treenode != {}
|
||||||
|
let x = system("open -R '" . treenode.path.str() . "'")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! NERDTreeExecuteFile()
|
||||||
|
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||||
|
if treenode != {}
|
||||||
|
let x = system("open '" . treenode.path.str() . "'")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
" File: NERD_tree.vim
|
" File: NERD_tree.vim
|
||||||
" Description: vim global plugin that provides a nice tree explorer
|
" Description: vim global plugin that provides a nice tree explorer
|
||||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||||
" Last Change: 1 December, 2009
|
" Last Change: 28 December, 2011
|
||||||
" License: This program is free software. It comes without any warranty,
|
" License: This program is free software. It comes without any warranty,
|
||||||
" to the extent permitted by applicable law. You can redistribute
|
" 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
|
" it and/or modify it under the terms of the Do What The Fuck You
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
"
|
"
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
let s:NERD_tree_version = '4.1.0'
|
let s:NERD_tree_version = '4.2.0'
|
||||||
|
|
||||||
" SECTION: Script init stuff {{{1
|
" SECTION: Script init stuff {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -27,6 +27,8 @@ let loaded_nerd_tree = 1
|
|||||||
let s:old_cpo = &cpo
|
let s:old_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
let s:running_windows = has("win16") || has("win32") || has("win64")
|
||||||
|
|
||||||
"Function: s:initVariable() function {{{2
|
"Function: s:initVariable() function {{{2
|
||||||
"This function is used to initialise a given variable to a given value. The
|
"This function is used to initialise a given variable to a given value. The
|
||||||
"variable is only initialised if it does not exist prior
|
"variable is only initialised if it does not exist prior
|
||||||
@@ -39,7 +41,7 @@ set cpo&vim
|
|||||||
"1 if the var is set, 0 otherwise
|
"1 if the var is set, 0 otherwise
|
||||||
function! s:initVariable(var, value)
|
function! s:initVariable(var, value)
|
||||||
if !exists(a:var)
|
if !exists(a:var)
|
||||||
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
|
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@@ -51,6 +53,7 @@ call s:initVariable("g:NERDTreeAutoCenter", 1)
|
|||||||
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
||||||
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||||
call s:initVariable("g:NERDTreeChDirMode", 0)
|
call s:initVariable("g:NERDTreeChDirMode", 0)
|
||||||
|
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
||||||
if !exists("g:NERDTreeIgnore")
|
if !exists("g:NERDTreeIgnore")
|
||||||
let g:NERDTreeIgnore = ['\~$']
|
let g:NERDTreeIgnore = ['\~$']
|
||||||
endif
|
endif
|
||||||
@@ -65,6 +68,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1)
|
|||||||
call s:initVariable("g:NERDTreeShowHidden", 0)
|
call s:initVariable("g:NERDTreeShowHidden", 0)
|
||||||
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
|
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
|
||||||
call s:initVariable("g:NERDTreeSortDirs", 1)
|
call s:initVariable("g:NERDTreeSortDirs", 1)
|
||||||
|
call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
|
||||||
|
|
||||||
if !exists("g:NERDTreeSortOrder")
|
if !exists("g:NERDTreeSortOrder")
|
||||||
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||||
@@ -90,8 +94,6 @@ endif
|
|||||||
call s:initVariable("g:NERDTreeWinPos", "left")
|
call s:initVariable("g:NERDTreeWinPos", "left")
|
||||||
call s:initVariable("g:NERDTreeWinSize", 31)
|
call s:initVariable("g:NERDTreeWinSize", 31)
|
||||||
|
|
||||||
let s:running_windows = has("win16") || has("win32") || has("win64")
|
|
||||||
|
|
||||||
"init the shell commands that will be used to copy nodes, and remove dir trees
|
"init the shell commands that will be used to copy nodes, and remove dir trees
|
||||||
"
|
"
|
||||||
"Note: the space after the command is important
|
"Note: the space after the command is important
|
||||||
@@ -142,12 +144,12 @@ call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
|
|||||||
if s:running_windows
|
if s:running_windows
|
||||||
let s:escape_chars = " `\|\"#%&,?()\*^<>"
|
let s:escape_chars = " `\|\"#%&,?()\*^<>"
|
||||||
else
|
else
|
||||||
let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
|
let s:escape_chars = " \\`\|\"#%&,?()\*^<>[]"
|
||||||
endif
|
endif
|
||||||
let s:NERDTreeBufName = 'NERD_tree_'
|
let s:NERDTreeBufName = 'NERD_tree_'
|
||||||
|
|
||||||
let s:tree_wid = 2
|
let s:tree_wid = 2
|
||||||
let s:tree_markup_reg = '^[ `|]*[\-+~]'
|
let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]\+'
|
||||||
let s:tree_up_dir_line = '.. (up a dir)'
|
let s:tree_up_dir_line = '.. (up a dir)'
|
||||||
|
|
||||||
"the number to add to the nerd tree buffer name to make the buf name unique
|
"the number to add to the nerd tree buffer name to make the buf name unique
|
||||||
@@ -167,6 +169,10 @@ command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
|
|||||||
augroup NERDTree
|
augroup NERDTree
|
||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call <SID>saveScreenState()"
|
exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call <SID>saveScreenState()"
|
||||||
|
|
||||||
|
"disallow insert mode in the NERDTree
|
||||||
|
exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert"
|
||||||
|
|
||||||
"cache bookmarks when vim loads
|
"cache bookmarks when vim loads
|
||||||
autocmd VimEnter * call s:Bookmark.CacheBookmarks(0)
|
autocmd VimEnter * call s:Bookmark.CacheBookmarks(0)
|
||||||
|
|
||||||
@@ -194,6 +200,7 @@ function! s:Bookmark.activate()
|
|||||||
if self.validate()
|
if self.validate()
|
||||||
let n = s:TreeFileNode.New(self.path)
|
let n = s:TreeFileNode.New(self.path)
|
||||||
call n.open()
|
call n.open()
|
||||||
|
call s:closeTreeIfQuitOnOpen()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -372,7 +379,7 @@ endfunction
|
|||||||
" FUNCTION: Bookmark.New(name, path) {{{3
|
" FUNCTION: Bookmark.New(name, path) {{{3
|
||||||
" Create a new bookmark object with the given name and path object
|
" Create a new bookmark object with the given name and path object
|
||||||
function! s:Bookmark.New(name, path)
|
function! s:Bookmark.New(name, path)
|
||||||
if a:name =~ ' '
|
if a:name =~# ' '
|
||||||
throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
|
throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -389,7 +396,7 @@ function! s:Bookmark.openInNewTab(options)
|
|||||||
tabnew
|
tabnew
|
||||||
call s:initNerdTree(self.name)
|
call s:initNerdTree(self.name)
|
||||||
else
|
else
|
||||||
exec "tabedit " . bookmark.path.str({'format': 'Edit'})
|
exec "tabedit " . self.path.str({'format': 'Edit'})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(a:options, 'stayInCurrentTab')
|
if has_key(a:options, 'stayInCurrentTab')
|
||||||
@@ -558,7 +565,7 @@ function! s:MenuController._echoPrompt()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._current(key) {{{3
|
"FUNCTION: MenuController._current(key) {{{3
|
||||||
"get the MenuItem that is curently selected
|
"get the MenuItem that is currently selected
|
||||||
function! s:MenuController._current()
|
function! s:MenuController._current()
|
||||||
return self.menuItems[self.selection]
|
return self.menuItems[self.selection]
|
||||||
endfunction
|
endfunction
|
||||||
@@ -806,15 +813,23 @@ endfunction
|
|||||||
"FUNCTION: TreeFileNode.bookmark(name) {{{3
|
"FUNCTION: TreeFileNode.bookmark(name) {{{3
|
||||||
"bookmark this node with a:name
|
"bookmark this node with a:name
|
||||||
function! s:TreeFileNode.bookmark(name)
|
function! s:TreeFileNode.bookmark(name)
|
||||||
|
|
||||||
|
"if a bookmark exists with the same name and the node is cached then save
|
||||||
|
"it so we can update its display string
|
||||||
|
let oldMarkedNode = {}
|
||||||
try
|
try
|
||||||
let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1)
|
let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1)
|
||||||
call oldMarkedNode.path.cacheDisplayString()
|
|
||||||
catch /^NERDTree.BookmarkNotFoundError/
|
catch /^NERDTree.BookmarkNotFoundError/
|
||||||
|
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
call s:Bookmark.AddBookmark(a:name, self.path)
|
call s:Bookmark.AddBookmark(a:name, self.path)
|
||||||
call self.path.cacheDisplayString()
|
call self.path.cacheDisplayString()
|
||||||
call s:Bookmark.Write()
|
call s:Bookmark.Write()
|
||||||
|
|
||||||
|
if !empty(oldMarkedNode)
|
||||||
|
call oldMarkedNode.path.cacheDisplayString()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.cacheParent() {{{3
|
"FUNCTION: TreeFileNode.cacheParent() {{{3
|
||||||
"initializes self.parent if it isnt already
|
"initializes self.parent if it isnt already
|
||||||
@@ -855,8 +870,10 @@ function! s:TreeFileNode.copy(dest)
|
|||||||
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
|
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||||
if !empty(parent)
|
if !empty(parent)
|
||||||
call parent.refresh()
|
call parent.refresh()
|
||||||
|
return parent.findNode(newPath)
|
||||||
|
else
|
||||||
|
return {}
|
||||||
endif
|
endif
|
||||||
return parent.findNode(newPath)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.delete {{{3
|
"FUNCTION: TreeFileNode.delete {{{3
|
||||||
@@ -1028,7 +1045,7 @@ endfunction
|
|||||||
"gets the line number of the root node
|
"gets the line number of the root node
|
||||||
function! s:TreeFileNode.GetRootLineNum()
|
function! s:TreeFileNode.GetRootLineNum()
|
||||||
let rootLine = 1
|
let rootLine = 1
|
||||||
while getline(rootLine) !~ '^\(/\|<\)'
|
while getline(rootLine) !~# '^\(/\|<\)'
|
||||||
let rootLine = rootLine + 1
|
let rootLine = rootLine + 1
|
||||||
endwhile
|
endwhile
|
||||||
return rootLine
|
return rootLine
|
||||||
@@ -1304,33 +1321,50 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
|||||||
"get all the leading spaces and vertical tree parts for this line
|
"get all the leading spaces and vertical tree parts for this line
|
||||||
if a:depth > 1
|
if a:depth > 1
|
||||||
for j in a:vertMap[0:-2]
|
for j in a:vertMap[0:-2]
|
||||||
if j ==# 1
|
if g:NERDTreeDirArrows
|
||||||
let treeParts = treeParts . '| '
|
|
||||||
else
|
|
||||||
let treeParts = treeParts . ' '
|
let treeParts = treeParts . ' '
|
||||||
|
else
|
||||||
|
if j ==# 1
|
||||||
|
let treeParts = treeParts . '| '
|
||||||
|
else
|
||||||
|
let treeParts = treeParts . ' '
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"get the last vertical tree part for this line which will be different
|
"get the last vertical tree part for this line which will be different
|
||||||
"if this node is the last child of its parent
|
"if this node is the last child of its parent
|
||||||
if a:isLastChild
|
if !g:NERDTreeDirArrows
|
||||||
let treeParts = treeParts . '`'
|
if a:isLastChild
|
||||||
else
|
let treeParts = treeParts . '`'
|
||||||
let treeParts = treeParts . '|'
|
else
|
||||||
|
let treeParts = treeParts . '|'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
"smack the appropriate dir/file symbol on the line before the file/dir
|
"smack the appropriate dir/file symbol on the line before the file/dir
|
||||||
"name itself
|
"name itself
|
||||||
if self.path.isDirectory
|
if self.path.isDirectory
|
||||||
if self.isOpen
|
if self.isOpen
|
||||||
let treeParts = treeParts . '~'
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . '▾ '
|
||||||
|
else
|
||||||
|
let treeParts = treeParts . '~'
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . '+'
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . '▸ '
|
||||||
|
else
|
||||||
|
let treeParts = treeParts . '+'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let treeParts = treeParts . '-'
|
if g:NERDTreeDirArrows
|
||||||
|
let treeParts = treeParts . ' '
|
||||||
|
else
|
||||||
|
let treeParts = treeParts . '-'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
let line = treeParts . self.displayString()
|
let line = treeParts . self.displayString()
|
||||||
|
|
||||||
@@ -1593,7 +1627,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
"filter out the .. and . directories
|
"filter out the .. and . directories
|
||||||
"Note: we must match .. AND ../ cos sometimes the globpath returns
|
"Note: we must match .. AND ../ cos sometimes the globpath returns
|
||||||
"../ for path with strange chars (eg $)
|
"../ for path with strange chars (eg $)
|
||||||
if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
|
if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
|
||||||
|
|
||||||
"put the next file in a new node and attach it
|
"put the next file in a new node and attach it
|
||||||
try
|
try
|
||||||
@@ -1730,7 +1764,7 @@ function! s:TreeDirNode.refresh()
|
|||||||
"filter out the .. and . directories
|
"filter out the .. and . directories
|
||||||
"Note: we must match .. AND ../ cos sometimes the globpath returns
|
"Note: we must match .. AND ../ cos sometimes the globpath returns
|
||||||
"../ for path with strange chars (eg $)
|
"../ for path with strange chars (eg $)
|
||||||
if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
|
if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
|
||||||
|
|
||||||
try
|
try
|
||||||
"create a new path and see if it exists in this nodes children
|
"create a new path and see if it exists in this nodes children
|
||||||
@@ -1852,9 +1886,9 @@ let s:Path = {}
|
|||||||
function! s:Path.AbsolutePathFor(str)
|
function! s:Path.AbsolutePathFor(str)
|
||||||
let prependCWD = 0
|
let prependCWD = 0
|
||||||
if s:running_windows
|
if s:running_windows
|
||||||
let prependCWD = a:str !~ '^.:\(\\\|\/\)'
|
let prependCWD = a:str !~# '^.:\(\\\|\/\)'
|
||||||
else
|
else
|
||||||
let prependCWD = a:str !~ '^/'
|
let prependCWD = a:str !~# '^/'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let toReturn = a:str
|
let toReturn = a:str
|
||||||
@@ -1971,7 +2005,7 @@ function! s:Path.Create(fullpath)
|
|||||||
try
|
try
|
||||||
|
|
||||||
"if it ends with a slash, assume its a dir create it
|
"if it ends with a slash, assume its a dir create it
|
||||||
if a:fullpath =~ '\(\\\|\/\)$'
|
if a:fullpath =~# '\(\\\|\/\)$'
|
||||||
"whack the trailing slash off the end if it exists
|
"whack the trailing slash off the end if it exists
|
||||||
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
|
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
|
||||||
|
|
||||||
@@ -2001,7 +2035,7 @@ function! s:Path.copy(dest)
|
|||||||
|
|
||||||
let dest = s:Path.WinToUnixPath(a:dest)
|
let dest = s:Path.WinToUnixPath(a:dest)
|
||||||
|
|
||||||
let cmd = g:NERDTreeCopyCmd . " " . self.str() . " " . dest
|
let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), s:escape_chars) . " " . escape(dest, s:escape_chars)
|
||||||
let success = system(cmd)
|
let success = system(cmd)
|
||||||
if success != 0
|
if success != 0
|
||||||
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
|
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
|
||||||
@@ -2144,7 +2178,7 @@ endfunction
|
|||||||
function! s:Path.getSortOrderIndex()
|
function! s:Path.getSortOrderIndex()
|
||||||
let i = 0
|
let i = 0
|
||||||
while i < len(g:NERDTreeSortOrder)
|
while i < len(g:NERDTreeSortOrder)
|
||||||
if self.getLastPathComponent(1) =~ g:NERDTreeSortOrder[i]
|
if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
|
||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
let i = i + 1
|
let i = i + 1
|
||||||
@@ -2160,14 +2194,14 @@ function! s:Path.ignore()
|
|||||||
"filter out the user specified paths to ignore
|
"filter out the user specified paths to ignore
|
||||||
if b:NERDTreeIgnoreEnabled
|
if b:NERDTreeIgnoreEnabled
|
||||||
for i in g:NERDTreeIgnore
|
for i in g:NERDTreeIgnore
|
||||||
if lastPathComponent =~ i
|
if lastPathComponent =~# i
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"dont show hidden files unless instructed to
|
"dont show hidden files unless instructed to
|
||||||
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~ '^\.'
|
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~# '^\.'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2257,7 +2291,7 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
|
|
||||||
let self.isExecutable = 0
|
let self.isExecutable = 0
|
||||||
if !self.isDirectory
|
if !self.isDirectory
|
||||||
let self.isExecutable = getfperm(a:fullpath) =~ 'x'
|
let self.isExecutable = getfperm(a:fullpath) =~# 'x'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"grab the last part of the path (minus the trailing slash)
|
"grab the last part of the path (minus the trailing slash)
|
||||||
@@ -2276,7 +2310,7 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
|
|
||||||
"we always wanna treat MS windows shortcuts as files for
|
"we always wanna treat MS windows shortcuts as files for
|
||||||
"simplicity
|
"simplicity
|
||||||
if hardPath !~ '\.lnk$'
|
if hardPath !~# '\.lnk$'
|
||||||
|
|
||||||
let self.symLinkDest = self.symLinkDest . '/'
|
let self.symLinkDest = self.symLinkDest . '/'
|
||||||
endif
|
endif
|
||||||
@@ -2508,7 +2542,7 @@ endfunction
|
|||||||
" FUNCTION: s:completeBookmarks(A,L,P) {{{2
|
" FUNCTION: s:completeBookmarks(A,L,P) {{{2
|
||||||
" completion function for the bookmark commands
|
" completion function for the bookmark commands
|
||||||
function! s:completeBookmarks(A,L,P)
|
function! s:completeBookmarks(A,L,P)
|
||||||
return filter(s:Bookmark.BookmarkNames(), 'v:val =~ "^' . a:A . '"')
|
return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:exec(cmd) {{{2
|
" FUNCTION: s:exec(cmd) {{{2
|
||||||
" same as :exec cmd but eventignore=all is set for the duration
|
" same as :exec cmd but eventignore=all is set for the duration
|
||||||
@@ -2521,14 +2555,25 @@ endfunction
|
|||||||
" FUNCTION: s:findAndRevealPath() {{{2
|
" FUNCTION: s:findAndRevealPath() {{{2
|
||||||
function! s:findAndRevealPath()
|
function! s:findAndRevealPath()
|
||||||
try
|
try
|
||||||
let p = s:Path.New(expand("%"))
|
let p = s:Path.New(expand("%:p"))
|
||||||
catch /^NERDTree.InvalidArgumentsError/
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
call s:echo("no file for the current buffer")
|
call s:echo("no file for the current buffer")
|
||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
if !s:treeExistsForTab()
|
if !s:treeExistsForTab()
|
||||||
call s:initNerdTree(p.getParent().str())
|
try
|
||||||
|
let cwd = s:Path.New(getcwd())
|
||||||
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
|
call s:echo("current directory does not exist.")
|
||||||
|
let cwd = p.getParent()
|
||||||
|
endtry
|
||||||
|
|
||||||
|
if p.isUnder(cwd)
|
||||||
|
call s:initNerdTree(cwd.str())
|
||||||
|
else
|
||||||
|
call s:initNerdTree(p.getParent().str())
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
if !p.isUnder(s:TreeFileNode.GetRootForTab().path)
|
if !p.isUnder(s:TreeFileNode.GetRootForTab().path)
|
||||||
call s:initNerdTree(p.getParent().str())
|
call s:initNerdTree(p.getParent().str())
|
||||||
@@ -2555,7 +2600,7 @@ function! s:initNerdTree(name)
|
|||||||
let dir = a:name ==# '' ? getcwd() : a:name
|
let dir = a:name ==# '' ? getcwd() : a:name
|
||||||
|
|
||||||
"hack to get an absolute path if a relative path is given
|
"hack to get an absolute path if a relative path is given
|
||||||
if dir =~ '^\.'
|
if dir =~# '^\.'
|
||||||
let dir = getcwd() . s:Path.Slash() . dir
|
let dir = getcwd() . s:Path.Slash() . dir
|
||||||
endif
|
endif
|
||||||
let dir = resolve(dir)
|
let dir = resolve(dir)
|
||||||
@@ -2624,43 +2669,9 @@ function! s:initNerdTreeInPlace(dir)
|
|||||||
let b:NERDTreeRoot = s:TreeDirNode.New(path)
|
let b:NERDTreeRoot = s:TreeDirNode.New(path)
|
||||||
call b:NERDTreeRoot.open()
|
call b:NERDTreeRoot.open()
|
||||||
|
|
||||||
"throwaway buffer options
|
call s:setCommonBufOptions()
|
||||||
setlocal noswapfile
|
|
||||||
setlocal buftype=nofile
|
|
||||||
setlocal bufhidden=hide
|
|
||||||
setlocal nowrap
|
|
||||||
setlocal foldcolumn=0
|
|
||||||
setlocal nobuflisted
|
|
||||||
setlocal nospell
|
|
||||||
if g:NERDTreeShowLineNumbers
|
|
||||||
setlocal nu
|
|
||||||
else
|
|
||||||
setlocal nonu
|
|
||||||
endif
|
|
||||||
|
|
||||||
iabc <buffer>
|
|
||||||
|
|
||||||
if g:NERDTreeHighlightCursorline
|
|
||||||
setlocal cursorline
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:setupStatusline()
|
|
||||||
|
|
||||||
let b:treeShowHelp = 0
|
|
||||||
let b:NERDTreeIgnoreEnabled = 1
|
|
||||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
|
||||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
|
||||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
|
||||||
|
|
||||||
let b:NERDTreeType = "secondary"
|
let b:NERDTreeType = "secondary"
|
||||||
|
|
||||||
call s:bindMappings()
|
|
||||||
setfiletype nerdtree
|
|
||||||
" syntax highlighting
|
|
||||||
if has("syntax") && exists("g:syntax_on")
|
|
||||||
call s:setupSyntaxHighlighting()
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:renderView()
|
call s:renderView()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:initNerdTreeMirror() {{{2
|
" FUNCTION: s:initNerdTreeMirror() {{{2
|
||||||
@@ -2812,9 +2823,17 @@ function! s:closeTree()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if winnr("$") != 1
|
if winnr("$") != 1
|
||||||
|
if winnr() == s:getTreeWinNum()
|
||||||
|
wincmd p
|
||||||
|
let bufnr = bufnr("")
|
||||||
|
wincmd p
|
||||||
|
else
|
||||||
|
let bufnr = bufnr("")
|
||||||
|
endif
|
||||||
|
|
||||||
call s:exec(s:getTreeWinNum() . " wincmd w")
|
call s:exec(s:getTreeWinNum() . " wincmd w")
|
||||||
close
|
close
|
||||||
call s:exec("wincmd p")
|
call s:exec(bufwinnr(bufnr) . " wincmd w")
|
||||||
else
|
else
|
||||||
close
|
close
|
||||||
endif
|
endif
|
||||||
@@ -2852,34 +2871,7 @@ function! s:createTreeWin()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal winfixwidth
|
setlocal winfixwidth
|
||||||
|
call s:setCommonBufOptions()
|
||||||
"throwaway buffer options
|
|
||||||
setlocal noswapfile
|
|
||||||
setlocal buftype=nofile
|
|
||||||
setlocal nowrap
|
|
||||||
setlocal foldcolumn=0
|
|
||||||
setlocal nobuflisted
|
|
||||||
setlocal nospell
|
|
||||||
if g:NERDTreeShowLineNumbers
|
|
||||||
setlocal nu
|
|
||||||
else
|
|
||||||
setlocal nonu
|
|
||||||
endif
|
|
||||||
|
|
||||||
iabc <buffer>
|
|
||||||
|
|
||||||
if g:NERDTreeHighlightCursorline
|
|
||||||
setlocal cursorline
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:setupStatusline()
|
|
||||||
|
|
||||||
call s:bindMappings()
|
|
||||||
setfiletype nerdtree
|
|
||||||
" syntax highlighting
|
|
||||||
if has("syntax") && exists("g:syntax_on")
|
|
||||||
call s:setupSyntaxHighlighting()
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:dumpHelp {{{2
|
"FUNCTION: s:dumpHelp {{{2
|
||||||
@@ -2979,12 +2971,12 @@ function! s:dumpHelp()
|
|||||||
let @h=@h."\" :OpenBookmark <name>\n"
|
let @h=@h."\" :OpenBookmark <name>\n"
|
||||||
let @h=@h."\" :ClearBookmarks [<names>]\n"
|
let @h=@h."\" :ClearBookmarks [<names>]\n"
|
||||||
let @h=@h."\" :ClearAllBookmarks\n"
|
let @h=@h."\" :ClearAllBookmarks\n"
|
||||||
else
|
silent! put h
|
||||||
|
elseif g:NERDTreeMinimalUI == 0
|
||||||
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
||||||
|
silent! put h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
silent! put h
|
|
||||||
|
|
||||||
let @h = old_h
|
let @h = old_h
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:echo {{{2
|
"FUNCTION: s:echo {{{2
|
||||||
@@ -3050,9 +3042,11 @@ function! s:getPath(ln)
|
|||||||
return b:NERDTreeRoot.path
|
return b:NERDTreeRoot.path
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" in case called from outside the tree
|
if !g:NERDTreeDirArrows
|
||||||
if line !~ '^ *[|`]' || line =~ '^$'
|
" in case called from outside the tree
|
||||||
return {}
|
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if line ==# s:tree_up_dir_line
|
if line ==# s:tree_up_dir_line
|
||||||
@@ -3065,7 +3059,7 @@ function! s:getPath(ln)
|
|||||||
let curFile = s:stripMarkupFromLine(line, 0)
|
let curFile = s:stripMarkupFromLine(line, 0)
|
||||||
|
|
||||||
let wasdir = 0
|
let wasdir = 0
|
||||||
if curFile =~ '/$'
|
if curFile =~# '/$'
|
||||||
let wasdir = 1
|
let wasdir = 1
|
||||||
let curFile = substitute(curFile, '/\?$', '/', "")
|
let curFile = substitute(curFile, '/\?$', '/', "")
|
||||||
endif
|
endif
|
||||||
@@ -3082,7 +3076,7 @@ function! s:getPath(ln)
|
|||||||
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
|
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
if curLineStripped =~ '/$'
|
if curLineStripped =~# '/$'
|
||||||
let lpindent = s:indentLevelFor(curLine)
|
let lpindent = s:indentLevelFor(curLine)
|
||||||
if lpindent < indent
|
if lpindent < indent
|
||||||
let indent = indent - 1
|
let indent = indent - 1
|
||||||
@@ -3108,7 +3102,13 @@ function! s:getTreeWinNum()
|
|||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:indentLevelFor(line) {{{2
|
"FUNCTION: s:indentLevelFor(line) {{{2
|
||||||
function! s:indentLevelFor(line)
|
function! s:indentLevelFor(line)
|
||||||
return match(a:line, '[^ \-+~`|]') / s:tree_wid
|
let level = match(a:line, '[^ \-+~▸▾`|]') / s:tree_wid
|
||||||
|
" check if line includes arrows
|
||||||
|
if match(a:line, '[▸▾]') > -1
|
||||||
|
" decrement level as arrow uses 3 ascii chars
|
||||||
|
let level = level - 1
|
||||||
|
endif
|
||||||
|
return level
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:isTreeOpen() {{{2
|
"FUNCTION: s:isTreeOpen() {{{2
|
||||||
function! s:isTreeOpen()
|
function! s:isTreeOpen()
|
||||||
@@ -3198,16 +3198,20 @@ function! s:putCursorOnBookmarkTable()
|
|||||||
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if g:NERDTreeMinimalUI
|
||||||
|
return cursor(1, 2)
|
||||||
|
endif
|
||||||
|
|
||||||
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
|
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
|
||||||
|
|
||||||
let line = 1
|
let line = 1
|
||||||
while getline(line) !~ '^>-\+Bookmarks-\+$'
|
while getline(line) !~# '^>-\+Bookmarks-\+$'
|
||||||
let line = line + 1
|
let line = line + 1
|
||||||
if line >= rootNodeLine
|
if line >= rootNodeLine
|
||||||
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
|
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
call cursor(line, 0)
|
call cursor(line, 2)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:putCursorInTreeWin(){{{2
|
"FUNCTION: s:putCursorInTreeWin(){{{2
|
||||||
@@ -3223,8 +3227,10 @@ endfunction
|
|||||||
"FUNCTION: s:renderBookmarks {{{2
|
"FUNCTION: s:renderBookmarks {{{2
|
||||||
function! s:renderBookmarks()
|
function! s:renderBookmarks()
|
||||||
|
|
||||||
call setline(line(".")+1, ">----------Bookmarks----------")
|
if g:NERDTreeMinimalUI == 0
|
||||||
call cursor(line(".")+1, col("."))
|
call setline(line(".")+1, ">----------Bookmarks----------")
|
||||||
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
for i in s:Bookmark.Bookmarks()
|
for i in s:Bookmark.Bookmarks()
|
||||||
call setline(line(".")+1, i.str())
|
call setline(line(".")+1, i.str())
|
||||||
@@ -3251,16 +3257,20 @@ function! s:renderView()
|
|||||||
call s:dumpHelp()
|
call s:dumpHelp()
|
||||||
|
|
||||||
"delete the blank line before the help and add one after it
|
"delete the blank line before the help and add one after it
|
||||||
call setline(line(".")+1, "")
|
if g:NERDTreeMinimalUI == 0
|
||||||
call cursor(line(".")+1, col("."))
|
call setline(line(".")+1, "")
|
||||||
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
if b:NERDTreeShowBookmarks
|
if b:NERDTreeShowBookmarks
|
||||||
call s:renderBookmarks()
|
call s:renderBookmarks()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"add the 'up a dir' line
|
"add the 'up a dir' line
|
||||||
call setline(line(".")+1, s:tree_up_dir_line)
|
if !g:NERDTreeMinimalUI
|
||||||
call cursor(line(".")+1, col("."))
|
call setline(line(".")+1, s:tree_up_dir_line)
|
||||||
|
call cursor(line(".")+1, col("."))
|
||||||
|
endif
|
||||||
|
|
||||||
"draw the header line
|
"draw the header line
|
||||||
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
|
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
|
||||||
@@ -3340,103 +3350,49 @@ function! s:saveScreenState()
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:setCommonBufOptions() {{{2
|
||||||
|
function! s:setCommonBufOptions()
|
||||||
|
"throwaway buffer options
|
||||||
|
setlocal noswapfile
|
||||||
|
setlocal buftype=nofile
|
||||||
|
setlocal bufhidden=hide
|
||||||
|
setlocal nowrap
|
||||||
|
setlocal foldcolumn=0
|
||||||
|
setlocal nobuflisted
|
||||||
|
setlocal nospell
|
||||||
|
if g:NERDTreeShowLineNumbers
|
||||||
|
setlocal nu
|
||||||
|
else
|
||||||
|
setlocal nonu
|
||||||
|
if v:version >= 703
|
||||||
|
setlocal nornu
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
iabc <buffer>
|
||||||
|
|
||||||
|
if g:NERDTreeHighlightCursorline
|
||||||
|
setlocal cursorline
|
||||||
|
endif
|
||||||
|
|
||||||
|
call s:setupStatusline()
|
||||||
|
|
||||||
|
|
||||||
|
let b:treeShowHelp = 0
|
||||||
|
let b:NERDTreeIgnoreEnabled = 1
|
||||||
|
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||||
|
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||||
|
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||||
|
setfiletype nerdtree
|
||||||
|
call s:bindMappings()
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:setupStatusline() {{{2
|
"FUNCTION: s:setupStatusline() {{{2
|
||||||
function! s:setupStatusline()
|
function! s:setupStatusline()
|
||||||
if g:NERDTreeStatusline != -1
|
if g:NERDTreeStatusline != -1
|
||||||
let &l:statusline = g:NERDTreeStatusline
|
let &l:statusline = g:NERDTreeStatusline
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:setupSyntaxHighlighting() {{{2
|
|
||||||
function! s:setupSyntaxHighlighting()
|
|
||||||
"treeFlags are syntax items that should be invisible, but give clues as to
|
|
||||||
"how things should be highlighted
|
|
||||||
syn match treeFlag #\~#
|
|
||||||
syn match treeFlag #\[RO\]#
|
|
||||||
|
|
||||||
"highlighting for the .. (up dir) line at the top of the tree
|
|
||||||
execute "syn match treeUp #". s:tree_up_dir_line ."#"
|
|
||||||
|
|
||||||
"highlighting for the ~/+ symbols for the directory nodes
|
|
||||||
syn match treeClosable #\~\<#
|
|
||||||
syn match treeClosable #\~\.#
|
|
||||||
syn match treeOpenable #+\<#
|
|
||||||
syn match treeOpenable #+\.#he=e-1
|
|
||||||
|
|
||||||
"highlighting for the tree structural parts
|
|
||||||
syn match treePart #|#
|
|
||||||
syn match treePart #`#
|
|
||||||
syn match treePartFile #[|`]-#hs=s+1 contains=treePart
|
|
||||||
|
|
||||||
"quickhelp syntax elements
|
|
||||||
syn match treeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
|
|
||||||
syn match treeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
|
|
||||||
syn match treeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=treeFlag
|
|
||||||
syn match treeToggleOn #".*(on)#hs=e-2,he=e-1 contains=treeHelpKey
|
|
||||||
syn match treeToggleOff #".*(off)#hs=e-3,he=e-1 contains=treeHelpKey
|
|
||||||
syn match treeHelpCommand #" :.\{-}\>#hs=s+3
|
|
||||||
syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
|
|
||||||
|
|
||||||
"highlighting for readonly files
|
|
||||||
syn match treeRO #.*\[RO\]#hs=s+2 contains=treeFlag,treeBookmark,treePart,treePartFile
|
|
||||||
|
|
||||||
"highlighting for sym links
|
|
||||||
syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash
|
|
||||||
|
|
||||||
"highlighing for directory nodes and file nodes
|
|
||||||
syn match treeDirSlash #/#
|
|
||||||
syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
|
|
||||||
syn match treeExecFile #[|`]-.*\*\($\| \)# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
|
|
||||||
syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile
|
|
||||||
syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile
|
|
||||||
syn match treeCWD #^/.*$#
|
|
||||||
|
|
||||||
"highlighting for bookmarks
|
|
||||||
syn match treeBookmark # {.*}#hs=s+1
|
|
||||||
|
|
||||||
"highlighting for the bookmarks table
|
|
||||||
syn match treeBookmarksLeader #^>#
|
|
||||||
syn match treeBookmarksHeader #^>-\+Bookmarks-\+$# contains=treeBookmarksLeader
|
|
||||||
syn match treeBookmarkName #^>.\{-} #he=e-1 contains=treeBookmarksLeader
|
|
||||||
syn match treeBookmark #^>.*$# contains=treeBookmarksLeader,treeBookmarkName,treeBookmarksHeader
|
|
||||||
|
|
||||||
if g:NERDChristmasTree
|
|
||||||
hi def link treePart Special
|
|
||||||
hi def link treePartFile Type
|
|
||||||
hi def link treeFile Normal
|
|
||||||
hi def link treeExecFile Title
|
|
||||||
hi def link treeDirSlash Identifier
|
|
||||||
hi def link treeClosable Type
|
|
||||||
else
|
|
||||||
hi def link treePart Normal
|
|
||||||
hi def link treePartFile Normal
|
|
||||||
hi def link treeFile Normal
|
|
||||||
hi def link treeClosable Title
|
|
||||||
endif
|
|
||||||
|
|
||||||
hi def link treeBookmarksHeader statement
|
|
||||||
hi def link treeBookmarksLeader ignore
|
|
||||||
hi def link treeBookmarkName Identifier
|
|
||||||
hi def link treeBookmark normal
|
|
||||||
|
|
||||||
hi def link treeHelp String
|
|
||||||
hi def link treeHelpKey Identifier
|
|
||||||
hi def link treeHelpCommand Identifier
|
|
||||||
hi def link treeHelpTitle Macro
|
|
||||||
hi def link treeToggleOn Question
|
|
||||||
hi def link treeToggleOff WarningMsg
|
|
||||||
|
|
||||||
hi def link treeDir Directory
|
|
||||||
hi def link treeUp Directory
|
|
||||||
hi def link treeCWD Statement
|
|
||||||
hi def link treeLink Macro
|
|
||||||
hi def link treeOpenable Title
|
|
||||||
hi def link treeFlag ignore
|
|
||||||
hi def link treeRO WarningMsg
|
|
||||||
hi def link treeBookmark Statement
|
|
||||||
|
|
||||||
hi def link NERDTreeCurrentNode Search
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2
|
"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2
|
||||||
"returns the given line with all the tree parts stripped off
|
"returns the given line with all the tree parts stripped off
|
||||||
"
|
"
|
||||||
@@ -3459,7 +3415,7 @@ function! s:stripMarkupFromLine(line, removeLeadingSpaces)
|
|||||||
let line = substitute (line, '*\ze\($\| \)', "","")
|
let line = substitute (line, '*\ze\($\| \)', "","")
|
||||||
|
|
||||||
let wasdir = 0
|
let wasdir = 0
|
||||||
if line =~ '/$'
|
if line =~# '/$'
|
||||||
let wasdir = 1
|
let wasdir = 1
|
||||||
endif
|
endif
|
||||||
let line = substitute (line,' -> .*',"","") " remove link to
|
let line = substitute (line,' -> .*',"","") " remove link to
|
||||||
@@ -3579,7 +3535,7 @@ function! s:bindMappings()
|
|||||||
"bind all the user custom maps
|
"bind all the user custom maps
|
||||||
call s:KeyMap.BindAll()
|
call s:KeyMap.BindAll()
|
||||||
|
|
||||||
command! -buffer -nargs=1 Bookmark :call <SID>bookmarkNode('<args>')
|
command! -buffer -nargs=? Bookmark :call <SID>bookmarkNode('<args>')
|
||||||
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call <SID>revealBookmark('<args>')
|
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call <SID>revealBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
|
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
|
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
|
||||||
@@ -3591,11 +3547,15 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: s:bookmarkNode(name) {{{2
|
" FUNCTION: s:bookmarkNode(name) {{{2
|
||||||
" Associate the current node with the given name
|
" Associate the current node with the given name
|
||||||
function! s:bookmarkNode(name)
|
function! s:bookmarkNode(...)
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode != {}
|
if currentNode != {}
|
||||||
|
let name = a:1
|
||||||
|
if empty(name)
|
||||||
|
let name = currentNode.path.getLastPathComponent(0)
|
||||||
|
endif
|
||||||
try
|
try
|
||||||
call currentNode.bookmark(a:name)
|
call currentNode.bookmark(name)
|
||||||
call s:renderView()
|
call s:renderView()
|
||||||
catch /^NERDTree.IllegalBookmarkNameError/
|
catch /^NERDTree.IllegalBookmarkNameError/
|
||||||
call s:echo("bookmark names must not contain spaces")
|
call s:echo("bookmark names must not contain spaces")
|
||||||
@@ -3612,19 +3572,17 @@ function! s:checkForActivate()
|
|||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode != {}
|
if currentNode != {}
|
||||||
let startToCur = strpart(getline(line(".")), 0, col("."))
|
let startToCur = strpart(getline(line(".")), 0, col("."))
|
||||||
let char = strpart(startToCur, strlen(startToCur)-1, 1)
|
|
||||||
|
|
||||||
"if they clicked a dir, check if they clicked on the + or ~ sign
|
|
||||||
"beside it
|
|
||||||
if currentNode.path.isDirectory
|
if currentNode.path.isDirectory
|
||||||
if startToCur =~ s:tree_markup_reg . '$' && char =~ '[+~]'
|
if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$'
|
||||||
call s:activateNode(0)
|
call s:activateNode(0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
|
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
|
||||||
if char !~ s:tree_markup_reg && startToCur !~ '\/$'
|
let char = strpart(startToCur, strlen(startToCur)-1, 1)
|
||||||
|
if char !~# s:tree_markup_reg
|
||||||
call s:activateNode(0)
|
call s:activateNode(0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -4024,7 +3982,7 @@ endfunction
|
|||||||
"re-rendered
|
"re-rendered
|
||||||
function! s:upDir(keepState)
|
function! s:upDir(keepState)
|
||||||
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
|
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
|
||||||
if cwd ==# "/" || cwd =~ '^[^/]..$'
|
if cwd ==# "/" || cwd =~# '^[^/]..$'
|
||||||
call s:echo("already at top dir")
|
call s:echo("already at top dir")
|
||||||
else
|
else
|
||||||
if !a:keepState
|
if !a:keepState
|
||||||
|
|||||||
88
syntax/nerdtree.vim
Normal file
88
syntax/nerdtree.vim
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
let s:tree_up_dir_line = '.. (up a dir)'
|
||||||
|
"NERDTreeFlags are syntax items that should be invisible, but give clues as to
|
||||||
|
"how things should be highlighted
|
||||||
|
syn match NERDTreeFlag #\~#
|
||||||
|
syn match NERDTreeFlag #\[RO\]#
|
||||||
|
|
||||||
|
"highlighting for the .. (up dir) line at the top of the tree
|
||||||
|
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
|
||||||
|
|
||||||
|
"highlighting for the ~/+ symbols for the directory nodes
|
||||||
|
syn match NERDTreeClosable #\~\<#
|
||||||
|
syn match NERDTreeClosable #\~\.#
|
||||||
|
syn match NERDTreeOpenable #+\<#
|
||||||
|
syn match NERDTreeOpenable #+\.#he=e-1
|
||||||
|
|
||||||
|
"highlighting for the tree structural parts
|
||||||
|
syn match NERDTreePart #|#
|
||||||
|
syn match NERDTreePart #`#
|
||||||
|
syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
|
||||||
|
|
||||||
|
"quickhelp syntax elements
|
||||||
|
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
|
||||||
|
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
|
||||||
|
syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
|
||||||
|
syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
|
||||||
|
syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
|
||||||
|
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
|
||||||
|
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
|
||||||
|
|
||||||
|
"highlighting for readonly files
|
||||||
|
syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
|
||||||
|
|
||||||
|
"highlighting for sym links
|
||||||
|
syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
|
||||||
|
|
||||||
|
"highlighing for directory nodes and file nodes
|
||||||
|
syn match NERDTreeDirSlash #/#
|
||||||
|
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
|
||||||
|
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
|
||||||
|
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||||
|
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||||
|
syn match NERDTreeCWD #^[</].*$#
|
||||||
|
|
||||||
|
"highlighting for bookmarks
|
||||||
|
syn match NERDTreeBookmark # {.*}#hs=s+1
|
||||||
|
|
||||||
|
"highlighting for the bookmarks table
|
||||||
|
syn match NERDTreeBookmarksLeader #^>#
|
||||||
|
syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
|
||||||
|
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
|
||||||
|
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
|
||||||
|
|
||||||
|
if exists("g:NERDChristmasTree") && g:NERDChristmasTree
|
||||||
|
hi def link NERDTreePart Special
|
||||||
|
hi def link NERDTreePartFile Type
|
||||||
|
hi def link NERDTreeFile Normal
|
||||||
|
hi def link NERDTreeExecFile Title
|
||||||
|
hi def link NERDTreeDirSlash Identifier
|
||||||
|
hi def link NERDTreeClosable Type
|
||||||
|
else
|
||||||
|
hi def link NERDTreePart Normal
|
||||||
|
hi def link NERDTreePartFile Normal
|
||||||
|
hi def link NERDTreeFile Normal
|
||||||
|
hi def link NERDTreeClosable Title
|
||||||
|
endif
|
||||||
|
|
||||||
|
hi def link NERDTreeBookmarksHeader statement
|
||||||
|
hi def link NERDTreeBookmarksLeader ignore
|
||||||
|
hi def link NERDTreeBookmarkName Identifier
|
||||||
|
hi def link NERDTreeBookmark normal
|
||||||
|
|
||||||
|
hi def link NERDTreeHelp String
|
||||||
|
hi def link NERDTreeHelpKey Identifier
|
||||||
|
hi def link NERDTreeHelpCommand Identifier
|
||||||
|
hi def link NERDTreeHelpTitle Macro
|
||||||
|
hi def link NERDTreeToggleOn Question
|
||||||
|
hi def link NERDTreeToggleOff WarningMsg
|
||||||
|
|
||||||
|
hi def link NERDTreeDir Directory
|
||||||
|
hi def link NERDTreeUp Directory
|
||||||
|
hi def link NERDTreeCWD Statement
|
||||||
|
hi def link NERDTreeLink Macro
|
||||||
|
hi def link NERDTreeOpenable Title
|
||||||
|
hi def link NERDTreeFlag ignore
|
||||||
|
hi def link NERDTreeRO WarningMsg
|
||||||
|
hi def link NERDTreeBookmark Statement
|
||||||
|
|
||||||
|
hi def link NERDTreeCurrentNode Search
|
||||||
Reference in New Issue
Block a user