mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 03:43:50 -05:00
make Bookmark use the new open() interface
This commit is contained in:
@@ -193,17 +193,7 @@ endif
|
|||||||
let s:Bookmark = {}
|
let s:Bookmark = {}
|
||||||
" FUNCTION: Bookmark.activate() {{{3
|
" FUNCTION: Bookmark.activate() {{{3
|
||||||
function! s:Bookmark.activate(...)
|
function! s:Bookmark.activate(...)
|
||||||
let opts = a:0 ? a:1 : {}
|
call self.open(a:0 ? a:1 : {})
|
||||||
|
|
||||||
if self.path.isDirectory
|
|
||||||
call self.toRoot()
|
|
||||||
else
|
|
||||||
if self.validate()
|
|
||||||
let n = s:TreeFileNode.New(self.path)
|
|
||||||
call n.open(opts)
|
|
||||||
call s:closeTreeIfQuitOnOpen()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.AddBookmark(name, path) {{{3
|
" FUNCTION: Bookmark.AddBookmark(name, path) {{{3
|
||||||
" Class method to add a new bookmark to the list, if a previous bookmark exists
|
" Class method to add a new bookmark to the list, if a previous bookmark exists
|
||||||
@@ -389,6 +379,33 @@ function! s:Bookmark.New(name, path)
|
|||||||
let newBookmark.path = a:path
|
let newBookmark.path = a:path
|
||||||
return newBookmark
|
return newBookmark
|
||||||
endfunction
|
endfunction
|
||||||
|
" FUNCTION: Bookmark.open([options]) {{{3
|
||||||
|
"Args:
|
||||||
|
"A dictionary containing the following keys (all optional):
|
||||||
|
" 'split': Specifies whether the node should be opened in new split/tab or in
|
||||||
|
" the previous window. Can be either 'v' or 'h' or 't' (for open in
|
||||||
|
" new tab)
|
||||||
|
" 'reuse': if a window is displaying the file then jump the cursor there
|
||||||
|
" 'keepopen': dont close the tree window
|
||||||
|
" 'stay': open the file, but keep the cursor in the tree win
|
||||||
|
"
|
||||||
|
function! s:Bookmark.open(...)
|
||||||
|
let opts = a:0 ? a:1 : {}
|
||||||
|
|
||||||
|
if self.path.isDirectory
|
||||||
|
if has_key(opts, 'split')
|
||||||
|
let n = s:TreeDirNode.New(self.path)
|
||||||
|
call n.open(opts)
|
||||||
|
else
|
||||||
|
call self.toRoot()
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if self.validate()
|
||||||
|
let n = s:TreeFileNode.New(self.path)
|
||||||
|
call n.open(opts)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
" FUNCTION: Bookmark.openInNewTab(options) {{{3
|
" FUNCTION: Bookmark.openInNewTab(options) {{{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:Bookmark.openInNewTab(options)
|
function! s:Bookmark.openInNewTab(options)
|
||||||
@@ -3817,6 +3834,9 @@ function! s:bindMappings()
|
|||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" })
|
||||||
|
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" })
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" })
|
||||||
@@ -4092,14 +4112,14 @@ function! s:openBookmark(name)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:openHSplit(node) {{{2
|
" FUNCTION: s:openHSplit(target) {{{2
|
||||||
function! s:openHSplit(node)
|
function! s:openHSplit(target)
|
||||||
call a:node.activate({'split': 'h'})
|
call a:target.activate({'split': 'h'})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:openVSplit(node) {{{2
|
" FUNCTION: s:openVSplit(target) {{{2
|
||||||
function! s:openVSplit(node)
|
function! s:openVSplit(target)
|
||||||
call a:node.activate({'split': 'v'})
|
call a:target.activate({'split': 'v'})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:openExplorer(node) {{{2
|
" FUNCTION: s:openExplorer(node) {{{2
|
||||||
|
|||||||
Reference in New Issue
Block a user