From 2a36ad79a7edb620210966fbbce1da4766cf38f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valter=20Sundstr=C3=B6m?= Date: Tue, 12 Jan 2021 05:41:44 +0100 Subject: [PATCH] Add TagbarJump (#515) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sundström Valter Co-authored-by: David Hegland --- autoload/tagbar.vim | 9 +++++++++ doc/tagbar.txt | 14 ++++++++++++++ plugin/tagbar.vim | 2 ++ 3 files changed, 25 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4d9dc61..2582999 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3969,5 +3969,14 @@ function! tagbar#IsOpen() abort endif endfunction +" tagbar#jump() {{{2 +function! tagbar#jump() abort + if &filetype !=# 'tagbar' + " Not in tagbar window - ignore this function call + return + endif + call s:JumpToTag(1) +endfun + " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 3350a8f..47cbd49 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -318,6 +318,13 @@ COMMANDS *tagbar-commands* the file size limit. So if the file is written and needs to be processed again, this command will need to be re-executed. +:TagbarJump *:TagbarJump* + Jump to the tag under the cursor. This only works while the cursor is in + the tagbar window. This will leave the cursor in the tagbar window. It is + the same behavior as the |p| key mapping. + + This command will call the |tagbar#jump()| function. + ------------------------------------------------------------------------------ FUNCTIONS *tagbar-functions* @@ -360,6 +367,13 @@ FUNCTIONS *tagbar-functions* This function will return 1 if the tagbar window is open, else it will return 0. +*tagbar#jump()* + Jump to the tag under the cursor. This only works while the cursor is in + the tagbar window. This will leave the cursor in the tagbar window. It is + the same behavior as the |p| key mapping. + + This is the function called when using the |:TagbarJump| command. + ------------------------------------------------------------------------------ KEY MAPPINGS *tagbar-keys* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 68ef10f..c93077d 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -195,6 +195,8 @@ command! -nargs=? TagbarDebug call tagbar#debug#start_debug() command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug() command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause() command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate() +command! -nargs=0 TagbarJump call tagbar#jump() + " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1