mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0620b91efa | ||
|
|
ea4d4ff80d | ||
|
|
45c33fe0f6 | ||
|
|
fe249e20b9 | ||
|
|
e819e13a5d | ||
|
|
5c95fbda65 | ||
|
|
3e217115bc | ||
|
|
5d564fdbcf | ||
|
|
8184b964bc | ||
|
|
0daeebc0eb | ||
|
|
5939fdb140 | ||
|
|
9dd850b672 | ||
|
|
21601d9c3d | ||
|
|
332a1baedd | ||
|
|
e8aadb77b8 | ||
|
|
31c1faea32 | ||
|
|
818a53003e | ||
|
|
78419f858c | ||
|
|
b1d10a12fa | ||
|
|
f404cdd54b | ||
|
|
c463234452 | ||
|
|
b1020ad9c8 | ||
|
|
0ad0d195e5 | ||
|
|
43bf05c42e | ||
|
|
236df49362 | ||
|
|
bccd73c8f5 | ||
|
|
fd487dfa5c |
@@ -25,6 +25,7 @@ CONTENTS *NERDTree-contents*
|
|||||||
2.2 Bookmarks.........................|NERDTreeBookmarks|
|
2.2 Bookmarks.........................|NERDTreeBookmarks|
|
||||||
2.2.1 The bookmark table..........|NERDTreeBookmarkTable|
|
2.2.1 The bookmark table..........|NERDTreeBookmarkTable|
|
||||||
2.2.2 Bookmark commands...........|NERDTreeBookmarkCommands|
|
2.2.2 Bookmark commands...........|NERDTreeBookmarkCommands|
|
||||||
|
2.2.3 Invalid bookmarks...........|NERDTreeInvalidBookmarks|
|
||||||
2.3 NERD tree mappings................|NERDTreeMappings|
|
2.3 NERD tree mappings................|NERDTreeMappings|
|
||||||
2.4 The filesystem menu...............|NERDTreeFilesysMenu|
|
2.4 The filesystem menu...............|NERDTreeFilesysMenu|
|
||||||
3.Options.................................|NERDTreeOptions|
|
3.Options.................................|NERDTreeOptions|
|
||||||
@@ -158,8 +159,27 @@ Note that the following commands are only available in the NERD tree buffer.
|
|||||||
:ClearAllBookmarks
|
:ClearAllBookmarks
|
||||||
Remove all bookmarks.
|
Remove all bookmarks.
|
||||||
|
|
||||||
|
:ReadBookmarks
|
||||||
|
Re-read the bookmarks in the |NERDTreeBookmarksFile|.
|
||||||
|
|
||||||
See also |:NERDTree| and |:NERDTreeFromBookmark|.
|
See also |:NERDTree| and |:NERDTreeFromBookmark|.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks*
|
||||||
|
|
||||||
|
If invalid bookmarks are detected, the script will issue an error message and
|
||||||
|
the invalid bookmarks will become unavailable for use.
|
||||||
|
|
||||||
|
These bookmarks will still be stored in the bookmarks file (see
|
||||||
|
|NERDTreeBookmarksFile|), down the bottom. There will always be a blank line
|
||||||
|
after the valid bookmarks but before the invalid ones.
|
||||||
|
|
||||||
|
Each line in the bookmarks file represents one bookmark. The proper format is:
|
||||||
|
<bookmark name><space><full path to the bookmark location>
|
||||||
|
|
||||||
|
After you have corrected any invalid bookmarks, either restart vim, or go
|
||||||
|
:ReadBookmarks from the NERD tree window.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.3. NERD tree Mappings *NERDTreeMappings*
|
2.3. NERD tree Mappings *NERDTreeMappings*
|
||||||
|
|
||||||
@@ -240,8 +260,8 @@ Default key: t
|
|||||||
Map option: NERDTreeMapOpenInTab
|
Map option: NERDTreeMapOpenInTab
|
||||||
Applies to: files and directories.
|
Applies to: files and directories.
|
||||||
|
|
||||||
Opens the selected file in a new tab. If a directory is selected, a netrw is
|
Opens the selected file in a new tab. If a directory is selected, a fresh
|
||||||
opened in a new tab.
|
NERD Tree for that directory is opened in a new tab.
|
||||||
|
|
||||||
If a bookmark which points to a directory is selected, open a NERD tree for
|
If a bookmark which points to a directory is selected, open a NERD tree for
|
||||||
that directory in a new tab. If the bookmark points to a file, open that file
|
that directory in a new tab. If the bookmark points to a file, open that file
|
||||||
@@ -648,7 +668,7 @@ account. The above nodes would then be sorted like this: >
|
|||||||
*NERDTreeChDirMode*
|
*NERDTreeChDirMode*
|
||||||
|
|
||||||
Values: 0, 1 or 2.
|
Values: 0, 1 or 2.
|
||||||
Default: 1.
|
Default: 0.
|
||||||
|
|
||||||
Use this option to tell the script when (if at all) to change the current
|
Use this option to tell the script when (if at all) to change the current
|
||||||
working directory (CWD) for vim.
|
working directory (CWD) for vim.
|
||||||
@@ -667,11 +687,6 @@ the CWD is changed whenever the tree root is changed. For example, if the CWD
|
|||||||
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
|
||||||
root then the CWD will become /home/marty/foobar/baz.
|
root then the CWD will become /home/marty/foobar/baz.
|
||||||
|
|
||||||
Authors note: at work i have this option set to 1 because i have a giant ctags
|
|
||||||
file in the root dir of my project. This way i can initialise the NERD tree
|
|
||||||
with the root dir of my project and always have ctags available to me --- no
|
|
||||||
matter where i go with the NERD tree.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeHighlightCursorline*
|
*NERDTreeHighlightCursorline*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
@@ -874,6 +889,28 @@ fridge for later ;)
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
7. Changelog *NERDTreeChangelog*
|
7. Changelog *NERDTreeChangelog*
|
||||||
|
|
||||||
|
2.13.0
|
||||||
|
- make NERDTreeChDir option default to 0 (i.e. never change vims current
|
||||||
|
working dir by default)
|
||||||
|
- when moving/deleting nodes with the filesystem menu, move/delete any
|
||||||
|
associated bookmarks
|
||||||
|
- make the t/T on directory nodes open a fresh NERD tree for the selected
|
||||||
|
dir in a new tab, rather than a netrw.
|
||||||
|
- place the cursor at the top of the bookmarks table when opening it with B
|
||||||
|
- make NERDTreeQuitOnOpen option work with the g<tab> and go mappings,
|
||||||
|
thanks to Maxim Kim for the bug report
|
||||||
|
- change how invalid bookmarks are handled. Now they are not deleted. If a
|
||||||
|
bookmark is malformed (in the bookmarks file) or points to an
|
||||||
|
invalid/nonexisting location then print an error and place the offending
|
||||||
|
bookmarks at the bottom of the bookmarks file. See :help
|
||||||
|
|NERDTreeInvalidBookmarks| for info. Thanks to Zhang Shuhan for the
|
||||||
|
suggestion and the testing.
|
||||||
|
- fix a bug with the 'o' mapping that occurred when opening a new buffer
|
||||||
|
for a file whose name was a substring of an already open file. Thanks to
|
||||||
|
Charlton Wang for the report.
|
||||||
|
- stop the script from going into an infinite loop when it tries to cache
|
||||||
|
a named pipe. Thanks to Charlton Wang for the report.
|
||||||
|
|
||||||
2.12.0
|
2.12.0
|
||||||
- added a UI for bookmarks. See :help NERDTreeBookmarkTable for details.
|
- added a UI for bookmarks. See :help NERDTreeBookmarkTable for details.
|
||||||
Thanks to Zhang Shuhan for testing and bug reports.
|
Thanks to Zhang Shuhan for testing and bug reports.
|
||||||
@@ -1148,7 +1185,7 @@ NERD tree window optional.
|
|||||||
|
|
||||||
Thanks to Zhang Shuhan for all of his emails and testing to help improve the
|
Thanks to Zhang Shuhan for all of his emails and testing to help improve the
|
||||||
NERD tree path handling. Thanks also for suggesting the bookmarks gui, and for
|
NERD tree path handling. Thanks also for suggesting the bookmarks gui, and for
|
||||||
testing and making suggestions and bugreports.
|
testing and his many suggestions and bugreports about bookmarks.
|
||||||
|
|
||||||
Thanks to Cory Echols for sending a patch to add the :NERDTreeClose command and
|
Thanks to Cory Echols for sending a patch to add the :NERDTreeClose command and
|
||||||
set the NERD tree buffers filetype to 'nerdtree'
|
set the NERD tree buffers filetype to 'nerdtree'
|
||||||
@@ -1160,6 +1197,13 @@ Thanks to Yuan Jiang for suggesting the "o" mapping shouldnt clobber "special"
|
|||||||
windows, like taglist.
|
windows, like taglist.
|
||||||
|
|
||||||
Thanks to Matan Nassau for the patch to add the NERDTreeQuitOnOpen option.
|
Thanks to Matan Nassau for the patch to add the NERDTreeQuitOnOpen option.
|
||||||
|
|
||||||
|
Thanks to Maxim Kim for reporting a bug with g<tab> and go mappings when
|
||||||
|
NERDTreeQuitOnOpen was set.
|
||||||
|
|
||||||
|
Thanks to Charlton Wang for reporting bugs with the 'o' mapping and with
|
||||||
|
handling named pipes.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. License *NERDTreeLicense*
|
9. License *NERDTreeLicense*
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
" File: NERD_tree.vim
|
" File: NERD_tree.vim
|
||||||
" Description: vim global plugin that provides a nice tree explorer
|
" Description: vim global plugin that provides a nice tree explorer
|
||||||
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
||||||
" Last Change: 5 July, 2008
|
" Last Change: 20 July, 2008
|
||||||
" License: This program is free software. It comes without any warranty,
|
" License: This program is free software. It comes without any warranty,
|
||||||
" to the extent permitted by applicable law. You can redistribute
|
" to the extent permitted by applicable law. You can redistribute
|
||||||
" it and/or modify it under the terms of the Do What The Fuck You
|
" it and/or modify it under the terms of the Do What The Fuck You
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
"
|
"
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
let s:NERD_tree_version = '2.12.0'
|
let s:NERD_tree_version = '2.13.0'
|
||||||
|
|
||||||
" SECTION: Script init stuff {{{1
|
" SECTION: Script init stuff {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -45,7 +45,7 @@ call s:InitVariable("g:NERDChristmasTree", 1)
|
|||||||
call s:InitVariable("g:NERDTreeAutoCenter", 1)
|
call s:InitVariable("g:NERDTreeAutoCenter", 1)
|
||||||
call s:InitVariable("g:NERDTreeAutoCenterThreshold", 3)
|
call s:InitVariable("g:NERDTreeAutoCenterThreshold", 3)
|
||||||
call s:InitVariable("g:NERDTreeCaseSensitiveSort", 0)
|
call s:InitVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||||
call s:InitVariable("g:NERDTreeChDirMode", 1)
|
call s:InitVariable("g:NERDTreeChDirMode", 0)
|
||||||
if !exists("g:NERDTreeIgnore")
|
if !exists("g:NERDTreeIgnore")
|
||||||
let g:NERDTreeIgnore = ['\~$']
|
let g:NERDTreeIgnore = ['\~$']
|
||||||
endif
|
endif
|
||||||
@@ -148,7 +148,7 @@ command! -n=1 -complete=customlist,s:CompleteBookmarks NERDTreeFromBookmark call
|
|||||||
"Save the cursor position whenever we close the nerd tree
|
"Save the cursor position whenever we close the nerd tree
|
||||||
exec "autocmd BufWinLeave *". s:NERDTreeWinName ."* :call <SID>SaveScreenState()"
|
exec "autocmd BufWinLeave *". s:NERDTreeWinName ."* :call <SID>SaveScreenState()"
|
||||||
"cache bookmarks when vim loads
|
"cache bookmarks when vim loads
|
||||||
autocmd VimEnter * call s:oBookmark.CacheBookmarks()
|
autocmd VimEnter * call s:oBookmark.CacheBookmarks(0)
|
||||||
|
|
||||||
"SECTION: Classes {{{1
|
"SECTION: Classes {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -177,6 +177,17 @@ function! s:oBookmark.Bookmarks() dict
|
|||||||
endif
|
endif
|
||||||
return g:NERDTreeBookmarks
|
return g:NERDTreeBookmarks
|
||||||
endfunction
|
endfunction
|
||||||
|
" Function: oBookmark.BookmarkExistsFor(name) {{{3
|
||||||
|
" class method that returns 1 if a bookmark with the given name is found, 0
|
||||||
|
" otherwise
|
||||||
|
function! s:oBookmark.BookmarkExistsFor(name) dict
|
||||||
|
try
|
||||||
|
call s:oBookmark.BookmarkFor(a:name)
|
||||||
|
return 1
|
||||||
|
catch /NERDTree.BookmarkNotFound/
|
||||||
|
return 0
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
" Function: oBookmark.BookmarkFor(name) {{{3
|
" Function: oBookmark.BookmarkFor(name) {{{3
|
||||||
" Class method to get the bookmark that has the given name. {} is return if no
|
" Class method to get the bookmark that has the given name. {} is return if no
|
||||||
" bookmark is found
|
" bookmark is found
|
||||||
@@ -186,7 +197,7 @@ function! s:oBookmark.BookmarkFor(name) dict
|
|||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return {}
|
throw "NERDTree.BookmarkNotFound exception: no bookmark found for name: \"". a:name .'"'
|
||||||
endfunction
|
endfunction
|
||||||
" Function: oBookmark.BookmarkNames() {{{3
|
" Function: oBookmark.BookmarkNames() {{{3
|
||||||
" Class method to return an array of all bookmark names
|
" Class method to return an array of all bookmark names
|
||||||
@@ -197,30 +208,42 @@ function! s:oBookmark.BookmarkNames() dict
|
|||||||
endfor
|
endfor
|
||||||
return names
|
return names
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: oBookmark.CacheBookmarks() {{{3
|
" FUNCTION: oBookmark.CacheBookmarks(silent) {{{3
|
||||||
" Class method to read all bookmarks from the bookmarks file intialize
|
" Class method to read all bookmarks from the bookmarks file intialize
|
||||||
" bookmark objects for each one.
|
" bookmark objects for each one.
|
||||||
function! s:oBookmark.CacheBookmarks() dict
|
"
|
||||||
|
" Args:
|
||||||
|
" silent - dont echo an error msg if invalid bookmarks are found
|
||||||
|
function! s:oBookmark.CacheBookmarks(silent) dict
|
||||||
if filereadable(g:NERDTreeBookmarksFile)
|
if filereadable(g:NERDTreeBookmarksFile)
|
||||||
let bookmarks = []
|
let g:NERDTreeBookmarks = []
|
||||||
|
let g:NERDTreeInvalidBookmarks = []
|
||||||
let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
|
let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
|
||||||
let invalidBookmarksFound = 0
|
let invalidBookmarksFound = 0
|
||||||
for i in bookmarkStrings
|
for i in bookmarkStrings
|
||||||
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
|
|
||||||
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
|
|
||||||
|
|
||||||
try
|
"ignore blank lines
|
||||||
let bookmark = s:oBookmark.New(name, s:oPath.New(path))
|
if i != ''
|
||||||
call add(bookmarks, bookmark)
|
|
||||||
catch /NERDTree.Path.InvalidArguments/
|
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
|
||||||
let invalidBookmarksFound += 1
|
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
|
||||||
endtry
|
|
||||||
|
try
|
||||||
|
let bookmark = s:oBookmark.New(name, s:oPath.New(path))
|
||||||
|
call add(g:NERDTreeBookmarks, bookmark)
|
||||||
|
catch /NERDTree.Path.InvalidArguments/
|
||||||
|
call add(g:NERDTreeInvalidBookmarks, i)
|
||||||
|
let invalidBookmarksFound += 1
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
let g:NERDTreeBookmarks = bookmarks
|
|
||||||
if invalidBookmarksFound
|
if invalidBookmarksFound
|
||||||
call s:Echo(invalidBookmarksFound . " invalid bookmarks were read and discarded")
|
|
||||||
call s:oBookmark.Write()
|
call s:oBookmark.Write()
|
||||||
|
if !a:silent
|
||||||
|
call s:Echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
call s:oBookmark.Sort()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: oBookmark.CompareTo(otherbookmark) {{{3
|
" FUNCTION: oBookmark.CompareTo(otherbookmark) {{{3
|
||||||
@@ -249,6 +272,7 @@ function! s:oBookmark.Delete() dict
|
|||||||
if !empty(node)
|
if !empty(node)
|
||||||
call node.path.CacheDisplayString()
|
call node.path.CacheDisplayString()
|
||||||
endif
|
endif
|
||||||
|
call s:oBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: oBookmark.GetNode(searchFromAbsoluteRoot) {{{3
|
" FUNCTION: oBookmark.GetNode(searchFromAbsoluteRoot) {{{3
|
||||||
" Gets the treenode for this bookmark
|
" Gets the treenode for this bookmark
|
||||||
@@ -260,7 +284,7 @@ function! s:oBookmark.GetNode(searchFromAbsoluteRoot) dict
|
|||||||
let searchRoot = a:searchFromAbsoluteRoot ? s:AbsoluteTreeRoot() : t:NERDTreeRoot
|
let searchRoot = a:searchFromAbsoluteRoot ? s:AbsoluteTreeRoot() : t:NERDTreeRoot
|
||||||
let targetNode = searchRoot.FindNode(self.path)
|
let targetNode = searchRoot.FindNode(self.path)
|
||||||
if empty(targetNode)
|
if empty(targetNode)
|
||||||
throw "NERDTree.BookmarkNotFound no node was found for bookmark: " . self.name
|
throw "NERDTree.BookmarkedNodeNotFound no node was found for bookmark: " . self.name
|
||||||
endif
|
endif
|
||||||
return targetNode
|
return targetNode
|
||||||
endfunction
|
endfunction
|
||||||
@@ -269,11 +293,25 @@ endfunction
|
|||||||
" treenode for it.
|
" treenode for it.
|
||||||
function! s:oBookmark.GetNodeForName(name, searchFromAbsoluteRoot) dict
|
function! s:oBookmark.GetNodeForName(name, searchFromAbsoluteRoot) dict
|
||||||
let bookmark = s:oBookmark.BookmarkFor(a:name)
|
let bookmark = s:oBookmark.BookmarkFor(a:name)
|
||||||
if bookmark == {}
|
|
||||||
throw "NERDTree.BookmarkNotFound no node was found for bookmark: " . a:name
|
|
||||||
endif
|
|
||||||
return bookmark.GetNode(a:searchFromAbsoluteRoot)
|
return bookmark.GetNode(a:searchFromAbsoluteRoot)
|
||||||
endfunction
|
endfunction
|
||||||
|
" Function: oBookmark.InvalidBookmarks() {{{3
|
||||||
|
" Class method to get all invalid bookmark strings read from the bookmarks
|
||||||
|
" file
|
||||||
|
function! s:oBookmark.InvalidBookmarks() dict
|
||||||
|
if !exists("g:NERDTreeInvalidBookmarks")
|
||||||
|
let g:NERDTreeInvalidBookmarks = []
|
||||||
|
endif
|
||||||
|
return g:NERDTreeInvalidBookmarks
|
||||||
|
endfunction
|
||||||
|
" FUNCTION: oBookmark.MustExist() {{{3
|
||||||
|
function! s:oBookmark.MustExist() dict
|
||||||
|
if !self.path.Exists()
|
||||||
|
call s:oBookmark.CacheBookmarks(1)
|
||||||
|
throw "NERDTree.BookmarkPointsToInvalidLocation exception: the bookmark \"".
|
||||||
|
\ self.name ."\" points to a non existing location: \"". self.path.StrForOS(0)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
" FUNCTION: oBookmark.New(name, path) {{{3
|
" FUNCTION: oBookmark.New(name, path) {{{3
|
||||||
" Create a new bookmark object with the given name and path object
|
" Create a new bookmark object with the given name and path object
|
||||||
function! s:oBookmark.New(name, path) dict
|
function! s:oBookmark.New(name, path) dict
|
||||||
@@ -286,6 +324,11 @@ function! s:oBookmark.New(name, path) dict
|
|||||||
let newBookmark.path = a:path
|
let newBookmark.path = a:path
|
||||||
return newBookmark
|
return newBookmark
|
||||||
endfunction
|
endfunction
|
||||||
|
" Function: oBookmark.SetPath(path) {{{3
|
||||||
|
" makes this bookmark point to the given path
|
||||||
|
function! s:oBookmark.SetPath(path) dict
|
||||||
|
let self.path = a:path
|
||||||
|
endfunction
|
||||||
" Function: oBookmark.Sort() {{{3
|
" Function: oBookmark.Sort() {{{3
|
||||||
" Class method that sorts all bookmarks
|
" Class method that sorts all bookmarks
|
||||||
function! s:oBookmark.Sort() dict
|
function! s:oBookmark.Sort() dict
|
||||||
@@ -313,6 +356,13 @@ function! s:oBookmark.Write() dict
|
|||||||
for i in s:oBookmark.Bookmarks()
|
for i in s:oBookmark.Bookmarks()
|
||||||
call add(bookmarkStrings, i.name . ' ' . i.path.StrForOS(0))
|
call add(bookmarkStrings, i.name . ' ' . i.path.StrForOS(0))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
"add a blank line before the invalid ones
|
||||||
|
call add(bookmarkStrings, "")
|
||||||
|
|
||||||
|
for j in s:oBookmark.InvalidBookmarks()
|
||||||
|
call add(bookmarkStrings, j)
|
||||||
|
endfor
|
||||||
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||||
endfunction
|
endfunction
|
||||||
"CLASS: oTreeFileNode {{{2
|
"CLASS: oTreeFileNode {{{2
|
||||||
@@ -541,6 +591,7 @@ function! s:oTreeFileNode.Rename(newName) dict
|
|||||||
|
|
||||||
if newParent != {}
|
if newParent != {}
|
||||||
call newParent.CreateChild(self.path, 1)
|
call newParent.CreateChild(self.path, 1)
|
||||||
|
call newParent.Refresh()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oTreeFileNode.StrDisplay() {{{3
|
"FUNCTION: oTreeFileNode.StrDisplay() {{{3
|
||||||
@@ -796,8 +847,8 @@ function! s:oTreeDirNode.InitChildren(silent) dict
|
|||||||
try
|
try
|
||||||
let path = s:oPath.New(i)
|
let path = s:oPath.New(i)
|
||||||
call self.CreateChild(path, 0)
|
call self.CreateChild(path, 0)
|
||||||
catch /^NERDTree.Path.InvalidArguments/
|
catch /^NERDTree.Path.\(InvalidArguments\|InvalidFiletype\)/
|
||||||
let invalidFilesFound = 1
|
let invalidFilesFound += 1
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -809,7 +860,7 @@ function! s:oTreeDirNode.InitChildren(silent) dict
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if invalidFilesFound
|
if invalidFilesFound
|
||||||
call s:EchoWarning("some files could not be loaded into the NERD tree")
|
call s:EchoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree")
|
||||||
endif
|
endif
|
||||||
return self.GetChildCount()
|
return self.GetChildCount()
|
||||||
endfunction
|
endfunction
|
||||||
@@ -990,7 +1041,7 @@ endfunction
|
|||||||
let s:oPath = {}
|
let s:oPath = {}
|
||||||
"FUNCTION: oPath.BookmarkNames() {{{3
|
"FUNCTION: oPath.BookmarkNames() {{{3
|
||||||
function! s:oPath.BookmarkNames() dict
|
function! s:oPath.BookmarkNames() dict
|
||||||
if !exists("self.bookmark")
|
if !exists("self.bookmarkNames")
|
||||||
call self.CacheDisplayString()
|
call self.CacheDisplayString()
|
||||||
endif
|
endif
|
||||||
return self.bookmarkNames
|
return self.bookmarkNames
|
||||||
@@ -1003,14 +1054,14 @@ function! s:oPath.CacheDisplayString() dict
|
|||||||
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let bookmarkNames = []
|
let self.bookmarkNames = []
|
||||||
for i in s:oBookmark.Bookmarks()
|
for i in s:oBookmark.Bookmarks()
|
||||||
if i.path.Equals(self)
|
if i.path.Equals(self)
|
||||||
call add(bookmarkNames, i.name)
|
call add(self.bookmarkNames, i.name)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if !empty(bookmarkNames)
|
if !empty(self.bookmarkNames)
|
||||||
let self.cachedDisplayString .= ' {' . join(bookmarkNames) . '}'
|
let self.cachedDisplayString .= ' {' . join(self.bookmarkNames) . '}'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if self.isSymLink
|
if self.isSymLink
|
||||||
@@ -1196,6 +1247,12 @@ function! s:oPath.Delete() dict
|
|||||||
throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'"
|
throw "NERDTree.Path.Deletion Exception: Could not delete file: '" . self.Str(0) . "'"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
"delete all bookmarks for this path
|
||||||
|
for i in self.BookmarkNames()
|
||||||
|
let bookmark = s:oBookmark.BookmarkFor(i)
|
||||||
|
call bookmark.Delete()
|
||||||
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.ExtractDriveLetter(fullpath) {{{3
|
"FUNCTION: oPath.ExtractDriveLetter(fullpath) {{{3
|
||||||
@@ -1209,6 +1266,11 @@ function! s:oPath.ExtractDriveLetter(fullpath) dict
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
"FUNCTION: oPath.Exists() {{{3
|
||||||
|
"return 1 if this path points to a location that is readable or is a directory
|
||||||
|
function! s:oPath.Exists() dict
|
||||||
|
return filereadable(self.StrForOS(0)) || isdirectory(self.StrForOS(0))
|
||||||
|
endfunction
|
||||||
"FUNCTION: oPath.GetDir() {{{3
|
"FUNCTION: oPath.GetDir() {{{3
|
||||||
"
|
"
|
||||||
"Returns this path if it is a directory, else this paths parent.
|
"Returns this path if it is a directory, else this paths parent.
|
||||||
@@ -1340,8 +1402,13 @@ function! s:oPath.ReadInfoFromDisk(fullpath) dict
|
|||||||
|
|
||||||
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
let fullpath = s:oPath.WinToUnixPath(a:fullpath)
|
||||||
|
|
||||||
|
if getftype(fullpath) == "fifo"
|
||||||
|
throw "NERDTree.Path.InvalidFiletype Exception: Cant handle FIFO files: " . a:fullpath
|
||||||
|
endif
|
||||||
|
|
||||||
let self.pathSegments = split(fullpath, '/')
|
let self.pathSegments = split(fullpath, '/')
|
||||||
|
|
||||||
|
|
||||||
let self.isReadOnly = 0
|
let self.isReadOnly = 0
|
||||||
if isdirectory(a:fullpath)
|
if isdirectory(a:fullpath)
|
||||||
let self.isDirectory = 1
|
let self.isDirectory = 1
|
||||||
@@ -1400,6 +1467,12 @@ function! s:oPath.Rename(newPath) dict
|
|||||||
throw "NERDTree.Path.Rename Exception: Could not rename: '" . self.StrForOS(0) . "'" . 'to:' . a:newPath
|
throw "NERDTree.Path.Rename Exception: Could not rename: '" . self.StrForOS(0) . "'" . 'to:' . a:newPath
|
||||||
endif
|
endif
|
||||||
call self.ReadInfoFromDisk(a:newPath)
|
call self.ReadInfoFromDisk(a:newPath)
|
||||||
|
|
||||||
|
for i in self.BookmarkNames()
|
||||||
|
let b = s:oBookmark.BookmarkFor(i)
|
||||||
|
call b.SetPath(copy(self))
|
||||||
|
endfor
|
||||||
|
call s:oBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Str(esc) {{{3
|
"FUNCTION: oPath.Str(esc) {{{3
|
||||||
@@ -1607,7 +1680,7 @@ endfunction
|
|||||||
"name: the name of a bookmark or a directory
|
"name: the name of a bookmark or a directory
|
||||||
function! s:InitNerdTree(name)
|
function! s:InitNerdTree(name)
|
||||||
let path = {}
|
let path = {}
|
||||||
if s:oBookmark.BookmarkFor(a:name) != {}
|
if s:oBookmark.BookmarkExistsFor(a:name)
|
||||||
let path = s:oBookmark.BookmarkFor(a:name).path
|
let path = s:oBookmark.BookmarkFor(a:name).path
|
||||||
else
|
else
|
||||||
let dir = a:name == '' ? expand('%:p:h') : a:name
|
let dir = a:name == '' ? expand('%:p:h') : a:name
|
||||||
@@ -1697,6 +1770,21 @@ endfunction
|
|||||||
|
|
||||||
" SECTION: View Functions {{{1
|
" SECTION: View Functions {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
|
" FUNCTION: s:BookmarkToRoot(name) {{{2
|
||||||
|
" Make the node for the given bookmark the new tree root
|
||||||
|
function! s:BookmarkToRoot(name)
|
||||||
|
let bookmark = s:oBookmark.BookmarkFor(a:name)
|
||||||
|
if s:ValidateBookmark(bookmark)
|
||||||
|
try
|
||||||
|
let targetNode = s:oBookmark.GetNodeForName(a:name, 1)
|
||||||
|
catch /NERDTree.BookmarkedNodeNotFound/
|
||||||
|
let targetNode = s:oTreeFileNode.New(s:oBookmark.BookmarkFor(a:name).path)
|
||||||
|
endtry
|
||||||
|
call targetNode.MakeRoot()
|
||||||
|
call s:RenderView()
|
||||||
|
call s:PutCursorOnNode(targetNode, 0, 0)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
"FUNCTION: s:CenterView() {{{2
|
"FUNCTION: s:CenterView() {{{2
|
||||||
"centers the nerd tree window around the cursor (provided the nerd tree
|
"centers the nerd tree window around the cursor (provided the nerd tree
|
||||||
"options permit)
|
"options permit)
|
||||||
@@ -1710,13 +1798,6 @@ function! s:CenterView()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:CloseTreeIfOpen() {{{2
|
|
||||||
"Closes the NERD tree window if it is open
|
|
||||||
function! s:CloseTreeIfOpen()
|
|
||||||
if s:IsTreeOpen()
|
|
||||||
call s:CloseTree()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
"FUNCTION: s:CloseTree() {{{2
|
"FUNCTION: s:CloseTree() {{{2
|
||||||
"Closes the NERD tree window
|
"Closes the NERD tree window
|
||||||
function! s:CloseTree()
|
function! s:CloseTree()
|
||||||
@@ -1733,6 +1814,20 @@ function! s:CloseTree()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:CloseTreeIfOpen() {{{2
|
||||||
|
"Closes the NERD tree window if it is open
|
||||||
|
function! s:CloseTreeIfOpen()
|
||||||
|
if s:IsTreeOpen()
|
||||||
|
call s:CloseTree()
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
"FUNCTION: s:CloseTreeIfQuitOnOpen() {{{2
|
||||||
|
"Closes the NERD tree window if the close on open option is set
|
||||||
|
function! s:CloseTreeIfQuitOnOpen()
|
||||||
|
if g:NERDTreeQuitOnOpen
|
||||||
|
call s:CloseTree()
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
"FUNCTION: s:CreateTreeWin() {{{2
|
"FUNCTION: s:CreateTreeWin() {{{2
|
||||||
"Inits the NERD tree window. ie. opens it, sizes it, sets all the local
|
"Inits the NERD tree window. ie. opens it, sizes it, sets all the local
|
||||||
"options etc
|
"options etc
|
||||||
@@ -2104,7 +2199,11 @@ function! s:GetSelectedBookmark()
|
|||||||
let line = getline(".")
|
let line = getline(".")
|
||||||
let name = substitute(line, '^>\(.\{-}\) \[.*\]$', '\1', '')
|
let name = substitute(line, '^>\(.\{-}\) \[.*\]$', '\1', '')
|
||||||
if name != line
|
if name != line
|
||||||
return s:oBookmark.BookmarkFor(name)
|
try
|
||||||
|
return s:oBookmark.BookmarkFor(name)
|
||||||
|
catch /NERDTree.BookmarkNotFound/
|
||||||
|
return {}
|
||||||
|
endtry
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -2222,7 +2321,7 @@ function! s:OpenFileNode(treenode)
|
|||||||
call s:PutCursorInTreeWin()
|
call s:PutCursorInTreeWin()
|
||||||
|
|
||||||
"if the file is already open in this tab then just stick the cursor in it
|
"if the file is already open in this tab then just stick the cursor in it
|
||||||
let winnr = bufwinnr(a:treenode.path.StrForOS(0))
|
let winnr = bufwinnr('^' . a:treenode.path.StrForOS(0) . '$')
|
||||||
if winnr != -1
|
if winnr != -1
|
||||||
exec winnr . "wincmd w"
|
exec winnr . "wincmd w"
|
||||||
|
|
||||||
@@ -2356,6 +2455,25 @@ function! s:PromptToDelBuffer(bufnum, msg)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:PutCursorOnBookmarkTable(){{{2
|
||||||
|
"Places the cursor at the top of the bookmarks table
|
||||||
|
function! s:PutCursorOnBookmarkTable()
|
||||||
|
if !t:NERDTreeShowBookmarks
|
||||||
|
throw "NERDTree.IllegalOperation exception: cant find bookmark table, bookmarks arent active"
|
||||||
|
endif
|
||||||
|
|
||||||
|
let rootNodeLine = s:FindRootNodeLineNumber()
|
||||||
|
|
||||||
|
let line = 1
|
||||||
|
while getline(line) !~ '^>-\+Bookmarks-\+$'
|
||||||
|
let line = line + 1
|
||||||
|
if line >= rootNodeLine
|
||||||
|
throw "NERDTree.BookmarkTableNotFound exception: didnt find the bookmarks table"
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
call cursor(line, 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:PutCursorOnNode(treenode, isJump, recurseUpward){{{2
|
"FUNCTION: s:PutCursorOnNode(treenode, isJump, recurseUpward){{{2
|
||||||
"Places the cursor on the line number representing the given node
|
"Places the cursor on the line number representing the given node
|
||||||
"
|
"
|
||||||
@@ -2696,12 +2814,27 @@ function! s:Toggle(dir)
|
|||||||
call s:InitNerdTree(a:dir)
|
call s:InitNerdTree(a:dir)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: s:ValidateBookmark(bookmark) {{{2
|
||||||
|
function! s:ValidateBookmark(bookmark)
|
||||||
|
try
|
||||||
|
call a:bookmark.MustExist()
|
||||||
|
return 1
|
||||||
|
catch /NERDTree.BookmarkPointsToInvalidLocation/
|
||||||
|
call s:RenderView()
|
||||||
|
call s:Echo(a:bookmark.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
"SECTION: Interface bindings {{{1
|
"SECTION: Interface bindings {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
"FUNCTION: s:ActivateNode() {{{2
|
"FUNCTION: s:ActivateNode(forceKeepWindowOpen) {{{2
|
||||||
"If the current node is a file, open it in the previous window (or a new one
|
"If the current node is a file, open it in the previous window (or a new one
|
||||||
"if the previous is modified). If it is a directory then it is opened.
|
"if the previous is modified). If it is a directory then it is opened.
|
||||||
function! s:ActivateNode()
|
"
|
||||||
|
"args:
|
||||||
|
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
||||||
|
function! s:ActivateNode(forceKeepWindowOpen)
|
||||||
if getline(".") == s:tree_up_dir_line
|
if getline(".") == s:tree_up_dir_line
|
||||||
return s:UpDir(0)
|
return s:UpDir(0)
|
||||||
endif
|
endif
|
||||||
@@ -2714,9 +2847,9 @@ function! s:ActivateNode()
|
|||||||
call s:PutCursorOnNode(treenode, 0, 0)
|
call s:PutCursorOnNode(treenode, 0, 0)
|
||||||
else
|
else
|
||||||
call s:OpenFileNode(treenode)
|
call s:OpenFileNode(treenode)
|
||||||
if g:NERDTreeQuitOnOpen
|
if !a:forceKeepWindowOpen
|
||||||
call s:CloseTree()
|
call s:CloseTreeIfQuitOnOpen()
|
||||||
endif
|
end
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let bookmark = s:GetSelectedBookmark()
|
let bookmark = s:GetSelectedBookmark()
|
||||||
@@ -2724,7 +2857,9 @@ function! s:ActivateNode()
|
|||||||
if bookmark.path.isDirectory
|
if bookmark.path.isDirectory
|
||||||
call s:BookmarkToRoot(bookmark.name)
|
call s:BookmarkToRoot(bookmark.name)
|
||||||
else
|
else
|
||||||
call s:OpenFileNode(s:oTreeFileNode.New(bookmark.path))
|
if s:ValidateBookmark(bookmark)
|
||||||
|
call s:OpenFileNode(s:oTreeFileNode.New(bookmark.path))
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -2735,10 +2870,10 @@ function! s:BindMappings()
|
|||||||
" set up mappings and commands for this buffer
|
" set up mappings and commands for this buffer
|
||||||
nnoremap <silent> <buffer> <middlerelease> :call <SID>HandleMiddleMouse()<cr>
|
nnoremap <silent> <buffer> <middlerelease> :call <SID>HandleMiddleMouse()<cr>
|
||||||
nnoremap <silent> <buffer> <leftrelease> <leftrelease>:call <SID>CheckForActivate()<cr>
|
nnoremap <silent> <buffer> <leftrelease> <leftrelease>:call <SID>CheckForActivate()<cr>
|
||||||
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>ActivateNode()<cr>
|
nnoremap <silent> <buffer> <2-leftmouse> :call <SID>ActivateNode(0)<cr>
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapActivateNode . " :call <SID>ActivateNode()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapActivateNode . " :call <SID>ActivateNode(0)<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenSplit ." :call <SID>OpenEntrySplit()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenSplit ." :call <SID>OpenEntrySplit(0)<cr>"
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreview ." :call <SID>PreviewNode(0)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreview ." :call <SID>PreviewNode(0)<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewSplit ." :call <SID>PreviewNode(1)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapPreviewSplit ." :call <SID>PreviewNode(1)<cr>"
|
||||||
@@ -2788,7 +2923,7 @@ function! s:BindMappings()
|
|||||||
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=* ClearBookmarks call <SID>ClearBookmarks('<args>')
|
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=* ClearBookmarks call <SID>ClearBookmarks('<args>')
|
||||||
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=+ BookmarkToRoot call <SID>BookmarkToRoot('<args>')
|
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=+ BookmarkToRoot call <SID>BookmarkToRoot('<args>')
|
||||||
command! -buffer -nargs=0 ClearAllBookmarks call s:oBookmark.ClearAll() <bar> call <SID>RenderView()
|
command! -buffer -nargs=0 ClearAllBookmarks call s:oBookmark.ClearAll() <bar> call <SID>RenderView()
|
||||||
command! -buffer -nargs=0 ReadBookmarks call s:oBookmark.CacheBookmarks() <bar> call <SID>RenderView()
|
command! -buffer -nargs=0 ReadBookmarks call s:oBookmark.CacheBookmarks(0) <bar> call <SID>RenderView()
|
||||||
command! -buffer -nargs=0 WriteBookmarks call s:oBookmark.Write()
|
command! -buffer -nargs=0 WriteBookmarks call s:oBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -2807,18 +2942,6 @@ function! s:BookmarkNode(name)
|
|||||||
call s:Echo("select a node first")
|
call s:Echo("select a node first")
|
||||||
endif
|
endif
|
||||||
endfunction
|
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:oBookmark.GetNodeForName(a:name, 1)
|
|
||||||
catch /NERDTree.BookmarkNotFound/
|
|
||||||
let targetNode = s:oTreeFileNode.New(s:oBookmark.BookmarkFor(a:name).path)
|
|
||||||
endtry
|
|
||||||
call targetNode.MakeRoot()
|
|
||||||
call s:RenderView()
|
|
||||||
call s:PutCursorOnNode(targetNode, 0, 0)
|
|
||||||
endfunction
|
|
||||||
"FUNCTION: s:CheckForActivate() {{{2
|
"FUNCTION: s:CheckForActivate() {{{2
|
||||||
"Checks if the click should open the current node, if so then activate() is
|
"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
|
"called (directories are automatically opened if the symbol beside them is
|
||||||
@@ -2834,14 +2957,14 @@ function! s:CheckForActivate()
|
|||||||
if currentNode.path.isDirectory
|
if currentNode.path.isDirectory
|
||||||
let reg = '^' . s:tree_markup_reg .'*[~+]$'
|
let reg = '^' . s:tree_markup_reg .'*[~+]$'
|
||||||
if startToCur =~ reg
|
if startToCur =~ reg
|
||||||
call s:ActivateNode()
|
call s:ActivateNode(0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (g:NERDTreeMouseMode == 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode == 3
|
if (g:NERDTreeMouseMode == 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode == 3
|
||||||
if char !~ s:tree_markup_reg && startToCur !~ '\/$'
|
if char !~ s:tree_markup_reg && startToCur !~ '\/$'
|
||||||
call s:ActivateNode()
|
call s:ActivateNode(0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -2890,7 +3013,6 @@ function! s:ClearBookmarks(bookmarks)
|
|||||||
call bookmark.Delete()
|
call bookmark.Delete()
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
call s:oBookmark.Write()
|
|
||||||
call s:RenderView()
|
call s:RenderView()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:CloseChildren() {{{2
|
" FUNCTION: s:CloseChildren() {{{2
|
||||||
@@ -3054,7 +3176,7 @@ function! s:HandleMiddleMouse()
|
|||||||
if curNode.path.isDirectory
|
if curNode.path.isDirectory
|
||||||
call s:OpenExplorer()
|
call s:OpenExplorer()
|
||||||
else
|
else
|
||||||
call s:OpenEntrySplit()
|
call s:OpenEntrySplit(0)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -3155,7 +3277,7 @@ function! s:OpenBookmark(name)
|
|||||||
let targetNode = s:oBookmark.GetNodeForName(a:name, 0)
|
let targetNode = s:oBookmark.GetNodeForName(a:name, 0)
|
||||||
call s:PutCursorOnNode(targetNode, 0, 1)
|
call s:PutCursorOnNode(targetNode, 0, 1)
|
||||||
redraw!
|
redraw!
|
||||||
catch /NERDTree.BookmarkNotFound/
|
catch /NERDTree.BookmarkedNodeNotFound/
|
||||||
call s:Echo("note - target node is not cached")
|
call s:Echo("note - target node is not cached")
|
||||||
let bookmark = s:oBookmark.BookmarkFor(a:name)
|
let bookmark = s:oBookmark.BookmarkFor(a:name)
|
||||||
let targetNode = s:oTreeFileNode.New(bookmark.path)
|
let targetNode = s:oTreeFileNode.New(bookmark.path)
|
||||||
@@ -3166,15 +3288,18 @@ function! s:OpenBookmark(name)
|
|||||||
call s:OpenFileNode(targetNode)
|
call s:OpenFileNode(targetNode)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:OpenEntrySplit() {{{2
|
" FUNCTION: s:OpenEntrySplit(forceKeepWindowOpen) {{{2
|
||||||
" Opens the currently selected file from the explorer in a
|
"Opens the currently selected file from the explorer in a
|
||||||
" new window
|
"new window
|
||||||
function! s:OpenEntrySplit()
|
"
|
||||||
|
"args:
|
||||||
|
"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set
|
||||||
|
function! s:OpenEntrySplit(forceKeepWindowOpen)
|
||||||
let treenode = s:GetSelectedNode()
|
let treenode = s:GetSelectedNode()
|
||||||
if treenode != {}
|
if treenode != {}
|
||||||
call s:OpenFileNodeSplit(treenode)
|
call s:OpenFileNodeSplit(treenode)
|
||||||
if g:NERDTreeQuitOnOpen
|
if !a:forceKeepWindowOpen
|
||||||
call s:CloseTree()
|
call s:CloseTreeIfQuitOnOpen()
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:Echo("select a node first")
|
call s:Echo("select a node first")
|
||||||
@@ -3201,23 +3326,26 @@ function! s:OpenInNewTab(stayCurrentTab)
|
|||||||
|
|
||||||
let treenode = s:GetSelectedNode()
|
let treenode = s:GetSelectedNode()
|
||||||
if treenode != {}
|
if treenode != {}
|
||||||
exec "tabedit " . treenode.path.StrForEditCmd()
|
if treenode.path.isDirectory
|
||||||
if a:stayCurrentTab
|
tabnew
|
||||||
exec "tabnext " . currentTab
|
call s:InitNerdTree(treenode.path.StrForOS(0))
|
||||||
|
else
|
||||||
|
exec "tabedit " . treenode.path.StrForEditCmd()
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let bookmark = s:GetSelectedBookmark()
|
let bookmark = s:GetSelectedBookmark()
|
||||||
if bookmark != {}
|
if bookmark != {}
|
||||||
if bookmark.path.isDirectory
|
if bookmark.path.isDirectory
|
||||||
exec "tabnew +NERDTreeFromBookmark\\ " . bookmark.name
|
tabnew
|
||||||
|
call s:InitNerdTree(bookmark.name)
|
||||||
else
|
else
|
||||||
exec "tabedit " . bookmark.path.StrForEditCmd()
|
exec "tabedit " . bookmark.path.StrForEditCmd()
|
||||||
endif
|
endif
|
||||||
if a:stayCurrentTab
|
|
||||||
exec "tabnext " . currentTab
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
if a:stayCurrentTab
|
||||||
|
exec "tabnext " . currentTab
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:OpenNodeRecursively() {{{2
|
" FUNCTION: s:OpenNodeRecursively() {{{2
|
||||||
@@ -3237,16 +3365,10 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: s:PreviewNode() {{{2
|
"FUNCTION: s:PreviewNode() {{{2
|
||||||
function! s:PreviewNode(openNewWin)
|
function! s:PreviewNode(openNewWin)
|
||||||
let treenode = s:GetSelectedNode()
|
|
||||||
if treenode == {} || treenode.path.isDirectory
|
|
||||||
call s:Echo("Select a file node first" )
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:openNewWin
|
if a:openNewWin
|
||||||
call s:OpenEntrySplit()
|
call s:OpenEntrySplit(1)
|
||||||
else
|
else
|
||||||
call s:ActivateNode()
|
call s:ActivateNode(1)
|
||||||
end
|
end
|
||||||
call s:PutCursorInTreeWin()
|
call s:PutCursorInTreeWin()
|
||||||
endfunction
|
endfunction
|
||||||
@@ -3375,7 +3497,12 @@ endfunction
|
|||||||
" toggles the display of bookmarks
|
" toggles the display of bookmarks
|
||||||
function! s:ToggleShowBookmarks()
|
function! s:ToggleShowBookmarks()
|
||||||
let t:NERDTreeShowBookmarks = !t:NERDTreeShowBookmarks
|
let t:NERDTreeShowBookmarks = !t:NERDTreeShowBookmarks
|
||||||
call s:RenderViewSavingPosition()
|
if t:NERDTreeShowBookmarks
|
||||||
|
call s:RenderView()
|
||||||
|
call s:PutCursorOnBookmarkTable()
|
||||||
|
else
|
||||||
|
call s:RenderViewSavingPosition()
|
||||||
|
endif
|
||||||
call s:CenterView()
|
call s:CenterView()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:ToggleShowFiles() {{{2
|
" FUNCTION: s:ToggleShowFiles() {{{2
|
||||||
|
|||||||
Reference in New Issue
Block a user