Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'b' binding to jump to bookmark table #1307

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
-->
#### 6.10
- **.17**: Add 'b' binding to to jump to bookmark table. (ds2606) [#1305](https://github.com/preservim/nerdtree/pull/1305)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not doing a new version for each PR anymore, just remove this change log. For now, I'll use the PR titles to write multi-bulletin change logs.

- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269)
- **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266)
- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265)
Expand Down
12 changes: 12 additions & 0 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
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:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
Expand Down Expand Up @@ -495,6 +496,17 @@ function! s:jumpToSibling(node, forward) abort
call b:NERDTree.ui.centerView()
endfunction

" FUNCTION: s:jumpToBookmarks() {{{1
" moves the cursor to the bookmark listing
function! s:jumpToBookmarks() abort
try
Copy link
Member

@rzvxa rzvxa Dec 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ds2606 Hello sir, I'm sorry to see your beautiful PR has been waiting for this long.
I'm Currently going back into old PRs to find useful unmerged ones like yours. Is there any chance that you have an interest in continuing to work on this PR?

My only issue with this code is using try/catch instead of checking whether or not the bookmark section is open via this function call:

b:NERDTree.ui.getShowBookmarks()

call g:NERDTree.CursorToBookmarkTable()
catch /^NERDTree.BookmarkTableNotFoundError\|^NERDTree.IllegalOperationError/
call nerdtree#echoError('bookmark table is closed')
return
endtry
endfunction

" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
" Open the Bookmark that has the specified name. This function provides the
" implementation for the :OpenBookmark command.
Expand Down
1 change: 1 addition & 0 deletions lib/nerdtree/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function! s:UI._dumpHelp()
let help .= "\"\n\" ----------------------------\n"
let help .= "\" Bookmark table mappings~\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:NERDTreeMapPreview .": preview file\n"
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
Expand Down
1 change: 1 addition & 0 deletions plugin/NERD_tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ endif

"SECTION: Init variable calls for key mappings {{{2
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'b')
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
Expand Down