From a81c01c29406df6aa59be221a17953c18ed57ccc Mon Sep 17 00:00:00 2001 From: Danilo Luvizotto Date: Mon, 17 Aug 2020 02:33:00 -0300 Subject: [PATCH 1/5] Fix maximized state track on close (#642) --- autoload/tagbar.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 932a682..29f9cb1 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1034,6 +1034,7 @@ function! s:CloseWindow() abort " Other windows are open, only close the tagbar one let curfile = tagbar#state#get_current_file(0) + let s:is_maximized = 0 close From bcc32b42b55d5aaf21c142b7acb7faa8e8ea2161 Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Mon, 24 Aug 2020 10:23:17 +0200 Subject: [PATCH 2/5] Fix has_key() parameters in currenttagtype function. (#645) --- autoload/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 29f9cb1..93a77e7 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3720,7 +3720,7 @@ function! tagbar#currenttagtype(fmt, default) abort let typeinfo = tag.fileinfo.typeinfo let plural = typeinfo.kinds[typeinfo.kinddict[kind]].long - if has_key(plural) + if has_key(s:singular_types, plural) let singular = s:singular_types[plural] else let singular = plural From 86b268471b381b5dd3946d99c05efd6599c2f7a9 Mon Sep 17 00:00:00 2001 From: zhmars <18466397+zhmars@users.noreply.github.com> Date: Wed, 26 Aug 2020 17:14:15 +0800 Subject: [PATCH 3/5] Fix --file-scope option warning (#648) --- autoload/tagbar.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 93a77e7..314b9cf 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1316,9 +1316,9 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort " universal-ctags deprecated this argument name if s:ctags_is_uctags - let ctags_args += [ '--extras=' ] + let ctags_args += [ '--extras=+F' ] else - let ctags_args += [ '--extra=' ] + let ctags_args += [ '--extra=', '--file-scope=yes' ] endif let ctags_args = ctags_args + [ @@ -1327,7 +1327,6 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort \ '--format=2', \ '--excmd=pattern', \ '--fields=nksSaf', - \ '--file-scope=yes', \ '--sort=no', \ '--append=no' \ ] From 600fb4255f61a41ccbcf2c6b0387e58aa0748d6b Mon Sep 17 00:00:00 2001 From: embear Date: Wed, 26 Aug 2020 11:16:59 +0200 Subject: [PATCH 4/5] Correct last contribution that contained an syntax error (#639) From 40413d8760146471757c69f08be68b24431f9474 Mon Sep 17 00:00:00 2001 From: raven42 Date: Wed, 26 Aug 2020 04:18:05 -0500 Subject: [PATCH 5/5] Add user facing function to get tag near line number (#643) --- autoload/tagbar.vim | 26 ++++++++++++++++++++++++++ doc/tagbar.txt | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 314b9cf..c825b97 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3515,6 +3515,32 @@ endfunction " Autoload functions {{{1 " Wrappers {{{2 +function! tagbar#GetTagNearLine(lnum, ...) abort + if a:0 > 0 + let fmt = a:1 + let longsig = a:2 =~# 's' + let fullpath = a:2 =~# 'f' + let prototype = a:2 =~# 'p' + else + let fmt = '%s' + let longsig = 0 + let fullpath = 0 + let prototype = 0 + endif + + let taginfo = s:GetNearbyTag(0, 1, a:lnum) + + if empty(taginfo) + return '' + endif + + if prototype + return taginfo.getPrototype(1) + else + return printf(fmt, taginfo.str(longsig, fullpath)) + endif +endfunction + function! tagbar#ToggleWindow(...) abort let flags = a:0 > 0 ? a:1 : '' call s:ToggleWindow(flags) diff --git a/doc/tagbar.txt b/doc/tagbar.txt index d8b009a..3695ed3 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -320,6 +320,24 @@ FUNCTIONS *tagbar-functions* update tag information. This should be called after you have used |tagbar#currenttag| manually. +*tagbar#GetTagNearLine()* + Get the current tag near the specified line number (lnum). Optionally + takes a fmt and signature specification using the same method as the + |tagbar#currenttag()| function. Defaults to GetTagNearLine(lnum, '%s', ''). + + This could be used in a custom foldtext function to show the current tag + the fold current fold is located in. + + Example: + > + set foldtext=MyFoldFunc() + function! MyFoldFunc() + let tag = tagbar#GetTagNearLine(v:foldend, '%s', 'p') + let lines = v:foldend - v:foldstart + 1 + return tag . ' --- ' . lines . ' lines' + endfunction +< + ------------------------------------------------------------------------------ KEY MAPPINGS *tagbar-keys*