mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
rename 'marks' to 'bookmarks'
This commit is contained in:
@@ -22,7 +22,7 @@ CONTENTS *NERDTree-contents*
|
|||||||
1.Intro...................................|NERDTree|
|
1.Intro...................................|NERDTree|
|
||||||
2.Functionality provided..................|NERDTreeFunctionality|
|
2.Functionality provided..................|NERDTreeFunctionality|
|
||||||
2.1 Global commands...................|NERDTreeGlobalCommands|
|
2.1 Global commands...................|NERDTreeGlobalCommands|
|
||||||
2.2 Mark commands.....................|NERDTreeMarkCommands|
|
2.2 Bookmark commands.................|NERDTreeBookmarkCommands|
|
||||||
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|
|
||||||
@@ -86,20 +86,20 @@ The following features and functionality are provided by the NERD tree:
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.1. Global Commands *NERDTreeGlobalCommands*
|
2.1. Global Commands *NERDTreeGlobalCommands*
|
||||||
|
|
||||||
:NERDTree [<start-directory> | <mark-name>] *:NERDTree*
|
:NERDTree [<start-directory> | <bookmark>] *:NERDTree*
|
||||||
Opens a fresh NERD tree. The root of the tree depends on the argument
|
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
|
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 mark name
|
will be used. If a directory is given, that will be used. If a bookmark
|
||||||
is given, the corresponding directory will be used. For example: >
|
name is given, the corresponding directory will be used. For example: >
|
||||||
:NERDTree /home/marty/vim7/src
|
:NERDTree /home/marty/vim7/src
|
||||||
:NERDTree foo (foo is the name of a mark)
|
:NERDTree foo (foo is the name of a bookmark)
|
||||||
<
|
<
|
||||||
:NERDTreeFromMark <mark-name> *:NERDTreeFromMark*
|
:NERDTreeFromBookmark <bookmark> *:NERDTreeFromBookmark*
|
||||||
Opens a fresh NERD tree with the root initialized to dir for <mark-name>.
|
Opens a fresh NERD tree with the root initialized to dir for <bookmark>.
|
||||||
This only reason to use this command over :NERDTree is for the completion
|
This only reason to use this command over :NERDTree is for the completion
|
||||||
(which is for marks rather than directories).
|
(which is for bookmarks rather than directories).
|
||||||
|
|
||||||
:NERDTreeToggle [<start-directory> | <mark-name>] *:NERDTreeToggle*
|
:NERDTreeToggle [<start-directory> | <bookmark>] *:NERDTreeToggle*
|
||||||
If a NERD tree already exists for this tab, it is reopened and rendered
|
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
|
again. If no NERD tree exists for this tab then this command acts the
|
||||||
same as the |:NERDTree| command.
|
same as the |:NERDTree| command.
|
||||||
@@ -108,39 +108,41 @@ The following features and functionality are provided by the NERD tree:
|
|||||||
Close the NERD tree in this tab.
|
Close the NERD tree in this tab.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2. Mark Commands *NERDTreeMarkCommands*
|
2.2. Bookmark Commands *NERDTreeBookmarkCommands*
|
||||||
|
|
||||||
Marks in the NERD tree are a way to tag files or directories of interest. For
|
Bookmarks in the NERD tree are a way to tag files or directories of interest.
|
||||||
example, you could use marks to tag all of your project directories. See also
|
For example, you could use bookmarks to tag all of your project directories.
|
||||||
|:NERDTreeFromMark|.
|
See also
|
||||||
|
|:NERDTreeFromBookmark|.
|
||||||
|
|
||||||
:Mark <name>
|
:Bookmark <name>
|
||||||
Mark the current node as <name>. If there is already a <name> mark, it is
|
Bookmark the current node as <name>. If there is already a <name>
|
||||||
overwritten. <name> must consist of alphanumeric characters and
|
bookmark, it is overwritten. <name> must consist of alphanumeric
|
||||||
underscores.
|
characters and underscores.
|
||||||
|
|
||||||
:MarkToRoot <mark>
|
:BookmarkToRoot <bookmark>
|
||||||
Make the directory corresponding to <mark> the new root. If a treenode
|
Make the directory corresponding to <bookmark> the new root. If a treenode
|
||||||
corresponding to <mark> is already cached somewhere in the tree then the
|
corresponding to <bookmark> is already cached somewhere in the tree then
|
||||||
current tree will be used, otherwise a fresh tree will be opened. Note
|
the current tree will be used, otherwise a fresh tree will be opened.
|
||||||
that if <mark> points to a file then its parent will be used instead.
|
Note that if <bookmark> points to a file then its parent will be used
|
||||||
|
instead.
|
||||||
|
|
||||||
:RevealMark <mark>
|
:RevealBookmark <bookmark>
|
||||||
If the node is cached under the current root then it will be revealed
|
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
|
(i.e. directory nodes above it will be opened) and the cursor will be
|
||||||
placed on it.
|
placed on it.
|
||||||
|
|
||||||
:OpenMark <mark>
|
:OpenBookmark <bookmark>
|
||||||
<mark> must point to a file. The file is opened as though |NERDTree-o| was
|
<bookmark> must point to a file. The file is opened as though |NERDTree-o|
|
||||||
applied. If the node is cached under the current root then it will be
|
was applied. If the node is cached under the current root then it will be
|
||||||
revealed and the cursor will be placed on it.
|
revealed and the cursor will be placed on it.
|
||||||
|
|
||||||
:ClearMarks [<marks>]
|
:ClearBookmarks [<bookmarks>]
|
||||||
Remove all the given marks. If no marks are given then remove all marks on
|
Remove all the given bookmarks. If no bookmarks are given then remove all
|
||||||
the current node.
|
bookmarks on the current node.
|
||||||
|
|
||||||
:ClearAllMarks
|
:ClearAllBookmarks
|
||||||
Remove all marks.
|
Remove all bookmarks.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.3. NERD tree Mappings *NERDTreeMappings*
|
2.3. NERD tree Mappings *NERDTreeMappings*
|
||||||
@@ -516,7 +518,7 @@ NERD tree. These options should be set in your vimrc.
|
|||||||
|
|
||||||
|NERDTreeIgnore| Tells the NERD tree which files to ignore.
|
|NERDTreeIgnore| Tells the NERD tree which files to ignore.
|
||||||
|
|
||||||
|NERDTreeMarksFile| Where the marks are stored.
|
|NERDTreeBookmarksFile| Where the bookmarks are stored.
|
||||||
|
|
||||||
|NERDTreeMouseMode| Tells the NERD tree how to handle mouse
|
|NERDTreeMouseMode| Tells the NERD tree how to handle mouse
|
||||||
clicks.
|
clicks.
|
||||||
@@ -667,11 +669,11 @@ The file filters can be turned on and off dynamically with the |NERDTree-f|
|
|||||||
mapping.
|
mapping.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeMarksFile*
|
*NERDTreeBookmarksFile*
|
||||||
Values: a path
|
Values: a path
|
||||||
Default: $HOME/.NERDTreeMarks
|
Default: $HOME/.NERDTreeBookmarks
|
||||||
|
|
||||||
This is where marks are saved. See |NERDTreeMarkCommands|.
|
This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*NERDTreeMouseMode*
|
*NERDTreeMouseMode*
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ if !exists("g:NERDTreeIgnore")
|
|||||||
let g:NERDTreeIgnore = ['\~$']
|
let g:NERDTreeIgnore = ['\~$']
|
||||||
endif
|
endif
|
||||||
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
|
call s:InitVariable("g:NERDTreeHighlightCursorline", 1)
|
||||||
call s:InitVariable("g:NERDTreeMarksFile", expand('$HOME') . '/.NERDTreeMarks')
|
call s:InitVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
|
||||||
call s:InitVariable("g:NERDTreeMouseMode", 1)
|
call s:InitVariable("g:NERDTreeMouseMode", 1)
|
||||||
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
|
call s:InitVariable("g:NERDTreeNotificationThreshold", 100)
|
||||||
call s:InitVariable("g:NERDTreeShowFiles", 1)
|
call s:InitVariable("g:NERDTreeShowFiles", 1)
|
||||||
@@ -141,13 +141,13 @@ endif
|
|||||||
command! -n=? -complete=dir NERDTree :call s:InitNerdTree('<args>')
|
command! -n=? -complete=dir NERDTree :call s:InitNerdTree('<args>')
|
||||||
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
|
command! -n=? -complete=dir NERDTreeToggle :call s:Toggle('<args>')
|
||||||
command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen()
|
command! -n=0 NERDTreeClose :call s:CloseTreeIfOpen()
|
||||||
command! -n=1 -complete=customlist,s:FindMarks NERDTreeFromMark call s:InitNerdTree('<args>')
|
command! -n=1 -complete=customlist,s:FindBookmarks NERDTreeFromBookmark call s:InitNerdTree('<args>')
|
||||||
" SECTION: Auto commands {{{1
|
" SECTION: Auto commands {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
"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 marks when vim loads
|
"cache bookmarks when vim loads
|
||||||
autocmd VimEnter * call <SID>ReadMarks()
|
autocmd VimEnter * call <SID>ReadBookmarks()
|
||||||
|
|
||||||
"SECTION: Classes {{{1
|
"SECTION: Classes {{{1
|
||||||
"============================================================
|
"============================================================
|
||||||
@@ -180,15 +180,15 @@ function! s:CompareNodes(n1, n2)
|
|||||||
return a:n1.path.CompareTo(a:n2.path)
|
return a:n1.path.CompareTo(a:n2.path)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oTreeFileNode.ClearMarks() {{{3
|
"FUNCTION: oTreeFileNode.ClearBookmarks() {{{3
|
||||||
function! s:oTreeFileNode.ClearMarks() dict
|
function! s:oTreeFileNode.ClearBookmarks() dict
|
||||||
let marks = s:GetMarks()
|
let bookmarks = s:GetBookmarks()
|
||||||
for i in keys(marks)
|
for i in keys(bookmarks)
|
||||||
if marks[i].Equals(self.path)
|
if bookmarks[i].Equals(self.path)
|
||||||
call remove(marks, i)
|
call remove(bookmarks, i)
|
||||||
end
|
end
|
||||||
endfor
|
endfor
|
||||||
call self.path.CacheMarkNames()
|
call self.path.CacheBookmarkNames()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
|
"FUNCTION: oTreeFileNode.Copy(dest) {{{3
|
||||||
function! s:oTreeFileNode.Copy(dest) dict
|
function! s:oTreeFileNode.Copy(dest) dict
|
||||||
@@ -813,16 +813,23 @@ endfunction
|
|||||||
"============================================================
|
"============================================================
|
||||||
let s:oPath = {}
|
let s:oPath = {}
|
||||||
let oPath = s:oPath
|
let oPath = s:oPath
|
||||||
"FUNCTION: oPath.CacheMarkNames() {{{3
|
"FUNCTION: oPath.BookmarkNames() {{{3
|
||||||
function! s:oPath.CacheMarkNames() dict
|
function! s:oPath.BookmarkNames() dict
|
||||||
let self.markNames = []
|
if !exists("self.bookmarkNames")
|
||||||
let marks = s:GetMarks()
|
call self.CacheBookmarkNames()
|
||||||
for k in keys(marks)
|
endif
|
||||||
if marks[k].Equals(self)
|
return self.bookmarkNames
|
||||||
call add(self.markNames, k)
|
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
|
endif
|
||||||
endfor
|
endfor
|
||||||
return self.markNames
|
return self.bookmarkNames
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: oPath.ChangeToDir() {{{3
|
"FUNCTION: oPath.ChangeToDir() {{{3
|
||||||
function! s:oPath.ChangeToDir() dict
|
function! s:oPath.ChangeToDir() dict
|
||||||
@@ -1120,13 +1127,6 @@ function! s:oPath.Equals(path) dict
|
|||||||
return self.Str(0) == a:path.Str(0)
|
return self.Str(0) == a:path.Str(0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.MarkNames() {{{3
|
|
||||||
function! s:oPath.MarkNames() dict
|
|
||||||
if !exists("self.markNames")
|
|
||||||
call self.CacheMarkNames()
|
|
||||||
endif
|
|
||||||
return self.markNames
|
|
||||||
endfunction
|
|
||||||
"FUNCTION: oPath.New() {{{3
|
"FUNCTION: oPath.New() {{{3
|
||||||
"
|
"
|
||||||
"The Constructor for the Path object
|
"The Constructor for the Path object
|
||||||
@@ -1187,7 +1187,7 @@ endfunction
|
|||||||
"FUNCTION: oPath.Refresh() {{{3
|
"FUNCTION: oPath.Refresh() {{{3
|
||||||
function! s:oPath.Refresh() dict
|
function! s:oPath.Refresh() dict
|
||||||
call self.ReadInfoFromDisk(self.StrForOS(0))
|
call self.ReadInfoFromDisk(self.StrForOS(0))
|
||||||
call self.CacheMarkNames()
|
call self.CacheBookmarkNames()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: oPath.Rename() {{{3
|
"FUNCTION: oPath.Rename() {{{3
|
||||||
@@ -1256,9 +1256,9 @@ endfunction
|
|||||||
function! s:oPath.StrDisplay() dict
|
function! s:oPath.StrDisplay() dict
|
||||||
let toReturn = self.GetLastPathComponent(1)
|
let toReturn = self.GetLastPathComponent(1)
|
||||||
|
|
||||||
let marks = self.MarkNames()
|
let bookmarks = self.BookmarkNames()
|
||||||
if !empty(marks)
|
if !empty(bookmarks)
|
||||||
let toReturn .= ' {' . join(marks, ',') . '}'
|
let toReturn .= ' {' . join(bookmarks, ',') . '}'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if self.isSymLink
|
if self.isSymLink
|
||||||
@@ -1402,60 +1402,60 @@ function! s:BufInWindows(bnum)
|
|||||||
return cnt
|
return cnt
|
||||||
endfunction " >>>
|
endfunction " >>>
|
||||||
|
|
||||||
"FUNCTION: s:ClearAllMarks() {{{2
|
"FUNCTION: s:ClearAllBookmarks() {{{2
|
||||||
"delete all marks
|
"delete all bookmarks
|
||||||
function! s:ClearAllMarks()
|
function! s:ClearAllBookmarks()
|
||||||
for name in keys(g:NERDTreeMarks)
|
for name in keys(g:NERDTreeBookmarks)
|
||||||
let node = {}
|
let node = {}
|
||||||
try
|
try
|
||||||
let node = s:GetNodeForMark(name, 1)
|
let node = s:GetNodeForBookmark(name, 1)
|
||||||
catch /NERDTree/
|
catch /NERDTree/
|
||||||
endtry
|
endtry
|
||||||
call remove(g:NERDTreeMarks, name)
|
call remove(g:NERDTreeBookmarks, name)
|
||||||
if !empty(node)
|
if !empty(node)
|
||||||
call node.path.CacheMarkNames()
|
call node.path.CacheBookmarkNames()
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call s:WriteMarks()
|
call s:WriteBookmarks()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:GetNodeForMark(name, searchFromAbsoluteRoot) {{{2
|
"FUNCTION: s:GetNodeForBookmark(name, searchFromAbsoluteRoot) {{{2
|
||||||
"get the treenode for the mark with the given name
|
"get the treenode for the bookmark with the given name
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
"name: name of mark
|
"name: name of bookmark
|
||||||
"searchFromAbsoluteRoot: specifies wheather we should search from the current
|
"searchFromAbsoluteRoot: specifies wheather we should search from the current
|
||||||
"tree root, or the highest cached node
|
"tree root, or the highest cached node
|
||||||
function! s:GetNodeForMark(name, searchFromAbsoluteRoot)
|
function! s:GetNodeForBookmark(name, searchFromAbsoluteRoot)
|
||||||
try
|
try
|
||||||
let mark = s:GetMarks()[a:name]
|
let bookmark = s:GetBookmarks()[a:name]
|
||||||
catch /E716/ "key not in dictionary error
|
catch /E716/ "key not in dictionary error
|
||||||
throw "NERDTree.MarkDoesntExist no mark found with name: " . a:name
|
throw "NERDTree.BookmarkDoesntExist no bookmark found with name: " . a:name
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
let searchRoot = a:searchFromAbsoluteRoot ? s:AbsoluteTreeRoot() : t:NERDTreeRoot
|
let searchRoot = a:searchFromAbsoluteRoot ? s:AbsoluteTreeRoot() : t:NERDTreeRoot
|
||||||
let targetNode = searchRoot.FindNode(mark)
|
let targetNode = searchRoot.FindNode(bookmark)
|
||||||
if empty(targetNode)
|
if empty(targetNode)
|
||||||
throw "NERDTree.MarkNotFound no node was found for mark: " . a:name
|
throw "NERDTree.BookmarkNotFound no node was found for bookmark: " . a:name
|
||||||
endif
|
endif
|
||||||
return targetNode
|
return targetNode
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:InitNerdTree(name) {{{2
|
"FUNCTION: s:InitNerdTree(name) {{{2
|
||||||
"Initialise the nerd tree for this tab. The tree will start in either the
|
"Initialise the nerd tree for this tab. The tree will start in either the
|
||||||
"given directory, or the directory associated with the given mark
|
"given directory, or the directory associated with the given bookmark
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
"name: the name of a mark 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 count(keys(s:GetMarks()), a:name)
|
if count(keys(s:GetBookmarks()), a:name)
|
||||||
let path = s:GetMarks()[a:name]
|
let path = s:GetBookmarks()[a:name]
|
||||||
else
|
else
|
||||||
let dir = a:name == '' ? expand('%:p:h') : a:name
|
let dir = a:name == '' ? expand('%:p:h') : a:name
|
||||||
let dir = resolve(dir)
|
let dir = resolve(dir)
|
||||||
try
|
try
|
||||||
let path = s:oPath.New(dir)
|
let path = s:oPath.New(dir)
|
||||||
catch /NERDTree.Path.InvalidArguments/
|
catch /NERDTree.Path.InvalidArguments/
|
||||||
call s:Echo("No mark or directory found for: " . a:name)
|
call s:Echo("No bookmark or directory found for: " . a:name)
|
||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
if !path.isDirectory
|
if !path.isDirectory
|
||||||
@@ -1486,15 +1486,15 @@ function! s:InitNerdTree(name)
|
|||||||
call s:RenderView()
|
call s:RenderView()
|
||||||
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
|
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
|
||||||
endfunction
|
endfunction
|
||||||
" Function: s:ReadMarks() {{{2
|
" Function: s:ReadBookmarks() {{{2
|
||||||
function! s:ReadMarks()
|
function! s:ReadBookmarks()
|
||||||
if filereadable(g:NERDTreeMarksFile)
|
if filereadable(g:NERDTreeBookmarksFile)
|
||||||
let marks = s:GetMarks()
|
let bookmarks = s:GetBookmarks()
|
||||||
let markStrings = readfile(g:NERDTreeMarksFile)
|
let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
|
||||||
for i in markStrings
|
for i in bookmarkStrings
|
||||||
let key = substitute(i, '^\(\w.\{-}\) .*$', '\1', '')
|
let key = substitute(i, '^\(\w.\{-}\) .*$', '\1', '')
|
||||||
let path = substitute(i, '^\w.\{-} \(.*\)$', '\1', '')
|
let path = substitute(i, '^\w.\{-} \(.*\)$', '\1', '')
|
||||||
let marks[key] = s:oPath.New(path)
|
let bookmarks[key] = s:oPath.New(path)
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1503,14 +1503,14 @@ endfunction
|
|||||||
function! s:TreeExistsForTab()
|
function! s:TreeExistsForTab()
|
||||||
return exists("t:NERDTreeRoot")
|
return exists("t:NERDTreeRoot")
|
||||||
endfunction
|
endfunction
|
||||||
" Function: s:WriteMarks() {{{2
|
" Function: s:WriteBookmarks() {{{2
|
||||||
function! s:WriteMarks()
|
function! s:WriteBookmarks()
|
||||||
let marks = s:GetMarks()
|
let bookmarks = s:GetBookmarks()
|
||||||
let markStrings = []
|
let bookmarkStrings = []
|
||||||
for k in keys(marks)
|
for k in keys(bookmarks)
|
||||||
call add(markStrings, k . ' ' . marks[k].StrForOS(0))
|
call add(bookmarkStrings, k . ' ' . bookmarks[k].StrForOS(0))
|
||||||
endfor
|
endfor
|
||||||
call writefile(markStrings, g:NERDTreeMarksFile)
|
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" SECTION: Public Functions {{{1
|
" SECTION: Public Functions {{{1
|
||||||
@@ -1776,13 +1776,13 @@ function! s:DumpHelp()
|
|||||||
let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
|
let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
|
||||||
let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
|
let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
|
||||||
let @h=@h."\" \n\" ----------------------------\n"
|
let @h=@h."\" \n\" ----------------------------\n"
|
||||||
let @h=@h."\" Mark commands~\n"
|
let @h=@h."\" Bookmark commands~\n"
|
||||||
let @h=@h."\" :Mark <name>\n"
|
let @h=@h."\" :Bookmark <name>\n"
|
||||||
let @h=@h."\" :MarkToRoot <mark>\n"
|
let @h=@h."\" :BookmarkToRoot <bookmark>\n"
|
||||||
let @h=@h."\" :RevealMark <mark>\n"
|
let @h=@h."\" :RevealBookmark <bookmark>\n"
|
||||||
let @h=@h."\" :OpenMark <mark>\n"
|
let @h=@h."\" :OpenBookmark <bookmark>\n"
|
||||||
let @h=@h."\" :ClearMarks [<marks>]\n"
|
let @h=@h."\" :ClearBookmarks [<bookmarks>]\n"
|
||||||
let @h=@h."\" :ClearAllMarks\n"
|
let @h=@h."\" :ClearAllBookmarks\n"
|
||||||
else
|
else
|
||||||
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
|
||||||
endif
|
endif
|
||||||
@@ -1818,10 +1818,10 @@ function! s:EchoError(msg)
|
|||||||
call s:Echo(a:msg)
|
call s:Echo(a:msg)
|
||||||
echohl normal
|
echohl normal
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:FindMarks(A,L,P) {{{2
|
" FUNCTION: s:FindBookmarks(A,L,P) {{{2
|
||||||
" completion function for the mark commands
|
" completion function for the bookmark commands
|
||||||
function! s:FindMarks(A,L,P)
|
function! s:FindBookmarks(A,L,P)
|
||||||
let keys = keys(s:GetMarks())
|
let keys = keys(s:GetBookmarks())
|
||||||
return filter(keys, 'v:val =~ "^' . a:A . '"')
|
return filter(keys, 'v:val =~ "^' . a:A . '"')
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:FindNodeLineNumber(treenode){{{2
|
"FUNCTION: s:FindNodeLineNumber(treenode){{{2
|
||||||
@@ -1886,13 +1886,13 @@ function! s:FindRootNodeLineNumber()
|
|||||||
return rootLine
|
return rootLine
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:GetMarks(name) {{{2
|
" FUNCTION: s:GetBookmarks(name) {{{2
|
||||||
" getter/lazy initializer for the g:NERDTreeMarks hash
|
" getter/lazy initializer for the g:NERDTreeBookmarks hash
|
||||||
function! s:GetMarks()
|
function! s:GetBookmarks()
|
||||||
if !exists("g:NERDTreeMarks")
|
if !exists("g:NERDTreeBookmarks")
|
||||||
let g:NERDTreeMarks = {}
|
let g:NERDTreeBookmarks = {}
|
||||||
endif
|
endif
|
||||||
return g:NERDTreeMarks
|
return g:NERDTreeBookmarks
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: s:GetPath(ln) {{{2
|
"FUNCTION: s:GetPath(ln) {{{2
|
||||||
"Gets the full path to the node that is rendered on the given line number
|
"Gets the full path to the node that is rendered on the given line number
|
||||||
@@ -2356,19 +2356,19 @@ function! s:SetupSyntaxHighlighting()
|
|||||||
syn match treeHelp #^" .*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
|
syn match treeHelp #^" .*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand
|
||||||
|
|
||||||
"highlighting for sym links
|
"highlighting for sym links
|
||||||
syn match treeLink #[^-| `].* -> # contains=treeMark
|
syn match treeLink #[^-| `].* -> # contains=treeBookmark
|
||||||
|
|
||||||
"highlighting for readonly files
|
"highlighting for readonly files
|
||||||
syn match treeRO #[0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag,treeMark
|
syn match treeRO #[0-9a-zA-Z]\+.*\[RO\]# contains=treeFlag,treeBookmark
|
||||||
|
|
||||||
"highlighting for marks
|
"highlighting for bookmarks
|
||||||
syn match treeMark # {.*}#hs=s+1
|
syn match treeBookmark # {.*}#hs=s+1
|
||||||
|
|
||||||
"highlighing for directory nodes and file nodes
|
"highlighing for directory nodes and file nodes
|
||||||
syn match treeDirSlash #/#
|
syn match treeDirSlash #/#
|
||||||
syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
|
syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable
|
||||||
syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeMark
|
syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
|
||||||
syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeMark
|
syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark
|
||||||
syn match treeCWD #^/.*$#
|
syn match treeCWD #^/.*$#
|
||||||
|
|
||||||
if g:NERDChristmasTree
|
if g:NERDChristmasTree
|
||||||
@@ -2398,7 +2398,7 @@ function! s:SetupSyntaxHighlighting()
|
|||||||
hi def link treeOpenable Title
|
hi def link treeOpenable Title
|
||||||
hi def link treeFlag ignore
|
hi def link treeFlag ignore
|
||||||
hi def link treeRO WarningMsg
|
hi def link treeRO WarningMsg
|
||||||
hi def link treeMark Statement
|
hi def link treeBookmark Statement
|
||||||
|
|
||||||
hi def link NERDTreeCurrentNode Search
|
hi def link NERDTreeCurrentNode Search
|
||||||
endfunction
|
endfunction
|
||||||
@@ -2437,7 +2437,7 @@ function! s:StripMarkupFromLine(line, removeLeadingSpaces)
|
|||||||
"strip off any read only flag
|
"strip off any read only flag
|
||||||
let line = substitute (line, s:tree_RO_str_reg, "","")
|
let line = substitute (line, s:tree_RO_str_reg, "","")
|
||||||
|
|
||||||
"strip off any mark flags
|
"strip off any bookmark flags
|
||||||
let line = substitute (line, ' {[^}]*}', "","")
|
let line = substitute (line, ' {[^}]*}', "","")
|
||||||
|
|
||||||
let wasdir = 0
|
let wasdir = 0
|
||||||
@@ -2552,16 +2552,48 @@ function! s:BindMappings()
|
|||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
|
||||||
|
|
||||||
command! -buffer -nargs=1 Mark :call <SID>MarkNode('<args>')
|
command! -buffer -nargs=1 Bookmark :call <SID>BookmarkNode('<args>')
|
||||||
command! -buffer -complete=customlist,s:FindMarks -nargs=1 RevealMark :call <SID>RevealMark('<args>')
|
command! -buffer -complete=customlist,s:FindBookmarks -nargs=1 RevealBookmark :call <SID>RevealBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:FindMarks -nargs=1 OpenMark :call <SID>OpenMark('<args>')
|
command! -buffer -complete=customlist,s:FindBookmarks -nargs=1 OpenBookmark :call <SID>OpenBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:FindMarks -nargs=* ClearMarks call <SID>ClearMarks('<args>')
|
command! -buffer -complete=customlist,s:FindBookmarks -nargs=* ClearBookmarks call <SID>ClearBookmarks('<args>')
|
||||||
command! -buffer -complete=customlist,s:FindMarks -nargs=+ MarkToRoot call <SID>MarkToRoot('<args>')
|
command! -buffer -complete=customlist,s:FindBookmarks -nargs=+ BookmarkToRoot call <SID>BookmarkToRoot('<args>')
|
||||||
command! -buffer -nargs=0 ClearAllMarks call <SID>ClearAllMarks() <bar> call <SID>RenderView()
|
command! -buffer -nargs=0 ClearAllBookmarks call <SID>ClearAllBookmarks() <bar> call <SID>RenderView()
|
||||||
command! -buffer -nargs=0 ReadMarks call <SID>ReadMarks() <bar> call <SID>RenderView()
|
command! -buffer -nargs=0 ReadBookmarks call <SID>ReadBookmarks() <bar> call <SID>RenderView()
|
||||||
command! -buffer -nargs=0 WriteMarks call <SID>WriteMarks()
|
command! -buffer -nargs=0 WriteBookmarks call <SID>WriteBookmarks()
|
||||||
endfunction
|
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 != {}
|
||||||
|
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
|
"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
|
||||||
@@ -2620,30 +2652,30 @@ function! s:ChRoot()
|
|||||||
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
|
call s:PutCursorOnNode(t:NERDTreeRoot, 0, 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:ClearMarks(marks) {{{2
|
" FUNCTION: s:ClearBookmarks(bookmarks) {{{2
|
||||||
function! s:ClearMarks(marks)
|
function! s:ClearBookmarks(bookmarks)
|
||||||
let marks = s:GetMarks()
|
let bookmarks = s:GetBookmarks()
|
||||||
if a:marks == ''
|
if a:bookmarks == ''
|
||||||
let currentNode = s:GetSelectedNode()
|
let currentNode = s:GetSelectedNode()
|
||||||
if currentNode != {}
|
if currentNode != {}
|
||||||
call currentNode.ClearMarks()
|
call currentNode.ClearBookmarks()
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
for name in split(a:marks, ' ')
|
for name in split(a:bookmarks, ' ')
|
||||||
if count(keys(marks), name)
|
if count(keys(bookmarks), name)
|
||||||
let node = {}
|
let node = {}
|
||||||
try
|
try
|
||||||
let node = s:GetNodeForMark(name, 1)
|
let node = s:GetNodeForBookmark(name, 1)
|
||||||
catch /NERDTree/
|
catch /NERDTree/
|
||||||
endtry
|
endtry
|
||||||
call remove(marks, name)
|
call remove(bookmarks, name)
|
||||||
if !empty(node)
|
if !empty(node)
|
||||||
call node.path.CacheMarkNames()
|
call node.path.CacheBookmarkNames()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
call s:WriteMarks()
|
call s:WriteBookmarks()
|
||||||
call s:RenderView()
|
call s:RenderView()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:CloseChildren() {{{2
|
" FUNCTION: s:CloseChildren() {{{2
|
||||||
@@ -2912,37 +2944,21 @@ function! s:JumpToSibling(forward)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:MarkNode(name) {{{2
|
" FUNCTION: s:OpenBookmark(name) {{{2
|
||||||
" Associate the current node with the given name
|
" put the cursor on the given bookmark and, if its a file, open it
|
||||||
function! s:MarkNode(name)
|
function! s:OpenBookmark(name)
|
||||||
if a:name !~ '^[0-9a-zA-Z_]*$'
|
|
||||||
call s:Echo("Marks must be named using numbers, letters and underscores only")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let currentNode = s:GetSelectedNode()
|
|
||||||
if currentNode != {}
|
|
||||||
let marks = s:GetMarks()
|
|
||||||
let marks[a:name] = currentNode.path
|
|
||||||
call currentNode.path.CacheMarkNames()
|
|
||||||
call s:WriteMarks()
|
|
||||||
call s:RenderView()
|
|
||||||
else
|
|
||||||
call s:Echo("select a node first")
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" FUNCTION: s:MarkToRoot(name) {{{2
|
|
||||||
" Make the node for the given mark the new tree root
|
|
||||||
function! s:MarkToRoot(name)
|
|
||||||
try
|
try
|
||||||
let targetNode = s:GetNodeForMark(a:name, 1)
|
let targetNode = s:GetNodeForBookmark(a:name, 0)
|
||||||
catch /NERDTree.MarkNotFound/
|
call s:PutCursorOnNode(targetNode, 0, 1)
|
||||||
let marks = s:GetMarks()
|
redraw!
|
||||||
let targetNode = s:oTreeFileNode.New(marks[a:name])
|
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
|
endtry
|
||||||
call targetNode.MakeRoot()
|
if !targetNode.path.isDirectory
|
||||||
call s:RenderView()
|
call s:OpenFileNode(targetNode)
|
||||||
call s:PutCursorOnNode(targetNode, 0, 0)
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:OpenEntrySplit() {{{2
|
" FUNCTION: s:OpenEntrySplit() {{{2
|
||||||
" Opens the currently selected file from the explorer in a
|
" Opens the currently selected file from the explorer in a
|
||||||
@@ -2973,22 +2989,6 @@ function! s:OpenExplorer()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:OpenMark(name) {{{2
|
|
||||||
" put the cursor on the given mark and, if its a file, open it
|
|
||||||
function! s:OpenMark(name)
|
|
||||||
try
|
|
||||||
let targetNode = s:GetNodeForMark(a:name, 0)
|
|
||||||
call s:PutCursorOnNode(targetNode, 0, 1)
|
|
||||||
redraw!
|
|
||||||
catch /NERDTree.MarkNotFound/
|
|
||||||
call s:Echo("note - target node is not cached")
|
|
||||||
let marks = s:GetMarks()
|
|
||||||
let targetNode = s:oTreeFileNode.New(marks[a:name])
|
|
||||||
endtry
|
|
||||||
if !targetNode.path.isDirectory
|
|
||||||
call s:OpenFileNode(targetNode)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2
|
" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2
|
||||||
" Opens the currently selected file from the explorer in a
|
" Opens the currently selected file from the explorer in a
|
||||||
" new tab
|
" new tab
|
||||||
@@ -3041,14 +3041,14 @@ function! s:PreviewNode(openNewWin)
|
|||||||
call s:PutCursorInTreeWin()
|
call s:PutCursorInTreeWin()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:RevealMark(name) {{{2
|
" FUNCTION: s:RevealBookmark(name) {{{2
|
||||||
" put the cursor on the node associate with the given name
|
" put the cursor on the node associate with the given name
|
||||||
function! s:RevealMark(name)
|
function! s:RevealBookmark(name)
|
||||||
try
|
try
|
||||||
let targetNode = s:GetNodeForMark(a:name, 0)
|
let targetNode = s:GetNodeForBookmark(a:name, 0)
|
||||||
call s:PutCursorOnNode(targetNode, 0, 1)
|
call s:PutCursorOnNode(targetNode, 0, 1)
|
||||||
catch /NERDTree.MarkDoesntExist/
|
catch /NERDTree.BookmarkDoesntExist/
|
||||||
call s:Echo("Mark isnt cached under the current root")
|
call s:Echo("Bookmark isnt cached under the current root")
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:RefreshRoot() {{{2
|
" FUNCTION: s:RefreshRoot() {{{2
|
||||||
|
|||||||
Reference in New Issue
Block a user