Skip to content

Commit 59d2a7c

Browse files
majutsushivim-scripts
authored andcommitted
Version 1.5
- Type definitions can now include a path to a file with the ctags definition. This is especially useful for ftplugins that can now ship with a complete ctags and Tagbar configuration without requiring user intervention. Thanks to Jan Christoph Ebersbach for the suggestion. - Added autofocus setting by Taybin Rutkin. This will put the cursor in the Tagbar window when it is opened. - The "scopes" field is no longer needed in type definitions, the information is already there in "scope2kind". Existing definitions will be ignored. - Some fixes and improvements related to redrawing and window switching.
1 parent 2ba44e2 commit 59d2a7c

File tree

3 files changed

+101
-77
lines changed

3 files changed

+101
-77
lines changed

doc/tagbar.txt

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Author: Jan Larres <jan@majutsushi.net>
44
Licence: Vim licence, see |license|
55
Homepage: http://majutsushi.github.com/tagbar/
6-
Version: 1.2
6+
Version: 1.5
77

88
==============================================================================
99
Contents *tagbar* *tagbar-contents*
@@ -283,6 +283,16 @@ Example:
283283
let g:tagbar_autoclose = 1
284284
<
285285

286+
*g:tagbar_autofocus*
287+
g:tagbar_autofocus~
288+
If you set this option the cursor will move to the Tagbar window when it is
289+
opened. The default is to not move the cursor to the window.
290+
291+
Example:
292+
>
293+
let g:tagbar_autofocus = 1
294+
<
295+
286296
*g:tagbar_sort*
287297
g:tagbar_sort~
288298
If this option is set the tags are sorted according to their name. If it is
@@ -342,11 +352,16 @@ kinds: A list of the "language kinds" that should be listed in Tagbar,
342352
"f:functions"
343353
< would list all the function definitions in a file under the header
344354
"functions".
345-
scopes: A list of the scopes that ctags supports for a given language, for
346-
example classes, structs etc. Unfortunately there is no ctags
347-
option to list the scopes, you have to look at the tags ctags
348-
generates manually. For example, let's say we have a C++ file
349-
"test.cpp" with the following contents: >
355+
sro: The scope resolution operator. For example, in C++ it is "::" and
356+
in Java it is ".". When in doubt run ctags as shown above and look
357+
at the output.
358+
kind2scope: A dictionary describing the mapping of tag kinds (in their
359+
one-character representation) to the scopes their children will
360+
appear in, for example classes, structs etc.
361+
Unfortunately there is no ctags option to list the scopes, you
362+
have to look at the tags ctags generates manually. For example,
363+
let's say we have a C++ file "test.cpp" with the following
364+
contents: >
350365
class Foo
351366
{
352367
public:
@@ -360,15 +375,8 @@ scopes: A list of the scopes that ctags supports for a given language, for
360375
< Then the output for the variable "var" would look like this: >
361376
var tmp.cpp /^ int var;$/;" kind:m line:11 class:Foo access:private
362377
< This shows that the scope name for an entry in a C++ class is
363-
simply "class". So you would need to put this exact word into the
364-
"scopes" list. The order again determines the order in which the
365-
tags will be displayed in Tagbar.
366-
sro: The scope resolution operator. For example, in C++ it is "::" and
367-
in Java it is ".". When in doubt run ctags as shown above and look
368-
at the output.
369-
kind2scope: A dictionary describing the mapping of tag kinds (in their
370-
one-character representation) to the scopes their children will
371-
appear in.
378+
simply "class". So this would be the word that the "kind"
379+
character of a class has to be mapped to.
372380
scope2kind: The opposite of the above, mapping scopes to the kinds of their
373381
parents. Most of the time it is the exact inverse of the above,
374382
but in some cases it can be different, for example when more than
@@ -383,6 +391,20 @@ sort: This entry can be used to override the global sort setting for
383391
with the global setting, that is if you want to sort tags by name
384392
set it to 1 and if you want to sort them according to their order
385393
in the file set it to 0.
394+
deffile: The path to a file with additional ctags definitions (see the
395+
{optional} section below on adding a new definition for what exactly that
396+
means). This is especially useful for ftplugins since they can
397+
provide a complete type definition with ctags and Tagbar
398+
configurations without requiring user intervention.
399+
Let's say you have an ftplugin that adds support for the language
400+
"mylang", and your directory structure looks like this: >
401+
ctags/mylang.cnf
402+
ftplugin/mylang.vim
403+
< Then the "deffile" entry would look like this to allow for the
404+
plugin to be installed in an arbitray location (for example
405+
with pathogen): >
406+
'deffile' : expand('<sfile>:p:h:h') . '/ctags/mylang.cnf'
407+
<
386408

387409
You then have to assign this dictionary to a variable with the name
388410
>
@@ -415,13 +437,6 @@ used in Tagbar.
415437
\ 'm:members',
416438
\ 'v:variables'
417439
\ ],
418-
\ 'scopes' : [
419-
\ 'namespace',
420-
\ 'class',
421-
\ 'struct',
422-
\ 'enum',
423-
\ 'union'
424-
\ ],
425440
\ 'sro' : '::',
426441
\ 'kind2scope' : {
427442
\ 'g' : 'enum',
@@ -487,7 +502,8 @@ those two and in addition "scopes", "sro" and at least one of "kind2scope" and
487502
"scope2kind".
488503

489504
Let's assume we want to add support for LaTeX to Tagbar using the regex
490-
approach. First we put the following text into ~/.ctags:
505+
approach. First we put the following text into ~/.ctags or a file pointed to
506+
by the "deffile" definition entry:
491507
>
492508
--langdef=latex
493509
--langmap=latex:.tex
@@ -529,9 +545,13 @@ Now we have to create the Tagbar language definition in our vimrc:
529545
\ 'r:refs',
530546
\ 'p:pagerefs'
531547
\ ],
532-
\ 'sort' : 0
548+
\ 'sort' : 0,
549+
\ 'deffile' : expand('<sfile>:p:h:h') . '/ctags/latex.cnf'
533550
\ }
534551
<
552+
The "deffile" field is of course only needed if the ctags definition actually
553+
is in that file and not in ~/.ctags.
554+
535555
Sort has been disabled for LaTeX so that the sections appear in their correct
536556
order. They unfortunately can't be shown nested with their correct scopes
537557
since as already mentioned the regular expression approach doesn't support
@@ -593,6 +613,18 @@ files.
593613
==============================================================================
594614
8. History *tagbar-history*
595615

616+
1.5 (2011-03-06)
617+
- Type definitions can now include a path to a file with the ctags
618+
definition. This is especially useful for ftplugins that can now ship
619+
with a complete ctags and Tagbar configuration without requiring user
620+
intervention. Thanks to Jan Christoph Ebersbach for the suggestion.
621+
- Added autofocus setting by Taybin Rutkin. This will put the cursor in
622+
the Tagbar window when it is opened.
623+
- The "scopes" field is no longer needed in type definitions, the
624+
information is already there in "scope2kind". Existing definitions will
625+
be ignored.
626+
- Some fixes and improvements related to redrawing and window switching.
627+
596628
1.2 (2011-02-28)
597629
- Fix typo in Ruby definition
598630

0 commit comments

Comments
 (0)