From 78a7eeecf3827acb9dcabbdf31c57440e288e201 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 11 Nov 2013 00:53:45 +1300 Subject: [PATCH] Add key to show tag in preview window --- autoload/tagbar.vim | 24 +++++++++++++++++++----- doc/tagbar.txt | 2 ++ plugin/tagbar.vim | 11 ++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index edb7ebd..13a779b 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -922,11 +922,12 @@ function! s:MapKeys() abort \ :call CheckMouseClick() let maps = [ - \ ['jump', 'JumpToTag(0)'], - \ ['preview', 'JumpToTag(1)'], - \ ['nexttag', 'GotoNextToplevelTag(1)'], - \ ['prevtag', 'GotoNextToplevelTag(-1)'], - \ ['showproto', 'ShowPrototype(0)'], + \ ['jump', 'JumpToTag(0)'], + \ ['preview', 'JumpToTag(1)'], + \ ['previewwin', 'ShowInPreviewWin()'], + \ ['nexttag', 'GotoNextToplevelTag(1)'], + \ ['prevtag', 'GotoNextToplevelTag(-1)'], + \ ['showproto', 'ShowPrototype(0)'], \ \ ['openfold', 'OpenFold()'], \ ['closefold', 'CloseFold()'], @@ -2797,6 +2798,7 @@ function! s:PrintHelp() abort silent put ='\" ' . s:get_map_str('jump') . ': Jump to tag definition' silent put ='\" ' . s:get_map_str('preview') . ': As above, but stay in' silent put ='\" Tagbar window' + silent put ='\" ' . s:get_map_str('previewwin') . ': Show tag in preview window' silent put ='\" ' . s:get_map_str('nexttag') . ': Go to next top-level tag' silent put ='\" ' . s:get_map_str('prevtag') . ': Go to previous top-level tag' silent put ='\" ' . s:get_map_str('showproto') . ': Display tag prototype' @@ -2996,6 +2998,18 @@ function! s:JumpToTag(stay_in_tagbar) abort endif endfunction +" s:ShowInPreviewWin() {{{2 +function! s:ShowInPreviewWin() abort + let taginfo = s:GetTagInfo(line('.'), 1) + + if empty(taginfo) || !taginfo.isNormalTag() + return + endif + + execute 'topleft pedit +' . taginfo.fields.line . ' ' . + \ s:known_files.getCurrent(0).fpath +endfunction + " s:ShowPrototype() {{{2 function! s:ShowPrototype(short) abort let taginfo = s:GetTagInfo(line('.'), 1) diff --git a/doc/tagbar.txt b/doc/tagbar.txt index cf29602..ab99afc 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -318,6 +318,8 @@ The following mappings are valid in the Tagbar window: Map option: tagbar_map_jump p Jump to the tag under the cursor, but stay in the Tagbar window. Map option: tagbar_map_preview +P Open the tag in a |preview-window|. + Map option: tagbar_map_previewwin When on a fold icon, open or close the fold depending on the current state. <2-LeftMouse> Same as . See |g:tagbar_singleclick| if you want to use a diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 52f4e1f..4e2e21a 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -80,11 +80,12 @@ if !exists('g:tagbar_iconchars') endif let s:keymaps = [ - \ ['jump', ''], - \ ['preview', 'p'], - \ ['nexttag', ''], - \ ['prevtag', ''], - \ ['showproto', ''], + \ ['jump', ''], + \ ['preview', 'p'], + \ ['previewwin', 'P'], + \ ['nexttag', ''], + \ ['prevtag', ''], + \ ['showproto', ''], \ \ ['openfold', ['+', '', 'zo']], \ ['closefold', ['-', '', 'zc']],