mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
make the t/T mappings work for bookmarks
when you hit t/T on a bookmark a new tab is opened and, if the bookmark is a dir, a nerd tree is opened for that dir. If the bookmark is a file then just open the file
This commit is contained in:
@@ -2749,8 +2749,8 @@ function! s:BindMappings()
|
|||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpLastChild ." :call <SID>JumpToLastChild()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpLastChild ." :call <SID>JumpToLastChild()<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpRoot ." :call <SID>JumpToRoot()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpRoot ." :call <SID>JumpToRoot()<cr>"
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>OpenNodeNewTab(0)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>OpenInNewTab(0)<cr>"
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenNodeNewTab(1)<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenInNewTab(1)<cr>"
|
||||||
|
|
||||||
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
|
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
|
||||||
|
|
||||||
@@ -3159,27 +3159,35 @@ function! s:OpenExplorer()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2
|
" FUNCTION: s:OpenInNewTab(stayCurrentTab) {{{2
|
||||||
" Opens the currently selected file from the explorer in a
|
" Opens the selected node or bookmark in a new tab
|
||||||
" new tab
|
|
||||||
"
|
|
||||||
" Args:
|
" Args:
|
||||||
" stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim
|
" stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim
|
||||||
" will go to the tab where the new file is opened
|
" will go to the tab where the new file is opened
|
||||||
function! s:OpenNodeNewTab(stayCurrentTab)
|
function! s:OpenInNewTab(stayCurrentTab)
|
||||||
|
let currentTab = tabpagenr()
|
||||||
|
|
||||||
let treenode = s:GetSelectedNode()
|
let treenode = s:GetSelectedNode()
|
||||||
if treenode != {}
|
if treenode != {}
|
||||||
let curTabNr = tabpagenr()
|
|
||||||
exec "tabedit " . treenode.path.StrForEditCmd()
|
exec "tabedit " . treenode.path.StrForEditCmd()
|
||||||
if a:stayCurrentTab
|
if a:stayCurrentTab
|
||||||
exec "tabnext " . curTabNr
|
exec "tabnext " . currentTab
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:Echo("select a node first")
|
let bookmark = s:GetSelectedBookmark()
|
||||||
|
if bookmark != {}
|
||||||
|
if bookmark.path.isDirectory
|
||||||
|
exec "tabnew +NERDTreeFromBookmark\\ " . bookmark.name
|
||||||
|
else
|
||||||
|
exec "tabedit " . bookmark.path.StrForEditCmd()
|
||||||
|
endif
|
||||||
|
if a:stayCurrentTab
|
||||||
|
exec "tabnext " . currentTab
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" FUNCTION: s:OpenNodeRecursively() {{{2
|
" FUNCTION: s:OpenNodeRecursively() {{{2
|
||||||
function! s:OpenNodeRecursively()
|
function! s:OpenNodeRecursively()
|
||||||
let treenode = s:GetSelectedNode()
|
let treenode = s:GetSelectedNode()
|
||||||
|
|||||||
Reference in New Issue
Block a user