1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2015-12-08 10:20:04 -03:00
parent 768c72a3ed
commit 3b37bba6cd
239 changed files with 8132 additions and 3198 deletions

View File

@ -0,0 +1,153 @@
Next
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)
- Remove the old style UI - Remove 'NERDTreeDirArrows' option.
- On windows default to + and ~ for expand/collapse directory symbols.
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
5.0.0
- Refactor the code significantly:
* Break the classes out into their own files.
* Make the majority of the code OO - previously large parts were
effectively a tangle of "global" methods.
- Add an API to assign flags to nodes. This allows VCS plugins like
https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to
Xuyuanp for helping design/test/build said API.
- add 'scope' argument to the key map API see :help NERDTreeAddKeyMap()
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
- expand the fs menu functionality to list file properties (PhilRunninger,
apbarrero, JESii)
- make bookmarks work with `~` home shortcuts (hiberabyss)
- show OSX specific fsmenu options in regular vim on mac (evindor)
- make dir arrow icons configurable (PickRelated)
- optimise node sorting performance when opening large dirs (vtsang)
- make the root note render prettier by truncating it at a path slash (gcmt)
- remove NERDChristmasTree option - its always christmas now
- add "cascade" open and closing for dirs containing only another single
dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
Many other fixes, doc updates and contributions from:
actionshrimp
SchDen
egalpin
cperl82 - many small fixes
toiffel
WoLpH
handcraftedbits
devmanhinton
xiaodili
zhangoose
gastropoda
mixvin
alvan
lucascaton
kelaban
shanesmith
staeff
pendulm
stephenprater
franksort
agrussellknives
AndrewRadev
Twinside
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,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring

View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@ -55,7 +55,7 @@ The following features and functionality are provided by the NERD tree:
Installation
------------
[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree.
####[pathogen.vim](https://github.com/tpope/vim-pathogen)
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
@ -63,6 +63,12 @@ Installation
Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
####[apt-vim](https://github.com/egalpin/apt-vim)
apt-vim install -y https://github.com/scrooloose/nerdtree.git
Faq
---
@ -85,11 +91,13 @@ Stick this in your vimrc: `autocmd vimenter * NERDTree`
> How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Note: Now start vim with plain `vim`, not `vim .`
> How can I map a specific key or shortcut to open NERDTree?
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
@ -100,8 +108,15 @@ Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever ke
Stick this in your vimrc:
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
> Can I have different highlighting for different file extensions?
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
> How can I change default arrows?
Use these variables in your vimrc. Note that below are default arrow symbols
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

View File

@ -4,17 +4,17 @@ endif
let g:loaded_nerdtree_autoload = 1
function! nerdtree#version()
return '4.2.0'
return '5.0.0'
endfunction
" SECTION: General Functions {{{1
"============================================================
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a secondary nerd tree in the current buffer if appropriate
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
if a:dir != '' && isdirectory(a:dir)
call g:NERDTreeCreator.CreateSecondary(a:dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endif
endfunction
@ -94,7 +94,7 @@ endfunction
" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
call g:NERDTreeBookmark.CacheBookmarks(0)
call g:NERDTreeBookmark.CacheBookmarks(1)
call nerdtree#ui_glue#createDefaultBindings()
"load all nerdtree plugins

View File

@ -105,7 +105,7 @@ endfunction
"FUNCTION: s:activateBookmark() {{{1
"handle the user activating a bookmark
function! s:activateBookmark(bm)
call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {})
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {})
endfunction
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
@ -140,9 +140,7 @@ endfunction
" FUNCTION: s:chRoot(node) {{{1
" changes the current root to the selected one
function! s:chRoot(node)
call a:node.makeRoot()
call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0)
call b:NERDTree.changeRoot(a:node)
endfunction
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
@ -157,7 +155,7 @@ function! nerdtree#ui_glue#chRootCwd()
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
return
endif
call s:chRoot(g:NERDTreeDirNode.New(cwd))
call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree))
endfunction
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
@ -173,6 +171,7 @@ function! nerdtree#ui_glue#clearBookmarks(bookmarks)
call bookmark.delete()
endfor
endif
call b:NERDTree.root.refresh()
call b:NERDTree.render()
endfunction
@ -208,8 +207,8 @@ endfunction
" FUNCTION: s:closeTreeWindow() {{{1
" close the tree window
function! s:closeTreeWindow()
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
exec "buffer " . b:NERDTreePreviousBuf
if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1
exec "buffer " . b:NERDTree.previousBuf()
else
if winnr("$") > 1
call g:NERDTree.Close()
@ -227,6 +226,7 @@ function! s:deleteBookmark(bm)
if nr2char(getchar()) ==# 'y'
try
call a:bm.delete()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
catch /^NERDTree/
@ -241,7 +241,7 @@ endfunction
" FUNCTION: s:displayHelp() {{{1
" toggles the help display
function! s:displayHelp()
let b:treeShowHelp = b:treeShowHelp ? 0 : 1
call b:NERDTree.ui.toggleHelp()
call b:NERDTree.render()
call b:NERDTree.ui.centerView()
endfunction
@ -269,27 +269,29 @@ function! s:findAndRevealPath()
endtry
if p.isUnder(cwd)
call g:NERDTreeCreator.CreatePrimary(cwd.str())
call g:NERDTreeCreator.CreateTabTree(cwd.str())
else
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
endif
else
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary('')
call g:NERDTreeCreator.ToggleTabTree('')
else
call g:NERDTree.CursorToTreeWin()
endif
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
call b:NERDTree.setShowHidden(g:NERDTreeShowHidden)
call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree))
else
if !g:NERDTree.IsOpen()
call g:NERDTreeCreator.TogglePrimary("")
call g:NERDTreeCreator.ToggleTabTree("")
endif
endif
endif
call g:NERDTree.CursorToTreeWin()
call b:NERDTreeRoot.reveal(p)
let node = b:NERDTree.root.reveal(p)
call b:NERDTree.render()
call node.putCursorHere(1,0)
if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden
@ -312,7 +314,7 @@ function! s:handleLeftClick()
endfor
if currentNode.path.isDirectory
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$'
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$'
call currentNode.activate()
return
endif
@ -409,7 +411,7 @@ endfunction
" FUNCTION: s:jumpToRoot() {{{1
" moves the cursor to the root node
function! s:jumpToRoot()
call b:NERDTreeRoot.putCursorHere(1, 0)
call b:NERDTree.root.putCursorHere(1, 0)
call b:NERDTree.ui.centerView()
endfunction
@ -442,13 +444,13 @@ endfunction
" put the cursor on the given bookmark and, if its a file, open it
function! nerdtree#ui_glue#openBookmark(name)
try
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1)
redraw!
catch /^NERDTree.BookmarkedNodeNotFoundError/
call nerdtree#echo("note - target node is not cached")
let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
let targetNode = g:NERDTreeFileNode.New(bookmark.path)
let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree)
endtry
if targetNode.path.isDirectory
call targetNode.openExplorer()
@ -510,7 +512,7 @@ endfunction
" put the cursor on the node associate with the given name
function! nerdtree#ui_glue#revealBookmark(name)
try
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
call targetNode.putCursorHere(0, 1)
catch /^NERDTree.BookmarkNotFoundError/
call nerdtree#echo("Bookmark isnt cached under the current root")
@ -522,7 +524,7 @@ endfunction
" will be reloaded.
function! s:refreshRoot()
call nerdtree#echo("Refreshing the root node. This could take a while...")
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
@ -545,10 +547,10 @@ endfunction
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
@ -602,28 +604,28 @@ endfunction
"keepState: 1 if the current root should be left open when the tree is
"re-rendered
function! nerdtree#ui_glue#upDir(keepState)
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
let cwd = b:NERDTree.root.path.str({'format': 'UI'})
if cwd ==# "/" || cwd =~# '^[^/]..$'
call nerdtree#echo("already at top dir")
else
if !a:keepState
call b:NERDTreeRoot.close()
call b:NERDTree.root.close()
endif
let oldRoot = b:NERDTreeRoot
let oldRoot = b:NERDTree.root
if empty(b:NERDTreeRoot.parent)
let path = b:NERDTreeRoot.path.getParent()
let newRoot = g:NERDTreeDirNode.New(path)
if empty(b:NERDTree.root.parent)
let path = b:NERDTree.root.path.getParent()
let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree)
call newRoot.open()
call newRoot.transplantChild(b:NERDTreeRoot)
let b:NERDTreeRoot = newRoot
call newRoot.transplantChild(b:NERDTree.root)
let b:NERDTree.root = newRoot
else
let b:NERDTreeRoot = b:NERDTreeRoot.parent
let b:NERDTree.root = b:NERDTree.root.parent
endif
if g:NERDTreeChDirMode ==# 2
call b:NERDTreeRoot.path.changeToDir()
call b:NERDTree.root.path.changeToDir()
endif
call b:NERDTree.render()

View File

@ -37,9 +37,7 @@ CONTENTS *NERDTree-contents*
4.3.Menu API..........................|NERDTreeAddPathFilter()|
4.4.Path Listener API.................|NERDTreePathListenerAPI|
5.About...................................|NERDTreeAbout|
6.Changelog...............................|NERDTreeChangelog|
7.Credits.................................|NERDTreeCredits|
8.License.................................|NERDTreeLicense|
6.License.................................|NERDTreeLicense|
==============================================================================
1. Intro *NERDTree*
@ -673,9 +671,6 @@ NERD tree. These options should be set in your vimrc.
|'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.
|'NERDTreeCascadeOpenSingleChildDir'|
Cascade open while selected directory has only
one child that also is a directory.
@ -778,13 +773,13 @@ Default: 1.
If set to 1, doing a >
:edit <some directory>
<
will open up a "secondary" NERD tree instead of a netrw in the target window.
will open up a window level NERD tree instead of a netrw in the target window.
Secondary NERD trees behaves slightly different from a regular trees in the
Window level trees behaves slightly different from a regular trees in the
following respects:
1. 'o' will open the selected file in the same window as the tree,
replacing it.
2. you can have as many secondary tree as you want in the same tab.
2. you can have one tree per window - instead of per tab.
------------------------------------------------------------------------------
*'NERDTreeIgnore'*
@ -947,7 +942,7 @@ Other examples: >
------------------------------------------------------------------------------
*'NERDTreeStatusline'*
Values: Any valid statusline setting.
Default: %{b:NERDTreeRoot.path.strForOS(0)}
Default: %{b:NERDTree.root.path.strForOS(0)}
Tells the script what to use as the |'statusline'| setting for NERD tree
windows.
@ -988,19 +983,6 @@ of the following lines to set this option: >
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
<
------------------------------------------------------------------------------
*'NERDTreeCascadeOpenSingleChildDir'*
Values: 0 or 1
@ -1205,7 +1187,7 @@ Use this API if you want to run a callback for events on Path objects. E.G >
"This function will be called whenever a Path object is created.
"a:event is an object that contains a bunch of relevant info -
"including the path in question. See lib/event.vim for details.
"including the path in question. See lib/nerdtree/event.vim for details.
endfunction
<
Current events supported:
@ -1235,187 +1217,8 @@ The latest stable versions can be found at
The latest dev versions are on github
http://github.com/scrooloose/nerdtree
==============================================================================
6. Changelog *NERDTreeChangelog*
Next
- add 'scope' argument to the key map API
- add NERDTreeCustomIgnoreFilter hook - needs doc
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
- add support for custom path filters. See :help NERDTreeAddPathFilter()
- add path listener API. See :help NERDTreePathListenerAPI.
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,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
NERDTree-gs
- make the statusline for the nerd tree window default to something
hopefully more useful. See :help 'NERDTreeStatusline'
Bugfixes:
- make the hijack netrw functionality work when vim is started with "vim
<some dir>" (thanks to Alf Mikula for the patch).
- fix a bug where the CWD wasnt being changed for some operations even when
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
- add -bar to all the nerd tree :commands so they can chain with other
:commands (thanks to tpope)
- fix bugs when ignorecase was set (thanks to nach)
- fix a bug with the relative path code (thanks to nach)
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
3.0.1
Bugfixes:
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
was not set
- fix a bug where :NERDTree <path> would fail if <path> was relative and
didnt start with a ./ or ../ Thanks to James Kanze.
- make the q mapping work with secondary (:e <dir> style) trees,
thanks to jamessan
- fix a bunch of small bugs with secondary trees
More insane refactoring.
3.0.0
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
- allow sharing of trees across tabs, see :help :NERDTreeMirror
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
- change the '<tab>' mapping to 'i'
- change the 'H' mapping to 'I'
- lots of refactoring
==============================================================================
7. Credits *NERDTreeCredits*
Thanks to the following people for testing, bug reports, ideas etc. Without
you I probably would have got bored of the hacking the NERD tree and
just downloaded pr0n instead.
Tim Carey-Smith (halorgium)
Vigil
Nick Brettell
Thomas Scott Urban
Terrance Cohen
Yegappan Lakshmanan
Jason Mills
Michael Geddes (frogonwheels)
Yu Jun
Michael Madsen
AOYAMA Shotaro
Zhang Weiwu
Niels Aan de Brugh
Olivier Yiptong
Zhang Shuhan
Cory Echols
Piotr Czachur
Yuan Jiang
Matan Nassau
Maxim Kim
Charlton Wang
Matt Wozniski (godlygeek)
knekk
Sean Chou
Ryan Penn
Simon Peter Nicholls
Michael Foobar
Tomasz Chomiuk
Denis Pokataev
Tim Pope (tpope)
James Kanze
James Vega (jamessan)
Frederic Chanal (nach)
Alf Mikula
Lucas S. Buchala
Curtis Harvey
Guillaume Duranceau
Richard Hart (hates)
Doug McInnes
Stefan Ritter
Rémi Prévost
Victor Gonzalez
Stephan Baumeister
Ricky
jfilip1024
Chris Chambers
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*
6. License *NERDTreeLicense*
The NERD tree is released under the wtfpl.
See http://sam.zoy.org/wtfpl/COPYING.

View File

@ -3,9 +3,9 @@
let s:Bookmark = {}
let g:NERDTreeBookmark = s:Bookmark
" FUNCTION: Bookmark.activate() {{{1
function! s:Bookmark.activate(...)
call self.open(a:0 ? a:1 : {})
" FUNCTION: Bookmark.activate(nerdtree) {{{1
function! s:Bookmark.activate(nerdtree, ...)
call self.open(a:nerdtree, a:0 ? a:1 : {})
endfunction
" FUNCTION: Bookmark.AddBookmark(name, path) {{{1
@ -87,6 +87,7 @@ function! s:Bookmark.CacheBookmarks(silent)
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
let path = fnamemodify(path, ':p')
try
let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path))
@ -127,26 +128,18 @@ endfunction
" Delete this bookmark. If the node for this bookmark is under the current
" root, then recache bookmarks for its Path object
function! s:Bookmark.delete()
let node = {}
try
let node = self.getNode(1)
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self))
if !empty(node)
call node.path.cacheDisplayString()
endif
call s:Bookmark.Write()
endfunction
" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
" Gets the treenode for this bookmark
"
" Args:
" searchFromAbsoluteRoot: specifies whether we should search from the current
" tree root, or the highest cached node
function! s:Bookmark.getNode(searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root
let targetNode = searchRoot.findNode(self.path)
if empty(targetNode)
throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name
@ -154,12 +147,12 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot)
return targetNode
endfunction
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1
" Class method that finds the bookmark with the given name and returns the
" treenode for it.
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree)
let bookmark = s:Bookmark.BookmarkFor(a:name)
return bookmark.getNode(a:searchFromAbsoluteRoot)
return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot)
endfunction
" FUNCTION: Bookmark.GetSelected() {{{1
@ -209,8 +202,11 @@ function! s:Bookmark.New(name, path)
return newBookmark
endfunction
" FUNCTION: Bookmark.open([options]) {{{1
" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1
"Args:
"
"nerdtree: the tree to load open the bookmark in
"
"A dictionary containing the following keys (all optional):
" 'where': Specifies whether the node should be opened in new split/tab or in
" the previous window. Can be either 'v' (vertical split), 'h'
@ -219,11 +215,11 @@ endfunction
" 'keepopen': dont close the tree window
" 'stay': open the file, but keep the cursor in the tree win
"
function! s:Bookmark.open(...)
function! s:Bookmark.open(nerdtree, ...)
let opts = a:0 ? a:1 : {}
if self.path.isDirectory && !has_key(opts, 'where')
call self.toRoot()
call self.toRoot(a:nerdtree)
else
let opener = g:NERDTreeOpener.New(self.path, opts)
call opener.open(self)
@ -265,26 +261,24 @@ function! s:Bookmark.str()
return '>' . self.name . ' ' . pathStr
endfunction
" FUNCTION: Bookmark.toRoot() {{{1
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1
" Make the node for this bookmark the new tree root
function! s:Bookmark.toRoot()
function! s:Bookmark.toRoot(nerdtree)
if self.validate()
try
let targetNode = self.getNode(1)
let targetNode = self.getNode(a:nerdtree, 1)
catch /^NERDTree.BookmarkedNodeNotFoundError/
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
endtry
call targetNode.makeRoot()
call b:NERDTree.render()
call targetNode.putCursorHere(0, 0)
call a:nerdtree.changeRoot(targetNode)
endif
endfunction
" FUNCTION: Bookmark.ToRoot(name) {{{1
" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1
" Make the node for this bookmark the new tree root
function! s:Bookmark.ToRoot(name)
function! s:Bookmark.ToRoot(name, nerdtree)
let bookmark = s:Bookmark.BookmarkFor(a:name)
call bookmark.toRoot()
call bookmark.toRoot(a:nerdtree)
endfunction
" FUNCTION: Bookmark.validate() {{{1
@ -293,7 +287,6 @@ function! s:Bookmark.validate()
return 1
else
call s:Bookmark.CacheBookmarks(1)
call b:NERDTree.render()
call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
return 0
endif
@ -304,7 +297,7 @@ endfunction
function! s:Bookmark.Write()
let bookmarkStrings = []
for i in s:Bookmark.Bookmarks()
call add(bookmarkStrings, i.name . ' ' . i.path.str())
call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~'))
endfor
"add a blank line before the invalid ones

View File

@ -1,5 +1,5 @@
"CLASS: Creator
"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and
"Creates tab/window/mirror nerdtree windows. Sets up all the window and
"buffer options and key mappings etc.
"============================================================
let s:Creator = {}
@ -16,7 +16,7 @@ function! s:Creator._bindMappings()
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>')
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
@ -32,22 +32,26 @@ function! s:Creator.BufNamePrefix()
return 'NERD_tree_'
endfunction
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
function! s:Creator.CreatePrimary(name)
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
function! s:Creator.CreateTabTree(name)
let creator = s:Creator.New()
call creator.createPrimary(a:name)
call creator.createTabTree(a:name)
endfunction
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
"name: the name of a bookmark or a directory
function! s:Creator.createPrimary(name)
function! s:Creator.createTabTree(name)
let path = self._pathForString(a:name)
"abort if exception was thrown (bookmark/dir doesn't exist)
if empty(path)
return
endif
if path == {}
return
endif
"if instructed to, then change the vim CWD to the dir the NERDTree is
"inited in
if g:NERDTreeChDirMode != 0
@ -58,32 +62,26 @@ function! s:Creator.createPrimary(name)
if g:NERDTree.IsOpen()
call g:NERDTree.Close()
endif
unlet t:NERDTreeBufName
call self._removeTreeBufForTab()
endif
call self._createTreeWin()
call self._createNERDTree(path)
let b:NERDTreeType = "primary"
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
call self._createNERDTree(path, "tab")
call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0)
call b:NERDTree.root.putCursorHere(0, 0)
call self._broadcastInitEvent()
endfunction
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
function! s:Creator.CreateSecondary(dir)
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
function! s:Creator.CreateWindowTree(dir)
let creator = s:Creator.New()
call creator.createSecondary(a:dir)
call creator.createWindowTree(a:dir)
endfunction
"FUNCTION: s:Creator.createSecondary(dir) {{{1
function! s:Creator.createSecondary(dir)
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
function! s:Creator.createWindowTree(dir)
try
let path = g:NERDTreePath.New(a:dir)
catch /^NERDTree.InvalidArgumentsError/
@ -96,14 +94,13 @@ function! s:Creator.createSecondary(dir)
let previousBuf = expand("#")
"we need a unique name for each secondary tree buffer to ensure they are
"we need a unique name for each window tree buffer to ensure they are
"all independent
exec "silent edit " . self._nextBufferName()
let b:NERDTreePreviousBuf = bufnr(previousBuf)
call self._createNERDTree(path)
call self._createNERDTree(path, "window")
let b:NERDTree._previousBuf = bufnr(previousBuf)
call self._setCommonBufOptions()
let b:NERDTreeType = "secondary"
call b:NERDTree.render()
@ -111,8 +108,8 @@ function! s:Creator.createSecondary(dir)
endfunction
" FUNCTION: s:Creator._createNERDTree(path) {{{1
function! s:Creator._createNERDTree(path)
let b:NERDTree = g:NERDTree.New(a:path)
function! s:Creator._createNERDTree(path, type)
let b:NERDTree = g:NERDTree.New(a:path, a:type)
"TODO: This is kept for compatability only since many things use
"b:NERDTreeRoot instead of the new NERDTree.root
"Remove this one day
@ -145,7 +142,7 @@ function! s:Creator.createMirror()
let i = 0
while i < len(treeBufNames)
let bufName = treeBufNames[i]
let treeRoot = getbufvar(bufName, "NERDTreeRoot")
let treeRoot = getbufvar(bufName, "NERDTree").root
let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName
let i = i + 1
endwhile
@ -201,6 +198,15 @@ function! s:Creator._createTreeWin()
call self._setCommonBufOptions()
endfunction
"FUNCTION: s:Creator._isBufHidden(nr) {{{1
function! s:Creator._isBufHidden(nr)
redir => bufs
silent ls!
redir END
return bufs =~ a:nr . '..h'
endfunction
"FUNCTION: s:Creator.New() {{{1
function! s:Creator.New()
let newCreator = copy(self)
@ -245,7 +251,7 @@ function! s:Creator._pathForString(str)
let path = g:NERDTreePath.New(dir)
catch /^NERDTree.InvalidArgumentsError/
call nerdtree#echo("No bookmark or directory found for: " . a:str)
return
return {}
endtry
endif
if !path.isDirectory
@ -255,6 +261,23 @@ function! s:Creator._pathForString(str)
return path
endfunction
" Function: s:Creator._removeTreeBufForTab() {{{1
function! s:Creator._removeTreeBufForTab()
let buf = bufnr(t:NERDTreeBufName)
"if &hidden is not set then it will already be gone
if buf != -1
"nerdtree buf may be mirrored/displayed elsewhere
if self._isBufHidden(buf)
exec "bwipeout " . buf
endif
endif
unlet t:NERDTreeBufName
endfunction
"FUNCTION: s:Creator._setCommonBufOptions() {{{1
function! s:Creator._setCommonBufOptions()
"throwaway buffer options
@ -283,12 +306,6 @@ function! s:Creator._setCommonBufOptions()
endif
call self._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 self._bindMappings()
setlocal filetype=nerdtree
endfunction
@ -318,20 +335,20 @@ function! s:Creator._tabpagevar(tabnr, var)
return v
endfunction
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
function! s:Creator.TogglePrimary(dir)
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
function! s:Creator.ToggleTabTree(dir)
let creator = s:Creator.New()
call creator.togglePrimary(a:dir)
call creator.toggleTabTree(a:dir)
endfunction
"FUNCTION: s:Creator.togglePrimary(dir) {{{1
"FUNCTION: s:Creator.toggleTabTree(dir) {{{1
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
"closed it is restored or initialized (if it doesnt exist)
"
"Args:
"dir: the full path for the root node (is only used if the NERD tree is being
"initialized.
function! s:Creator.togglePrimary(dir)
function! s:Creator.toggleTabTree(dir)
if g:NERDTree.ExistsForTab()
if !g:NERDTree.IsOpen()
call self._createTreeWin()
@ -343,7 +360,7 @@ function! s:Creator.togglePrimary(dir)
call g:NERDTree.Close()
endif
else
call self.createPrimary(a:dir)
call self.createTabTree(a:dir)
endif
endfunction

View File

@ -8,8 +8,30 @@ function! s:NERDTree.AddPathFilter(callback)
call add(s:NERDTree.PathFilters(), a:callback)
endfunction
"FUNCTION: s:NERDTree.changeRoot(node) {{{1
function! s:NERDTree.changeRoot(node)
if a:node.path.isDirectory
let self.root = a:node
else
call a:node.cacheParent()
let self.root = a:node.parent
endif
call self.root.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
exec "cd " . self.root.path.str({'format': 'Edit'})
endif
call self.render()
call self.root.putCursorHere(0, 0)
silent doautocmd User NERDTreeNewRoot
endfunction
"FUNCTION: s:NERDTree.Close() {{{1
"Closes the primary NERD tree window for this tab
"Closes the tab tree window for this tab
function! s:NERDTree.Close()
if !s:NERDTree.IsOpen()
return
@ -43,7 +65,7 @@ endfunction
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
"Places the cursor at the top of the bookmarks table
function! s:NERDTree.CursorToBookmarkTable()
if !b:NERDTreeShowBookmarks
if !b:NERDTree.ui.getShowBookmarks()
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif
@ -73,13 +95,18 @@ endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
return exists("b:NERDTreeRoot")
return exists("b:NERDTree")
endfunction
" Function: s:NERDTree.ExistsForTab() {{{1
" Returns 1 if a nerd tree root exists in the current tab
function! s:NERDTree.ExistsForTab()
return exists("t:NERDTreeBufName")
if !exists("t:NERDTreeBufName")
return
end
"check b:NERDTree is still there and hasn't been e.g. :bdeleted
return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree'))
endfunction
function! s:NERDTree.ForCurrentBuf()
@ -90,14 +117,29 @@ function! s:NERDTree.ForCurrentBuf()
endif
endfunction
"FUNCTION: s:NERDTree.ForCurrentTab() {{{1
function! s:NERDTree.ForCurrentTab()
if !s:NERDTree.ExistsForTab()
return
endif
let bufnr = bufnr(t:NERDTreeBufName)
return getbufvar(bufnr, "NERDTree")
endfunction
"FUNCTION: s:NERDTree.getRoot() {{{1
function! s:NERDTree.getRoot()
return self.root
endfunction
"FUNCTION: s:NERDTree.GetWinNum() {{{1
"gets the nerd tree window number for this tab
function! s:NERDTree.GetWinNum()
if exists("t:NERDTreeBufName")
return bufwinnr(t:NERDTreeBufName)
else
return -1
endif
return -1
endfunction
"FUNCTION: s:NERDTree.IsOpen() {{{1
@ -105,6 +147,16 @@ function! s:NERDTree.IsOpen()
return s:NERDTree.GetWinNum() != -1
endfunction
"FUNCTION: s:NERDTree.isTabTree() {{{1
function! s:NERDTree.isTabTree()
return self._type == "tab"
endfunction
"FUNCTION: s:NERDTree.isWinTree() {{{1
function! s:NERDTree.isWinTree()
return self._type == "window"
endfunction
"FUNCTION: s:NERDTree.MustBeOpen() {{{1
function! s:NERDTree.MustBeOpen()
if !s:NERDTree.IsOpen()
@ -113,11 +165,11 @@ function! s:NERDTree.MustBeOpen()
endfunction
"FUNCTION: s:NERDTree.New() {{{1
function! s:NERDTree.New(path)
function! s:NERDTree.New(path, type)
let newObj = copy(self)
let newObj.ui = g:NERDTreeUI.New(newObj)
let newObj.root = g:NERDTreeDirNode.New(a:path)
let newObj.root = g:NERDTreeDirNode.New(a:path, newObj)
let newObj._type = a:type
return newObj
endfunction
@ -129,6 +181,10 @@ function! s:NERDTree.PathFilters()
return s:NERDTree._PathFilters
endfunction
"FUNCTION: s:NERDTree.previousBuf() {{{1
function! s:NERDTree.previousBuf()
return self._previousBuf
endfunction
"FUNCTION: s:NERDTree.render() {{{1
"A convenience function - since this is called often

View File

@ -11,8 +11,8 @@ function! s:Notifier.AddListener(event, funcname)
call add(listeners, a:funcname)
endfunction
function! s:Notifier.NotifyListeners(event, path, params)
let event = g:NERDTreeEvent.New(b:NERDTree, a:path, a:event, a:params)
function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
for listener in s:Notifier.GetListenersForEvent(a:event)
call {listener}(event)

View File

@ -64,7 +64,7 @@ endfunction
"FUNCTION: Opener._gotoTargetWin() {{{1
function! s:Opener._gotoTargetWin()
if b:NERDTreeType ==# "secondary"
if b:NERDTree.isWinTree()
if self._where == 'v'
vsplit
elseif self._where == 'h'
@ -149,7 +149,7 @@ function! s:Opener.New(path, opts)
let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
let newObj._treetype = b:NERDTreeType
let newObj._nerdtree = b:NERDTree
call newObj._saveCursorPos()
return newObj
@ -247,34 +247,25 @@ function! s:Opener._openFile()
endif
call self._gotoTargetWin()
if self._treetype ==# "secondary"
call self._path.edit()
else
call self._path.edit()
if self._stay
call self._restoreCursorPos()
endif
call self._path.edit()
if self._stay
call self._restoreCursorPos()
endif
endfunction
"FUNCTION: Opener._openDirectory(node) {{{1
function! s:Opener._openDirectory(node)
if self._treetype ==# "secondary"
if self._nerdtree.isWinTree()
call self._gotoTargetWin()
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
else
call self._gotoTargetWin()
if empty(self._where)
call a:node.makeRoot()
call b:NERDTree.render()
call a:node.putCursorHere(0, 0)
call b:NERDTree.changeRoot(a:node)
elseif self._where == 't'
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
else
call g:NERDTreeCreator.CreateSecondary(a:node.path.str())
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
endif
endif

View File

@ -40,9 +40,7 @@ endfunction
"FUNCTION: Path.cacheDisplayString() {{{1
function! s:Path.cacheDisplayString() abort
let self.cachedDisplayString = self.flagSet.renderToString()
let self.cachedDisplayString .= self.getLastPathComponent(1)
let self.cachedDisplayString = self.getLastPathComponent(1)
if self.isExecutable
let self.cachedDisplayString = self.cachedDisplayString . '*'
@ -406,11 +404,11 @@ function! s:Path.isUnixHiddenPath()
endif
endfunction
"FUNCTION: Path.ignore() {{{1
"FUNCTION: Path.ignore(nerdtree) {{{1
"returns true if this path should be ignored
function! s:Path.ignore()
function! s:Path.ignore(nerdtree)
"filter out the user specified paths to ignore
if b:NERDTreeIgnoreEnabled
if a:nerdtree.ui.isIgnoreFilterEnabled()
for i in g:NERDTreeIgnore
if self._ignorePatternMatches(i)
return 1
@ -418,18 +416,18 @@ function! s:Path.ignore()
endfor
for callback in g:NERDTree.PathFilters()
if {callback}({'path': self, 'nerdtree': b:NERDTree})
if {callback}({'path': self, 'nerdtree': a:nerdtree})
return 1
endif
endfor
endif
"dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile()
if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile()
return 1
endif
if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0
if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0
return 1
endif
@ -455,10 +453,22 @@ function! s:Path._ignorePatternMatches(pattern)
return self.getLastPathComponent(0) =~# pat
endfunction
"FUNCTION: Path.isUnder(path) {{{1
"return 1 if this path is somewhere under the given path in the filesystem.
"FUNCTION: Path.isAncestor(path) {{{1
"return 1 if this path is somewhere above the given path in the filesystem.
"
"a:path should be a dir
function! s:Path.isAncestor(path)
if !self.isDirectory
return 0
endif
let this = self.str()
let that = a:path.str()
return stridx(that, this) == 0
endfunction
"FUNCTION: Path.isUnder(path) {{{1
"return 1 if this path is somewhere under the given path in the filesystem.
function! s:Path.isUnder(path)
if a:path.isDirectory == 0
return 0
@ -572,16 +582,16 @@ function! s:Path.readInfoFromDisk(fullpath)
endif
endfunction
"FUNCTION: Path.refresh() {{{1
function! s:Path.refresh()
"FUNCTION: Path.refresh(nerdtree) {{{1
function! s:Path.refresh(nerdtree)
call self.readInfoFromDisk(self.str())
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, {})
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction
"FUNCTION: Path.refreshFlags() {{{1
function! s:Path.refreshFlags()
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, {})
"FUNCTION: Path.refreshFlags(nerdtree) {{{1
function! s:Path.refreshFlags(nerdtree)
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {})
call self.cacheDisplayString()
endfunction

View File

@ -9,7 +9,7 @@ let g:NERDTreeDirNode = s:TreeDirNode
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1
"class method that returns the highest cached ancestor of the current root
function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = b:NERDTreeRoot
let currentNode = b:NERDTree.root
while currentNode.parent != {}
let currentNode = currentNode.parent
endwhile
@ -21,7 +21,7 @@ unlet s:TreeDirNode.activate
function! s:TreeDirNode.activate(...)
let opts = a:0 ? a:1 : {}
call self.toggleOpen(opts)
call b:NERDTree.render()
call self.getNerdtree().render()
call self.putCursorHere(0, 0)
endfunction
@ -68,11 +68,27 @@ endfunction
"Returns:
"the newly created node
function! s:TreeDirNode.createChild(path, inOrder)
let newTreeNode = g:NERDTreeFileNode.New(a:path)
let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree())
call self.addChild(newTreeNode, a:inOrder)
return newTreeNode
endfunction
"FUNCTION: TreeDirNode.displayString() {{{1
unlet s:TreeDirNode.displayString
function! s:TreeDirNode.displayString()
let cascade = self.getCascade()
let rv = ""
for node in cascade
let rv = rv . node.path.displayString()
endfor
let sym = cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable
let flags = cascade[-1].path.flagSet.renderToString()
return sym . ' ' . flags . rv
endfunction
"FUNCTION: TreeDirNode.findNode(path) {{{1
"Will find one of the children (recursively) that has the given path
"
@ -98,6 +114,33 @@ function! s:TreeDirNode.findNode(path)
return {}
endfunction
"FUNCTION: TreeDirNode.getCascade() {{{1
"Return an array of dir nodes (starting from self) that can be cascade opened.
function! s:TreeDirNode.getCascade()
let rv = [self]
let node = self
while 1
let vc = node.getVisibleChildren()
if len(vc) != 1
break
endif
let visChild = vc[0]
"TODO: optimize
if !visChild.path.isDirectory
break
endif
call add(rv, visChild)
let node = visChild
endwhile
return rv
endfunction
"FUNCTION: TreeDirNode.getChildCount() {{{1
"Returns the number of children this node has
function! s:TreeDirNode.getChildCount()
@ -171,6 +214,12 @@ function! s:TreeDirNode.getChildIndex(path)
return -1
endfunction
"FUNCTION: TreeDirNode.getDirChildren() {{{1
"Get all children that are directories
function! s:TreeDirNode.getDirChildren()
return filter(self.children, 'v:val.path.isDirectory == 1')
endfunction
"FUNCTION: TreeDirNode.GetSelected() {{{1
"Returns the current node if it is a dir node, or else returns the current
"nodes parent
@ -199,7 +248,7 @@ endfunction
function! s:TreeDirNode.getVisibleChildren()
let toReturn = []
for i in self.children
if i.path.ignore() ==# 0
if i.path.ignore(self.getNerdtree()) ==# 0
call add(toReturn, i)
endif
endfor
@ -212,6 +261,13 @@ function! s:TreeDirNode.hasVisibleChildren()
return self.getVisibleChildCount() != 0
endfunction
"FUNCTION: TreeDirNode.isCascadable() {{{1
"true if this dir has only one visible child - which is also a dir
function! s:TreeDirNode.isCascadable()
let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory
endfunction
"FUNCTION: TreeDirNode._initChildren() {{{1
"Removes all childen from this node and re-reads them
"
@ -244,19 +300,15 @@ function! s:TreeDirNode._initChildren(silent)
for i in files
"filter out the .. and . directories
"Note: we must match .. AND ../ cos sometimes the globpath returns
"Note: we must match .. AND ../ since sometimes the globpath returns
"../ for path with strange chars (eg $)
" if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
"
" Regular expression is too expensive. Use simply string comparison
" instead
if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." &&
if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." &&
\ i[len(i)-2:1] != "." && i[len(i)-1] != "."
"put the next file in a new node and attach it
try
let path = g:NERDTreePath.New(i)
call self.createChild(path, 0)
call g:NERDTreePathNotifier.NotifyListeners('init', path, {})
call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {})
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
let invalidFilesFound += 1
endtry
@ -275,13 +327,13 @@ function! s:TreeDirNode._initChildren(silent)
return self.getChildCount()
endfunction
"FUNCTION: TreeDirNode.New(path) {{{1
"FUNCTION: TreeDirNode.New(path, nerdtree) {{{1
"Returns a new TreeNode object with the given path and parent
"
"Args:
"path: a path object representing the full filesystem path to the file/dir that the node represents
unlet s:TreeDirNode.New
function! s:TreeDirNode.New(path)
"path: dir that the node represents
"nerdtree: the tree the node belongs to
function! s:TreeDirNode.New(path, nerdtree)
if a:path.isDirectory != 1
throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object."
endif
@ -293,6 +345,7 @@ function! s:TreeDirNode.New(path)
let newTreeNode.children = []
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endfunction
@ -356,7 +409,7 @@ endfunction
"FUNCTION: TreeDirNode._openInNewTab() {{{1
function! s:TreeDirNode._openInNewTab()
tabnew
call g:NERDTreeCreator.CreatePrimary(self.path.str())
call g:NERDTreeCreator.CreateTabTree(self.path.str())
endfunction
"FUNCTION: TreeDirNode.openRecursively() {{{1
@ -377,7 +430,7 @@ endfunction
"Args:
"forceOpen: 1 if this node should be opened regardless of file filters
function! s:TreeDirNode._openRecursively2(forceOpen)
if self.path.ignore() ==# 0 || a:forceOpen
if self.path.ignore(self.getNerdtree()) ==# 0 || a:forceOpen
let self.isOpen = 1
if self.children ==# []
call self._initChildren(1)
@ -394,7 +447,7 @@ endfunction
"FUNCTION: TreeDirNode.refresh() {{{1
unlet s:TreeDirNode.refresh
function! s:TreeDirNode.refresh()
call self.path.refresh()
call self.path.refresh(self.getNerdtree())
"if this node was ever opened, refresh its children
if self.isOpen || !empty(self.children)
@ -425,7 +478,7 @@ function! s:TreeDirNode.refresh()
"the node doesnt exist so create it
else
let newNode = g:NERDTreeFileNode.New(path)
let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree())
let newNode.parent = self
call add(newChildNodes, newNode)
endif
@ -450,7 +503,7 @@ endfunction
"FUNCTION: TreeDirNode.refreshFlags() {{{1
unlet s:TreeDirNode.refreshFlags
function! s:TreeDirNode.refreshFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
for i in self.children
call i.refreshFlags()
endfor
@ -458,13 +511,16 @@ endfunction
"FUNCTION: TreeDirNode.refreshDirFlags() {{{1
function! s:TreeDirNode.refreshDirFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
"FUNCTION: TreeDirNode.reveal(path) {{{1
"reveal the given path, i.e. cache and open all treenodes needed to display it
"in the UI
function! s:TreeDirNode.reveal(path)
"Returns the revealed node
function! s:TreeDirNode.reveal(path, ...)
let opts = a:0 ? a:1 : {}
if !a:path.isUnder(self.path)
throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str()
endif
@ -473,9 +529,10 @@ function! s:TreeDirNode.reveal(path)
if self.path.equals(a:path.getParent())
let n = self.findNode(a:path)
call b:NERDTree.render()
call n.putCursorHere(1,0)
return
if has_key(opts, "open")
call n.open()
endif
return n
endif
let p = a:path
@ -484,7 +541,7 @@ function! s:TreeDirNode.reveal(path)
endwhile
let n = self.findNode(p)
call n.reveal(a:path)
return n.reveal(a:path, opts)
endfunction
"FUNCTION: TreeDirNode.removeChild(treenode) {{{1

View File

@ -19,7 +19,7 @@ function! s:TreeFileNode.bookmark(name)
"it so we can update its display string
let oldMarkedNode = {}
try
let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1)
let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree())
catch /^NERDTree.BookmarkNotFoundError/
catch /^NERDTree.BookmarkedNodeNotFoundError/
endtry
@ -41,7 +41,7 @@ function! s:TreeFileNode.cacheParent()
if parentPath.equals(self.path)
throw "NERDTree.CannotCacheParentError: already at root"
endif
let self.parent = s:TreeFileNode.New(parentPath)
let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree())
endif
endfunction
@ -59,7 +59,7 @@ endfunction
function! s:TreeFileNode.copy(dest)
call self.path.copy(a:dest)
let newPath = g:NERDTreePath.New(a:dest)
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
let parent = self.getNerdtree().root.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
return parent.findNode(newPath)
@ -83,7 +83,7 @@ endfunction
"Return:
"a string that can be used in the view to represent this node
function! s:TreeFileNode.displayString()
return self.path.displayString()
return self.path.flagSet.renderToString() . self.path.displayString()
endfunction
"FUNCTION: TreeFileNode.equals(treenode) {{{1
@ -165,7 +165,7 @@ function! s:TreeFileNode.findSibling(direction)
"if the next node is not an ignored node (i.e. wont show up in the
"view) then return it
if self.parent.children[siblingIndx].path.ignore() ==# 0
if self.parent.children[siblingIndx].path.ignore(self.getNerdtree()) ==# 0
return self.parent.children[siblingIndx]
endif
@ -178,11 +178,16 @@ function! s:TreeFileNode.findSibling(direction)
return {}
endfunction
"FUNCTION: TreeFileNode.getNerdtree(){{{1
function! s:TreeFileNode.getNerdtree()
return self._nerdtree
endfunction
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
"get the root node for this tab
function! s:TreeFileNode.GetRootForTab()
if g:NERDTree.ExistsForTab()
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
return getbufvar(t:NERDTreeBufName, 'NERDTree').root
end
return {}
endfunction
@ -195,7 +200,7 @@ function! s:TreeFileNode.GetSelected()
if path ==# {}
return {}
endif
return b:NERDTreeRoot.findNode(path)
return b:NERDTree.root.findNode(path)
catch /^NERDTree/
return {}
endtry
@ -205,51 +210,32 @@ endfunction
"returns 1 if this node should be visible according to the tree filters and
"hidden file filters (and their on/off status)
function! s:TreeFileNode.isVisible()
return !self.path.ignore()
return !self.path.ignore(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.isRoot() {{{1
"returns 1 if this node is b:NERDTreeRoot
function! s:TreeFileNode.isRoot()
if !g:NERDTree.ExistsForBuf()
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
endif
return self.equals(b:NERDTreeRoot)
return self.equals(self.getNerdtree().root)
endfunction
"FUNCTION: TreeFileNode.makeRoot() {{{1
"Make this node the root of the tree
function! s:TreeFileNode.makeRoot()
if self.path.isDirectory
let b:NERDTreeRoot = self
else
call self.cacheParent()
let b:NERDTreeRoot = self.parent
endif
call b:NERDTreeRoot.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'})
endif
silent doautocmd User NERDTreeNewRoot
endfunction
"FUNCTION: TreeFileNode.New(path) {{{1
"FUNCTION: TreeFileNode.New(path, nerdtree) {{{1
"Returns a new TreeNode object with the given path and parent
"
"Args:
"path: a path object representing the full filesystem path to the file/dir that the node represents
function! s:TreeFileNode.New(path)
"path: file/dir that the node represents
"nerdtree: the tree the node belongs to
function! s:TreeFileNode.New(path, nerdtree)
if a:path.isDirectory
return g:NERDTreeDirNode.New(a:path)
return g:NERDTreeDirNode.New(a:path, a:nerdtree)
else
let newTreeNode = copy(self)
let newTreeNode.path = a:path
let newTreeNode.parent = {}
let newTreeNode._nerdtree = a:nerdtree
return newTreeNode
endif
endfunction
@ -289,7 +275,7 @@ endfunction
"recurseUpward: try to put the cursor on the parent if the this node isnt
"visible
function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
let ln = b:NERDTree.ui.getLineNum(self)
let ln = self.getNerdtree().ui.getLineNum(self)
if ln != -1
if a:isJump
mark '
@ -298,11 +284,11 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
else
if a:recurseUpward
let node = self
while node != {} && b:NERDTree.ui.getLineNum(node) ==# -1
while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1
let node = node.parent
call node.open()
endwhile
call b:NERDTree.render()
call self._nerdtree.render()
call node.putCursorHere(a:isJump, 0)
endif
endif
@ -310,12 +296,12 @@ endfunction
"FUNCTION: TreeFileNode.refresh() {{{1
function! s:TreeFileNode.refresh()
call self.path.refresh()
call self.path.refresh(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.refreshFlags() {{{1
function! s:TreeFileNode.refreshFlags()
call self.path.refreshFlags()
call self.path.refreshFlags(self.getNerdtree())
endfunction
"FUNCTION: TreeFileNode.rename() {{{1
@ -326,7 +312,7 @@ function! s:TreeFileNode.rename(newName)
call self.parent.removeChild(self)
let parentPath = self.path.getParent()
let newParent = b:NERDTreeRoot.findNode(parentPath)
let newParent = self.getNerdtree().root.findNode(parentPath)
if newParent != {}
call newParent.createChild(self.path, 1)
@ -337,70 +323,24 @@ endfunction
"FUNCTION: TreeFileNode.renderToString {{{1
"returns a string representation for this tree to be rendered in the view
function! s:TreeFileNode.renderToString()
return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
return self._renderToString(0, 0)
endfunction
"Args:
"depth: the current depth in the tree for this call
"drawText: 1 if we should actually draw the line for this node (if 0 then the
"child nodes are rendered only)
"vertMap: a binary array that indicates whether a vertical bar should be draw
"for each depth in the tree
"isLastChild:true if this curNode is the last child of its parent
function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
function! s:TreeFileNode._renderToString(depth, drawText)
let output = ""
if a:drawText ==# 1
let treeParts = ''
let treeParts = repeat(' ', a:depth - 1)
"get all the leading spaces and vertical tree parts for this line
if a:depth > 1
for j in a:vertMap[0:-2]
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
if j ==# 1
let treeParts = treeParts . '| '
else
let treeParts = treeParts . ' '
endif
endif
endfor
if !self.path.isDirectory
let treeParts = treeParts . ' '
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 !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
if g:NERDTreeDirArrows
let treeParts = treeParts . '▾ '
else
let treeParts = treeParts . '~'
endif
else
if g:NERDTreeDirArrows
let treeParts = treeParts . '▸ '
else
let treeParts = treeParts . '+'
endif
endif
else
if g:NERDTreeDirArrows
let treeParts = treeParts . ' '
else
let treeParts = treeParts . '-'
endif
endif
let line = treeParts . self.displayString()
let output = output . line . "\n"
@ -410,18 +350,15 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
if self.path.isDirectory ==# 1 && self.isOpen ==# 1
let childNodesToDraw = self.getVisibleChildren()
if len(childNodesToDraw) > 0
"draw all the nodes children except the last
let lastIndx = len(childNodesToDraw)-1
if lastIndx > 0
for i in childNodesToDraw[0:lastIndx-1]
let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0)
endfor
endif
if self.isCascadable() && a:depth > 0
"draw the last child, indicating that it IS the last
let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1)
let output = output . childNodesToDraw[0]._renderToString(a:depth, 0)
elseif len(childNodesToDraw) > 0
for i in childNodesToDraw
let output = output . i._renderToString(a:depth + 1, 1)
endfor
endif
endif

View File

@ -21,18 +21,18 @@ endfunction
"prints out the quick help
function! s:UI._dumpHelp()
let old_h = @h
if b:treeShowHelp ==# 1
if self.getShowHelp()
let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n"
let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
let @h=@h."\" <CR>,\n"
if b:NERDTreeType ==# "primary"
if self.nerdtree.isTabTree()
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
else
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
endif
if b:NERDTreeType ==# "primary"
if self.nerdtree.isTabTree()
let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
endif
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
@ -87,10 +87,10 @@ function! s:UI._dumpHelp()
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree filtering mappings~\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n"
"add quickhelp entries for each custom key map
let @h=@h."\"\n\" ----------------------------\n"
@ -116,7 +116,7 @@ function! s:UI._dumpHelp()
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
silent! put h
elseif g:NERDTreeMinimalUI == 0
elseif !self.isMinimal()
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
silent! put h
endif
@ -129,6 +129,12 @@ endfunction
function! s:UI.New(nerdtree)
let newObj = copy(self)
let newObj.nerdtree = a:nerdtree
let newObj._showHelp = 0
let newObj._ignoreEnabled = 1
let newObj._showFiles = g:NERDTreeShowFiles
let newObj._showHidden = g:NERDTreeShowHidden
let newObj._showBookmarks = g:NERDTreeShowBookmarks
return newObj
endfunction
@ -149,18 +155,11 @@ function! s:UI.getPath(ln)
"check to see if we have the root node
if a:ln == rootLine
return b:NERDTreeRoot.path
endif
if !g:NERDTreeDirArrows
" in case called from outside the tree
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
return {}
endif
return self.nerdtree.root.path
endif
if line ==# s:UI.UpDirLine()
return b:NERDTreeRoot.path.getParent()
return self.nerdtree.root.path.getParent()
endif
let indent = self._indentLevelFor(line)
@ -183,7 +182,7 @@ function! s:UI.getPath(ln)
"have we reached the top of the tree?
if lnum == rootLine
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
break
endif
if curLineStripped =~# '/$'
@ -196,7 +195,7 @@ function! s:UI.getPath(ln)
endif
endif
endwhile
let curFile = b:NERDTreeRoot.path.drive . dir . curFile
let curFile = self.nerdtree.root.path.drive . dir . curFile
let toReturn = g:NERDTreePath.New(curFile)
return toReturn
endfunction
@ -206,19 +205,19 @@ endfunction
function! s:UI.getLineNum(file_node)
"if the node is the root then return the root line no.
if a:file_node.isRoot()
return b:NERDTree.ui.getRootLineNum()
return self.getRootLineNum()
endif
let totalLines = line("$")
"the path components we have matched so far
let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
"the index of the component we are searching for
let curPathComponent = 1
let fullpath = a:file_node.path.str({'format': 'UI'})
let lnum = b:NERDTree.ui.getRootLineNum()
let lnum = self.getRootLineNum()
while lnum > 0
let lnum = lnum + 1
"have we reached the bottom of the tree?
@ -259,15 +258,33 @@ function! s:UI.getRootLineNum()
return rootLine
endfunction
"FUNCTION: s:UI.getShowBookmarks() {{{1
function! s:UI.getShowBookmarks()
return self._showBookmarks
endfunction
"FUNCTION: s:UI.getShowFiles() {{{1
function! s:UI.getShowFiles()
return self._showFiles
endfunction
"FUNCTION: s:UI.getShowHelp() {{{1
function! s:UI.getShowHelp()
return self._showHelp
endfunction
"FUNCTION: s:UI.getShowHidden() {{{1
function! s:UI.getShowHidden()
return self._showHidden
endfunction
"FUNCTION: s:UI._indentLevelFor(line) {{{1
function! s:UI._indentLevelFor(line)
let level = match(a:line, '[^ \-+~▸▾`|]') / s:UI.IndentWid()
" 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
"have to do this work around because match() returns bytes, not chars
let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
let leadChars = strchars(a:line[0:numLeadBytes-1])
return leadChars / s:UI.IndentWid()
endfunction
"FUNCTION: s:UI.IndentWid() {{{1
@ -275,19 +292,25 @@ function! s:UI.IndentWid()
return 2
endfunction
"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
function! s:UI.isIgnoreFilterEnabled()
return self._ignoreEnabled == 1
endfunction
"FUNCTION: s:UI.isMinimal() {{{1
function! s:UI.isMinimal()
return g:NERDTreeMinimalUI
endfunction
"FUNCTION: s:UI.MarkupReg() {{{1
function! s:UI.MarkupReg()
if g:NERDTreeDirArrows
return '^\([▾▸] \| \+[▾▸] \| \+\)'
endif
return '^[ `|]*[\-+~]'
return '^\(['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \| \+\)'
endfunction
"FUNCTION: s:UI._renderBookmarks {{{1
function! s:UI._renderBookmarks()
if g:NERDTreeMinimalUI == 0
if !self.isMinimal()
call setline(line(".")+1, ">----------Bookmarks----------")
call cursor(line(".")+1, col("."))
endif
@ -334,6 +357,11 @@ function! s:UI.saveScreenState()
call nerdtree#exec(win . "wincmd w")
endfunction
"FUNCTION: s:UI.setShowHidden(val) {{{1
function! s:UI.setShowHidden(val)
let self._showHidden = a:val
endfunction
"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1
"returns the given line with all the tree parts stripped off
"
@ -390,29 +418,29 @@ function! s:UI.render()
call self._dumpHelp()
"delete the blank line before the help and add one after it
if g:NERDTreeMinimalUI == 0
if !self.isMinimal()
call setline(line(".")+1, "")
call cursor(line(".")+1, col("."))
endif
if b:NERDTreeShowBookmarks
if self.getShowBookmarks()
call self._renderBookmarks()
endif
"add the 'up a dir' line
if !g:NERDTreeMinimalUI
if !self.isMinimal()
call setline(line(".")+1, s:UI.UpDirLine())
call cursor(line(".")+1, col("."))
endif
"draw the header line
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
call setline(line(".")+1, header)
call cursor(line(".")+1, col("."))
"draw the tree
let old_o = @o
let @o = b:NERDTreeRoot.renderToString()
let @o = self.nerdtree.root.renderToString()
silent put o
let @o = old_o
@ -443,47 +471,52 @@ function! s:UI.renderViewSavingPosition()
let currentNode = currentNode.parent
endwhile
call b:NERDTree.render()
call self.render()
if currentNode != {}
call currentNode.putCursorHere(0, 0)
endif
endfunction
"FUNCTION: s:UI.toggleHelp() {{{1
function! s:UI.toggleHelp()
let self._showHelp = !self._showHelp
endfunction
" FUNCTION: s:UI.toggleIgnoreFilter() {{{1
" toggles the use of the NERDTreeIgnore option
function! s:UI.toggleIgnoreFilter()
let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled
call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView()
let self._ignoreEnabled = !self._ignoreEnabled
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
" toggles the display of bookmarks
function! s:UI.toggleShowBookmarks()
let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks
if b:NERDTreeShowBookmarks
call b:NERDTree.render()
let self._showBookmarks = !self._showBookmarks
if self.getShowBookmarks()
call self.nerdtree.render()
call g:NERDTree.CursorToBookmarkTable()
else
call b:NERDTree.ui.renderViewSavingPosition()
call self.renderViewSavingPosition()
endif
call b:NERDTree.ui.centerView()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowFiles() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowFiles()
let b:NERDTreeShowFiles = !b:NERDTreeShowFiles
call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView()
let self._showFiles = !self._showFiles
call self.renderViewSavingPosition()
call self.centerView()
endfunction
" FUNCTION: s:UI.toggleShowHidden() {{{1
" toggles the display of hidden files
function! s:UI.toggleShowHidden()
let b:NERDTreeShowHidden = !b:NERDTreeShowHidden
call b:NERDTree.ui.renderViewSavingPosition()
let self._showHidden = !self._showHidden
call self.renderViewSavingPosition()
call self.centerView()
endfunction

View File

@ -2,7 +2,6 @@
" File: exec_menuitem.vim
" Description: plugin for NERD Tree that provides an execute file menu item
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 22 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You

View File

@ -2,7 +2,6 @@
" File: fs_menu.vim
" Description: plugin for the NERD Tree that provides a file system menu
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 17 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
@ -24,7 +23,7 @@ call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callbac
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")
if has("gui_mac") || has("gui_macvim") || has("mac")
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'})
@ -34,18 +33,11 @@ if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
"FUNCTION: s:echo(msg){{{1
function! s:echo(msg)
redraw
echomsg "NERDTree: " . a:msg
endfunction
"FUNCTION: s:echoWarning(msg){{{1
function! s:echoWarning(msg)
echohl warningmsg
call s:echo(a:msg)
echohl normal
endfunction
if has("unix") || has("osx")
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
else
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
endif
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
@ -107,17 +99,17 @@ function! NERDTreeAddNode()
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
call nerdtree#echo("Node Creation Aborted.")
return
endif
try
let newPath = g:NERDTreePath.Create(newNodeName)
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
let parentNode = b:NERDTree.root.findNode(newPath.getParent())
let newTreeNode = g:NERDTreeFileNode.New(newPath)
let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree)
if empty(parentNode)
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
elseif parentNode.isOpen || !empty(parentNode.children)
call parentNode.addChild(newTreeNode, 1)
@ -125,7 +117,7 @@ function! NERDTreeAddNode()
call newTreeNode.putCursorHere(1, 0)
endif
catch /^NERDTree/
call s:echoWarning("Node Not Created.")
call nerdtree#echoWarning("Node Not Created.")
endtry
endfunction
@ -138,7 +130,7 @@ function! NERDTreeMoveNode()
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
call nerdtree#echo("Node Renaming Aborted.")
return
endif
@ -159,7 +151,7 @@ function! NERDTreeMoveNode()
redraw
catch /^NERDTree/
call s:echoWarning("Node Not Renamed.")
call nerdtree#echoWarning("Node Not Renamed.")
endtry
endfunction
@ -199,10 +191,33 @@ function! NERDTreeDeleteNode()
redraw
catch /^NERDTree/
call s:echoWarning("Could not remove node")
call nerdtree#echoWarning("Could not remove node")
endtry
else
call s:echo("delete aborted")
call nerdtree#echo("delete aborted")
endif
endfunction
" FUNCTION: NERDTreeListNode() {{{1
function! NERDTreeListNode()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let metadata = split(system('ls -ld ' . shellescape(treenode.path.str())), '\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information avaialable")
endif
endfunction
" FUNCTION: NERDTreeListNodeWin32() {{{1
function! NERDTreeListNodeWin32()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n')
call nerdtree#echo(metadata[0])
else
call nerdtree#echo("No information avaialable")
endif
endfunction
@ -221,7 +236,7 @@ function! NERDTreeCopyNode()
let confirmed = 1
if currentNode.path.copyingWillOverwrite(newNodePath)
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
call nerdtree#echo("Warning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
@ -230,22 +245,23 @@ function! NERDTreeCopyNode()
try
let newNode = currentNode.copy(newNodePath)
if empty(newNode)
call b:NERDTreeRoot.refresh()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
else
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
call nerdtree#echoWarning("Could not copy node")
endtry
endif
else
call s:echo("Copy aborted.")
call nerdtree#echo("Copy aborted.")
endif
redraw
endfunction
" FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
@ -253,18 +269,19 @@ function! NERDTreeQuickLook()
endif
endfunction
" FUNCTION: NERDTreeRevealInFinder() {{{1
function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open -R '" . treenode.path.str() . "'")
call system("open -R '" . treenode.path.str() . "'")
endif
endfunction
" FUNCTION: NERDTreeExecuteFile() {{{1
function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open '" . treenode.path.str() . "'")
call system("open '" . treenode.path.str() . "'")
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,8 +1,6 @@
" ============================================================================
" 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: 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
@ -67,7 +65,14 @@ 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", !nerdtree#runningWindows())
if !nerdtree#runningWindows()
call s:initVariable("g:NERDTreeDirArrowExpandable", "▸")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾")
else
call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
@ -83,8 +88,8 @@ if !exists('g:NERDTreeStatusline')
"the exists() crap here is a hack to stop vim spazzing out when
"loading a session that was created with an open nerd tree. It spazzes
"because it doesnt store b:NERDTreeRoot (its a b: var, and its a hash)
let g:NERDTreeStatusline = "%{exists('b:NERDTreeRoot')?b:NERDTreeRoot.path.str():''}"
"because it doesnt store b:NERDTree(its a b: var, and its a hash)
let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}"
endif
call s:initVariable("g:NERDTreeWinPos", "left")
@ -188,7 +193,7 @@ function! NERDTreeFocus()
if g:NERDTree.IsOpen()
call g:NERDTree.CursorToTreeWin()
else
call g:NERDTreeCreator.TogglePrimary("")
call g:NERDTreeCreator.ToggleTabTree("")
endif
endfunction

View File

@ -22,42 +22,19 @@ syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
if g:NERDTreeDirArrows
syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile
syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile
exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile'
syn match NERDTreeDir #[^▾▸ ].*/#
syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark
syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~')
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'
syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark
exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile'
"highlighting for readonly files
syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile
"highlighting for readonly files
syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir
else
"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
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
"highlighting for readonly files
syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
syn match NERDTreeFlags #-\[.\]# containedin=NERDTreeFile,NERDTreePartFile
syn match NERDTreeFlags #[+~]\zs\[.\]# containedin=NERDTreeDir
endif
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile,NERDTreeExecFile
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir
syn match NERDTreeCWD #^[</].*$#