mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 05:50:00 +08:00
feat: jump to bookmark table shortcut. (#1394)
Co-authored-by: Daniel Schreck <daniel.s.schreck@gmail.com>
This commit is contained in:
parent
f3a4d8eaa8
commit
6ad85ec29b
|
@ -70,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
||||||
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
||||||
|
@ -496,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort
|
||||||
call b:NERDTree.ui.centerView()
|
call b:NERDTree.ui.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:jumpToBookmarks() {{{1
|
||||||
|
" moves the cursor to the bookmark table
|
||||||
|
function! s:jumpToBookmarks() abort
|
||||||
|
try
|
||||||
|
if b:NERDTree.ui.getShowBookmarks()
|
||||||
|
call g:NERDTree.CursorToBookmarkTable()
|
||||||
|
else
|
||||||
|
call b:NERDTree.ui.setShowBookmarks(1)
|
||||||
|
endif
|
||||||
|
catch /^NERDTree/
|
||||||
|
call nerdtree#echoError('Failed to jump to the bookmark table')
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||||
" Open the Bookmark that has the specified name. This function provides the
|
" Open the Bookmark that has the specified name. This function provides the
|
||||||
" implementation for the :OpenBookmark command.
|
" implementation for the :OpenBookmark command.
|
||||||
|
|
|
@ -62,6 +62,7 @@ function! s:UI._dumpHelp()
|
||||||
let help .= "\"\n\" ----------------------------\n"
|
let help .= "\"\n\" ----------------------------\n"
|
||||||
let help .= "\" Bookmark table mappings~\n"
|
let help .= "\" Bookmark table mappings~\n"
|
||||||
let help .= "\" double-click,\n"
|
let help .= "\" double-click,\n"
|
||||||
|
let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n"
|
||||||
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
||||||
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
||||||
|
@ -482,10 +483,10 @@ function! s:UI.toggleIgnoreFilter()
|
||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
" FUNCTION: s:UI.setShowBookmarks() {{{1
|
||||||
" Toggle the visibility of the Bookmark table.
|
" Sets the visibility of the Bookmark table.
|
||||||
function! s:UI.toggleShowBookmarks()
|
function! s:UI.setShowBookmarks(value)
|
||||||
let self._showBookmarks = !self._showBookmarks
|
let self._showBookmarks = a:value
|
||||||
|
|
||||||
if self.getShowBookmarks()
|
if self.getShowBookmarks()
|
||||||
call self.nerdtree.render()
|
call self.nerdtree.render()
|
||||||
|
@ -503,6 +504,12 @@ function! s:UI.toggleShowBookmarks()
|
||||||
call self.centerView()
|
call self.centerView()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||||
|
" Toggle the visibility of the Bookmark table.
|
||||||
|
function! s:UI.toggleShowBookmarks()
|
||||||
|
call self.setShowBookmarks(!self._showBookmarks)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
||||||
" toggles the display of hidden files
|
" toggles the display of hidden files
|
||||||
function! s:UI.toggleShowFiles()
|
function! s:UI.toggleShowFiles()
|
||||||
|
|
|
@ -101,6 +101,7 @@ endif
|
||||||
|
|
||||||
"SECTION: Init variable calls for key mappings {{{2
|
"SECTION: Init variable calls for key mappings {{{2
|
||||||
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
||||||
|
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb')
|
||||||
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
||||||
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
||||||
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user