Compare commits

...

66 Commits
4.1.0 ... 4.2.0

Author SHA1 Message Date
Martin Grenfell
205367ab3f update changelog/credits and bump to version 4.2.0 2011-12-28 13:16:57 +00:00
Martin Grenfell
4bd0def6fb add a note about vim-nerdtree-tabs to the readme 2011-12-27 22:53:38 +00:00
Martin Grenfell
4411344f7c update the doc for the new NERDTreeFind behaviour 2011-12-27 22:22:10 +00:00
Martin Grenfell
7ff9def95b fix mixed indenting 2011-12-27 22:18:28 +00:00
Benjamin Geiger
b3b394c329 Open NERDTreeFind tree at CWD if current file is below it. 2011-12-27 22:15:31 +00:00
Martin Grenfell
4dd1bc9ef6 make a minor formatting fix for the readme 2011-12-27 21:53:12 +00:00
Martin Grenfell
1b4dfc8745 add first version of readme 2011-12-24 10:58:57 +00:00
Martin Grenfell
0747198ee3 remove Rakefile - pathogen is now the recommended way to install 2011-12-24 10:58:45 +00:00
Martin Grenfell
23d1746bbf refactor tree window creation to remove duplication
create s:setCommonBufOptions() with the previously duplicated parts of
s:initNerdTreeInPlace() and s:createTreeWin()
2011-12-21 14:43:20 +00:00
Martin Grenfell
aa28ae7863 Merge pull request #87 from scottstvnsn/master
Add nolist to buffer options.
2011-12-21 06:40:49 -08:00
Martin Grenfell
02f1d828d9 Merge pull request #88 from andersonfreitas/master
Added new options in the file system menu
2011-12-21 06:27:25 -08:00
Martin Grenfell
b528910e7a dont add a trailing slash to auto-named bookmarked dirs
this breaks the highlighting of the nerdtree buffer, and seems dodgy
2011-12-21 13:20:09 +00:00
Min-Young Wu
dcccd0e532 Defaulting bookmark name to file/dir name
Note that for directories, there is a trailing slash
2011-12-21 13:15:56 +00:00
Martin Grenfell
af833e3006 remove the now unused s:setupSyntaxHighlighting() 2011-12-21 12:51:32 +00:00
Martin Grenfell
82c93a6448 Merge remote-tracking branch 'gnap/master' 2011-12-21 12:50:05 +00:00
Martin Grenfell
49b88757b0 enable NERDTreeDirArrows by default except on windows 2011-12-15 17:35:18 +00:00
Martin Grenfell
30f6bcc30c Merge pull request #86 from mathias/patch-1
Spelling
2011-10-09 09:34:12 -07:00
Anderson Freitas
796a40b5d7 New options in the file system menu:
- Reveal In Finder
 - Open with system editor
 - Quicklook

Current only when using MacVim under MacOSX
2011-09-06 21:15:44 -03:00
Scott Stevenson
1c568a4916 Add nolist to buffer options. 2011-08-31 12:34:41 +01:00
Martin Grenfell
12f692f436 always disallow insert mode
Remove the NERDTreeStopInsert option and always activate the
functionality. If, later on, it becomes apparent that some people might
not want this functionality then we can re-add the option, but in the
meantime, simplify things by removing the option.
2011-08-30 12:03:49 +01:00
Martin Grenfell
9b5851c36c Merge pull request #84 from kml/master
wycats's "disallow insert mode"

An explanation from vguerci@github:

Insert mode can be entered in nerdtree not sure the exact sequence / reason, but i guess that involve using mouse (sounds weird, a bug?) :

- open nerdtree, select a buffer, enter insert mode in buffer.
- select nerdtree buffer with mouse, you're in insert mode.

...then you can easily get E21, E382 errors.
Not a big deal but that can happen, if you use mouse... (which I don't)
(reproduced this on latests macvim (vim 7.3.260) from terminal (vim) or macvim)
2011-08-30 03:58:05 -07:00
Matt Gauger
077e330b64 Spelling 2011-08-25 13:39:02 -05:00
Kamil K. Lemański
86364c2150 wycats's "disallow insert mode"
3bb112d916
2011-08-05 17:42:41 +03:00
Martin Grenfell
2dd198c6c4 fix for copying files
when copying a file outside the current tree root, {} is returned by
TreeFileNode.copy() so try to reposition the cursor
2011-07-09 18:44:03 +12:00
Martin Grenfell
c08d7e9f19 Merge pull request #79 from AndrewRadev/master
Fix for an error when copying nodes
2011-07-08 23:35:10 -07:00
Andrew Radev
5bd641834d Fix for copying error
When copying a node to a directory that's outside the current path, the
"parent" node doesn't really exist, so the code raised an error.
2011-07-08 22:10:13 +03:00
Martin Grenfell
2fbd578a77 Merge remote-tracking branch 'EvanDotPro/master' 2011-07-06 13:59:57 +12:00
Martin Grenfell
04aa45fcd8 Merge pull request #74 from iNecas/nerd_tree_find_fix
NERDTreeFind fix revert
2011-07-05 03:55:05 -07:00
Evan Coury
71d6c1d3c6 specify 'file' input types to allow for tab-completion of paths when copying, moving, or creating a node 2011-07-04 05:56:39 -07:00
Ivan Necas
063e4d0870 Revert commit 7f5a8caa
Some other changes causted previos commit to break the NERDTreeFind functionality
instead of fixing it. Reverting...
2011-06-25 11:51:21 +02:00
George Ang
70ba0d60ec separate syntax file for better combacibility with plugins that reloads
vimrc files(such as perdirvimrc) after BufRead.
2011-06-18 23:56:31 +08:00
Martin Grenfell
1cd50482d2 Merge pull request #56 from iNecas/nerd_tree_find_fix
NERDTreeFind fix
2011-05-06 03:00:50 -07:00
Martin Grenfell
bf73470723 Merge pull request #50 from sdewald/master
Fix for issue #22 -- "FUNCTION: NERDTreeAddNode() cannot handle paths with spaces"
2011-05-06 02:33:57 -07:00
Martin Grenfell
2e072fe0e2 fix the mouse and NERDTreeDirArrows 2011-04-24 02:13:54 +12:00
Ivan Necas
7f5a8c3aac Fix for getting line of node
Set curPathComponent to 0 correctly identify with indent level of node.
2011-03-20 14:25:41 +01:00
Martin Grenfell
f621df68ae fix a minor bug with syntax highlighting of the root node 2011-03-10 10:43:47 +13:00
Steve DeWald
6a6ffe2ad6 Merge branch 'master' of github.com:scrooloose/nerdtree 2011-03-04 11:24:54 -08:00
Martin Grenfell
1dd345c56d only set relativenumber for vim >= 7.3 2011-03-03 12:18:04 +13:00
Martin Grenfell
bc0c64ef82 fix a bug when the bookmarks are toggled with NERDTreeMinimalUI 2011-03-01 11:28:57 +13:00
Martin Grenfell
702a88956b remove '.. (up a dir)' when NERDTreeMinimalUI is set
Shortening this line doesnt add anything to the UI (functionally
speaking), but removing frees up an extra line. Anyone who sets
NERDTreeMinimalUI probably uses the u/U mappings anyway.
2011-03-01 11:03:05 +13:00
Martin Grenfell
fad6f06ace fix a bug with NERDTreeMinimalUI and syntax highlighting
Use \V for the updir text regex. Otherwise '..' is treated as a regex
rather than 2 literal dots.
2011-03-01 10:56:03 +13:00
Cam Thompson
e697444f29 set nornu when line numbers aren't shown 2011-02-27 21:30:43 -05:00
Cam Thompson
d595605ff1 hide (up a dir) when using minimal ui 2011-02-27 21:18:28 -05:00
Cam Thompson
b9e970d934 Merge branch 'master' of git://github.com/scrooloose/nerdtree
Conflicts:
	doc/NERD_tree.txt
2011-02-27 20:45:22 -05:00
Cam Thompson
999ba49857 merge hide bookmarks and press ? options 2011-02-27 20:36:06 -05:00
Martin Grenfell
21bd141866 fix highlighting of executable files with NERDTreeDirArrows 2011-02-28 10:55:15 +13:00
Cam Thompson
e88f436302 Merge remote-tracking branch 'upstream/master' 2011-02-25 13:16:03 -05:00
Cam Thompson
2d17132f48 add bookmarks and press help documentation 2011-02-25 13:14:49 -05:00
Marcin Kulik
8accb0978e Make tree style (|+~ or arrows) configurable 2011-02-23 18:40:11 +01:00
Marcin Kulik
867de91643 Make indentation of file nodes more intuitive 2011-02-20 20:42:03 +01:00
Steve DeWald
1de3c22a44 Fixed two bugs affecting adding and copying nodes with escaped chars (e.g. spaces) in the filepath 2011-02-20 09:40:34 -08:00
Marcin Kulik
eac32148a4 Use small triangles for directories and get rid of ascii bars 2011-02-19 13:11:30 +01:00
Cam Thompson
37bfae0d2f rename press for help and bmark label options 2011-02-18 00:10:48 -05:00
Martin Grenfell
2504666a72 make it handle dirs of the form '[foo]baz' properly in *nix
previously such dirs always appeared to be empty
2011-02-14 10:20:15 +13:00
Cam Thompson
9e415dcc6d add option to hide bookmarks label 2011-02-08 18:59:38 -05:00
Cam Thompson
e4efdb3bd4 add option to hide 'Press ? for help' 2011-02-08 18:59:38 -05:00
Martin Grenfell
721ad3ecc2 fix a bug when opening a file bookmark in a new tab 2011-02-08 17:44:38 +13:00
Martin Grenfell
8618929e9a fix a couple of typos in the filesystem menu 2011-02-08 17:16:30 +13:00
Martin Grenfell
b3df8fb1e6 make all regex matching case sensitive 2011-02-08 16:53:45 +13:00
Martin Grenfell
492f491056 prefix all highlight groups with NERDTree for namespace reasons 2011-02-08 11:37:28 +13:00
marty
7650cdc662 update credits/changelog 2010-11-20 18:04:39 +13:00
marty
a72cb80337 fix a bug with :NERDTreeFind and symlinks
Previously, if we called NERDTreeFind for a file that was inside a
symlinked dir (when vims CWD was above that dir) then it would get
confused by the symlink and fail. Use :p with expand to get around this.
2010-11-20 18:01:38 +13:00
marty
e1abd4d373 close the tree win when opening bookmarked files for NERDTreeQuitOnOpen 2010-09-18 18:15:30 +12:00
marty
37859888b5 correct the window the cursor jumps to on :NERDTree(Close|Toggle) 2010-09-18 18:12:17 +12:00
paddyoloughlin
88aaba22b5 Escaped "value" parameter to initVariable, so it is a valid literal-string. 2010-07-31 19:30:15 +08:00
marty
a997ab3341 fix a bug with `:Bookmark foo' where foo was an existing bookmark 2010-06-21 21:49:04 +12:00
6 changed files with 465 additions and 306 deletions

89
README.markdown Normal file
View 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!)

View File

@@ -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']

View File

@@ -129,9 +129,13 @@ The following features and functionality are provided by the NERD tree:
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.
Find the current file in the tree.
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*
@@ -155,6 +159,8 @@ Note that the following commands are only available in the NERD tree buffer.
:Bookmark <name>
Bookmark the current node as <name>. If there is already a <name>
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>
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
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*
@@ -921,6 +933,30 @@ Default: 31.
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*
@@ -1080,6 +1116,23 @@ The latest dev versions are on github
==============================================================================
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
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
@@ -1214,6 +1267,22 @@ just downloaded pr0n instead.
Ricky
jfilip1024
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*

View File

@@ -16,8 +16,15 @@ 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'})
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
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()
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
@@ -57,7 +64,7 @@ function! NERDTreeAddNode()
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())
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
@@ -85,7 +92,7 @@ function! NERDTreeMoveNode()
let newNodePath = input("Rename the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path for the node: \n" .
\ "", curNode.path.str())
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
@@ -163,7 +170,7 @@ function! NERDTreeCopyNode()
let newNodePath = input("Copy the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path to copy the node to: \n" .
\ "", currentNode.path.str())
\ "", currentNode.path.str(), "file")
if newNodePath != ""
"strip trailing slash
@@ -179,8 +186,10 @@ function! NERDTreeCopyNode()
if confirmed
try
let newNode = currentNode.copy(newNodePath)
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
if !empty(newNode)
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
endtry
@@ -191,4 +200,25 @@ function! NERDTreeCopyNode()
redraw
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:

View File

@@ -2,7 +2,7 @@
" File: NERD_tree.vim
" Description: vim global plugin that provides a nice tree explorer
" 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,
" 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
@@ -10,7 +10,7 @@
" 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
"============================================================
@@ -27,6 +27,8 @@ let loaded_nerd_tree = 1
let s:old_cpo = &cpo
set cpo&vim
let s:running_windows = has("win16") || has("win32") || has("win64")
"Function: s:initVariable() function {{{2
"This function is used to initialise a given variable to a given value. The
"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
function! s:initVariable(var, value)
if !exists(a:var)
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
return 1
endif
return 0
@@ -51,6 +53,7 @@ call s:initVariable("g:NERDTreeAutoCenter", 1)
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
call s:initVariable("g:NERDTreeChDirMode", 0)
call s:initVariable("g:NERDTreeMinimalUI", 0)
if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$']
endif
@@ -65,6 +68,7 @@ call s:initVariable("g:NERDTreeShowFiles", 1)
call s:initVariable("g:NERDTreeShowHidden", 0)
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
@@ -90,8 +94,6 @@ endif
call s:initVariable("g:NERDTreeWinPos", "left")
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
"
"Note: the space after the command is important
@@ -142,12 +144,12 @@ call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
if s:running_windows
let s:escape_chars = " `\|\"#%&,?()\*^<>"
else
let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
let s:escape_chars = " \\`\|\"#%&,?()\*^<>[]"
endif
let s:NERDTreeBufName = 'NERD_tree_'
let s:tree_wid = 2
let s:tree_markup_reg = '^[ `|]*[\-+~]'
let s:tree_markup_reg = '^[ `|]*[\-+~▾▸ ]\+'
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
@@ -167,6 +169,10 @@ command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
augroup NERDTree
"Save the cursor position whenever we close the nerd tree
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
autocmd VimEnter * call s:Bookmark.CacheBookmarks(0)
@@ -194,6 +200,7 @@ function! s:Bookmark.activate()
if self.validate()
let n = s:TreeFileNode.New(self.path)
call n.open()
call s:closeTreeIfQuitOnOpen()
endif
endif
endfunction
@@ -372,7 +379,7 @@ endfunction
" FUNCTION: Bookmark.New(name, path) {{{3
" Create a new bookmark object with the given name and path object
function! s:Bookmark.New(name, path)
if a:name =~ ' '
if a:name =~# ' '
throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
endif
@@ -389,7 +396,7 @@ function! s:Bookmark.openInNewTab(options)
tabnew
call s:initNerdTree(self.name)
else
exec "tabedit " . bookmark.path.str({'format': 'Edit'})
exec "tabedit " . self.path.str({'format': 'Edit'})
endif
if has_key(a:options, 'stayInCurrentTab')
@@ -558,7 +565,7 @@ function! s:MenuController._echoPrompt()
endfunction
"FUNCTION: MenuController._current(key) {{{3
"get the MenuItem that is curently selected
"get the MenuItem that is currently selected
function! s:MenuController._current()
return self.menuItems[self.selection]
endfunction
@@ -806,15 +813,23 @@ endfunction
"FUNCTION: TreeFileNode.bookmark(name) {{{3
"bookmark this node with a: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
let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1)
call oldMarkedNode.path.cacheDisplayString()
catch /^NERDTree.BookmarkNotFoundError/
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
call s:Bookmark.AddBookmark(a:name, self.path)
call self.path.cacheDisplayString()
call s:Bookmark.Write()
if !empty(oldMarkedNode)
call oldMarkedNode.path.cacheDisplayString()
endif
endfunction
"FUNCTION: TreeFileNode.cacheParent() {{{3
"initializes self.parent if it isnt already
@@ -855,8 +870,10 @@ function! s:TreeFileNode.copy(dest)
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
return parent.findNode(newPath)
else
return {}
endif
return parent.findNode(newPath)
endfunction
"FUNCTION: TreeFileNode.delete {{{3
@@ -1028,7 +1045,7 @@ endfunction
"gets the line number of the root node
function! s:TreeFileNode.GetRootLineNum()
let rootLine = 1
while getline(rootLine) !~ '^\(/\|<\)'
while getline(rootLine) !~# '^\(/\|<\)'
let rootLine = rootLine + 1
endwhile
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
if a:depth > 1
for j in a:vertMap[0:-2]
if j ==# 1
let treeParts = treeParts . '| '
else
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
if j ==# 1
let treeParts = treeParts . '| '
else
let treeParts = treeParts . ' '
endif
endif
endfor
endif
"get the last vertical tree part for this line which will be different
"if this node is the last child of its parent
if a:isLastChild
let treeParts = treeParts . '`'
else
let treeParts = treeParts . '|'
if !g:NERDTreeDirArrows
if a:isLastChild
let treeParts = treeParts . '`'
else
let treeParts = treeParts . '|'
endif
endif
"smack the appropriate dir/file symbol on the line before the file/dir
"name itself
if self.path.isDirectory
if self.isOpen
let treeParts = treeParts . '~'
if g:NERDTreeDirArrows
let treeParts = treeParts . '▾ '
else
let treeParts = treeParts . '~'
endif
else
let treeParts = treeParts . '+'
if g:NERDTreeDirArrows
let treeParts = treeParts . '▸ '
else
let treeParts = treeParts . '+'
endif
endif
else
let treeParts = treeParts . '-'
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
let treeParts = treeParts . '-'
endif
endif
let line = treeParts . self.displayString()
@@ -1593,7 +1627,7 @@ function! s:TreeDirNode._initChildren(silent)
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"../ for path with strange chars (eg $)
if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
"put the next file in a new node and attach it
try
@@ -1730,7 +1764,7 @@ function! s:TreeDirNode.refresh()
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"../ for path with strange chars (eg $)
if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$'
if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
try
"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)
let prependCWD = 0
if s:running_windows
let prependCWD = a:str !~ '^.:\(\\\|\/\)'
let prependCWD = a:str !~# '^.:\(\\\|\/\)'
else
let prependCWD = a:str !~ '^/'
let prependCWD = a:str !~# '^/'
endif
let toReturn = a:str
@@ -1971,7 +2005,7 @@ function! s:Path.Create(fullpath)
try
"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
let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
@@ -2001,7 +2035,7 @@ function! s:Path.copy(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)
if success != 0
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
@@ -2144,7 +2178,7 @@ endfunction
function! s:Path.getSortOrderIndex()
let i = 0
while i < len(g:NERDTreeSortOrder)
if self.getLastPathComponent(1) =~ g:NERDTreeSortOrder[i]
if self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
return i
endif
let i = i + 1
@@ -2160,14 +2194,14 @@ function! s:Path.ignore()
"filter out the user specified paths to ignore
if b:NERDTreeIgnoreEnabled
for i in g:NERDTreeIgnore
if lastPathComponent =~ i
if lastPathComponent =~# i
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~ '^\.'
if b:NERDTreeShowHidden ==# 0 && lastPathComponent =~# '^\.'
return 1
endif
@@ -2257,7 +2291,7 @@ function! s:Path.readInfoFromDisk(fullpath)
let self.isExecutable = 0
if !self.isDirectory
let self.isExecutable = getfperm(a:fullpath) =~ 'x'
let self.isExecutable = getfperm(a:fullpath) =~# 'x'
endif
"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
"simplicity
if hardPath !~ '\.lnk$'
if hardPath !~# '\.lnk$'
let self.symLinkDest = self.symLinkDest . '/'
endif
@@ -2508,7 +2542,7 @@ endfunction
" FUNCTION: s:completeBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
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
" FUNCTION: s:exec(cmd) {{{2
" same as :exec cmd but eventignore=all is set for the duration
@@ -2521,14 +2555,25 @@ endfunction
" FUNCTION: s:findAndRevealPath() {{{2
function! s:findAndRevealPath()
try
let p = s:Path.New(expand("%"))
let p = s:Path.New(expand("%:p"))
catch /^NERDTree.InvalidArgumentsError/
call s:echo("no file for the current buffer")
return
endtry
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
if !p.isUnder(s:TreeFileNode.GetRootForTab().path)
call s:initNerdTree(p.getParent().str())
@@ -2555,7 +2600,7 @@ function! s:initNerdTree(name)
let dir = a:name ==# '' ? getcwd() : a:name
"hack to get an absolute path if a relative path is given
if dir =~ '^\.'
if dir =~# '^\.'
let dir = getcwd() . s:Path.Slash() . dir
endif
let dir = resolve(dir)
@@ -2624,43 +2669,9 @@ function! s:initNerdTreeInPlace(dir)
let b:NERDTreeRoot = s:TreeDirNode.New(path)
call b:NERDTreeRoot.open()
"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
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
call s:setCommonBufOptions()
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()
endfunction
" FUNCTION: s:initNerdTreeMirror() {{{2
@@ -2812,9 +2823,17 @@ function! s:closeTree()
endif
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")
close
call s:exec("wincmd p")
call s:exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
@@ -2852,34 +2871,7 @@ function! s:createTreeWin()
endif
setlocal winfixwidth
"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
call s:setCommonBufOptions()
endfunction
"FUNCTION: s:dumpHelp {{{2
@@ -2979,12 +2971,12 @@ function! s:dumpHelp()
let @h=@h."\" :OpenBookmark <name>\n"
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
else
silent! put h
elseif g:NERDTreeMinimalUI == 0
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
silent! put h
endif
silent! put h
let @h = old_h
endfunction
"FUNCTION: s:echo {{{2
@@ -3050,9 +3042,11 @@ function! s:getPath(ln)
return b:NERDTreeRoot.path
endif
" in case called from outside the tree
if line !~ '^ *[|`]' || line =~ '^$'
return {}
if !g:NERDTreeDirArrows
" in case called from outside the tree
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
return {}
endif
endif
if line ==# s:tree_up_dir_line
@@ -3065,7 +3059,7 @@ function! s:getPath(ln)
let curFile = s:stripMarkupFromLine(line, 0)
let wasdir = 0
if curFile =~ '/$'
if curFile =~# '/$'
let wasdir = 1
let curFile = substitute(curFile, '/\?$', '/', "")
endif
@@ -3082,7 +3076,7 @@ function! s:getPath(ln)
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
break
endif
if curLineStripped =~ '/$'
if curLineStripped =~# '/$'
let lpindent = s:indentLevelFor(curLine)
if lpindent < indent
let indent = indent - 1
@@ -3108,7 +3102,13 @@ function! s:getTreeWinNum()
endfunction
"FUNCTION: s:indentLevelFor(line) {{{2
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
"FUNCTION: s:isTreeOpen() {{{2
function! s:isTreeOpen()
@@ -3198,16 +3198,20 @@ function! s:putCursorOnBookmarkTable()
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif
if g:NERDTreeMinimalUI
return cursor(1, 2)
endif
let rootNodeLine = s:TreeFileNode.GetRootLineNum()
let line = 1
while getline(line) !~ '^>-\+Bookmarks-\+$'
while getline(line) !~# '^>-\+Bookmarks-\+$'
let line = line + 1
if line >= rootNodeLine
throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
endif
endwhile
call cursor(line, 0)
call cursor(line, 2)
endfunction
"FUNCTION: s:putCursorInTreeWin(){{{2
@@ -3223,8 +3227,10 @@ endfunction
"FUNCTION: s:renderBookmarks {{{2
function! s:renderBookmarks()
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
if g:NERDTreeMinimalUI == 0
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
endif
for i in s:Bookmark.Bookmarks()
call setline(line(".")+1, i.str())
@@ -3251,16 +3257,20 @@ function! s:renderView()
call s:dumpHelp()
"delete the blank line before the help and add one after it
call setline(line(".")+1, "")
call cursor(line(".")+1, col("."))
if g:NERDTreeMinimalUI == 0
call setline(line(".")+1, "")
call cursor(line(".")+1, col("."))
endif
if b:NERDTreeShowBookmarks
call s:renderBookmarks()
endif
"add the 'up a dir' line
call setline(line(".")+1, s:tree_up_dir_line)
call cursor(line(".")+1, col("."))
if !g:NERDTreeMinimalUI
call setline(line(".")+1, s:tree_up_dir_line)
call cursor(line(".")+1, col("."))
endif
"draw the header line
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
@@ -3340,103 +3350,49 @@ function! s:saveScreenState()
endtry
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()
if g:NERDTreeStatusline != -1
let &l:statusline = g:NERDTreeStatusline
endif
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
"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 wasdir = 0
if line =~ '/$'
if line =~# '/$'
let wasdir = 1
endif
let line = substitute (line,' -> .*',"","") " remove link to
@@ -3579,7 +3535,7 @@ function! s:bindMappings()
"bind all the user custom maps
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 OpenBookmark :call <SID>openBookmark('<args>')
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
@@ -3591,11 +3547,15 @@ endfunction
" FUNCTION: s:bookmarkNode(name) {{{2
" Associate the current node with the given name
function! s:bookmarkNode(name)
function! s:bookmarkNode(...)
let currentNode = s:TreeFileNode.GetSelected()
if currentNode != {}
let name = a:1
if empty(name)
let name = currentNode.path.getLastPathComponent(0)
endif
try
call currentNode.bookmark(a:name)
call currentNode.bookmark(name)
call s:renderView()
catch /^NERDTree.IllegalBookmarkNameError/
call s:echo("bookmark names must not contain spaces")
@@ -3612,19 +3572,17 @@ function! s:checkForActivate()
let currentNode = s:TreeFileNode.GetSelected()
if currentNode != {}
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 startToCur =~ s:tree_markup_reg . '$' && char =~ '[+~]'
if startToCur =~# s:tree_markup_reg . '$' && startToCur =~# '[+~▾▸]$'
call s:activateNode(0)
return
endif
endif
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)
return
endif
@@ -4024,7 +3982,7 @@ endfunction
"re-rendered
function! s:upDir(keepState)
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
if cwd ==# "/" || cwd =~ '^[^/]..$'
if cwd ==# "/" || cwd =~# '^[^/]..$'
call s:echo("already at top dir")
else
if !a:keepState

88
syntax/nerdtree.vim Normal file
View 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