1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:40:06 +08:00

feat(bundle): update bundle tagbar

This commit is contained in:
wsdjeg 2022-01-16 10:48:49 +08:00
parent 1470aa788a
commit ef67c70f50
22 changed files with 2077 additions and 336 deletions

2
bundle/tagbar/.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: [alerque]
custom: ['https://paypal.me/alerque', 'https://paypal.me/dhegland42']

View File

@ -0,0 +1,30 @@
name: Check
on: [push, pull_request]
jobs:
check:
strategy:
fail-fast: false
matrix:
vimFlavor: ["vim", "nvim"]
tagsProvider: ["exuberant-ctags", "universal-ctags"]
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Enable Universe package repository
run: |
sudo add-apt-repository universe
sudo apt-get update
- name: Install ${{ matrix.tagsProvider }}
run: |
sudo apt-get install ${{ matrix.tagsProvider }}
- name: Install ${{ matrix.vimFlavor }}
run: |
sudo apt-get install ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }}
- name: Review versions
run: |
ctags --version
${{ matrix.vimFlavor }} --version
- name: "Try tagbar#OpenWindow()"
run: |
${{ matrix.vimFlavor == 'nvim' && 'nvim -u /dev/null --headless' || 'vim' }} -i NONE "+set rtp+=$(pwd)" "+call tagbar#OpenWindow() | q" "+cq" plugin/tagbar.vim

View File

@ -0,0 +1,13 @@
name: Reviewdog
on: [pull_request]
jobs:
vint:
name: vint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: vint
uses: reviewdog/action-vint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review

View File

@ -0,0 +1,15 @@
name: Vint
on: [push]
jobs:
vint:
name: vint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Setup dependencies
run: pip install vim-vint
- name: Lint Vimscript
run: vint .

View File

@ -0,0 +1,5 @@
cmdargs:
severity: style_problem
color: true
env:
neovim: false

View File

@ -26,7 +26,7 @@ II) It is allowed to distribute a modified (or extended) version of Tagbar,
then this license, or a later version, also applies to your changes. then this license, or a later version, also applies to your changes.
The current maintainer is Jan Larres <jan@majutsushi.net>. If this The current maintainer is Jan Larres <jan@majutsushi.net>. If this
changes it will be announced in appropriate places (most likely changes it will be announced in appropriate places (most likely
majutsushi.github.io/tagbar and/or github.com/majutsushi/tagbar). preservim.github.io/tagbar and/or github.com/preservim/tagbar).
When it is completely impossible to contact the maintainer, the When it is completely impossible to contact the maintainer, the
obligation to send him your changes ceases. Once the maintainer has obligation to send him your changes ceases. Once the maintainer has
confirmed that he has received your changes they will not have to be confirmed that he has received your changes they will not have to be

View File

@ -1,5 +1,7 @@
# Tagbar: a class outline viewer for Vim # Tagbar: a class outline viewer for Vim
> a forked version which is based on [tagbar](https://github.com/majutsushi/tagbar/commit/387bbadda98e1376ff3871aa461b1f0abd4ece70).
[![Vint](https://github.com/preservim/tagbar/workflows/Vint/badge.svg)](https://github.com/preservim/tagbar/actions?workflow=Vint)
[![Check](https://github.com/preservim/tagbar/workflows/Check/badge.svg)](https://github.com/preservim/tagbar/actions?workflow=Check)
## What Tagbar is ## What Tagbar is
@ -18,10 +20,19 @@ creates the tags it needs on-the-fly in-memory without creating any files.
## Dependencies ## Dependencies
[Vim 7.3.1058](http://www.vim.org/) * [Vim](http://www.vim.org/) >= 7.3.1058
[Exuberant Ctags 5.5](http://ctags.sourceforge.net/) or or any version of [NeoVim](https://neovim.io/).
[Universal Ctags](https://ctags.io) (recommended), a maintained fork of
Exuberant Ctags. * A ctags implementation: We _highly recommend_ any version of [Universal
Ctags](https://ctags.io). It is a maintained fork of Exuberant Ctags with
many bugfixes, support for many more formats, and proper Unicode support.
[Exuberant Ctags](http://ctags.sourceforge.net/) 5.5 or higher works to some
degree but will be deprecated eventually.
Some additional formats can also be handled by other providers such as
[jsctags](https://github.com/sergioramos/jsctags) or
[phpctags](https://github.com/vim-php/phpctags).
## Installation ## Installation
@ -45,12 +56,12 @@ nmap <F8> :TagbarToggle<CR>
If you do this the F8 key will toggle the Tagbar window. You can of course use If you do this the F8 key will toggle the Tagbar window. You can of course use
any shortcut you want. For more flexible ways to open and close the window any shortcut you want. For more flexible ways to open and close the window
(and the rest of the functionality) see the documentation. (and the rest of the functionality) see the [documentation](https://github.com/majutsushi/tagbar/blob/master/doc/tagbar.txt) using `:help tagbar`.
## Support for additional filetypes ## Support for additional filetypes
For filetypes that are not supported by Exuberant Ctags check out [the For filetypes that are not supported by Exuberant Ctags check out [the
wiki](https://github.com/majutsushi/tagbar/wiki) to see whether other projects wiki](https://github.com/preservim/tagbar/wiki) to see whether other projects
offer support for them and how to use them. Please add any other offer support for them and how to use them. Please add any other
projects/configurations that you find or create yourself so that others can projects/configurations that you find or create yourself so that others can
benefit from them, too. benefit from them, too.
@ -70,7 +81,7 @@ please report it on their website instead, as there is nothing I can do about
it in Tagbar. Thank you! it in Tagbar. Thank you!
You can also have a look at [ctags bugs that have previously been filed You can also have a look at [ctags bugs that have previously been filed
against Tagbar](https://github.com/majutsushi/tagbar/issues?labels=ctags-bug&page=1&state=closed). against Tagbar](https://github.com/preservim/tagbar/issues?labels=ctags-bug&page=1&state=closed).
## Screenshots ## Screenshots
@ -79,8 +90,11 @@ against Tagbar](https://github.com/majutsushi/tagbar/issues?labels=ctags-bug&pag
## License ## License
Vim license, see LICENSE Tagbar is distributed under the terms of the *Vim license*, see the included [LICENSE](LICENSE) file.
## Maintainer ## Contributors
Jan Larres <[jan@majutsushi.net](mailto:jan@majutsushi.net)> Tagbar was originally written by [Jan Larres](https://github.com/majutsushi).
It is actively maintained by [Caleb Maclennan](https://github.com/alerque) and [David Hegland](https://github.com/raven42).
At least [75 others have contributed](https://github.com/preservim/tagbar/graphs/contributors) features and bug fixes over the years.
Please document [issues](https://github.com/preservim/tagbar/issues) or submit [pull requests](https://github.com/preservim/tagbar/issues) on Github.

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,3 @@
let s:LOG = SpaceVim#api#import('logger')
function! tagbar#debug#start_debug(...) abort function! tagbar#debug#start_debug(...) abort
let filename = a:0 > 0 ? a:1 : '' let filename = a:0 > 0 ? a:1 : ''
@ -29,14 +27,6 @@ function! tagbar#debug#stop_debug() abort
let s:debug_file = '' let s:debug_file = ''
endfunction endfunction
function! tagbar#debug#info(msg) abort
call s:LOG.info(a:msg)
endfunction
function! tagbar#debug#warn(msg) abort
call s:LOG.warn(a:msg)
endfunction
function! tagbar#debug#log(msg) abort function! tagbar#debug#log(msg) abort
if s:debug_enabled if s:debug_enabled
execute 'redir >> ' . s:debug_file execute 'redir >> ' . s:debug_file

View File

@ -3,6 +3,9 @@ let s:visibility_symbols = {
\ 'protected' : '#', \ 'protected' : '#',
\ 'private' : '-' \ 'private' : '-'
\ } \ }
if exists('g:tagbar_visibility_symbols') && !empty(g:tagbar_visibility_symbols)
let s:visibility_symbols = g:tagbar_visibility_symbols
endif
function! tagbar#prototypes#basetag#new(name) abort function! tagbar#prototypes#basetag#new(name) abort
let newobj = {} let newobj = {}
@ -11,7 +14,9 @@ function! tagbar#prototypes#basetag#new(name) abort
let newobj.fields = {} let newobj.fields = {}
let newobj.fields.line = 0 let newobj.fields.line = 0
let newobj.fields.column = 0 let newobj.fields.column = 0
let newobj.fields.end = 0
let newobj.prototype = '' let newobj.prototype = ''
let newobj.data_type = ''
let newobj.path = '' let newobj.path = ''
let newobj.fullpath = a:name let newobj.fullpath = a:name
let newobj.depth = 0 let newobj.depth = 0
@ -27,6 +32,7 @@ function! tagbar#prototypes#basetag#new(name) abort
let newobj.isSplitTag = function(s:add_snr('s:isSplitTag')) let newobj.isSplitTag = function(s:add_snr('s:isSplitTag'))
let newobj.isKindheader = function(s:add_snr('s:isKindheader')) let newobj.isKindheader = function(s:add_snr('s:isKindheader'))
let newobj.getPrototype = function(s:add_snr('s:getPrototype')) let newobj.getPrototype = function(s:add_snr('s:getPrototype'))
let newobj.getDataType = function(s:add_snr('s:getDataType'))
let newobj._getPrefix = function(s:add_snr('s:_getPrefix')) let newobj._getPrefix = function(s:add_snr('s:_getPrefix'))
let newobj.initFoldState = function(s:add_snr('s:initFoldState')) let newobj.initFoldState = function(s:add_snr('s:initFoldState'))
let newobj.getClosedParentTline = function(s:add_snr('s:getClosedParentTline')) let newobj.getClosedParentTline = function(s:add_snr('s:getClosedParentTline'))
@ -69,6 +75,11 @@ function! s:getPrototype(short) abort dict
return self.prototype return self.prototype
endfunction endfunction
" s:getDataType() {{{1
function! s:getDataType() abort dict
return self.data_type
endfunction
" s:_getPrefix() {{{1 " s:_getPrefix() {{{1
function! s:_getPrefix() abort dict function! s:_getPrefix() abort dict
let fileinfo = self.fileinfo let fileinfo = self.fileinfo
@ -227,7 +238,7 @@ endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -9,6 +9,12 @@ function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort
" File modification time " File modification time
let newobj.mtime = getftime(a:fname) let newobj.mtime = getftime(a:fname)
" Get file size
let newobj.fsize = getfsize(a:fname)
" Get the number of lines in the file
let newobj.lnum = line('$')
" The vim file type " The vim file type
let newobj.ftype = a:ftype let newobj.ftype = a:ftype
@ -52,6 +58,10 @@ function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort
let newobj.openKindFold = function(s:add_snr('s:openKindFold')) let newobj.openKindFold = function(s:add_snr('s:openKindFold'))
let newobj.closeKindFold = function(s:add_snr('s:closeKindFold')) let newobj.closeKindFold = function(s:add_snr('s:closeKindFold'))
" This is used during file processing. If the limit is exceeded at that
" point, then mark this flag for displaying to the tagbar window
let newobj.fsize_exceeded = 0
return newobj return newobj
endfunction endfunction
@ -136,7 +146,7 @@ endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -51,7 +51,7 @@ endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -1,3 +1,12 @@
function! s:maybe_map_scope(scopestr) abort
if !empty(g:tagbar_scopestrs)
if has_key(g:tagbar_scopestrs, a:scopestr)
return g:tagbar_scopestrs[a:scopestr]
endif
endif
return a:scopestr
endfunction
function! tagbar#prototypes#normaltag#new(name) abort function! tagbar#prototypes#normaltag#new(name) abort
let newobj = tagbar#prototypes#basetag#new(a:name) let newobj = tagbar#prototypes#basetag#new(a:name)
@ -5,6 +14,7 @@ function! tagbar#prototypes#normaltag#new(name) abort
let newobj.strfmt = function(s:add_snr('s:strfmt')) let newobj.strfmt = function(s:add_snr('s:strfmt'))
let newobj.str = function(s:add_snr('s:str')) let newobj.str = function(s:add_snr('s:str'))
let newobj.getPrototype = function(s:add_snr('s:getPrototype')) let newobj.getPrototype = function(s:add_snr('s:getPrototype'))
let newobj.getDataType = function(s:add_snr('s:getDataType'))
return newobj return newobj
endfunction endfunction
@ -22,15 +32,29 @@ function! s:strfmt() abort dict
if has_key(self.fields, 'type') if has_key(self.fields, 'type')
let suffix .= ' : ' . self.fields.type let suffix .= ' : ' . self.fields.type
elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind) elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind)
let suffix .= ' : ' . 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
let prefix = self._getPrefix()
if g:tagbar_show_data_type && self.getDataType() !=# ''
let suffix .= ' : ' . self.getDataType()
endif endif
return self._getPrefix() . self.name . suffix if g:tagbar_show_tag_linenumbers == 1
let suffix .= ' [' . self.fields.line . ']'
elseif g:tagbar_show_tag_linenumbers == 2
let prefix .= '[' . self.fields.line . '] '
endif
return prefix . self.name . suffix
endfunction endfunction
" s:str() {{{1 " s:str() {{{1
function! s:str(longsig, full) abort dict function! s:str(longsig, full) abort dict
if a:full && self.path != '' if a:full && self.path !=# ''
let str = self.path . self.typeinfo.sro . self.name let str = self.path . self.typeinfo.sro . self.name
else else
let str = self.name let str = self.name
@ -49,7 +73,7 @@ endfunction
" s:getPrototype() {{{1 " s:getPrototype() {{{1
function! s:getPrototype(short) abort dict function! s:getPrototype(short) abort dict
if self.prototype != '' if self.prototype !=# ''
let prototype = self.prototype let prototype = self.prototype
else else
let bufnr = self.fileinfo.bufnr let bufnr = self.fileinfo.bufnr
@ -61,6 +85,11 @@ function! s:getPrototype(short) abort dict
endif endif
let line = getbufline(bufnr, self.fields.line)[0] let line = getbufline(bufnr, self.fields.line)[0]
" If prototype includes declaration, remove the '=' and anything after
" FIXME: Need to remove this code. This breaks python prototypes that
" can include a '=' in the function paramter list.
" ex: function(arg1, optional_arg2=False)
" let line = substitute(line, '\s*=.*', '', '')
let list = split(line, '\zs') let list = split(line, '\zs')
let start = index(list, '(') let start = index(list, '(')
@ -78,7 +107,7 @@ function! s:getPrototype(short) abort dict
let prototype = line let prototype = line
let curlinenr = self.fields.line + 1 let curlinenr = self.fields.line + 1
while balance > 0 while balance > 0 && curlinenr < line('$')
let curline = getbufline(bufnr, curlinenr)[0] let curline = getbufline(bufnr, curlinenr)[0]
let curlist = split(curline, '\zs') let curlist = split(curline, '\zs')
let balance += count(curlist, '(') let balance += count(curlist, '(')
@ -107,9 +136,42 @@ function! s:getPrototype(short) abort dict
return prototype return prototype
endfunction endfunction
" s:getDataType() {{{1
function! s:getDataType() abort dict
if self.data_type !=# ''
let data_type = self.data_type
else
" This is a fallthrough attempt to derive the data_type from the line
" in the event ctags doesn't return the typeref field
let bufnr = self.fileinfo.bufnr
if self.fields.line == 0 || !bufloaded(bufnr)
" No linenumber available or buffer not loaded (probably due to
" 'nohidden'), try the pattern instead
return substitute(self.pattern, '^\\M\\^\\C\s*\(.*\)\\$$', '\1', '')
endif
let line = getbufline(bufnr, self.fields.line)[0]
let data_type = substitute(line, '\s*' . escape(self.name, '~') . '.*', '', '')
" Strip off the path if we have one along with any spaces prior to the
" path
if self.path !=# ''
let data_type = substitute(data_type, '\s*' . self.path . self.typeinfo.sro, '', '')
endif
" Strip off leading spaces
let data_type = substitute(data_type, '^\s\+', '', '')
let self.data_type = data_type
endif
return data_type
endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -20,13 +20,20 @@ function! s:strfmt() abort dict
if has_key(typeinfo.kind2scope, self.fields.kind) if has_key(typeinfo.kind2scope, self.fields.kind)
let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind]
endif endif
let prefix = self._getPrefix()
return self._getPrefix() . self.name . '*' . suffix if g:tagbar_show_tag_linenumbers == 1
let suffix .= ' [' . self.fields.line . ']'
elseif g:tagbar_show_tag_linenumbers == 2
let prefix .= '[' . self.fields.line . '] '
endif
return prefix . self.name . '*' . suffix
endfunction endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -16,7 +16,7 @@ function! s:isSplitTag() abort dict
endfunction endfunction
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -15,7 +15,8 @@ endfunction
" s:getKind() {{{1 " s:getKind() {{{1
function! s:getKind(kind) abort dict function! s:getKind(kind) abort dict
let idx = self.kinddict[a:kind] "let idx = self.kinddict[a:kind]
let idx = has_key(self.kinddict, a:kind) ? self.kinddict[a:kind] : -1
return self.kinds[idx] return self.kinds[idx]
endfunction endfunction
@ -32,7 +33,7 @@ endfunction
" s:add_snr() {{{1 " s:add_snr() {{{1
function! s:add_snr(funcname) abort function! s:add_snr(funcname) abort
if !exists("s:snr") if !exists('s:snr')
let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$') let s:snr = matchstr(expand('<sfile>'), '<SNR>\d\+_\zeget_snr$')
endif endif
return s:snr . a:funcname return s:snr . a:funcname

View File

@ -6,7 +6,7 @@ function! tagbar#sorting#sort(tags, compareby, compare_typeinfo) abort
let s:compare_typeinfo = a:compare_typeinfo let s:compare_typeinfo = a:compare_typeinfo
let comparemethod = let comparemethod =
\ a:compareby == 'kind' ? 's:compare_by_kind' : 's:compare_by_line' \ a:compareby ==# 'kind' ? 's:compare_by_kind' : 's:compare_by_line'
call sort(a:tags, comparemethod) call sort(a:tags, comparemethod)
@ -21,6 +21,12 @@ endfunction
function! s:compare_by_kind(tag1, tag2) abort function! s:compare_by_kind(tag1, tag2) abort
let typeinfo = s:compare_typeinfo let typeinfo = s:compare_typeinfo
if !has_key(typeinfo.kinddict, a:tag1.fields.kind)
return -1
endif
if !has_key(typeinfo.kinddict, a:tag2.fields.kind)
return 1
endif
if typeinfo.kinddict[a:tag1.fields.kind] <# if typeinfo.kinddict[a:tag1.fields.kind] <#
\ typeinfo.kinddict[a:tag2.fields.kind] \ typeinfo.kinddict[a:tag2.fields.kind]
return -1 return -1

View File

@ -115,6 +115,7 @@ function! tagbar#types#ctags#init(supported_types) abort
\ 'union' : 'u' \ 'union' : 'u'
\ } \ }
let types.c = type_c let types.c = type_c
let types.lpc = type_c
" C++ {{{1 " C++ {{{1
let type_cpp = tagbar#prototypes#typeinfo#new() let type_cpp = tagbar#prototypes#typeinfo#new()
let type_cpp.ctagstype = 'c++' let type_cpp.ctagstype = 'c++'
@ -194,6 +195,21 @@ function! tagbar#types#ctags#init(supported_types) abort
\ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}
\ ] \ ]
let types.cobol = type_cobol let types.cobol = type_cobol
" Crystal {{{1
let type_crystal = tagbar#prototypes#typeinfo#new()
let type_crystal.ctagstype = 'crystal'
let type_crystal.kinds = [
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'd', 'long' : 'defs', 'fold' : 0, 'stl' : 1},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'M', 'long' : 'macros', 'fold' : 0, 'stl' : 1},
\ {'short' : 'l', 'long' : 'libs', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
\ {'short' : 'a', 'long' : 'aliases', 'fold' : 0, 'stl' : 1}
\ ]
let type_crystal.sro = '::'
let types.crystal = type_crystal
" DOS Batch {{{1 " DOS Batch {{{1
let type_dosbatch = tagbar#prototypes#typeinfo#new() let type_dosbatch = tagbar#prototypes#typeinfo#new()
let type_dosbatch.ctagstype = 'dosbatch' let type_dosbatch.ctagstype = 'dosbatch'
@ -292,6 +308,27 @@ function! tagbar#types#ctags#init(supported_types) abort
\ 'subroutine' : 's' \ 'subroutine' : 's'
\ } \ }
let types.fortran = type_fortran let types.fortran = type_fortran
" Go {{{1
let type_go = tagbar#prototypes#typeinfo#new()
let type_go.ctagstype = 'go'
let type_go.kinds = [
\ {'short' : 'p', 'long' : 'packages', 'fold' : 0, 'stl' : 0},
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 0},
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
\ {'short' : 'm', 'long' : 'struct members', 'fold' : 0, 'stl' : 0},
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
\ ]
let type_go.sro = '.'
let type_go.kind2scope = {
\ 's' : 'struct'
\ }
let type_go.scope2kind = {
\ 'struct' : 's'
\ }
let types.go = type_go
" HTML {{{1 " HTML {{{1
let type_html = tagbar#prototypes#typeinfo#new() let type_html = tagbar#prototypes#typeinfo#new()
let type_html.ctagstype = 'html' let type_html.ctagstype = 'html'

View File

@ -215,6 +215,7 @@ function! tagbar#types#uctags#init(supported_types) abort
\ 'union' : 'u' \ 'union' : 'u'
\ } \ }
let types.c = type_c let types.c = type_c
let types.lpc = type_c
" C++ {{{1 " C++ {{{1
let type_cpp = tagbar#prototypes#typeinfo#new() let type_cpp = tagbar#prototypes#typeinfo#new()
let type_cpp.ctagstype = 'c++' let type_cpp.ctagstype = 'c++'
@ -250,6 +251,7 @@ function! tagbar#types#uctags#init(supported_types) abort
\ } \ }
let types.cpp = type_cpp let types.cpp = type_cpp
let types.cuda = type_cpp let types.cuda = type_cpp
let types.arduino = type_cpp
" C# {{{1 " C# {{{1
let type_cs = tagbar#prototypes#typeinfo#new() let type_cs = tagbar#prototypes#typeinfo#new()
let type_cs.ctagstype = 'c#' let type_cs.ctagstype = 'c#'
@ -298,6 +300,40 @@ function! tagbar#types#uctags#init(supported_types) abort
\ 'namespace' : 'n' \ 'namespace' : 'n'
\ } \ }
let types.clojure = type_clojure let types.clojure = type_clojure
" CMake {{{1
let type_cmake = tagbar#prototypes#typeinfo#new()
let type_cmake.ctagstype = 'cmake'
let type_cmake.kinds = [
\ {'short': 'p', 'long': 'projects' , 'fold': 0, 'stl': 1},
\ {'short': 'm', 'long': 'macros' , 'fold': 0, 'stl': 1},
\ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1},
\ {'short': 'D', 'long': 'options' , 'fold': 0, 'stl': 1},
\ {'short': 'v', 'long': 'variables', 'fold': 0, 'stl': 1},
\ {'short': 't', 'long': 'targets' , 'fold': 0, 'stl': 1},
\ ]
let type_cmake.sro = '.'
let type_cmake.kind2scope = {
\ 'f' : 'function',
\ }
let type_cmake.scope2kind = {
\ 'function' : 'f',
\ }
let types.cmake = type_cmake
" Crystal {{{1
let type_crystal = tagbar#prototypes#typeinfo#new()
let type_crystal.ctagstype = 'crystal'
let type_crystal.kinds = [
\ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1},
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'd', 'long' : 'defs', 'fold' : 0, 'stl' : 1},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'M', 'long' : 'macros', 'fold' : 0, 'stl' : 1},
\ {'short' : 'l', 'long' : 'libs', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1},
\ {'short' : 'a', 'long' : 'aliases', 'fold' : 0, 'stl' : 1}
\ ]
let type_crystal.sro = '::'
let types.crystal = type_crystal
" Ctags config {{{1 " Ctags config {{{1
let type_ctags = tagbar#prototypes#typeinfo#new() let type_ctags = tagbar#prototypes#typeinfo#new()
let type_ctags.ctagstype = 'ctags' let type_ctags.ctagstype = 'ctags'
@ -527,12 +563,28 @@ function! tagbar#types#uctags#init(supported_types) abort
" HTML {{{1 " HTML {{{1
let type_html = tagbar#prototypes#typeinfo#new() let type_html = tagbar#prototypes#typeinfo#new()
let type_html.ctagstype = 'html' let type_html.ctagstype = 'html'
let type_html.ctagsargs = [
\ '--fields=+{roles}',
\ '--extras=+{reference}',
\ '--extras=+F',
\ '-f',
\ '-',
\ '--format=2',
\ '--excmd=pattern',
\ '--fields=nksSafet',
\ '--sort=no',
\ '--append=no',
\ ]
let type_html.kinds = [ let type_html.kinds = [
\ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1}, \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1},
\ {'short' : 'h', 'long' : 'H1 headings', 'fold' : 0, 'stl' : 1}, \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'i', 'long' : 'H2 headings', 'fold' : 0, 'stl' : 1}, \ {'short' : 'C', 'long' : 'stylesheets', 'fold' : 0, 'stl' : 1},
\ {'short' : 'j', 'long' : 'H3 headings', 'fold' : 0, 'stl' : 1}, \ {'short' : 'I', 'long' : 'identifiers', 'fold' : 0, 'stl' : 1},
\ ] \ {'short' : 'J', 'long' : 'scripts', 'fold' : 0, 'stl' : 1},
\ {'short' : 'h', 'long' : 'H1 headings', 'fold' : 1, 'stl' : 1},
\ {'short' : 'i', 'long' : 'H2 headings', 'fold' : 1, 'stl' : 1},
\ {'short' : 'j', 'long' : 'H3 headings', 'fold' : 1, 'stl' : 1},
\ ]
let types.html = type_html let types.html = type_html
" Java {{{1 " Java {{{1
let type_java = tagbar#prototypes#typeinfo#new() let type_java = tagbar#prototypes#typeinfo#new()
@ -583,6 +635,31 @@ function! tagbar#types#uctags#init(supported_types) abort
\ 'function' : 'f', \ 'function' : 'f',
\ } \ }
let types.javascript = type_javascript let types.javascript = type_javascript
" Kotlin {{{1
let type_kotlin = tagbar#prototypes#typeinfo#new()
let type_kotlin.ctagstype = 'kotlin'
let type_kotlin.kinds = [
\ {'short': 'p', 'long': 'packages', 'fold':0, 'stl':0},
\ {'short': 'c', 'long': 'classes', 'fold':0, 'stl':1},
\ {'short': 'o', 'long': 'objects', 'fold':0, 'stl':0},
\ {'short': 'i', 'long': 'interfaces', 'fold':0, 'stl':0},
\ {'short': 'T', 'long': 'typealiases', 'fold':0, 'stl':0},
\ {'short': 'm', 'long': 'methods', 'fold':0, 'stl':1},
\ {'short': 'C', 'long': 'constants', 'fold':0, 'stl':0},
\ {'short': 'v', 'long': 'variables', 'fold':0, 'stl':0},
\ ]
let type_kotlin.sro = '.'
" Note: the current universal ctags version does not have proper
" definition for the scope of the tags. So for now we can't add the
" kind2scope / scope2kind for anything until ctags supports the correct
" scope info
let type_kotlin.kind2scope = {
\ }
let type_kotlin.scope2kind = {
\ }
let types.kotlin = type_kotlin
" Lisp {{{1 " Lisp {{{1
let type_lisp = tagbar#prototypes#typeinfo#new() let type_lisp = tagbar#prototypes#typeinfo#new()
let type_lisp.ctagstype = 'lisp' let type_lisp.ctagstype = 'lisp'
@ -606,6 +683,36 @@ function! tagbar#types#uctags#init(supported_types) abort
\ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1}
\ ] \ ]
let types.make = type_make let types.make = type_make
" Markdown {{{1
let type_markdown = tagbar#prototypes#typeinfo#new()
let type_markdown.ctagstype = 'markdown'
let type_markdown.kinds = [
\ {'short' : 'c', 'long' : 'chapter', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'section', 'fold' : 0, 'stl' : 1},
\ {'short' : 'S', 'long' : 'subsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 't', 'long' : 'subsubsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 'T', 'long' : 'l3subsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 'u', 'long' : 'l4subsection', 'fold' : 0, 'stl' : 1},
\ ]
let type_markdown.kind2scope = {
\ 'c' : 'chapter',
\ 's' : 'section',
\ 'S' : 'subsection',
\ 't' : 'subsubsection',
\ 'T' : 'l3subsection',
\ 'u' : 'l4subsection',
\ }
let type_markdown.scope2kind = {
\ 'chapter' : 'c',
\ 'section' : 's',
\ 'subsection' : 'S',
\ 'subsubsection' : 't',
\ 'l3subsection' : 'T',
\ 'l4subsection' : 'u',
\ }
let type_markdown.sro = '""'
let type_markdown.sort = 0
let types.markdown = type_markdown
" Matlab {{{1 " Matlab {{{1
let type_matlab = tagbar#prototypes#typeinfo#new() let type_matlab = tagbar#prototypes#typeinfo#new()
let type_matlab.ctagstype = 'matlab' let type_matlab.ctagstype = 'matlab'
@ -614,6 +721,23 @@ function! tagbar#types#uctags#init(supported_types) abort
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}
\ ] \ ]
let types.matlab = type_matlab let types.matlab = type_matlab
" NRoff {{{1
let type_nroff = tagbar#prototypes#typeinfo#new()
let type_nroff.ctagstype = 'nroff'
let type_nroff.kinds = [
\ {'short' : 't', 'long' : 'titles', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}
\ ]
let type_nroff.sro = '.'
let type_nroff.kind2scope = {
\ 't' : 'title',
\ 's' : 'section'
\ }
let type_nroff.scope2kind = {
\ 'section' : 't',
\ 'title' : 's'
\ }
let types.nroff = type_nroff
" ObjectiveC {{{1 " ObjectiveC {{{1
let type_objc = tagbar#prototypes#typeinfo#new() let type_objc = tagbar#prototypes#typeinfo#new()
let type_objc.ctagstype = 'objectivec' let type_objc.ctagstype = 'objectivec'
@ -688,9 +812,11 @@ function! tagbar#types#uctags#init(supported_types) abort
let type_perl.kinds = [ let type_perl.kinds = [
\ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0},
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
\ {'short' : 'M', 'long' : 'modules', 'fold' : 0, 'stl' : 0},
\ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0},
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1},
\ {'short' : 'd', 'long' : 'subroutineDeclarations', 'fold' : 0, 'stl' : 0}
\ ] \ ]
let types.perl = type_perl let types.perl = type_perl
" Perl 6 {{{1 " Perl 6 {{{1
@ -784,6 +910,36 @@ function! tagbar#types#uctags#init(supported_types) abort
\ {'short' : 'v', 'long' : 'function variables', 'fold' : 0, 'stl' : 0}, \ {'short' : 'v', 'long' : 'function variables', 'fold' : 0, 'stl' : 0},
\ ] \ ]
let types.r = type_r let types.r = type_r
" ReStructuredText {{{1
let type_restructuredtext = tagbar#prototypes#typeinfo#new()
let type_restructuredtext.ctagstype = 'restructuredtext'
let type_restructuredtext.kinds = [
\ {'short' : 'c', 'long' : 'chapter', 'fold' : 0, 'stl' : 1},
\ {'short' : 's', 'long' : 'section', 'fold' : 0, 'stl' : 1},
\ {'short' : 'S', 'long' : 'subsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 't', 'long' : 'subsubsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 'T', 'long' : 'l3subsection', 'fold' : 0, 'stl' : 1},
\ {'short' : 'u', 'long' : 'l4subsection', 'fold' : 0, 'stl' : 1},
\ ]
let type_restructuredtext.kind2scope = {
\ 'c' : 'chapter',
\ 's' : 'section',
\ 'S' : 'subsection',
\ 't' : 'subsubsection',
\ 'T' : 'l3subsection',
\ 'u' : 'l4subsection',
\ }
let type_restructuredtext.scope2kind = {
\ 'chapter' : 'c',
\ 'section' : 's',
\ 'subsection' : 'S',
\ 'subsubsection' : 't',
\ 'l3subsection' : 'T',
\ 'l4subsection' : 'u',
\ }
let type_restructuredtext.sro = '""'
let type_restructuredtext.sort = 0
let types.rst = type_restructuredtext
" REXX {{{1 " REXX {{{1
let type_rexx = tagbar#prototypes#typeinfo#new() let type_rexx = tagbar#prototypes#typeinfo#new()
let type_rexx.ctagstype = 'rexx' let type_rexx.ctagstype = 'rexx'
@ -928,6 +1084,35 @@ function! tagbar#types#uctags#init(supported_types) abort
\ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}
\ ] \ ]
let types.tcl = type_tcl let types.tcl = type_tcl
" TypeScript {{{1
let type_ts = tagbar#prototypes#typeinfo#new()
let type_ts.ctagstype = 'typescript'
let type_ts.kinds = [
\ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1},
\ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1},
\ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1},
\ {'short' : 'e', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1},
\ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1},
\ {'short' : 'C', 'long' : 'constants', 'fold' : 0, 'stl' : 1},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1},
\ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1},
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1},
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1},
\ ]
let type_ts.sro = '.'
let type_ts.kind2scope = {
\ 'c' : 'class',
\ 'i' : 'interface',
\ 'g' : 'enum',
\ 'n' : 'namespace',
\ }
let type_ts.scope2kind = {
\ 'class' : 'c',
\ 'interface' : 'i',
\ 'enum' : 'g',
\ 'namespace' : 'n'
\ }
let types.typescript = type_ts
" LaTeX {{{1 " LaTeX {{{1
let type_tex = tagbar#prototypes#typeinfo#new() let type_tex = tagbar#prototypes#typeinfo#new()
let type_tex.ctagstype = 'tex' let type_tex.ctagstype = 'tex'
@ -940,7 +1125,8 @@ function! tagbar#types#uctags#init(supported_types) abort
\ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1},
\ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0},
\ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0},
\ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0},
\ {'short' : 'f', 'long' : 'frames', 'fold' : 0, 'stl' : 1}
\ ] \ ]
let type_tex.sro = '""' let type_tex.sro = '""'
let type_tex.kind2scope = { let type_tex.kind2scope = {

View File

@ -2,8 +2,8 @@
Author: Jan Larres <jan@majutsushi.net> Author: Jan Larres <jan@majutsushi.net>
Licence: Vim licence, see |license| Licence: Vim licence, see |license|
Homepage: http://majutsushi.github.com/tagbar/ Homepage: https://preservim.github.io/tagbar
Version: 2.7 Version: 3.0.0
============================================================================== ==============================================================================
Contents *tagbar* *tagbar-contents* Contents *tagbar* *tagbar-contents*
@ -103,6 +103,10 @@ The following features are supported by Tagbar:
Fortran, HTML, Java, JavaScript, Lisp, Lua, Make, MatLab, OCaml, Pascal, Fortran, HTML, Java, JavaScript, Lisp, Lua, Make, MatLab, OCaml, Pascal,
Perl, PHP, Python, REXX, Ruby, Scheme, Shell script, SLang, SML, SQL, Tcl, Perl, PHP, Python, REXX, Ruby, Scheme, Shell script, SLang, SML, SQL, Tcl,
Tex, Vera, Verilog, VHDL, Vim and YACC. Tex, Vera, Verilog, VHDL, Vim and YACC.
- Additional languages are supported through universal-ctags, including
CUDA, R, Rust, Go, and many others. See
https://github.com/universal-ctags/ctags/blob/master/docs/news.rst#new-parsers
for the complete list.
- Can be extended to support arbitrary new types. - Can be extended to support arbitrary new types.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -123,12 +127,13 @@ The following requirements have to be met in order to be able to use tagbar:
- Vim 7.0 or higher. Older versions will not work since Tagbar uses data - Vim 7.0 or higher. Older versions will not work since Tagbar uses data
structures that were only introduced in Vim 7. structures that were only introduced in Vim 7.
- Exuberant ctags 5.5 or higher. Ctags is the program that generates the - At a minimum Exuberant Ctags >= 5.5, or (highly recommended) any version
tag information that Tagbar uses. It is shipped with most Linux of Universal Ctags which is a currently maintained fork of Exuberant Ctags
distributions, otherwise it can be downloaded from the following with many bugfixes, support for many more formats, and proper Unicode
website: support. Some additional formats can also be handled by other providers
such as jsctags, phpctags, or others.
http://ctags.sourceforge.net/ Universal Ctags can be downloaded from https://ctags.io/
Tagbar will work on any platform that ctags runs on -- this includes Tagbar will work on any platform that ctags runs on -- this includes
UNIX derivatives, Mac OS X and Windows. Note that other versions like UNIX derivatives, Mac OS X and Windows. Note that other versions like
@ -179,16 +184,16 @@ There are essentially two ways to use Tagbar:
Opening and closing the Tagbar window~ Opening and closing the Tagbar window~
Use |:TagbarOpen| or |:TagbarToggle| to open the Tagbar window if it is Use |:TagbarOpen| or |:TagbarToggle| to open the Tagbar window if it is
closed. By default the window is opened on the right side, set the option closed. By default the window is opened on the right side, set the option
|g:tagbar_left| to open it on the left instead. If the window is already open, |g:tagbar_position| to open it elsewhere instead. If the window is already open,
|:TagbarOpen| will jump to it and |:TagbarToggle| will close it again. |:TagbarOpen| will jump to it and |:TagbarToggle| will close it again.
|:TagbarClose| will simply close the window if it is open. |:TagbarClose| will simply close the window if it is open.
It is probably a good idea to assign a key to these commands. For example, put It is probably a good idea to assign a key to these commands. For example, put
this into your |vimrc|: this into your |vimrc|:
> >
nnoremap <silent> <F9> :TagbarToggle<CR> nnoremap <silent> <F8> :TagbarToggle<CR>
< <
You can then open and close Tagbar by simply pressing the <F9> key. You can then open and close Tagbar by simply pressing the <F8> key.
You can also use |:TagbarOpenAutoClose| to open the Tagbar window, jump to it You can also use |:TagbarOpenAutoClose| to open the Tagbar window, jump to it
and have it close automatically on tag selection regardless of the and have it close automatically on tag selection regardless of the
@ -207,6 +212,10 @@ by moving the cursor to a tag and pressing <Enter> or double-clicking on it
with the mouse. The source file will then move to the definition and put the with the mouse. The source file will then move to the definition and put the
cursor in the corresponding line. This won't work for pseudo-tags. cursor in the corresponding line. This won't work for pseudo-tags.
If the current line of the tagbar window is not on a tag, for example on the
'functions' tag-kind and <Enter> is hit, then that tag-kind will be folded or
unfolded if possible.
Sorting~ Sorting~
You can sort the tags in the Tagbar window in two ways: by name or by file You can sort the tags in the Tagbar window in two ways: by name or by file
order. Sorting them by name simply displays the tags in their alphabetical order. Sorting them by name simply displays the tags in their alphabetical
@ -261,9 +270,11 @@ COMMANDS *tagbar-commands*
:TagbarClose *:TagbarClose* :TagbarClose *:TagbarClose*
Close the Tagbar window if it is open. Close the Tagbar window if it is open.
:TagbarToggle *:TagbarToggle* :TagbarToggle [{flags}] *:TagbarToggle*
:Tagbar :Tagbar [{flags}]
Open the Tagbar window if it is closed, or close it if it is open. Open the Tagbar window if it is closed, or close it if it is open.
Additional behaviour can be specified with the same optional {flags}
argument as :TagbarOpen.
:TagbarOpenAutoClose *:TagbarOpenAutoClose* :TagbarOpenAutoClose *:TagbarOpenAutoClose*
Open the Tagbar window, jump to it and close it on tag selection. This is Open the Tagbar window, jump to it and close it on tag selection. This is
@ -284,9 +295,9 @@ COMMANDS *tagbar-commands*
Open the parent folds of the current tag in the file window as much as Open the parent folds of the current tag in the file window as much as
needed for the tag to be visible in the Tagbar window. needed for the tag to be visible in the Tagbar window.
:TagbarCurrentTag [{flags}] *:TagbarCurrentTag* :TagbarCurrentTag [{flags} [{search-method}]] *:TagbarCurrentTag*
Echo the current tag in the command line. For {flags} see Echo the current tag in the command line. For {flags} and {search-method}
|tagbar-statusline|. see |tagbar-statusline|.
:TagbarGetTypeConfig {filetype} *:TagbarGetTypeConfig* :TagbarGetTypeConfig {filetype} *:TagbarGetTypeConfig*
Paste the Tagbar configuration of the vim filetype {filetype} at the Paste the Tagbar configuration of the vim filetype {filetype} at the
@ -306,72 +317,194 @@ COMMANDS *tagbar-commands*
:TagbarDebugEnd *:TagbarDebugEnd* :TagbarDebugEnd *:TagbarDebugEnd*
End debug mode, debug messages will no longer be written to the logfile. End debug mode, debug messages will no longer be written to the logfile.
:TagbarForceUpdate *:TagbarForceUpdate*
Forcefully update a file even if it exceeds the |g:tagbar_file_size_limit|
value. This will only work for one invocation of the file processing.
After the file is processed and tags are generated, then it will re-enable
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.
:TagbarJumpPrev *:TagbarJumpPrev*
Jump to the previous tag under the cursor. This works in the file window.
This will search for the previous {'nearest-stl'} type tag starting at the
line just before the current line and do a backwards search.
This command will call the |tagbar#jumpToNearbyTag(-1)| function.
:TagbarJumpNext *:TagbarJumpNext*
Jump to the next tag under the cursor. This works in the file window.
This will search for the next {'nearest-stl'} type tag starting at the
line just after the current line and do a forward search.
This command will call the |tagbar#jumpToNearbyTag(1)| function.
------------------------------------------------------------------------------
FUNCTIONS *tagbar-functions*
*tagbar#StopAutoUpdate()*
Remove autocommands that might have been installed to automatically
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.
This function can also take in a search method similar to the
|tagbar#currenttag()| function. Full syntax is as follows:
tagbar#GetTagNearLine(lnum [, {fmt}, {flags} [, {search-method}]])
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
<
*tagbar#ForceUpdate()*
Forcefully update a file even if it exceeds the |g:tagbar_file_size_limit|
value. This also clears the internal flags to the file will be re-examined
again.
*tagbar#printfileinfo()*
This function is used in conjunction with |TagbarDebug| and will print all
the known tags into the tagbar debug logfile. This is useful for looking
at the internal tag information that tagbar tracks.
*tagbar#IsOpen()*
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.
*tagbar#jumpToNearbyTag()*
This function will jump to the next tag or previous tag starting a search
from the line under the cursor. This works when in the file window instead
of inside the tagbar window like the |tagbar#jump()| function.
The direction of search must be provided. If the [direction] is greater
than 0, then it will do a forward search. If the [direction] is less
than 0, then it will do a backward search.
Can also optionally provide a [search_method] which is used in the
|tagbar#GetTagNearLine()| function call and behaves the same way. This
will default to *'nearest-stl'* if not specified.
Can optionally provide a flags field [flags] to control the nearby tag
jumping. The flags should be a string of characters with the following
meanings:
's' - use the |g:tagbar_scroll_off| setting when jumping
Full syntax:
tagbar#jumpToNearbyTag(direction [, {search-method} [, {flags}]])
Examples:
>
" These keymaps will jump to the next/prev tag that can be scoped. Ex:
" function calls, class definitions, etc.
nnoremap t] :call tagbar#jumpToNearbyTag(1)
nnoremap t[ :call tagbar#jumpToNearbyTag(-1)
" These keymaps will jump to the next/prev tag regardless of type. Ex:
" function calls, class definitions, variable definitions, typedefs, etc.
nnoremap t] :call tagbar#jumpToNearbyTag(1, 'nearest')
nnoremap t[ :call tagbar#jumpToNearbyTag(-1, 'nearest')
" These keymaps will jump to the next/prev tag regardless of type, and
" will also use the jump_offset configuration to position the cursor
nnoremap t] :call tagbar#jumpToNearbyTag(1, 'nearest', 's')
nnoremap t[ :call tagbar#jumpToNearbyTag(-1, 'nearest', 's')
<
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
KEY MAPPINGS *tagbar-keys* KEY MAPPINGS *tagbar-keys*
The following mappings are valid in the Tagbar window: The following mappings are valid in the Tagbar window:
<F1>/? Display key mapping help. <F1>/? Display key mapping help.
Map option: tagbar_map_help Map option: |tagbar_map_help|
<CR>/<Enter> Jump to the tag under the cursor. Doesn't work for pseudo-tags <CR>/<Enter> Jump to the tag under the cursor. Doesn't work for pseudo-tags.
or generic headers. If on generic header, it will fold/unfold that header.
Map option: tagbar_map_jump Map option: |tagbar_map_jump|
p Jump to the tag under the cursor, but stay in the Tagbar window. p Jump to the tag under the cursor, but stay in the Tagbar window.
Map option: tagbar_map_preview Map option: |tagbar_map_preview|
P Open the tag in a |preview-window|. P Open the tag in a |preview-window|.
Map option: tagbar_map_previewwin Map option: |tagbar_map_previewwin|
<LeftMouse> When on a fold icon, open or close the fold depending on the <LeftMouse> When on a fold icon, open or close the fold depending on the
current state. current state.
<2-LeftMouse> Same as <CR>. See |g:tagbar_singleclick| if you want to use a <2-LeftMouse> Same as <CR>. See |g:tagbar_singleclick| if you want to use a
single- instead of a double-click. single- instead of a double-click.
<C-N> Go to the next top-level tag. <C-N> Go to the next top-level tag.
Map option: tagbar_map_nexttag Map option: |tagbar_map_nexttag|
<C-P> Go to the previous top-level tag. <C-P> Go to the previous top-level tag.
Map option: tagbar_map_prevtag Map option: |tagbar_map_prevtag|
<Space> Display the prototype of the current tag (i.e. the line defining <Space> Display the prototype of the current tag (i.e. the line defining
it) in the command line. it) in the command line.
Map option: tagbar_map_showproto Map option: |tagbar_map_showproto|
v Hide tags that are declared non-public. Tags without any v Hide tags that are declared non-public. Tags without any
visibility information will still be shown. visibility information will still be shown.
Map option: tagbar_map_hidenonpublic Map option: |tagbar_map_hidenonpublic|
+/zo Open the fold under the cursor. +/zo Open the fold under the cursor.
Map option: tagbar_map_openfold Map option: |tagbar_map_openfold|
-/zc Close the fold under the cursor or the current one if there is -/zc Close the fold under the cursor or the current one if there is
no fold under the cursor. no fold under the cursor.
Map option: tagbar_map_closefold Map option: |tagbar_map_closefold|
o/za Toggle the fold under the cursor or the current one if there is o/za Toggle the fold under the cursor or the current one if there is
no fold under the cursor. no fold under the cursor.
Map option: tagbar_map_togglefold Map option: |tagbar_map_togglefold|
*/zR Open all folds by setting foldlevel to 99. */zR Open all folds by setting foldlevel to 99.
Map option: tagbar_map_openallfolds Map option: |tagbar_map_openallfolds|
=/zM Close all folds by setting foldlevel to 0. =/zM Close all folds by setting foldlevel to 0.
Map option: tagbar_map_closeallfolds Map option: |tagbar_map_closeallfolds|
zr Increase the fold level of the buffer by 1. Opens all folds one zr Increase the fold level of the buffer by 1. Opens all folds one
level. level.
Map option: tagbar_map_incrementfolds Map option: |tagbar_map_incrementfolds|
zm Decrease the fold level of the buffer by 1. Closes all folds one zm Decrease the fold level of the buffer by 1. Closes all folds one
level. level.
Map option: tagbar_map_decrementfolds Map option: |tagbar_map_decrementfolds|
zj Go to the start of the next fold, like the standard Vim |zj|. zj Go to the start of the next fold, like the standard Vim |zj|.
Map option: tagbar_map_nextfold Map option: |tagbar_map_nextfold|
zk Go to the end of the previous fold, like the standard Vim |zk|. zk Go to the end of the previous fold, like the standard Vim |zk|.
Map option: tagbar_map_prevfold Map option: |tagbar_map_prevfold|
s Toggle sort order between name and file order. s Toggle sort order between name and file order.
Map option: tagbar_map_togglesort Map option: |tagbar_map_togglesort|
c Toggle the |g:tagbar_autoclose| option. c Toggle the |g:tagbar_autoclose| option.
Map option: tagbar_map_toggleautoclose Map option: |tagbar_map_toggleautoclose|
t Toggle the pause (like :TagbarTogglePause)
Map option: |tagbar_map_togglepause|
x Toggle zooming the window. x Toggle zooming the window.
Map option: tagbar_map_zoomwin Map option: |tagbar_map_zoomwin|
q Close the Tagbar window. q Close the Tagbar window.
Map option: tagbar_map_close Map option: |tagbar_map_close|
These mappings can be redefined with the given map options. The argument can These mappings can be redefined with the given map options. The argument can
be either a string or a |List| of strings. In the latter case the be either a string or a |List| of strings. In the latter case the
functionality will be assigned to all of the keys in the list. For example, if functionality will be assigned to all of the keys in the list.
you want to remap the sort toggling functionality to "r": For example, if you want to remap the sort toggling functionality to "r":
> >
let g:tagbar_map_togglesort = "r" let g:tagbar_map_togglesort = "r"
< <
Alternatively, if you want to disable this mapping, then set to '':
>
let g:tagbar_map_togglesort = ''
<
See |key-notation| for how to write special keys like <Space> or the keypad See |key-notation| for how to write special keys like <Space> or the keypad
keys. keys.
@ -390,10 +523,56 @@ Example:
let g:tagbar_ctags_bin = 'C:\Ctags5.8\ctags.exe' let g:tagbar_ctags_bin = 'C:\Ctags5.8\ctags.exe'
< <
*g:tagbar_ctags_options*
g:tagbar_ctags_options
Default: undefined
Use this option to specify a list of filenames to pass to ctags with the
'--options' flag. This is similar to the deffile key for tagbar type
extensions, see |tagbar-extend|, but acts globally. The special value 'NONE'
as the first entry disables reading of the default configuration files (e.g.
~/.ctags). Without this, if ~/.ctags and other files listed in
g:tagbar_ctags_options include some of the same patterns, tagbar might show
duplicate entries.
Example:
>
let g:tagbar_ctags_options = ['NONE', split(&rtp,",")[0].'/ctags.cnf']
This causes ctags to use settings from ~/.vim/ctags.cnf, ignoring other
configuration files.
*g:tagbar_position*
g:tagbar_position~
Default: 'botright vertical'
By default the Tagbar window will be opened on the right-hand side of vim in a
vertical split. Set this option to one of the standart vim split options such
as 'topleft', 'botright', 'leftabove', or 'rightbelow' to open in the
corresponding position instead. If desiring a vertically split window, then
include a ' vertical' in the field value as well. This can be useful when
activating Tagbar at the same time as another plugin which creates a new
window. It allows for more granular control of the Tagbar position in
relation to the current active window.
If using a vertical split, |g:tagbar_width| will be used to determine the
window width for the tagbar window. Else |g:tagbar_height| will be used to
determine the window height for the tagbar window.
See |split| for more details on window positioning.
Example:
>
let g:tagbar_position = 'leftabove'
<
*g:tagbar_left* *g:tagbar_left*
g:tagbar_left~ g:tagbar_left~
Default: 0 Default: 0
This option has been superceded by |g:tagbar_position| instead. It has been left
around for backward compatibility.
By default the Tagbar window will be opened on the right-hand side of vim. Set By default the Tagbar window will be opened on the right-hand side of vim. Set
this option to open it on the left instead. this option to open it on the left instead.
@ -409,6 +588,9 @@ Example:
g:tagbar_vertical~ g:tagbar_vertical~
Default: 0 Default: 0
This option has been superceded by |g:tagbar_height| instead. It has been left
around for backward compatibility.
If this is set to a positive value then the Tagbar window will be opened at If this is set to a positive value then the Tagbar window will be opened at
the top or bottom of the Vim window instead of at the side. This can be useful the top or bottom of the Vim window instead of at the side. This can be useful
for monitors that have been rotated into a vertical position. The value of for monitors that have been rotated into a vertical position. The value of
@ -420,15 +602,32 @@ Example:
let g:tagbar_vertical = 30 let g:tagbar_vertical = 30
< <
*g:tagbar_height*
g:tagbar_height~
Default: 0
If |g:tagbar_position| does not include a 'vertical' option, then this
value is used to determine the height of the Tagbar window.
Example:
>
let g:tagbar_height = 30
<
*g:tagbar_width* *g:tagbar_width*
g:tagbar_width~ g:tagbar_width~
Default: 40 Default: 40
Width of the Tagbar window in characters. If |g:tagbar_position| does include a 'vertical' options, then this value is
used to determine the width of the Tagbar window in characters. This value can
also be set using the |winwidth(0)| function call to calculate a dynamic value
to make the tagbar width relative to a percentage of the vim window size as
seen in the example below that will open the tagbar window to 20 percent of
the window width with a limit of no less than 25 characters.
Example: Example:
> >
let g:tagbar_width = 30 let g:tagbar_width = max([25, winwidth(0) / 5])
< <
*g:tagbar_zoomwidth* *g:tagbar_zoomwidth*
@ -507,11 +706,24 @@ Setting this option will result in Tagbar omitting the short help at the
top of the window and the blank lines in between top-level scopes in order to top of the window and the blank lines in between top-level scopes in order to
save screen real estate. save screen real estate.
Possible values are:
0: Show short help and blank lines between top-level scopes
1: Don't show the short help or the blank lines.
2: Don't show the short help but show the blank lines.
Example: Example:
> >
let g:tagbar_compact = 1 let g:tagbar_compact = 1
< <
*g:tagbar_help_visibility*
g:tagbar_help_visibility~
Default: 0
Setting this option will cause the full help information to be displayed all
the time in the tagbar window.
>
let g:tagbar_help_visibility = 1
<
*g:tagbar_indent* *g:tagbar_indent*
g:tagbar_indent~ g:tagbar_indent~
Default: 2 Default: 2
@ -524,6 +736,32 @@ Example:
let g:tagbar_indent = 1 let g:tagbar_indent = 1
< <
*g:tagbar_show_balloon*
g:tagbar_show_balloon~
Default: 1
Whether balloon messages should be shown in the Tagbar window.
Possible values are:
0: Don't show any balloon messages.
1: Show balloon messages. This is only available in the GUI when
compiled with the |+balloon_eval| feature.
Example:
>
let g:tagbar_show_balloon = 0
<
*g:tagbar_show_data_type*
g:tagbar_show_data_type~
Default: 0
When set to non-zero, the tag data-type will be displayed to the right of the
tag in the tagbar window.
Example:
>
let g:tagbar_show_data_type = 1
<
*g:tagbar_show_visibility* *g:tagbar_show_visibility*
g:tagbar_show_visibility~ g:tagbar_show_visibility~
Default: 1 Default: 1
@ -535,7 +773,21 @@ Example:
> >
let g:tagbar_show_visibility = 0 let g:tagbar_show_visibility = 0
< <
*g:tagbar_visibility_symbols*
g:tagbar_visibility_symbols
Default: { 'public' : '+', 'protected' : '#', 'private' : '-' }
Symbols to use for visibility (public/protected/private) to the left of the tag
name. See |g:tagbar_show_visibility|.
Example:
>
let g:tagbar_visibility_symbols = {
\ 'public' : '+',
\ 'protected' : '#',
\ 'private' : '-'
\ }
<
*g:tagbar_show_linenumbers* *g:tagbar_show_linenumbers*
g:tagbar_show_linenumbers~ g:tagbar_show_linenumbers~
Default: 0 Default: 0
@ -552,7 +804,35 @@ Example:
> >
let g:tagbar_show_linenumbers = 2 let g:tagbar_show_linenumbers = 2
< <
*g:tagbar_show_tag_linenumbers*
g:tagbar_show_tag_linenumbers~
Default: 0
This option allows printing the tag line number next to the tag in the tagbar
window. It can be set to the following values:
0 - The line number will not be printed
1 - The line number will be printed to the right of the tag >
Example: function1(int i) [123]
<
2 - The line number will be printed to the left of the tag >
Example: [123] function1(int i)
<
Example:
>
let g:tagbar_show_tag_linenumbers = 1
<
*g:tagbar_show_tag_count*
g:tagbar_show_tag_count~
Default: 0
This option allows showing the tag count next to the tag kind in the tagbar
window. This will show up like this >
> functions (<tag-count>)
<
Example:
>
let g:tagbar_show_tag_count = 1
<
*g:tagbar_hide_nonpublic* *g:tagbar_hide_nonpublic*
g:tagbar_hide_nonpublic~ g:tagbar_hide_nonpublic~
Default: 0 Default: 0
@ -621,6 +901,38 @@ just choose other characters in that case):
let g:tagbar_iconchars = ['▸', '▾'] let g:tagbar_iconchars = ['▸', '▾']
let g:tagbar_iconchars = ['▷', '◢'] let g:tagbar_iconchars = ['▷', '◢']
let g:tagbar_iconchars = ['+', '-'] (default on Windows) let g:tagbar_iconchars = ['+', '-'] (default on Windows)
<
*g:tagbar_scopestrs*
g:tagbar_scopestrs~
Default: {}
Setting to replace a tag's scope with a user-specified string in Tagbar's
display. If a scope is found in the keys of |g:tagbar_scopestrs|, then the
scope will be displayed as the corresponding value. If the scope is not
found, then the scope will be displayed as normal.
Example (don't worry if some of the characters aren't displayed correctly,
just choose other characters or strings in that case):
>
let g:tagbar_scopestrs = {
\ 'class': "\uf0e8",
\ 'const': "\uf8ff",
\ 'constant': "\uf8ff",
\ 'enum': "\uf702",
\ 'field': "\uf30b",
\ 'func': "\uf794",
\ 'function': "\uf794",
\ 'getter': "\ufab6",
\ 'implementation': "\uf776",
\ 'interface': "\uf7fe",
\ 'map': "\ufb44",
\ 'member': "\uf02b",
\ 'method': "\uf6a6",
\ 'setter': "\uf7a9",
\ 'variable': "\uf71b",
\ }
< <
*g:tagbar_autoshowtag* *g:tagbar_autoshowtag*
@ -718,14 +1030,27 @@ default statusline:
> >
function! TagbarStatusFunc(current, sort, fname, flags, ...) abort function! TagbarStatusFunc(current, sort, fname, flags, ...) abort
let colour = a:current ? '%#StatusLine#' : '%#StatusLineNC#' let colour = a:current ? '%#StatusLine#' : '%#StatusLineNC#'
let flagstr = join(flags, '') let flagstr = join(a:flags, '')
if flagstr != '' if flagstr != ''
let flagstr = '[' . flagstr . '] ' let flagstr = '[' . flagstr . '] '
endif endif
return colour . '[' . sort . '] ' . flagstr . fname return colour . '[' . a:sort . '] ' . flagstr . a:fname
endfunction endfunction
let g:tagbar_status_func = 'TagbarStatusFunc' let g:tagbar_status_func = 'TagbarStatusFunc'
< <
*g:tagbar_no_status_line*
g:no_status_line~
Default: undefined
This option will prevent any status line updates being done by Tagbar. Use
this in the event where another plugin is being used to update the status
line. If |g:tagbar_status_func| is set, then that function will never be
called.
Example:
>
let g:no_status_line = 1
<
*g:tagbar_silent* *g:tagbar_silent*
g:tagbar_silent~ g:tagbar_silent~
@ -738,6 +1063,231 @@ Example:
> >
let g:tagbar_silent = 1 let g:tagbar_silent = 1
< <
*g:tagbar_use_cache*
g:tagbar_use_cache~
Default: 1
By default the file contents are passed to ctags by writing them to
a temporary file and invoking ctags on that file. This greatly speeds up tag
generation in the event of slow file systems such as network shares and
enables tagbar to run even on netrw virtual files that ctags would otherwise
not be able to find at all. However it does incure the cost of an extra write
operation. Additionally not all sysems are able to let programs share access
to temporary file space (for example Snap packages cannot read from the host
system's temp file space). This setting can disable the cache mechanism
entriely forcing the tags to be generated from the existing copy of the file
on disk rather than the current buffer written to a temporary file.
Example:
>
let g:tagbar_use_cache = 0
<
*g:tagbar_file_size_limit*
g:tagbar_file_size_limit~
Default: 0
By default, all files are processed by tagbar. Setting this value to non-zero
will disable processing for any file with a byte count greater than
|g:tagbar_file_size_limit|. A message will be displayed once for a given buffer
if the limit is exceeded. The file can be forcefully updated with the
|tagbar#ForceUpdate()| function or with the |:TagbarForceUpdate| command. If
the value is set to 0, then the file will always be processed.
Example:
>
let g:tagbar_file_size_limit = 10000
<
*g:tagbar_wrap*
g:tagbar_wrap~
Default: 0
Possible Values:
0 Disable line wrapping.
1 Enable the |wrap| option and also enable the |linebreak| option to
split the lines on word boundaries. This will use the default
|breakat| setting in vim. Note: This can cause possible display issues
with tags that exceed the tagbar window width. A very long tag name
will cause the tag itself to wrap resulting in an empty line and
indentation of the tag (see example below).
2 Enable the |wrap| option but disable the |linebreak| option. This will
split the lines at the end of the tagbar window and can cause it to
wrap in the middle of a word. This should be used if there are tags
that are regularly longer than the tagbar window width.
This also will use the |breakindent| and |breakindentopt| options in vim to
set the indentation of the wrapped lines.
Note: This requires VIM to be compiled with the |+linebreak| option for the
wrap intentation to function.
Examples:
>
" Wrap with linebreak - note the wrap works on word boundaries, but
" a very long tag name does cause an odd display issue.
let g:tagbar_wrap = 1
+-------------------------------------------+
| ⯆ functions (106) |
| s:add_tag_recursive(parent,taginfo, |
| pathlist) : function! |
| s:AutoUpdate(fname,force,...) : |
| function! |
| |
| s:SomeReallyLongTagNameThatWillExc|
| eedWindowWidth : function! |
+-------------------------------------------+
" Wrap without linbreak - note the display issue is gone for the
" really long tag name, but the other wraps will breakup words.
let g:tagbar_wrap = 2
+-------------------------------------------+
| ⯆ functions (106) |
| s:add_tag_recursive(parent,taginfo,pat|
| hlist) : function! |
| s:AutoUpdate(fname,force,...) : functi|
| on! |
| s:SomeReallyLongTagNameThatWillExceedW|
| indowWidth : funciton! |
+-------------------------------------------+
<
*g:tagbar_no_autocmds*
g:tagbar_no_autocmds~
Default: 0
If set to non-zero, tagbar will not enable any autocmds. Note: This greatly
limits what tagbar can do. When activated, it will generate the tags once and
display the contents once. You can use |:TagbarForceUpdate| to manually update
the tagbar window if this is activated. There will only be two autocmds
created in the tagbar autocmd group to handle closing the tagbar window
automatically on the QuitPre event.
Example:
>
let g:tagbar_no_autocmds = 1
<
*g:tagbar_scrolloff*
g:tagbar_scrolloff~
Default: 0
If set to non-zero, the tagbar window initialization will set the |scrolloff|
value local to the tagbar window to the specified value. This is used to
position the current tag in the tagbar window. See the help for |scrolloff|
for more details. If set to a very high value (greater than the height of the
tagbar window), then the current tag should always stay in the center of the
tagbar window.
Example:
>
let g:tagbar_scrolloff = 10
<
*g:tagbar_jump_offset*
g:tagbar_jump_offset~
Default: 0
This value can be used to control the jump offset positioning. When jumping to
a tag from the tagbar window, the tag will appear |g:tagbar_jump_offset| lines
above or below the center of the window. For example, if set to 10 and you
jump to a tag, the tag will appear 10 lines above the center of the window.
This can also be set to a negative value if you want the tag jump location to
be below the center of the window.
If set to greater than |winheight|() then the tag will always appear at the
top of the screen. If set to less than -|winheight|(), then the tag will
always appear at the bottom of the screen.
Examples:
>
" Set the tag jump location to appear at the top
let g:tagbar_jump_offset = 999
" Set the tag jump locaiton to appear at the bottom
let g:tagbar_jump_offset = -999
" Set the tag jump location to appear 25% from the top
let g:tagbar_jump_offset = winheight(0) / 4
<
*g:tagbar_jump_lazy_scroll*
g:tagbar_jump_lazy_scroll~
Default: 0
If set to non-zero, a jump to a tag will only scroll the window if the
tag is not already visible in the window. In other words, when jumping to
a tag that is already visible, the cursor will simply be placed on the line
containing the tag without scrolling the window. If the tag is not visible
in the window then the window will be scrolled and the tag (and cursor)
placed in the location dictated by |g:tagbar_jump_offset|.
*g:tagbar_highlight_follow_insert*
g:tagbar_highlight_follow_insert~
Default: 0
If set to non-zero, the highlight of the current tag in the Tagbar will follow
the cursor in insert mode as well, after a short pause once the cursor stops
moving. Enabling this option may introduce some lag during the input, so it is
disabled by default.
Example:
>
let g:tagbar_highlight_follow_insert = 1
<
*g:tagbar_highlight_method*
g:tagbar_highlight_method~
Default: 'nearest-stl'
This configuration controls how the tag highlighting works in the tagbar
window. The possible values are:
'nearest-stl' - Highlight the nearest tag that is defined with the
{stl} option
'scoped-stl' - Highlight the nearest tag defined with the {stl} flag
in the kind definition, also taking into account the
scope.
'nearest' - Highlight the nearest tag regardless of the type or
flags. This was the behavior prior to the introduction
of the 'scoped-stl' idea. If you want to revert to the
old method, set |g:tagbar_highlight_method| to
'nearest'.
Use case example: Consider the following example. If the cursor is at line
#10, then the highlight method will behave differently in each case. If set to
'nearest-stl', the tag for some_function() will be highlighted. If set to
'scoped-stl', the tag for 'class A' will be highlighted. If set to 'nearest',
then the tag for 'SOME_MACRO' will be highlighted.
If the cursor is moded to line #8, then both 'nearest-stl' and 'scoped-stl'
will highlight the tag for 'some_function()'. The 'nearest' method will
highlight the 'SOME_MACRO' tag.
>
1 class A {
2
3 int some_function(int arg) {
4 int var1;
5 int var2;
6 #define SOME_MACRO 1
7 ...
8 printf("...");
9 }
10
11 int another_function(int arg) {
12 int varA;
13 printf("###");
14 }
15 }
<
Example: >
let g:tagbar_highlight_method = 'nearest'
<
*g:tagbar_ignore_anonymous*
g:tagbar_ignore_anonymous~
Default: 0
If set, any '__anon' tags generated by ctags will be ignored and will not be
displayed in the tagbar window. Note: this will also mean any child tags of
that anonymous tag will also not be visible.
Example: >
let g:tagbar_ignore_anonymous = 1
<
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
HIGHLIGHT COLOURS *tagbar-highlight* HIGHLIGHT COLOURS *tagbar-highlight*
@ -760,6 +1310,9 @@ TagbarScope
TagbarType TagbarType
The type of a tag or scope if available. The type of a tag or scope if available.
TagbarTagLineN
The source line number displayed to the right of each tag entry.
TagbarSignature TagbarSignature
Function signatures. Function signatures.
@ -844,7 +1397,7 @@ read |tagbar-extend| (especially the "kinds" entry) on how to do that.
The function has the following signature: The function has the following signature:
tagbar#currenttag({format}, {default} [, {flags}]) tagbar#currenttag({format}, {default} [, {flags} [, {search-method}]])
{format} is a |printf()|-compatible format string where "%s" will be {format} is a |printf()|-compatible format string where "%s" will be
replaced by the name of the tag. {default} will be displayed instead of replaced by the name of the tag. {default} will be displayed instead of
the format string if no tag can be found. the format string if no tag can be found.
@ -859,14 +1412,52 @@ tagbar#currenttag({format}, {default} [, {flags}])
useful in cases where ctags doesn't report some information, like useful in cases where ctags doesn't report some information, like
the signature. Note that this can get quite long. the signature. Note that this can get quite long.
The optional {search-method} argument specified how to search for the
nearest tag. Valid options are:
'nearest' This will look for the closest tag above the current line
regardless of type. This will match even one line tags or
other tags not defined with the {stl} flag in their kind
definition. This is the quickest option, but least
accurate.
'nearest-stl' This will look for the closest tag above the current line
which is defined with the {stl} flag in its kind
definition. This is a little slower, but provides a little
more context and accuracy.
'scoped-stl' This will look for the closest tag above the current line
taking scope into account as well as the {stl} flag. The
scope is determined by the ctags 'end' field. This is the
slowest of the options as when outside of a function
scope, it could end up searching all the way to the top of
the file for the nearest scoped tag (or possibly none if
not in any scope at all).
For example, if you put the following into your statusline: > For example, if you put the following into your statusline: >
%{tagbar#currenttag('[%s] ','')} %{tagbar#currenttag('[%s] ','')}
< then the function "myfunc" will be shown as "[myfunc()] ". < then the function "myfunc" will be shown as "[myfunc()] ".
As another example, we can use the following in our status line to find
the current scoped tag and also print the full path when found: >
%{tagbar#currenttag('%s', '', 'f', 'scoped-stl')}
< then the function "myfunc" within class "myclass" will be shown as
"myclass::myfunc()". But when outside of the function, it will be shown as
"myclass"
Additionally you can show the kind (type) of the current tag, using following
function:
tagbar#currenttagtype({format}, {default})
{format} and {default} are treated in the same way as for
tagbar#currenttag function.
Altering previous example, like below: >
%{tagbar#currenttag('[%s] ','')}\ %{tagbar#currenttagtype("(%s) ", '')
< the function "myfunc" will be shown as "[myfunc()] (function)".
Note that if there is an error when processing the current file no error Note that if there is an error when processing the current file no error
message will be shown in order to not disrupt the statusline. If the function message will be shown in order to not disrupt the statusline. If the function
doesn't seem to work right open the Tagbar window to see any error messages. doesn't seem to work right open the Tagbar window to see any error messages.
Note you should call |tagbar#StopAutoUpdate| manually in case you do not want
to display the current tag anymore. Otherwise the autocommands to update the
state are being executed all the time still.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
IGNORING SPECIFIC FILES *tagbar-ignore* IGNORING SPECIFIC FILES *tagbar-ignore*
@ -908,7 +1499,7 @@ support package for the language. Some tips on how to write such a program are
given at the end of this section. given at the end of this section.
Before writing your own extension have a look at the wiki Before writing your own extension have a look at the wiki
(https://github.com/majutsushi/tagbar/wiki) or try googling for existing ones. (https://github.com/preservim/tagbar/wiki) or try googling for existing ones.
If you do end up creating your own extension please consider adding it to the If you do end up creating your own extension please consider adding it to the
wiki so that others can benefit from it, too. wiki so that others can benefit from it, too.
@ -942,7 +1533,26 @@ kinds: A list of the "language kinds" that should be listed in Tagbar,
"f:functions:1" "f:functions:1"
< would list all the function definitions in a file under the header < would list all the function definitions in a file under the header
"functions", fold them, and implicitly show them in the statusline "functions", fold them, and implicitly show them in the statusline
if tagbar#currenttag() is used. if tagbar#currenttag() is used. The {stl} field is also used to
determine tag that are considered for scoped highlighting in the
tagbar window. By default, whenever the cursor is on a line
containing a known tag, then that tag will be highlighted in the
tagbar window. However if the cursor is not on a line containing a
tag, then only tags of a type that has {stl} set to 1 will be
highlighted. For example, in C the "macro" type has an {stl} value
of 0. So if there is a macro defined within the scope of a
function such as this:
>
int function1(int arg) {
#define BUF_LENGTH 10
char buffer[BUF_LENGTH + 1];
snprintf(buffer, BUF_LENGTH, "some string");
}
<
Then when the cursor is on the #define line, then that macro will
be highlighted in the tagbar window. However if the cursor was on
the snprintf() line, then the tag for function1() would be
highlighted.
sro: The scope resolution operator. For example, in C++ it is "::" and sro: The scope resolution operator. For example, in C++ it is "::" and
in Java it is ".". If in doubt run ctags as shown below and check in Java it is ".". If in doubt run ctags as shown below and check
the output. the output.
@ -962,7 +1572,7 @@ kind2scope: A dictionary describing the mapping of tag kinds (in their
int var; int var;
}; };
< We then run ctags in the following way: > < We then run ctags in the following way: >
ctags -f - --format=2 --excmd=pattern --extra= --fields=nksaSmt test.cpp ctags -f - --format=2 --excmd=pattern --extras= --fields=nksaSmt test.cpp
< Then the output for the variable "var" would look like this: > < Then the output for the variable "var" would look like this: >
var tmp.cpp /^ int var;$/;" kind:m line:11 class:Foo access:private var tmp.cpp /^ int var;$/;" kind:m line:11 class:Foo access:private
< This shows that the scope name for an entry in a C++ class is < This shows that the scope name for an entry in a C++ class is
@ -1266,10 +1876,12 @@ try running ctags manually to see whether ctags reports the wrong information
or whether that information is correct and Tagbar does something wrong. To run or whether that information is correct and Tagbar does something wrong. To run
ctags manually execute the following command in a terminal: ctags manually execute the following command in a terminal:
> >
ctags -f - --format=2 --excmd=pattern --extra= --fields=nksaSmt myfile ctags -f - --format=2 --excmd=pattern --extras= --fields=nksaSmt myfile
< <
If you set the |g:tagbar_ctags_bin| variable you probably have to use the same If you set the |g:tagbar_ctags_bin| variable you probably have to use the same
value here instead of simply "ctags". value here instead of simply "ctags". Also, if you use
|:tagbar_ctags_options|, you should include the equivalent --options flag in
the call to ctags.
If something more fundamental isn't working right then try running the If something more fundamental isn't working right then try running the
|:messages| command to see if Tagbar printed any error messages that might |:messages| command to see if Tagbar printed any error messages that might
@ -1357,6 +1969,14 @@ Known issues~
============================================================================== ==============================================================================
8. History *tagbar-history* 8. History *tagbar-history*
3.0.0 (2021-01-21)
- Massive rollup with years of small changes, see `git log v2.7..v3.0.0`
- New upstream project namespace (Preservim) and maintainers
- Deprecate Exuberant Ctags, primarily support Universal Ctags
- Add lots of configuration options (see `:help tagbar`)
- Add utility functions to ease integration with other plugins
- Support many new filetypes out of the box
2.7 (2017-01-09) 2.7 (2017-01-09)
- Added support for Universal Ctags, courtesy of Dmytro Konstantinov - Added support for Universal Ctags, courtesy of Dmytro Konstantinov
- Added option to arrange Tagbar window vertically - Added option to arrange Tagbar window vertically

View File

@ -3,8 +3,8 @@
" Description: List the current file's tags in a sidebar, ordered by class etc " Description: List the current file's tags in a sidebar, ordered by class etc
" Author: Jan Larres <jan@majutsushi.net> " Author: Jan Larres <jan@majutsushi.net>
" Licence: Vim licence " Licence: Vim licence
" Website: http://majutsushi.github.com/tagbar/ " Website: https://preservim.github.io/tagbar
" Version: 2.7 " Version: 3.0.0
" Note: This plugin was heavily inspired by the 'Taglist' plugin by " Note: This plugin was heavily inspired by the 'Taglist' plugin by
" Yegappan Lakshmanan and uses a small amount of code from it. " Yegappan Lakshmanan and uses a small amount of code from it.
" "
@ -20,7 +20,7 @@
scriptencoding utf-8 scriptencoding utf-8
if &cp || exists('g:loaded_tagbar') if &compatible || exists('g:loaded_tagbar')
finish finish
endif endif
@ -49,10 +49,39 @@ function! s:init_var(var, value) abort
endfunction endfunction
function! s:setup_options() abort function! s:setup_options() abort
if !exists('g:tagbar_vertical') || g:tagbar_vertical == 0 if exists('g:tagbar_position')
let previewwin_pos = 'topleft' " Map older deprecated values to correct values
if g:tagbar_position ==# 'top'
let g:tagbar_position = 'leftabove'
elseif g:tagbar_position ==# 'bottom'
let g:tagbar_position = 'rightbelow'
elseif g:tagbar_position ==# 'left'
let g:tagbar_position = 'topleft vertical'
elseif g:tagbar_position ==# 'right'
let g:tagbar_position = 'botright vertical'
endif
if g:tagbar_position !~# 'vertical'
let previewwin_pos = 'rightbelow vertical'
else
let previewwin_pos = 'topleft'
endif
let default_pos = g:tagbar_position
else else
let previewwin_pos = 'rightbelow vertical' if exists('g:tagbar_vertical') && g:tagbar_vertical > 0
let previewwin_pos = 'rightbelow vertical'
if exists('g:tagbar_left') && g:tagbar_left
let default_pos = 'leftabove'
else
let default_pos = 'rightbelow'
endif
let g:tagbar_height = g:tagbar_vertical
elseif exists('g:tagbar_left') && g:tagbar_left
let previewwin_pos = 'topleft'
let default_pos = 'topleft vertical'
else
let previewwin_pos = 'topleft'
let default_pos = 'botright vertical'
endif
endif endif
let options = [ let options = [
\ ['autoclose', 0], \ ['autoclose', 0],
@ -62,13 +91,29 @@ function! s:setup_options() abort
\ ['case_insensitive', 0], \ ['case_insensitive', 0],
\ ['compact', 0], \ ['compact', 0],
\ ['expand', 0], \ ['expand', 0],
\ ['file_size_limit', 0],
\ ['foldlevel', 99], \ ['foldlevel', 99],
\ ['hide_nonpublic', 0], \ ['hide_nonpublic', 0],
\ ['height', 10],
\ ['indent', 2], \ ['indent', 2],
\ ['jump_offset', 0],
\ ['jump_lazy_scroll', 0],
\ ['left', 0], \ ['left', 0],
\ ['help_visibility', 0],
\ ['highlight_follow_insert', 0],
\ ['highlight_method', 'nearest-stl'],
\ ['ignore_anonymous', 0],
\ ['no_autocmds', 0],
\ ['position', default_pos],
\ ['previewwin_pos', previewwin_pos], \ ['previewwin_pos', previewwin_pos],
\ ['scopestrs', {}],
\ ['scrolloff', 0],
\ ['show_balloon', 1],
\ ['show_data_type', 0],
\ ['show_visibility', 1], \ ['show_visibility', 1],
\ ['show_linenumbers', 0], \ ['show_linenumbers', 0],
\ ['show_tag_count', 0],
\ ['show_tag_linenumbers', 0],
\ ['singleclick', 0], \ ['singleclick', 0],
\ ['sort', 1], \ ['sort', 1],
\ ['systemenc', &encoding], \ ['systemenc', &encoding],
@ -76,17 +121,20 @@ function! s:setup_options() abort
\ ['width', 40], \ ['width', 40],
\ ['zoomwidth', 1], \ ['zoomwidth', 1],
\ ['silent', 0], \ ['silent', 0],
\ ['use_cache', 1],
\ ['wrap', 0],
\ ] \ ]
for [opt, val] in options for [opt, val] in options
call s:init_var(opt, val) call s:init_var(opt, val)
unlet val
endfor endfor
endfunction endfunction
call s:setup_options() call s:setup_options()
if !exists('g:tagbar_iconchars') if !exists('g:tagbar_iconchars')
if has('multi_byte') && has('unix') && &encoding == 'utf-8' && if has('multi_byte') && has('unix') && &encoding ==# 'utf-8' &&
\ (empty(&termencoding) || &termencoding == 'utf-8') \ (!exists('+termencoding') || empty(&termencoding) || &termencoding ==# 'utf-8')
let g:tagbar_iconchars = ['▶', '▼'] let g:tagbar_iconchars = ['▶', '▼']
else else
let g:tagbar_iconchars = ['+', '-'] let g:tagbar_iconchars = ['+', '-']
@ -116,6 +164,7 @@ function! s:setup_keymaps() abort
\ ['togglesort', 's'], \ ['togglesort', 's'],
\ ['togglecaseinsensitive', 'i'], \ ['togglecaseinsensitive', 'i'],
\ ['toggleautoclose', 'c'], \ ['toggleautoclose', 'c'],
\ ['togglepause', 't'],
\ ['zoomwin', 'x'], \ ['zoomwin', 'x'],
\ ['close', 'q'], \ ['close', 'q'],
\ ['help', ['<F1>', '?']], \ ['help', ['<F1>', '?']],
@ -134,18 +183,23 @@ augroup TagbarSession
augroup END augroup END
" Commands {{{1 " Commands {{{1
command! -nargs=0 Tagbar call tagbar#ToggleWindow() command! -nargs=? Tagbar call tagbar#ToggleWindow(<f-args>)
command! -nargs=0 TagbarToggle call tagbar#ToggleWindow() command! -nargs=? TagbarToggle call tagbar#ToggleWindow(<f-args>)
command! -nargs=? TagbarOpen call tagbar#OpenWindow(<f-args>) command! -nargs=? TagbarOpen call tagbar#OpenWindow(<f-args>)
command! -nargs=0 TagbarOpenAutoClose call tagbar#OpenWindow('fcj') command! -nargs=0 TagbarOpenAutoClose call tagbar#OpenWindow('fcj')
command! -nargs=0 TagbarClose call tagbar#CloseWindow() command! -nargs=0 TagbarClose call tagbar#CloseWindow()
command! -nargs=1 -bang TagbarSetFoldlevel call tagbar#SetFoldLevel(<args>, <bang>0) command! -nargs=1 -bang TagbarSetFoldlevel call tagbar#SetFoldLevel(<args>, <bang>0)
command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1) command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1)
command! -nargs=? TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', <f-args>) command! -nargs=* TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', <f-args>)
command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig(<f-args>) command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig(<f-args>)
command! -nargs=? TagbarDebug call tagbar#debug#start_debug(<f-args>) command! -nargs=? TagbarDebug call tagbar#debug#start_debug(<f-args>)
command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug() command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug()
command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause() command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause()
command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate()
command! -nargs=0 TagbarJump call tagbar#jump()
command! -nargs=0 TagbarJumpPrev call tagbar#jumpToNearbyTag(-1)
command! -nargs=0 TagbarJumpNext call tagbar#jumpToNearbyTag(1)
" Modeline {{{1 " Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1

View File

@ -2,12 +2,12 @@
" Description: Tagbar syntax settings " Description: Tagbar syntax settings
" Author: Jan Larres <jan@majutsushi.net> " Author: Jan Larres <jan@majutsushi.net>
" Licence: Vim licence " Licence: Vim licence
" Website: http://majutsushi.github.com/tagbar/ " Website: https://preservim.github.io/tagbar
" Version: 2.7 " Version: 3.0.0
scriptencoding utf-8 scriptencoding utf-8
if exists("b:current_syntax") if exists('b:current_syntax')
finish finish
endif endif
@ -36,8 +36,9 @@ syntax match TagbarHelpKey '" \zs.*\ze:' contained
syntax match TagbarHelpTitle '" \zs-\+ \w\+ -\+' contained syntax match TagbarHelpTitle '" \zs-\+ \w\+ -\+' contained
syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$' syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$'
syntax match TagbarType ' : \zs.*' syntax match TagbarType ' : \zs.*' contains=TagbarTagLineN
syntax match TagbarSignature '(.*)' syntax match TagbarTagLineN '\s\+\[[0-9]\+\]\(\s\+\|$\)'
syntax match TagbarSignature '\(\<operator *( *) *\)\?\zs(.*)\ze'
syntax match TagbarPseudoID '\*\ze :' syntax match TagbarPseudoID '\*\ze :'
highlight default link TagbarHelp Comment highlight default link TagbarHelp Comment
@ -47,6 +48,7 @@ highlight default link TagbarKind Identifier
highlight default link TagbarNestedKind TagbarKind highlight default link TagbarNestedKind TagbarKind
highlight default link TagbarScope Title highlight default link TagbarScope Title
highlight default link TagbarType Type highlight default link TagbarType Type
highlight default link TagbarTagLineN Comment
highlight default link TagbarSignature SpecialKey highlight default link TagbarSignature SpecialKey
highlight default link TagbarPseudoID NonText highlight default link TagbarPseudoID NonText
highlight default link TagbarFoldIcon Statement highlight default link TagbarFoldIcon Statement
@ -59,6 +61,6 @@ highlight default link TagbarVisibilityPublic TagbarAccessPublic
highlight default link TagbarVisibilityProtected TagbarAccessProtected highlight default link TagbarVisibilityProtected TagbarAccessProtected
highlight default link TagbarVisibilityPrivate TagbarAccessPrivate highlight default link TagbarVisibilityPrivate TagbarAccessPrivate
let b:current_syntax = "tagbar" let b:current_syntax = 'tagbar'
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1