Compare commits

..

78 Commits

Author SHA1 Message Date
Martin Grenfell
95ee07c9d3 switch version to 2.10.0rc1 2008-06-13 18:46:34 +12:00
Martin Grenfell
b58ccce913 update changelog and credits 2008-06-13 18:46:26 +12:00
Martin Grenfell
b60bcb6cb2 bugfix for :NERDTree when a file bookmark is given 2008-06-13 13:01:05 +12:00
Martin Grenfell
f7e8c453ea make :OpenBookmark open a netrw for dir bookmarks 2008-06-13 12:51:06 +12:00
Martin Grenfell
58ccd230fa refactor the logic out of s:OpenExplorer()
refactor out the code that actually opens the explorer window into
s:OpenExplorerFor(treenode) so that we can call it separately
2008-06-13 12:48:56 +12:00
Martin Grenfell
866df769b5 fix for quickhelp highlighting bug 2008-06-12 22:53:45 +12:00
Martin Grenfell
bd3b03fd79 update doc/changelog 2008-06-12 22:44:31 +12:00
Martin Grenfell
9030ff0312 make the quickhelp narrower so it fits 2008-06-12 22:35:17 +12:00
Martin Grenfell
5172efc976 bugfix: dont render duplicate bookmarks
if a bookmark is created, remove any previously cached bookmark of the
same name from the tree
2008-06-12 22:31:28 +12:00
Martin Grenfell
b252a1250a rename 'marks' to 'bookmarks' 2008-06-12 21:14:07 +12:00
Martin Grenfell
dae5c93fec fix NERDTree-C doc 2008-06-10 23:00:22 +12:00
Martin Grenfell
004b4fc9dd add a note marks to the intro 2008-06-10 23:00:03 +12:00
Martin Grenfell
7614f745ae some fixes/enhancements to the marks doc 2008-06-10 22:57:30 +12:00
Martin Grenfell
585b5f1579 remove trailing whitespace 2008-06-10 22:51:36 +12:00
Martin Grenfell
bc41c51f93 doc :RevealMark 2008-06-10 22:50:52 +12:00
Martin Grenfell
0888f6c011 fix an error in a method header 2008-06-10 22:49:20 +12:00
Martin Grenfell
df8f132d6e update the quickhelp 2008-06-10 22:49:10 +12:00
Martin Grenfell
d7a319c3a6 rename RecallMark to RevealMark 2008-06-10 22:48:31 +12:00
Martin Grenfell
5a45ea08c4 add/update doc for the mark commands 2008-06-10 22:45:10 +12:00
Martin Grenfell
ec7e013150 add some mark quickhelp 2008-06-10 21:53:31 +12:00
Martin Grenfell
5b35d0bb31 bugfix: fix NERDTreeFromMark command
previously it called a nonexisting function
2008-06-10 12:49:14 +12:00
Martin Grenfell
40ccf3cd45 make the mark manipulation funcs use the caching
s:ClearMarks(), s:ClearAllMarks() and s:MarkNode() now use tell the
relevant path objects to update their mark cache
2008-06-09 22:04:31 +12:00
Martin Grenfell
1b17f945a3 refactor s:GetPath() to take marks into account 2008-06-09 21:23:43 +12:00
Martin Grenfell
421431b5df correct a method header comment 2008-06-09 21:22:34 +12:00
Martin Grenfell
26983f1921 make oPath cache the marks associated with it
This is mainly for performance reasons. Calculating the marks anew
everytime oPath#MarkNames() is called greatly increases the rendering
time of the tree. It trippled it for just a handful of marks...
2008-06-09 21:18:30 +12:00
Martin Grenfell
1571274aec refactor the Refresh() method for tree nodes
create a oFileTreeNode#Refresh() and make sure that Refresh() is always
called for dir nodes
2008-06-09 21:13:25 +12:00
Martin Grenfell
a111af5361 merge InitNerdTreeFromMark into InitNerdTree 2008-06-09 18:20:22 +12:00
Martin Grenfell
64514e3ceb make :ClearMarks default to all marks on the current node 2008-06-09 13:21:44 +12:00
Martin Grenfell
bcc690a141 put cursor on the tree root by default 2008-06-09 13:01:48 +12:00
Martin Grenfell
397dee5cb1 remove all trailing whitespace 2008-06-09 12:46:53 +12:00
Martin Grenfell
dbb0677749 add :NERDTreeFromMark and corresponding function 2008-06-09 12:44:05 +12:00
Martin Grenfell
0fed73d83a read marks when vim loads, not when a nerd tree loads 2008-06-09 12:40:04 +12:00
Martin Grenfell
3a437b402a dont call RenderView() inside ReadMarks() 2008-06-09 12:37:20 +12:00
Martin Grenfell
1d9564db54 improve the error handling of RecallMark() 2008-06-08 21:53:25 +12:00
Martin Grenfell
c63e183acf make OpenMark open the mark even if its not cached
if OpenMark is called for a mark for a file that isnt cached in the
tree, just open the file anyway and dont put attempt to put the
cursor on it etc
2008-06-08 21:07:13 +12:00
Martin Grenfell
6334e99192 be silent when opening files 2008-06-08 21:02:54 +12:00
Martin Grenfell
776aeef26f bugfix for oTreeFileNode#MakeRoot()
if MakeRoot is called for a file, make sure that the nodes parent is
initialized
2008-06-08 20:53:43 +12:00
Martin Grenfell
1d6516b96d add oTreeFileNode.CacheParent() 2008-06-08 20:53:12 +12:00
Martin Grenfell
995f7faec3 only attempt to open marks file if it exists 2008-06-08 19:16:38 +12:00
Martin Grenfell
140deac284 add NERDTreeMarksFile global var
NERDTreeMarksFile is full path of the file that stores the marks
2008-06-08 18:42:07 +12:00
Martin Grenfell
6e24eed04a use a script lvl variable for NERDTreeSortStarIndex 2008-06-08 18:30:31 +12:00
Martin Grenfell
82c1fece9f make MarkToRoot() work for nodes that arent cached
now if you go :MarkToRoot foo  and foo points to a path that isnt
cached, a new tree node will be created and made root. Note that all
cached nodes will be lost as this is the same as opening a new nerd tree
2008-06-08 18:24:47 +12:00
Martin Grenfell
371379a860 read and write marks automatically 2008-06-08 17:58:38 +12:00
Martin Grenfell
0a91f3511e add functions and :commands to read/write marks to a file 2008-06-08 17:57:13 +12:00
Martin Grenfell
192424429d make marks global instead of tab based 2008-06-08 17:51:05 +12:00
Martin Grenfell
3092355648 add a modeline 2008-06-08 17:34:22 +12:00
Martin Grenfell
ae50662943 clear all marks when the tree is initialized 2008-06-07 18:12:05 +12:00
Martin Grenfell
8529b6f0e3 add s:ClearAllMark() and refactor to use it 2008-06-07 18:11:48 +12:00
Martin Grenfell
d718f1098c put the cursor on the new root after :MarkToRoot 2008-06-07 18:06:32 +12:00
Martin Grenfell
0501fc825c add :MarkToRoot command and a corresponding function 2008-06-07 17:40:18 +12:00
Martin Grenfell
05ce3ab896 add searchFromAbsoluteRoot flag to s:GetNodeForMark 2008-06-07 17:38:56 +12:00
Martin Grenfell
642c2b76fc add oFileNode#MakeRoot() and refactor s:ChRoot()
not that as of this commit, you can now use the C mapping on a file node
and its parent dir node will become the new root
2008-06-07 17:36:14 +12:00
Martin Grenfell
6b7760e6e4 add s:AbsoluteTreeRoot() 2008-06-07 17:34:45 +12:00
Martin Grenfell
5cafc7018d bugfix to s:GetNodeForMark() 2008-06-07 14:37:39 +12:00
Martin Grenfell
332756282a add :ClearAllMarks 2008-06-07 13:57:02 +12:00
Martin Grenfell
bcc1180510 add :ClearMarks and bind it to s:ClearMarks() 2008-06-07 13:56:41 +12:00
Martin Grenfell
2ecd6ebd63 add s:MarkForNode() and refactor to use it 2008-06-07 12:45:21 +12:00
Martin Grenfell
5a4ef66db2 improve error messages when marks dont exist 2008-06-07 10:12:37 +12:00
Martin Grenfell
a537e1535c some highlighting fixes for marks 2008-06-07 00:43:24 +12:00
Martin Grenfell
44e8534f1f display marks before the symlink target 2008-06-07 00:43:00 +12:00
Martin Grenfell
c108a19881 add a redraw! in s:OpenMark()
if we were opening a mark (with :OpenMark) that was scrolled off the
screen, the tree  window wasnt getting scrolled to the node
2008-06-07 00:24:51 +12:00
Martin Grenfell
5685fa7af4 add :OpenMark command 2008-06-06 23:33:48 +12:00
Martin Grenfell
990706b725 restrict mark names to alphanumeric + underscores 2008-06-06 23:33:01 +12:00
Martin Grenfell
6e60ecfee1 check for nonexistent marks 2008-06-06 23:19:28 +12:00
Martin Grenfell
219d16f61a bugfix for stripping :Mark markup from a line 2008-06-06 23:13:05 +12:00
Martin Grenfell
5fd7441dbe add highlighting for marks 2008-06-06 23:02:37 +12:00
Martin Grenfell
a5f86e1a8f minor fix to method header 2008-06-06 22:55:20 +12:00
Martin Grenfell
782e60efc9 display marks on tree 2008-06-06 22:27:01 +12:00
Martin Grenfell
7b26dac959 add oPath#MarkNames() 2008-06-06 22:26:41 +12:00
Martin Grenfell
600f2cac14 make PutCursorOnNode open ancestors until target node is visible 2008-06-06 13:21:55 +12:00
Martin Grenfell
fb3c4f9212 add marking functionality
add ability to give a node a name and the abiliy to jump back to the
node for a given name
2008-06-05 22:41:05 +12:00
Martin Grenfell
24c1f6beab add recurseUpward arg to s:PutCursorOnNode
makes it attempt to put the cursor on the treenodes parent (recursively)
if the target node is hidden
2008-06-05 22:15:08 +12:00
Martin Grenfell
3e507620fe update changelog 2008-06-03 22:07:31 +12:00
Martin Grenfell
a520080cc3 put cursor on new node after copying 2008-06-03 22:02:59 +12:00
Martin Grenfell
b747086137 strip trailing slashes off copy destination 2008-06-03 22:02:59 +12:00
Martin Grenfell
7a1dbcbdb0 fix a bug with refreshing after copying 2008-06-03 22:02:59 +12:00
Martin Grenfell
ce9fece626 fix screen jumping bug with &scrolloff 2008-05-29 15:27:42 +12:00
Martin Grenfell
90fd47bd00 update the credits 2008-05-17 16:29:50 +12:00
2 changed files with 786 additions and 432 deletions

View File

@@ -2,7 +2,7 @@
omg its ... ~
________ ________ _ ____________ ____ __________ ____________~
/_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~
@@ -21,9 +21,10 @@ CONTENTS *NERDTree-contents*
1.Intro...................................|NERDTree|
2.Functionality provided..................|NERDTreeFunctionality|
2.1 Commands..........................|NERDTreeCommands|
2.2 NERD tree mappings................|NERDTreeMappings|
2.3 The filesystem menu...............|NERDTreeFilesysMenu|
2.1 Global commands...................|NERDTreeGlobalCommands|
2.2 Bookmark commands.................|NERDTreeBookmarkCommands|
2.3 NERD tree mappings................|NERDTreeMappings|
2.4 The filesystem menu...............|NERDTreeFilesysMenu|
3.Options.................................|NERDTreeOptions|
3.1 Option summary....................|NERDTreeOptionSummary|
3.2 Option details....................|NERDTreeOptionDetails|
@@ -57,6 +58,7 @@ The following features and functionality are provided by the NERD tree:
* 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
* Dynamic customisation of tree content
* custom file filters to prevent e.g. vim backup files being displayed
@@ -82,25 +84,69 @@ The following features and functionality are provided by the NERD tree:
2. Functionality provided *NERDTreeFunctionality*
------------------------------------------------------------------------------
2.1. Commands *NERDTreeCommands*
2.1. Global Commands *NERDTreeGlobalCommands*
:NERDTree [start-directory] *:NERDTree*
Opens a fresh NERD tree in [start-directory] or the current
directory if [start-directory] isn't specified.
For example: >
:NERDTree [<start-directory> | <bookmark>] *:NERDTree*
Opens a fresh NERD tree. The root of the tree depends on the argument
given. There are 3 cases: If no argument is given, the current directory
will be used. If a directory is given, that will be used. If a bookmark
name is given, the corresponding directory will be used. For example: >
:NERDTree /home/marty/vim7/src
< will open a NERD tree in /home/marty/vim7/src.
:NERDTree foo (foo is the name of a bookmark)
<
:NERDTreeFromBookmark <bookmark> *:NERDTreeFromBookmark*
Opens a fresh NERD tree with the root initialized to the dir for
<bookmark>. This only reason to use this command over :NERDTree is for
the completion (which is for bookmarks rather than directories).
:NERDTreeToggle [start-directory] *:NERDTreeToggle*
If a NERD tree already exists for this tab, it is reopened and
rendered again. If no NERD tree exists for this tab then this
command acts the same as the |:NERDTree| command.
:NERDTreeToggle [<start-directory> | <bookmark>] *:NERDTreeToggle*
If a NERD tree already exists for this tab, it is reopened and rendered
again. If no NERD tree exists for this tab then this command acts the
same as the |:NERDTree| command.
:NERDTreeClose
Close the NERD tree in this tab.
------------------------------------------------------------------------------
2.2. NERD tree Mappings *NERDTreeMappings*
2.2. Bookmark Commands *NERDTreeBookmarkCommands*
Bookmarks in the NERD tree are a way to tag files or directories of interest.
For example, you could use bookmarks to tag all of your project directories.
See also |:NERDTree| and |:NERDTreeFromBookmark|.
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 consist of alphanumeric
characters and underscores.
:BookmarkToRoot <bookmark>
Make the directory corresponding to <bookmark> the new root. If a treenode
corresponding to <bookmark> is already cached somewhere in the tree then
the current tree will be used, otherwise a fresh tree will be opened.
Note that if <bookmark> points to a file then its parent will be used
instead.
:RevealBookmark <bookmark>
If the node is cached under the current root then it will be revealed
(i.e. directory nodes above it will be opened) and the cursor will be
placed on it.
:OpenBookmark <bookmark>
<bookmark> must point to a file. The file is opened as though |NERDTree-o|
was applied. If the node is cached under the current root then it will be
revealed and the cursor will be placed on it.
:ClearBookmarks [<bookmarks>]
Remove all the given bookmarks. If no bookmarks are given then remove all
bookmarks on the current node.
:ClearAllBookmarks
Remove all bookmarks.
------------------------------------------------------------------------------
2.3. NERD tree Mappings *NERDTreeMappings*
Default Description~ help-tag~
Key~
@@ -315,7 +361,8 @@ Default key: C
Map option: NERDTreeMapChdir
Applies to: directories.
Made the selected directory node the new tree root.
Make the selected directory node the new tree root. If a file is selected, its
parent is used.
------------------------------------------------------------------------------
*NERDTree-u*
@@ -472,6 +519,8 @@ NERD tree. These options should be set in your vimrc.
|NERDTreeIgnore| Tells the NERD tree which files to ignore.
|NERDTreeBookmarksFile| Where the bookmarks are stored.
|NERDTreeMouseMode| Tells the NERD tree how to handle mouse
clicks.
@@ -620,6 +669,13 @@ line: >
The file filters can be turned on and off dynamically with the |NERDTree-f|
mapping.
------------------------------------------------------------------------------
*NERDTreeBookmarksFile*
Values: a path
Default: $HOME/.NERDTreeBookmarks
This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
------------------------------------------------------------------------------
*NERDTreeMouseMode*
Values: 1, 2 or 3.
@@ -784,6 +840,13 @@ fridge for later ;)
==============================================================================
7. Changelog *NERDTreeChangelog*
2.10.0
- added bookmarks, see :help NERDTreeBookmarkCommands for details. Thanks
to Piotr Czachur for all his testing and suggestions.
- fixed screen jumping bug with when &scrolloff != 0
- fixed some bugs with copying nodes
- other random fixes
2.9.0
- path handling improvements, thanks to Zhang Shuhan for heaps of
@@ -1014,3 +1077,9 @@ NERD tree window optional.
Thanks to Zhang Shuhan for all of his emails and testing to help improve the
NERD tree path handling.
Thanks to Cory Echols for sending a patch to add the :NERDTreeClose command and
set the NERD tree buffers filetype to 'nerdtree'
Thanks to Piotr Czachur for all his suggestions and testing for the bookmarks
feature.

View File

@@ -1,7 +1,7 @@
" vim global plugin that provides a nice tree explorer
" Last Change: 17 May 2008
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
let s:NERD_tree_version = '2.9.0'
let s:NERD_tree_version = '2.10.0rc1'
" SECTION: Script init stuff {{{1
"============================================================
@@ -41,6 +41,7 @@ if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$']
endif
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
call s:InitVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
call s:InitVariable("g:NERDTreeMouseMode", 1)
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
call s:InitVariable("g:NERDTreeShowFiles", 1)
@@ -59,7 +60,7 @@ endif
"we need to use this number many times for sorting... so we calculate it only
"once here
let g:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
call s:InitVariable("g:NERDTreeSplitVertical", 1)
call s:InitVariable("g:NERDTreeWinPos", 1)
@@ -140,10 +141,13 @@ endif
command! -n=? -complete=dir NERDTree :call s:InitNerdTree('<args>')
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen()
command! -n=1 -complete=customlist,s:FindBookmarks NERDTreeFromBookmark call s:InitNerdTree('<args>')
" SECTION: Auto commands {{{1
"============================================================
"Save the cursor position whenever we close the nerd tree
exec "autocmd BufWinLeave *". s:NERDTreeWinName ."* :call <SID>SaveScreenState()"
"cache bookmarks when vim loads
autocmd VimEnter * call <SID>ReadBookmarks()
"SECTION: Classes {{{1
"============================================================
@@ -153,6 +157,17 @@ exec "autocmd BufWinLeave *". s:NERDTreeWinName ."* :call <SID>SaveScreenState()
"classes.
"============================================================
let s:oTreeFileNode = {}
"FUNCTION: oTreeFileNode.CacheParent {{{3
"initializes self.parent if it isnt already
function! s:oTreeFileNode.CacheParent() dict
if empty(self.parent)
let parentPath = self.path.GetParent()
if parentPath.Equals(self.path)
throw "NERDTree.CannotCacheParent exception: already at root"
endif
let self.parent = s:oTreeFileNode.New(parentPath)
endif
endfunction
"FUNCTION: oTreeFileNode.CompareNodes {{{3
"This is supposed to be a class level method but i cant figure out how to
"get func refs to work from a dict..
@@ -165,14 +180,25 @@ function! s:CompareNodes(n1, n2)
return a:n1.path.CompareTo(a:n2.path)
endfunction
"FUNCTION: oTreeFileNode.ClearBookmarks() {{{3
function! s:oTreeFileNode.ClearBookmarks() dict
let bookmarks = s:GetBookmarks()
for i in keys(bookmarks)
if bookmarks[i].Equals(self.path)
call remove(bookmarks, i)
end
endfor
call self.path.CacheBookmarkNames()
endfunction
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
function! s:oTreeFileNode.Copy(dest) dict
call self.path.Copy(a:dest)
let newPath = s:oPath.New(a:dest)
let parentNode = t:NERDTreeRoot.FindNode(newPath.GetDir())
if !empty(parentNode)
call parentNode.Refresh()
let parent = t:NERDTreeRoot.FindNode(newPath.GetParent())
if !empty(parent)
call parent.Refresh()
endif
return parent.FindNode(newPath)
endfunction
"FUNCTION: oTreeFileNode.Delete {{{3
@@ -289,6 +315,23 @@ function! s:oTreeFileNode.IsRoot() dict
return self.Equals(t:NERDTreeRoot)
endfunction
"FUNCTION: oTreeFileNode.MakeRoot() {{{3
"Make this node the root of the tree
function! s:oTreeFileNode.MakeRoot() dict
if self.path.isDirectory
let t:NERDTreeRoot = self
else
call self.CacheParent()
let t:NERDTreeRoot = self.parent
endif
call t:NERDTreeRoot.Open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode == 2
exec "cd " . t:NERDTreeRoot.path.StrForEditCmd()
endif
endfunction
"FUNCTION: oTreeFileNode.New(path) {{{3
"Returns a new TreeNode object with the given path and parent
"
@@ -306,6 +349,10 @@ function! s:oTreeFileNode.New(path) dict
endif
endfunction
"FUNCTION: oTreeFileNode.Refresh {{{3
function! s:oTreeFileNode.Refresh() dict
call self.path.Refresh()
endfunction
"FUNCTION: oTreeFileNode.Rename {{{3
"Calls the rename method for this nodes path obj
function! s:oTreeFileNode.Rename(newName) dict
@@ -659,11 +706,15 @@ function! s:oTreeDirNode.OpenRecursively2(forceOpen) dict
endfunction
"FUNCTION: oTreeDirNode.Refresh {{{3
unlet s:oTreeDirNode.Refresh
function! s:oTreeDirNode.Refresh() dict
call self.path.Refresh()
"if this node was ever opened, refresh its children
if self.isOpen || !empty(self.children)
"go thru all the files/dirs under this node
let newChildNodes = []
let invalidFilesFound = 0
"go thru all the files/dirs under this node
let dir = self.path
let filesStr = globpath(dir.StrForGlob(), '*') . "\n" . globpath(dir.StrForGlob(), '.*')
let files = split(filesStr, "\n")
@@ -675,17 +726,7 @@ function! s:oTreeDirNode.Refresh() dict
let path = s:oPath.New(i)
let newNode = self.GetChild(path)
if newNode != {}
"if the existing node is a dir can be refreshed then
"refresh it
if newNode.path.isDirectory && (!empty(newNode.children) || newNode.isOpen == 1)
call newNode.Refresh()
"if we have a filenode then refresh the path
elseif newNode.path.isDirectory == 0
call newNode.path.Refresh()
endif
call add(newChildNodes, newNode)
"the node doesnt exist so create it
@@ -709,6 +750,7 @@ function! s:oTreeDirNode.Refresh() dict
if invalidFilesFound
call s:EchoWarning("some files could not be loaded into the NERD tree")
endif
endif
endfunction
"FUNCTION: oTreeDirNode.RemoveChild {{{3
@@ -771,6 +813,24 @@ endfunction
"============================================================
let s:oPath = {}
let oPath = s:oPath
"FUNCTION: oPath.BookmarkNames() {{{3
function! s:oPath.BookmarkNames() dict
if !exists("self.bookmarkNames")
call self.CacheBookmarkNames()
endif
return self.bookmarkNames
endfunction
"FUNCTION: oPath.CacheBookmarkNames() {{{3
function! s:oPath.CacheBookmarkNames() dict
let self.bookmarkNames = []
let bookmarks = s:GetBookmarks()
for k in keys(bookmarks)
if bookmarks[k].Equals(self)
call add(self.bookmarkNames, k)
endif
endfor
return self.bookmarkNames
endfunction
"FUNCTION: oPath.ChangeToDir() {{{3
function! s:oPath.ChangeToDir() dict
let dir = self.StrForCd()
@@ -1018,7 +1078,7 @@ function! s:oPath.GetSortOrderIndex() dict
endif
let i = i + 1
endwhile
return g:NERDTreeSortStarIndex
return s:NERDTreeSortStarIndex
endfunction
"FUNCTION: oPath.Ignore() {{{3
@@ -1127,6 +1187,7 @@ endfunction
"FUNCTION: oPath.Refresh() {{{3
function! s:oPath.Refresh() dict
call self.ReadInfoFromDisk(self.StrForOS(0))
call self.CacheBookmarkNames()
endfunction
"FUNCTION: oPath.Rename() {{{3
@@ -1195,6 +1256,11 @@ endfunction
function! s:oPath.StrDisplay() dict
let toReturn = self.GetLastPathComponent(1)
let bookmarks = self.BookmarkNames()
if !empty(bookmarks)
let toReturn .= ' {' . join(bookmarks, ',') . '}'
endif
if self.isSymLink
let toReturn .= ' -> ' . self.symLinkDest
endif
@@ -1269,6 +1335,15 @@ function! s:oPath.StrTrunk() dict
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
endfunction
"FUNCTION: oPath.UncacheBookmark(name){{{3
"remove the given bookmark from this paths cached bookmarks
function! s:oPath.UncacheBookmark(name) dict
let bookmarks = self.BookmarkNames()
let i = index(bookmarks, a:name)
if i != -1
echo remove(bookmarks, i)
endif
endfunction
"FUNCTION: oPath.WinToUnixPath(pathstr){{{3
"Takes in a windows path and returns the unix equiv
"
@@ -1303,7 +1378,15 @@ function! s:Abs(num)
return 0 - a:num
end
endfunction
"FUNCTION: s:AbsoluteTreeRoot(){{{2
" returns the highest cached ancestor of the current root
function! s:AbsoluteTreeRoot()
let currentNode = t:NERDTreeRoot
while currentNode.parent != {}
let currentNode = currentNode.parent
endwhile
return currentNode
endfunction
"FUNCTION: s:BufInWindows(bnum){{{2
"[[STOLEN FROM VTREEEXPLORER.VIM]]
"Determine the number of windows open to this buffer number.
@@ -1328,21 +1411,65 @@ function! s:BufInWindows(bnum)
return cnt
endfunction " >>>
"FUNCTION: s:InitNerdTree(dir) {{{2
"Initialized the NERD tree, where the root will be initialized with the given
"directory
"FUNCTION: s:ClearAllBookmarks() {{{2
"delete all bookmarks
function! s:ClearAllBookmarks()
for name in keys(g:NERDTreeBookmarks)
let node = {}
try
let node = s:GetNodeForBookmark(name, 1)
catch /NERDTree/
endtry
call remove(g:NERDTreeBookmarks, name)
if !empty(node)
call node.path.CacheBookmarkNames()
endif
endfor
call s:WriteBookmarks()
endfunction
"FUNCTION: s:GetNodeForBookmark(name, searchFromAbsoluteRoot) {{{2
"get the treenode for the bookmark with the given name
"
"Arg:
"dir: the dir to init the root with
function! s:InitNerdTree(dir)
let dir = a:dir == '' ? expand('%:p:h') : a:dir
"Args:
"name: name of bookmark
"searchFromAbsoluteRoot: specifies wheather we should search from the current
"tree root, or the highest cached node
function! s:GetNodeForBookmark(name, searchFromAbsoluteRoot)
try
let bookmark = s:GetBookmarks()[a:name]
catch /E716/ "key not in dictionary error
throw "NERDTree.BookmarkDoesntExist no bookmark found with name: " . a:name
endtry
let searchRoot = a:searchFromAbsoluteRoot ? s:AbsoluteTreeRoot() : t:NERDTreeRoot
let targetNode = searchRoot.FindNode(bookmark)
if empty(targetNode)
throw "NERDTree.BookmarkNotFound no node was found for bookmark: " . a:name
endif
return targetNode
endfunction
"FUNCTION: s:InitNerdTree(name) {{{2
"Initialise the nerd tree for this tab. The tree will start in either the
"given directory, or the directory associated with the given bookmark
"
"Args:
"name: the name of a bookmark or a directory
function! s:InitNerdTree(name)
let path = {}
if count(keys(s:GetBookmarks()), a:name)
let path = s:GetBookmarks()[a:name]
else
let dir = a:name == '' ? expand('%:p:h') : a:name
let dir = resolve(dir)
try
let path = s:oPath.New(dir)
if !path.isDirectory
call s:EchoWarning("Error reading: " . dir)
catch /NERDTree.Path.InvalidArguments/
call s:Echo("No bookmark or directory found for: " . a:name)
return
endtry
endif
if !path.isDirectory
let path = path.GetParent()
endif
"if instructed to, then change the vim CWD to the dir the NERDTree is
@@ -1365,15 +1492,35 @@ function! s:InitNerdTree(dir)
call t:NERDTreeRoot.Open()
call s:CreateTreeWin()
call s:RenderView()
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
endfunction
" Function: s:ReadBookmarks() {{{2
function! s:ReadBookmarks()
if filereadable(g:NERDTreeBookmarksFile)
let bookmarks = s:GetBookmarks()
let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
for i in bookmarkStrings
let key = substitute(i, '^\(\w.\{-}\) .*$', '\1', '')
let path = substitute(i, '^\w.\{-} \(.*\)$', '\1', '')
let bookmarks[key] = s:oPath.New(path)
endfor
endif
endfunction
" Function: s:TreeExistsForTab() {{{2
" Returns 1 if a nerd tree root exists in the current tab
function! s:TreeExistsForTab()
return exists("t:NERDTreeRoot")
endfunction
" Function: s:WriteBookmarks() {{{2
function! s:WriteBookmarks()
let bookmarks = s:GetBookmarks()
let bookmarkStrings = []
for k in keys(bookmarks)
call add(bookmarkStrings, k . ' ' . bookmarks[k].StrForOS(0))
endfor
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
endfunction
" SECTION: Public Functions {{{1
"============================================================
@@ -1596,7 +1743,7 @@ function! s:DumpHelp()
let @h=@h."\" \n\" ----------------------------\n"
let @h=@h."\" Directory node mappings~\n"
let @h=@h."\" ". (g:NERDTreeMouseMode == 1 ? "double" : "single") ."-click,\n"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open/close node \n"
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n"
@@ -1637,6 +1784,14 @@ function! s:DumpHelp()
let @h=@h."\" Other mappings~\n"
let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
let @h=@h."\" \n\" ----------------------------\n"
let @h=@h."\" Bookmark commands~\n"
let @h=@h."\" :Bookmark <name>\n"
let @h=@h."\" :BookmarkToRoot <name>\n"
let @h=@h."\" :RevealBookmark <name>\n"
let @h=@h."\" :OpenBookmark <name>\n"
let @h=@h."\" :ClearBookmarks [<names>]\n"
let @h=@h."\" :ClearAllBookmarks\n"
else
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
endif
@@ -1672,6 +1827,12 @@ function! s:EchoError(msg)
call s:Echo(a:msg)
echohl normal
endfunction
" FUNCTION: s:FindBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
function! s:FindBookmarks(A,L,P)
let keys = keys(s:GetBookmarks())
return filter(keys, 'v:val =~ "^' . a:A . '"')
endfunction
"FUNCTION: s:FindNodeLineNumber(treenode){{{2
"Finds the line number for the given tree node
"
@@ -1724,7 +1885,7 @@ function! s:FindNodeLineNumber(treenode)
return -1
endfunction
"FUNCTION: s:FindRootNodeLineNumber(path){{{2
"FUNCTION: s:FindRootNodeLineNumber(){{{2
"Finds the line number of the root node
function! s:FindRootNodeLineNumber()
let rootLine = 1
@@ -1734,6 +1895,14 @@ function! s:FindRootNodeLineNumber()
return rootLine
endfunction
" FUNCTION: s:GetBookmarks(name) {{{2
" getter/lazy initializer for the g:NERDTreeBookmarks hash
function! s:GetBookmarks()
if !exists("g:NERDTreeBookmarks")
let g:NERDTreeBookmarks = {}
endif
return g:NERDTreeBookmarks
endfunction
"FUNCTION: s:GetPath(ln) {{{2
"Gets the full path to the node that is rendered on the given line number
"
@@ -1772,9 +1941,6 @@ function! s:GetPath(ln)
let wasdir = 0
if curFile =~ '/$'
let wasdir = 1
endif
let curFile = substitute (curFile,' -> .*',"","") " remove link to
if wasdir == 1
let curFile = substitute(curFile, '/\?$', '/', "")
endif
@@ -1784,24 +1950,19 @@ function! s:GetPath(ln)
while lnum > 0
let lnum = lnum - 1
let curLine = getline(lnum)
let curLineStripped = s:StripMarkupFromLine(curLine, 1)
"have we reached the top of the tree?
if curLine =~ '^/'
let sd = substitute (curLine, '[ ]*$', "", "")
let dir = sd . dir
let dir = substitute (curLine, ' *$', "", "") . dir
break
endif
if curLine =~ '/$'
if curLineStripped =~ '/$'
let lpindent = match(curLine,s:tree_markup_reg_neg) / s:tree_wid
if lpindent < indent
let indent = indent - 1
let sd = substitute (curLine, '^' . s:tree_markup_reg . '*',"","")
let sd = substitute (sd, ' -> .*', '',"")
" remove leading escape
let sd = substitute (sd,'^\\', "", "")
let dir = sd . dir
let dir = substitute (curLineStripped,'^\\', "", "") . dir
continue
endif
endif
@@ -1885,7 +2046,7 @@ function! s:JumpToChild(direction)
endif
endif
call s:PutCursorOnNode(targetNode, 1)
call s:PutCursorOnNode(targetNode, 1, 0)
call s:CenterView()
endfunction
@@ -1903,6 +2064,18 @@ function! s:OpenDirNodeSplit(treenode)
endif
endfunction
" FUNCTION: s:OpenExplorerFor(treenode) {{{2
" opens a netrw window for the given dir treenode
function! s:OpenExplorerFor(treenode)
let oldwin = winnr()
wincmd p
if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2)
wincmd p
call s:OpenDirNodeSplit(a:treenode)
else
exec ("silent edit " . a:treenode.path.StrForEditCmd())
endif
endfunction
"FUNCTION: s:OpenFileNode(treenode) {{{2
"Open the file represented by the given node in the current window, splitting
"the window if needed
@@ -1917,7 +2090,7 @@ function! s:OpenFileNode(treenode)
else
try
wincmd p
exec ("edit " . a:treenode.path.StrForEditCmd())
silent exec ("edit " . a:treenode.path.StrForEditCmd())
catch /^Vim\%((\a\+)\)\=:E37/
call s:PutCursorInTreeWin()
call s:Echo("Cannot open file, it is already open and modified")
@@ -2041,19 +2214,31 @@ function! s:PromptToDelBuffer(bufnum, msg)
endif
endfunction
"FUNCTION: s:PutCursorOnNode(treenode, is_jump){{{2
"FUNCTION: s:PutCursorOnNode(treenode, isJump, recurseUpward){{{2
"Places the cursor on the line number representing the given node
"
"Args:
"treenode: the node to put the cursor on
"is_jump: 1 if this cursor movement should be counted as a jump by vim
function! s:PutCursorOnNode(treenode, is_jump)
"isJump: 1 if this cursor movement should be counted as a jump by vim
"recurseUpward: try to put the cursor on the parent if the this node isnt
"visible
function! s:PutCursorOnNode(treenode, isJump, recurseUpward)
let ln = s:FindNodeLineNumber(a:treenode)
if ln != -1
if a:is_jump
if a:isJump
mark '
endif
call cursor(ln, col("."))
else
if a:recurseUpward
let node = a:treenode
while s:FindNodeLineNumber(node) == -1 && node != {}
let node = node.parent
call node.Open()
endwhile
call s:RenderView()
call s:PutCursorOnNode(a:treenode, a:isJump, 0)
endif
endif
endfunction
@@ -2107,9 +2292,12 @@ function! s:RenderView()
:silent 1,1delete _
"restore the view
let old_scrolloff=&scrolloff
let &scrolloff=0
call cursor(topLine, 1)
normal! zt
call cursor(curLine, curCol)
let &scrolloff = old_scrolloff
setlocal nomodifiable
endfunction
@@ -2129,7 +2317,7 @@ function! s:RenderViewSavingPosition()
call s:RenderView()
if currentNode != {}
call s:PutCursorOnNode(currentNode, 0)
call s:PutCursorOnNode(currentNode, 0, 0)
endif
endfunction
"FUNCTION: s:RestoreScreenState() {{{2
@@ -2185,19 +2373,23 @@ function! s:SetupSyntaxHighlighting()
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 treeHelp #^" .*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn
syn match treeHelpCommand #" :.\{-}\>#hs=s+3
syn match treeHelp #^" .*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
"highlighting for sym links
syn match treeLink #[^-| `].* -> #
syn match treeLink #[^-| `].* -> # contains=treeBookmark
"highlighting for readonly files
syn match treeRO #[0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag
syn match treeRO #[0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag,treeBookmark
"highlighting for bookmarks
syn match treeBookmark # {.*}#hs=s+1
"highlighing for directory nodes and file nodes
syn match treeDirSlash #/#
syn match treeDir #[^-| `].*/\([ {}]\{4\}\)*$# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile
syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile
syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
syn match treeCWD #^/.*$#
if g:NERDChristmasTree
@@ -2215,6 +2407,7 @@ function! s:SetupSyntaxHighlighting()
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
@@ -2226,6 +2419,7 @@ function! s:SetupSyntaxHighlighting()
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
@@ -2249,7 +2443,7 @@ function! s:ShouldSplitToOpen(winnumber)
return winnr("$") == 1 || (modified && s:BufInWindows(winbufnr(a:winnumber)) < 2)
endfunction
"FUNCTION: s:StripMarkupFromLine(line){{{2
"FUNCTION: s:StripMarkupFromLine(line, removeLeadingSpaces){{{2
"returns the given line with all the tree parts stripped off
"
"Args:
@@ -2264,6 +2458,9 @@ function! s:StripMarkupFromLine(line, removeLeadingSpaces)
"strip off any read only flag
let line = substitute (line, s:tree_RO_str_reg, "","")
"strip off any bookmark flags
let line = substitute (line, ' {[^}]*}', "","")
let wasdir = 0
if line =~ '/$'
let wasdir = 1
@@ -2319,7 +2516,7 @@ function! s:ActivateNode()
if treenode.path.isDirectory
call treenode.ToggleOpen()
call s:RenderView()
call s:PutCursorOnNode(treenode, 0)
call s:PutCursorOnNode(treenode, 0, 0)
else
call s:OpenFileNode(treenode)
endif
@@ -2375,8 +2572,56 @@ function! s:BindMappings()
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenNodeNewTab(1)<cr>"
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
command! -buffer -nargs=1 Bookmark :call <SID>BookmarkNode('<args>')
command! -buffer -complete=customlist,s:FindBookmarks -nargs=1 RevealBookmark :call <SID>RevealBookmark('<args>')
command! -buffer -complete=customlist,s:FindBookmarks -nargs=1 OpenBookmark :call <SID>OpenBookmark('<args>')
command! -buffer -complete=customlist,s:FindBookmarks -nargs=* ClearBookmarks call <SID>ClearBookmarks('<args>')
command! -buffer -complete=customlist,s:FindBookmarks -nargs=+ BookmarkToRoot call <SID>BookmarkToRoot('<args>')
command! -buffer -nargs=0 ClearAllBookmarks call <SID>ClearAllBookmarks() <bar> call <SID>RenderView()
command! -buffer -nargs=0 ReadBookmarks call <SID>ReadBookmarks() <bar> call <SID>RenderView()
command! -buffer -nargs=0 WriteBookmarks call <SID>WriteBookmarks()
endfunction
" FUNCTION: s:BookmarkNode(name) {{{2
" Associate the current node with the given name
function! s:BookmarkNode(name)
if a:name !~ '^[0-9a-zA-Z_]*$'
call s:Echo("Bookmarks must be named using numbers, letters and underscores only")
return
endif
let currentNode = s:GetSelectedNode()
if currentNode != {}
try
let oldMarkedNode = s:GetNodeForBookmark(a:name, 1)
call oldMarkedNode.path.UncacheBookmark(a:name)
catch /NERDTree.Bookmark\(DoesntExist\|NotFound\)/
endtry
let bookmarks = s:GetBookmarks()
let bookmarks[a:name] = currentNode.path
call currentNode.path.CacheBookmarkNames()
call s:WriteBookmarks()
call s:RenderView()
else
call s:Echo("select a node first")
endif
endfunction
" FUNCTION: s:BookmarkToRoot(name) {{{2
" Make the node for the given bookmark the new tree root
function! s:BookmarkToRoot(name)
try
let targetNode = s:GetNodeForBookmark(a:name, 1)
catch /NERDTree.BookmarkNotFound/
let bookmarks = s:GetBookmarks()
let targetNode = s:oTreeFileNode.New(bookmarks[a:name])
endtry
call targetNode.MakeRoot()
call s:RenderView()
call s:PutCursorOnNode(targetNode, 0, 0)
endfunction
"FUNCTION: s:CheckForActivate() {{{2
"Checks if the click should open the current node, if so then activate() is
"called (directories are automatically opened if the symbol beside them is
@@ -2425,27 +2670,42 @@ endfunction
" changes the current root to the selected one
function! s:ChRoot()
let treenode = s:GetSelectedNode()
if treenode == {} || treenode.path.isDirectory == 0
call s:Echo("Select a directory node first")
if treenode == {}
call s:Echo("Select a node first")
return
endif
if treenode.isOpen == 0
call treenode.Open()
endif
let t:NERDTreeRoot = treenode
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode == 2
exec "cd " . treenode.path.StrForEditCmd()
endif
call treenode.MakeRoot()
call s:RenderView()
call s:PutCursorOnNode(t:NERDTreeRoot, 0)
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
endfunction
" FUNCTION: s:ClearBookmarks(bookmarks) {{{2
function! s:ClearBookmarks(bookmarks)
let bookmarks = s:GetBookmarks()
if a:bookmarks == ''
let currentNode = s:GetSelectedNode()
if currentNode != {}
call currentNode.ClearBookmarks()
endif
else
for name in split(a:bookmarks, ' ')
if count(keys(bookmarks), name)
let node = {}
try
let node = s:GetNodeForBookmark(name, 1)
catch /NERDTree/
endtry
call remove(bookmarks, name)
if !empty(node)
call node.path.CacheBookmarkNames()
endif
endif
endfor
endif
call s:WriteBookmarks()
call s:RenderView()
endfunction
" FUNCTION: s:CloseChildren() {{{2
" closes all childnodes of the current node
function! s:CloseChildren()
@@ -2457,7 +2717,7 @@ function! s:CloseChildren()
call currentNode.CloseChildren()
call s:RenderView()
call s:PutCursorOnNode(currentNode, 0)
call s:PutCursorOnNode(currentNode, 0, 0)
endfunction
" FUNCTION: s:CloseCurrentDir() {{{2
" closes the parent dir of the current node
@@ -2474,7 +2734,7 @@ function! s:CloseCurrentDir()
else
call treenode.parent.Close()
call s:RenderView()
call s:PutCursorOnNode(treenode.parent, 0)
call s:PutCursorOnNode(treenode.parent, 0, 0)
endif
endfunction
@@ -2492,6 +2752,9 @@ function! s:CopyNode()
\ "", currentNode.path.Str(0))
if newNodePath != ""
"strip trailing slash
let newNodePath = substitute(newNodePath, '\/$', '', '')
let confirmed = 1
if currentNode.path.CopyingWillOverwrite(newNodePath)
echo "\nWarning: copying may overwrite files! Continue? (yN)"
@@ -2501,12 +2764,13 @@ function! s:CopyNode()
if confirmed
try
call currentNode.Copy(newNodePath)
let newNode = currentNode.Copy(newNodePath)
call s:RenderView()
call s:PutCursorOnNode(newNode, 0, 0)
catch /^NERDTree/
call s:EchoWarning("Could not copy node")
endtry
endif
call s:RenderView()
else
call s:Echo("Copy aborted.")
endif
@@ -2635,7 +2899,7 @@ function! s:InsertNewNode()
if parentNode.isOpen || !empty(parentNode.children)
call parentNode.AddChild(newTreeNode, 1)
call s:RenderView()
call s:PutCursorOnNode(newTreeNode, 1)
call s:PutCursorOnNode(newTreeNode, 1, 0)
endif
catch /^NERDTree/
call s:EchoWarning("Node Not Created.")
@@ -2660,7 +2924,7 @@ function! s:JumpToParent()
let currentNode = s:GetSelectedNode()
if !empty(currentNode)
if !empty(currentNode.parent)
call s:PutCursorOnNode(currentNode.parent, 1)
call s:PutCursorOnNode(currentNode.parent, 1, 0)
call s:CenterView()
else
call s:Echo("cannot jump to parent")
@@ -2673,7 +2937,7 @@ endfunction
" FUNCTION: s:JumpToRoot() {{{2
" moves the cursor to the root node
function! s:JumpToRoot()
call s:PutCursorOnNode(t:NERDTreeRoot, 1)
call s:PutCursorOnNode(t:NERDTreeRoot, 1, 0)
call s:CenterView()
endfunction
@@ -2700,7 +2964,7 @@ function! s:JumpToSibling(forward)
endif
if !empty(sibling)
call s:PutCursorOnNode(sibling, 1)
call s:PutCursorOnNode(sibling, 1, 0)
call s:CenterView()
endif
else
@@ -2708,6 +2972,24 @@ function! s:JumpToSibling(forward)
endif
endfunction
" FUNCTION: s:OpenBookmark(name) {{{2
" put the cursor on the given bookmark and, if its a file, open it
function! s:OpenBookmark(name)
try
let targetNode = s:GetNodeForBookmark(a:name, 0)
call s:PutCursorOnNode(targetNode, 0, 1)
redraw!
catch /NERDTree.BookmarkNotFound/
call s:Echo("note - target node is not cached")
let bookmarks = s:GetBookmarks()
let targetNode = s:oTreeFileNode.New(bookmarks[a:name])
endtry
if targetNode.path.isDirectory
call s:OpenExplorerFor(targetNode)
else
call s:OpenFileNode(targetNode)
endif
endfunction
" FUNCTION: s:OpenEntrySplit() {{{2
" Opens the currently selected file from the explorer in a
" new window
@@ -2724,14 +3006,7 @@ endfunction
function! s:OpenExplorer()
let treenode = s:GetSelectedDir()
if treenode != {}
let oldwin = winnr()
wincmd p
if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2)
wincmd p
call s:OpenDirNodeSplit(treenode)
else
exec ("silent edit " . treenode.path.StrForEditCmd())
endif
call s:OpenExplorerFor(treenode)
else
call s:Echo("select a node first")
endif
@@ -2789,6 +3064,16 @@ function! s:PreviewNode(openNewWin)
call s:PutCursorInTreeWin()
endfunction
" FUNCTION: s:RevealBookmark(name) {{{2
" put the cursor on the node associate with the given name
function! s:RevealBookmark(name)
try
let targetNode = s:GetNodeForBookmark(a:name, 0)
call s:PutCursorOnNode(targetNode, 0, 1)
catch /NERDTree.BookmarkDoesntExist/
call s:Echo("Bookmark isnt cached under the current root")
endtry
endfunction
" FUNCTION: s:RefreshRoot() {{{2
" Reloads the current root. All nodes below this will be lost and the root dir
" will be reloaded.
@@ -2847,7 +3132,7 @@ function! s:RenameCurrent()
call s:PromptToDelBuffer(bufnum, prompt)
endif
call s:PutCursorOnNode(curNode, 1)
call s:PutCursorOnNode(curNode, 1, 0)
redraw
catch /^NERDTree/
@@ -2944,8 +3229,8 @@ function! s:UpDir(keepState)
endif
call s:RenderView()
call s:PutCursorOnNode(oldRoot, 0)
call s:PutCursorOnNode(oldRoot, 0, 0)
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker: