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

This adds support for controlling display of suffix/prefix #893

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autoload/tagbar/prototypes/basetag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ endfunction
function! s:_getPrefix() abort dict
let fileinfo = self.fileinfo

if !empty(self._childlist)
if !empty(self._childlist) && g:tagbar_show_prefix == 1
if fileinfo.tagfolds[self.fields.kind][self.fullpath]
let prefix = g:tagbar#icon_closed
else
Expand All @@ -95,9 +95,9 @@ function! s:_getPrefix() abort dict
endif
" Visibility is called 'access' in the ctags output
if g:tagbar_show_visibility
if has_key(self.fields, 'access')
if has_key(self.fields, 'access') && g:tagbar_show_prefix == 1
let prefix .= get(s:visibility_symbols, self.fields.access, ' ')
elseif has_key(self.fields, 'file')
elseif has_key(self.fields, 'file') && g:tagbar_show_prefix == 1
let prefix .= s:visibility_symbols.private
else
let prefix .= ' '
Expand Down
27 changes: 16 additions & 11 deletions autoload/tagbar/prototypes/normaltag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@ endfunction
function! s:strfmt() abort dict
let typeinfo = self.typeinfo

let suffix = get(self.fields, 'signature', '')
if has_key(self.fields, 'type')
let suffix .= ' : ' . self.fields.type
elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind)
let scope = s:maybe_map_scope(typeinfo.kind2scope[self.fields.kind])
if !g:tagbar_show_data_type
let suffix .= ' : ' . scope
if g:tagbar_show_suffix == 1
let suffix = get(self.fields, 'signature', '')
if has_key(self.fields, 'type')
let suffix .= ' : ' . self.fields.type
elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind)
let scope = s:maybe_map_scope(typeinfo.kind2scope[self.fields.kind])
if !g:tagbar_show_data_type
let suffix .= ' : ' . scope
endif
endif
endif
let prefix = self._getPrefix()

if g:tagbar_show_data_type && self.getDataType() !=# ''
let suffix .= ' : ' . self.getDataType()
if g:tagbar_show_data_type && self.getDataType() !=# ''
let suffix .= ' : ' . self.getDataType()
endif
else
let suffix = ''
endif

let prefix = self._getPrefix()

if g:tagbar_show_tag_linenumbers == 1
let suffix .= ' [' . self.fields.line . ']'
elseif g:tagbar_show_tag_linenumbers == 2
Expand Down
31 changes: 31 additions & 0 deletions doc/tagbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,37 @@ Possible values are:
Example:
>
let g:tagbar_show_linenumbers = 2
<
*g:tagbar_show_prefix*
g:tagbar_show_prefix~
Default: 1

Controls if the prefix information is shown before the tag. The prefix info is
usually defined as the variable scope. For example, if a variable is private
scope only, then a '-' symbol will be used by default.

Possible values are:
0: Don't show the prefix.
1: Show the prefix.

Example:
>
let g:tagbar_show_prefix = 0
<
*g:tagbar_show_suffix*
g:tagbar_show_suffix~
Default: 1

Controls if the suffix information is shown after the tag. The suffix info is
usually data type.

Possible values are:
0: Don't show the suffix.
1: Show the suffix.

Example:
>
let g:tagbar_show_suffix = 0
<
*g:tagbar_show_tag_linenumbers*
g:tagbar_show_tag_linenumbers~
Expand Down
2 changes: 2 additions & 0 deletions plugin/tagbar.vim
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ function! s:setup_options() abort
\ ['show_data_type', 0],
\ ['show_visibility', 1],
\ ['show_linenumbers', 0],
\ ['show_prefix', 1],
\ ['show_suffix', 1],
\ ['show_tag_count', 0],
\ ['show_tag_linenumbers', 0],
\ ['singleclick', 0],
Expand Down
Loading