The image shows that global variable Class A, but the local variable can't be show in tagbar,why? I want tagbar show local variable str,m,n and how to set??
Can the vim tagbar display a local variable?
3.4k Views Asked by Da Lin At
3
There are 3 best solutions below
0
On
Exuberant Ctags has support for local variables as tags, they're just turned off by default. I'd imagine they'd make your tags file huge for a project of any significant size, and I've never turned them on for just that reason (my tags files are already many megabytes). But if you want to give them a try, just add --c++-kinds=+l (assuming c++) to your ctags command when you generate the tags file and that should work.
0
On
first, tagbar show all tags from ctags and ctags default do not deal with function prototypes, external variable, and local variables (try this in shell: ctags --list-kinds=c++);
second, tagbar's tagbar_type_cpp variable use for this:
let g:tagbar_type_cpp = {
\ 'kinds' : [
\ 'd:macros:1',
\ 'g:enums',
\ 't:typedefs:0:0',
\ 'e:enumerators:0:0',
\ 'n:namespaces',
\ 'c:classes',
\ 's:structs',
\ 'u:unions',
\ 'f:functions',
\ 'm:members:0:0',
\ 'v:global:0:0',
\ 'x:external:0:0',
\ 'l:local:0:0'
\ ]
\ }
Look at the last two lines.
that's all.
What gets parsed by ctags depends on the language; based on the screenshot, you're interested in C/C++, where it doesn't do this. I don't know the original reasons, but I guess:
The Exuberant Ctags parser can be extended with custom language definitions based on regular expressions (see the
--langdef=<language>and--regex-<language>arguments). If you can come up with a good pattern for local variables, you could have them parsed.