diff --git a/doc/tagbar.txt b/doc/tagbar.txt index dff4af9..aaa99dc 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -352,11 +352,16 @@ kinds: A list of the "language kinds" that should be listed in Tagbar, "f:functions" < would list all the function definitions in a file under the header "functions". -scopes: A list of the scopes that ctags supports for a given language, for - example classes, structs etc. Unfortunately there is no ctags - option to list the scopes, you have to look at the tags ctags - generates manually. For example, let's say we have a C++ file - "test.cpp" with the following contents: > +sro: The scope resolution operator. For example, in C++ it is "::" and + in Java it is ".". When in doubt run ctags as shown above and look + at the output. +kind2scope: A dictionary describing the mapping of tag kinds (in their + one-character representation) to the scopes their children will + appear in, for example classes, structs etc. + Unfortunately there is no ctags option to list the scopes, you + have to look at the tags ctags generates manually. For example, + let's say we have a C++ file "test.cpp" with the following + contents: > class Foo { public: @@ -370,15 +375,8 @@ scopes: A list of the scopes that ctags supports for a given language, for < Then the output for the variable "var" would look like this: > 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 - simply "class". So you would need to put this exact word into the - "scopes" list. The order again determines the order in which the - tags will be displayed in Tagbar. -sro: The scope resolution operator. For example, in C++ it is "::" and - in Java it is ".". When in doubt run ctags as shown above and look - at the output. -kind2scope: A dictionary describing the mapping of tag kinds (in their - one-character representation) to the scopes their children will - appear in. + simply "class". So this would be the word that the "kind" + character of a class has to be mapped to. scope2kind: The opposite of the above, mapping scopes to the kinds of their parents. Most of the time it is the exact inverse of the above, but in some cases it can be different, for example when more than @@ -439,13 +437,6 @@ used in Tagbar. \ 'm:members', \ 'v:variables' \ ], - \ 'scopes' : [ - \ 'namespace', - \ 'class', - \ 'struct', - \ 'enum', - \ 'union' - \ ], \ 'sro' : '::', \ 'kind2scope' : { \ 'g' : 'enum', diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 349d58c..8b5b41c 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -150,8 +150,6 @@ function! s:InitTypes() " C {{{3 let type_c = {} let type_c.ctagstype = 'c' - let type_c.scopes = ['enum', 'struct', 'union'] - let type_c.sro = '::' let type_c.kinds = [ \ 'd:macros', \ 'p:prototypes', @@ -164,6 +162,7 @@ function! s:InitTypes() \ 'v:variables', \ 'f:functions' \ ] + let type_c.sro = '::' let type_c.kind2scope = { \ 'g' : 'enum', \ 's' : 'struct', @@ -178,14 +177,6 @@ function! s:InitTypes() " C++ {{{3 let type_cpp = {} let type_cpp.ctagstype = 'c++' - let type_cpp.scopes = [ - \ 'namespace', - \ 'class', - \ 'struct', - \ 'enum', - \ 'union' - \ ] - let type_cpp.sro = '::' let type_cpp.kinds = [ \ 'd:macros', \ 'p:prototypes', @@ -200,6 +191,7 @@ function! s:InitTypes() \ 'm:members', \ 'v:variables' \ ] + let type_cpp.sro = '::' let type_cpp.kind2scope = { \ 'g' : 'enum', \ 'n' : 'namespace', @@ -218,14 +210,6 @@ function! s:InitTypes() " C# {{{3 let type_cs = {} let type_cs.ctagstype = 'c#' - let type_cs.scopes = [ - \ 'namespace', - \ 'interface', - \ 'class', - \ 'struct', - \ 'enum' - \ ] - let type_cs.sro = '.' let type_cs.kinds = [ \ 'd:macros', \ 'f:fields', @@ -240,6 +224,7 @@ function! s:InitTypes() \ 'm:methods', \ 'p:properties' \ ] + let type_cs.sro = '.' let type_cs.kind2scope = { \ 'n' : 'namespace', \ 'i' : 'interface', @@ -278,12 +263,11 @@ function! s:InitTypes() " Eiffel {{{3 let type_eiffel = {} let type_eiffel.ctagstype = 'eiffel' - let type_eiffel.scopes = ['class', 'feature'] - let type_eiffel.sro = '.' " Not sure, is nesting even possible? let type_eiffel.kinds = [ \ 'c:classes', \ 'f:features' \ ] + let type_eiffel.sro = '.' " Not sure, is nesting even possible? let type_eiffel.kind2scope = { \ 'c' : 'class', \ 'f' : 'feature' @@ -296,14 +280,13 @@ function! s:InitTypes() " Erlang {{{3 let type_erlang = {} let type_erlang.ctagstype = 'erlang' - let type_erlang.scopes = ['module'] - let type_erlang.sro = '.' " Not sure, is nesting even possible? let type_erlang.kinds = [ \ 'm:modules', \ 'd:macro definitions', \ 'f:functions', \ 'r:record definitions' \ ] + let type_erlang.sro = '.' " Not sure, is nesting even possible? let type_erlang.kind2scope = { \ 'm' : 'module' \ } @@ -318,8 +301,6 @@ function! s:InitTypes() " Improvements welcome! let type_mxml = {} let type_mxml.ctagstype = 'flex' - let type_mxml.scopes = ['class'] - let type_mxml.sro = '.' let type_mxml.kinds = [ \ 'v:global variables', \ 'c:classes', @@ -328,6 +309,7 @@ function! s:InitTypes() \ 'f:functions', \ 'x:mxtags' \ ] + let type_mxml.sro = '.' let type_mxml.kind2scope = { \ 'c' : 'class' \ } @@ -338,8 +320,6 @@ function! s:InitTypes() " Fortran {{{3 let type_fortran = {} let type_fortran.ctagstype = 'fortran' - let type_fortran.scopes = ['module', 'program', 'function', 'subroutine'] - let type_fortran.sro = '.' " Not sure, is nesting even possible? let type_fortran.kinds = [ \ 'm:modules', \ 'p:programs', @@ -354,6 +334,7 @@ function! s:InitTypes() \ 'n:namelists', \ 'v:variables' \ ] + let type_fortran.sro = '.' " Not sure, is nesting even possible? let type_fortran.kind2scope = { \ 'm' : 'module', \ 'p' : 'program', @@ -378,8 +359,6 @@ function! s:InitTypes() " Java {{{3 let type_java = {} let type_java.ctagstype = 'java' - let type_java.scopes = ['enum', 'interface', 'class'] - let type_java.sro = '.' let type_java.kinds = [ \ 'p:packages', \ 'f:fields', @@ -389,6 +368,7 @@ function! s:InitTypes() \ 'c:classes', \ 'm:methods' \ ] + let type_java.sro = '.' let type_java.kind2scope = { \ 'g' : 'enum', \ 'i' : 'interface', @@ -445,8 +425,6 @@ function! s:InitTypes() " Ocaml {{{3 let type_ocaml = {} let type_ocaml.ctagstype = 'ocaml' - let type_ocaml.scopes = ['Module', 'class', 'type'] - let type_ocaml.sro = '.' " Not sure, is nesting even possible? let type_ocaml.kinds = [ \ 'M:modules or functors', \ 'v:global variables', @@ -458,6 +436,7 @@ function! s:InitTypes() \ 'f:functions', \ 'r:structure fields' \ ] + let type_ocaml.sro = '.' " Not sure, is nesting even possible? let type_ocaml.kind2scope = { \ 'M' : 'Module', \ 'c' : 'class', @@ -503,8 +482,6 @@ function! s:InitTypes() " Python {{{3 let type_python = {} let type_python.ctagstype = 'python' - let type_python.scopes = ['class', 'function'] - let type_python.sro = '.' let type_python.kinds = [ \ 'i:imports', \ 'c:classes', @@ -517,6 +494,7 @@ function! s:InitTypes() \ 'f' : 'function', \ 'm' : 'function' \ } + let type_python.sro = '.' let type_python.scope2kind = { \ 'class' : 'c', \ 'function' : 'f' @@ -532,14 +510,13 @@ function! s:InitTypes() " Ruby {{{3 let type_ruby = {} let type_ruby.ctagstype = 'ruby' - let type_ruby.scopes = ['class'] - let type_ruby.sro = '.' let type_ruby.kinds = [ \ 'm:modules', \ 'c:classes', \ 'f:methods', \ 'F:singleton methods' \ ] + let type_ruby.sro = '.' let type_ruby.kind2scope = { \ 'c' : 'class', \ 'm' : 'class' @@ -640,8 +617,6 @@ function! s:InitTypes() " Why are variables 'virtual'? let type_vera = {} let type_vera.ctagstype = 'vera' - let type_vera.scopes = ['enum', 'class', 'virtual'] - let type_vera.sro = '.' " Nesting doesn't seem to be possible let type_vera.kinds = [ \ 'd:macros', \ 'g:enums', @@ -654,6 +629,7 @@ function! s:InitTypes() \ 'v:variables', \ 'p:programs' \ ] + let type_vera.sro = '.' " Nesting doesn't seem to be possible let type_vera.kind2scope = { \ 'g' : 'enum', \ 'c' : 'class', @@ -1038,7 +1014,7 @@ function! s:ProcessFile(fname, ftype) endif endfor - if has_key(typeinfo, 'scopes') && !empty(typeinfo.scopes) + if has_key(typeinfo, 'kind2scope') let scopedtags = [] let is_scoped = 'has_key(typeinfo.kind2scope, v:val.fields.kind) || \ has_key(v:val, "scope")' @@ -1115,8 +1091,8 @@ function! s:ParseTagline(part1, part2, typeinfo) " Make some information easier accessible let taginfo.path = '' let taginfo.fullpath = taginfo.name - if has_key(a:typeinfo, 'scopes') - for scope in a:typeinfo.scopes + if has_key(a:typeinfo, 'scope2kind') + for scope in keys(a:typeinfo.scope2kind) if has_key(taginfo.fields, scope) let taginfo.scope = scope let taginfo.path = taginfo.fields[scope]