From a6dd1c3887bac1224ee713c8c544beab1501823a Mon Sep 17 00:00:00 2001 From: Kris Warner Date: Tue, 2 Feb 2021 09:15:01 -0500 Subject: [PATCH] Add searchmethod setting for tagbar extension The current implementation of tagbar does not allow for setting the search-method in the `tagbar#currenttag` function. In https://github.com/preservim/tagbar/pull/696, tagbar implemented this, which has three options: nearest, neartest-stl, and scoped-stl. The reason for adding this - for me, at least - is to use the scoped-stl option, so that the statusline will display the proper function when there are nested functions. (Otherwise, once you go past a nested function, tagbar#currenttag still returns the nested function rather than the function it was nested in.) --- autoload/airline/extensions/tagbar.vim | 2 +- doc/airline.txt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tagbar.vim b/autoload/airline/extensions/tagbar.vim index e7f47d16..264f8350 100644 --- a/autoload/airline/extensions/tagbar.vim +++ b/autoload/airline/extensions/tagbar.vim @@ -43,7 +43,7 @@ function! airline#extensions#tagbar#currenttag() endif " function tagbar#currenttag does not exist, if filetype is not enabled if s:airline_tagbar_last_lookup_time != localtime() && exists("*tagbar#currenttag") - let s:airline_tagbar_last_lookup_val = tagbar#currenttag('%s', '', s:flags) + let s:airline_tagbar_last_lookup_val = tagbar#currenttag('%s', '', s:flags, get(g:, 'airline#extensions#tagbar#searchmethod', '')) let s:airline_tagbar_last_lookup_time = localtime() endif return s:airline_tagbar_last_lookup_val diff --git a/doc/airline.txt b/doc/airline.txt index a5b735a0..2c7f0a12 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -1377,6 +1377,11 @@ tagbar let g:airline#extensions#tagbar#flags = 's' let g:airline#extensions#tagbar#flags = 'p' < +* configure how to search for the nearest tag (:help tagbar-statusline) > + let g:airline#extensions#tagbar#searchmethod = 'nearest-stl' (default) + let g:airline#extensions#tagbar#searchmethod = 'nearest' + let g:airline#extensions#tagbar#searchmethod = 'scoped-stl' +< ------------------------------------- *airline-tmuxline* tmuxline