├── README ├── README.md ├── syntax └── tagbar.vim ├── plugin └── tagbar.vim ├── doc └── tagbar.txt └── autoload └── tagbar.vim /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=3465 2 | 3 | Tagbar displays the tags of the current file in a sidebar, similar to vimscript #273. But it has the advantage that it will display them ordered by their scope -- for example, methods and members in languages like C++, Python or Java will be listed under their correct class instead of just under the general categories 'functions' or 'variables'. This gives a more helpful overview of the file. 4 | 5 | Additionally the Tagbar window can be used to quickly jump to tags. 6 | 7 | Tagbar requires Exuberant ctags (http://ctags.sourceforge.net/) in at least version 5.5 to work. 8 | 9 | Plugin homepage with screenshots: 10 | http://majutsushi.github.com/tagbar/ 11 | 12 | Code repository: 13 | https://github.com/majutsushi/tagbar 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Tagbar is a vim plugin for browsing the tags of source code files. 4 | It provides a sidebar that displays the ctags-generated tags of the current file, ordered by their scope. This means that for example methods in C++ are displayed under the class they are defined in. 5 | 6 | Check out the homepage at http://majutsushi.github.io/tagbar/ for more information. 7 | 8 | # Support for additional filetypes 9 | 10 | For filetypes that are not supported by Exuberant Ctags check out [the wiki](https://github.com/majutsushi/tagbar/wiki) to see whether other projects 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 benefit from them, too. 11 | 12 | # Important: If the file structure is displayed wrong 13 | 14 | If you notice that there are some errors in the way your file's structure is displayed in Tagbar, please make sure that the bug is actually in Tagbar before you report a bug. Since Tagbar uses [exuberant-ctags](http://ctags.sourceforge.net/) and compatible programs to do the actual file parsing, it is likely that the bug is actually in one of those programs instead. 15 | 16 | There is an example in `:h tagbar-issues` about how to run ctags manually so you can determine where the bug actually is. If the bug is actually in ctags, please report it on their website instead, as there is nothing I can do about it in Tagbar. Thank you! 17 | 18 | You can also have a look at ctags bugs that have previously been filed on Tagbar here: 19 | https://github.com/majutsushi/tagbar/issues?labels=ctags-bug&page=1&state=closed 20 | -------------------------------------------------------------------------------- /syntax/tagbar.vim: -------------------------------------------------------------------------------- 1 | " File: tagbar.vim 2 | " Description: Tagbar syntax settings 3 | " Author: Jan Larres 4 | " Licence: Vim licence 5 | " Website: http://majutsushi.github.com/tagbar/ 6 | " Version: 2.6.1 7 | 8 | scriptencoding utf-8 9 | 10 | if exists("b:current_syntax") 11 | finish 12 | endif 13 | 14 | let s:ics = escape(join(g:tagbar_iconchars, ''), ']^\-') 15 | let s:pattern = '\(^[' . s:ics . '] \?\)\@<=[^-+: ]\+[^:]\+$' 16 | execute "syntax match TagbarKind '" . s:pattern . "'" 17 | 18 | let s:pattern = '\(\S\@ 5 | " Licence: Vim licence 6 | " Website: http://majutsushi.github.com/tagbar/ 7 | " Version: 2.6.1 8 | " Note: This plugin was heavily inspired by the 'Taglist' plugin by 9 | " Yegappan Lakshmanan and uses a small amount of code from it. 10 | " 11 | " Original taglist copyright notice: 12 | " Permission is hereby granted to use and distribute this code, 13 | " with or without modifications, provided that this copyright 14 | " notice is copied with it. Like anything else that's free, 15 | " taglist.vim is provided *as is* and comes with no warranty of 16 | " any kind, either expressed or implied. In no event will the 17 | " copyright holder be liable for any damamges resulting from the 18 | " use of this software. 19 | " ============================================================================ 20 | 21 | scriptencoding utf-8 22 | 23 | if &cp || exists('g:loaded_tagbar') 24 | finish 25 | endif 26 | 27 | " Basic init {{{1 28 | 29 | if v:version < 700 30 | echohl WarningMsg 31 | echomsg 'Tagbar: Vim version is too old, Tagbar requires at least 7.0' 32 | echohl None 33 | finish 34 | endif 35 | 36 | if v:version == 700 && !has('patch167') 37 | echohl WarningMsg 38 | echomsg 'Tagbar: Vim versions lower than 7.0.167 have a bug' 39 | \ 'that prevents this version of Tagbar from working.' 40 | \ 'Please use the alternate version posted on the website.' 41 | echohl None 42 | finish 43 | endif 44 | 45 | function! s:init_var(var, value) abort 46 | if !exists('g:tagbar_' . a:var) 47 | execute 'let g:tagbar_' . a:var . ' = ' . string(a:value) 48 | endif 49 | endfunction 50 | 51 | let s:options = [ 52 | \ ['autoclose', 0], 53 | \ ['autofocus', 0], 54 | \ ['autopreview', 0], 55 | \ ['autoshowtag', 0], 56 | \ ['compact', 0], 57 | \ ['expand', 0], 58 | \ ['foldlevel', 99], 59 | \ ['indent', 2], 60 | \ ['left', 0], 61 | \ ['previewwin_pos', 'topleft'], 62 | \ ['show_visibility', 1], 63 | \ ['show_linenumbers', 0], 64 | \ ['singleclick', 0], 65 | \ ['sort', 1], 66 | \ ['systemenc', &encoding], 67 | \ ['width', 40], 68 | \ ] 69 | 70 | for [opt, val] in s:options 71 | call s:init_var(opt, val) 72 | endfor 73 | unlet s:options 74 | 75 | if !exists('g:tagbar_iconchars') 76 | if has('multi_byte') && has('unix') && &encoding == 'utf-8' && 77 | \ (empty(&termencoding) || &termencoding == 'utf-8') 78 | let g:tagbar_iconchars = ['▶', '▼'] 79 | else 80 | let g:tagbar_iconchars = ['+', '-'] 81 | endif 82 | endif 83 | 84 | let s:keymaps = [ 85 | \ ['jump', ''], 86 | \ ['preview', 'p'], 87 | \ ['previewwin', 'P'], 88 | \ ['nexttag', ''], 89 | \ ['prevtag', ''], 90 | \ ['showproto', ''], 91 | \ 92 | \ ['openfold', ['+', '', 'zo']], 93 | \ ['closefold', ['-', '', 'zc']], 94 | \ ['togglefold', ['o', 'za']], 95 | \ ['openallfolds', ['*', '', 'zR']], 96 | \ ['closeallfolds', ['=', 'zM']], 97 | \ 98 | \ ['togglesort', 's'], 99 | \ ['zoomwin', 'x'], 100 | \ ['close', 'q'], 101 | \ ['help', ''], 102 | \ ] 103 | 104 | for [map, key] in s:keymaps 105 | call s:init_var('map_' . map, key) 106 | unlet key 107 | endfor 108 | unlet s:keymaps 109 | 110 | augroup TagbarSession 111 | autocmd! 112 | autocmd SessionLoadPost * nested call tagbar#RestoreSession() 113 | augroup END 114 | 115 | " Commands {{{1 116 | command! -nargs=0 Tagbar call tagbar#ToggleWindow() 117 | command! -nargs=0 TagbarToggle call tagbar#ToggleWindow() 118 | command! -nargs=? TagbarOpen call tagbar#OpenWindow() 119 | command! -nargs=0 TagbarOpenAutoClose call tagbar#OpenWindow('fcj') 120 | command! -nargs=0 TagbarClose call tagbar#CloseWindow() 121 | command! -nargs=1 -bang TagbarSetFoldlevel call tagbar#SetFoldLevel(, 0) 122 | command! -nargs=0 TagbarShowTag call tagbar#highlighttag(1, 1) 123 | command! -nargs=? TagbarCurrentTag echo tagbar#currenttag('%s', 'No current tag', ) 124 | command! -nargs=1 TagbarGetTypeConfig call tagbar#gettypeconfig() 125 | command! -nargs=? TagbarDebug call tagbar#StartDebug() 126 | command! -nargs=0 TagbarDebugEnd call tagbar#StopDebug() 127 | command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause() 128 | 129 | " Modeline {{{1 130 | " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 131 | -------------------------------------------------------------------------------- /doc/tagbar.txt: -------------------------------------------------------------------------------- 1 | *tagbar.txt* Display tags of a file ordered by scope 2 | 3 | Author: Jan Larres 4 | Licence: Vim licence, see |license| 5 | Homepage: http://majutsushi.github.com/tagbar/ 6 | Version: 2.6.1 7 | 8 | ============================================================================== 9 | Contents *tagbar* *tagbar-contents* 10 | 11 | 1. Intro ........................... |tagbar-intro| 12 | Pseudo-tags ................... |tagbar-pseudotags| 13 | Supported features ............ |tagbar-features| 14 | Other ctags-compatible programs |tagbar-other| 15 | 2. Requirements .................... |tagbar-requirements| 16 | 3. Installation .................... |tagbar-installation| 17 | 4. Usage ........................... |tagbar-usage| 18 | Commands ...................... |tagbar-commands| 19 | Key mappings .................. |tagbar-keys| 20 | 5. Configuration ................... |tagbar-configuration| 21 | Highlight colours ............. |tagbar-highlight| 22 | Automatically opening Tagbar .. |tagbar-autoopen| 23 | Show current tag in statusline |tagbar-statusline| 24 | Ignoring specific files ....... |tagbar-ignore| 25 | 6. Extending Tagbar ................ |tagbar-extend| 26 | 7. Troubleshooting & Known issues .. |tagbar-issues| 27 | 8. History ......................... |tagbar-history| 28 | 9. Todo ............................ |tagbar-todo| 29 | 10. Credits ......................... |tagbar-credits| 30 | 31 | ============================================================================== 32 | 1. Intro *tagbar-intro* 33 | 34 | Tagbar is a plugin for browsing the tags of source code files. It provides a 35 | sidebar that displays the ctags-generated tags of the current file, ordered by 36 | their scope. This means that for example methods in C++ are displayed under 37 | the class they are defined in. 38 | 39 | Let's say we have the following code inside of a C++ file: 40 | > 41 | namespace { 42 | char a; 43 | 44 | class Foo 45 | { 46 | public: 47 | Foo(); 48 | ~Foo(); 49 | private: 50 | int var; 51 | }; 52 | }; 53 | < 54 | Then Tagbar would display the tag information like so: 55 | > 56 | __anon1* : namespace 57 | Foo : class 58 | +Foo() 59 | +~Foo() 60 | -var 61 | a 62 | < 63 | This example shows several important points. First, the tags are listed 64 | indented below the scope they are defined in. Second, the type of a scope is 65 | listed after its name and a colon. Third, tags for which the visibility 66 | information is known are prefixed with a symbol indicating that. 67 | 68 | ------------------------------------------------------------------------------ 69 | PSEUDO-TAGS *tagbar-pseudotags* 70 | 71 | The example also introduces the concept of "pseudo-tags". Pseudo-tags are tags 72 | that are not explicitly defined in the file but have children in it. In this 73 | example the namespace doesn't have a name and thus ctags doesn't generate a 74 | tag for it, but since it has children it still needs to be displayed using an 75 | auto-generated name. 76 | 77 | Another case where pseudo-tags appear is in C++ implementation files. Since 78 | classes are usually defined in a header file but the member methods and 79 | variables in the implementation file the class itself won't generate a tag 80 | in that file. 81 | 82 | Since pseudo-tags don't really exist they cannot be jumped to from the Tagbar 83 | window. 84 | 85 | Pseudo-tags are denoted with an asterisk ('*') at the end of their name. 86 | 87 | ------------------------------------------------------------------------------ 88 | SUPPORTED FEATURES *tagbar-features* 89 | 90 | The following features are supported by Tagbar: 91 | 92 | - Display tags under their correct scope. 93 | - Automatically update the tags when switching between buffers and editing 94 | files. 95 | - Display visibility information of tags if available. 96 | - Highlight the tag near the cursor while editing files. 97 | - Jump to a tag from the Tagbar window. 98 | - Display the complete prototype of a tag. 99 | - Tags can be sorted either by name or order of appearance in the file. 100 | - Scopes can be folded to hide uninteresting information. 101 | - Supports all of the languages that ctags does, i.e. Ant, Assembler, ASP, 102 | Awk, Basic, BETA, C, C++, C#, COBOL, DosBatch, Eiffel, Erlang, Flex, 103 | Fortran, HTML, Java, JavaScript, Lisp, Lua, Make, MatLab, OCaml, Pascal, 104 | Perl, PHP, Python, REXX, Ruby, Scheme, Shell script, SLang, SML, SQL, Tcl, 105 | Tex, Vera, Verilog, VHDL, Vim and YACC. 106 | - Can be extended to support arbitrary new types. 107 | 108 | ------------------------------------------------------------------------------ 109 | OTHER CTAGS-COMPATIBLE PROGRAMS *tagbar-other* 110 | 111 | Tagbar theoretically also supports filetype-specific programs that can output 112 | tag information that is compatible with ctags. However due to potential 113 | incompatibilities this may not always completely work. Tagbar has been tested 114 | with doctorjs/jsctags and will use that if present, other programs require 115 | some configuration (see |tagbar-extend|). If a program does not work even with 116 | correct configuration please contact me. 117 | 118 | Note: Please check |tagbar-issues| for some possible issues with jsctags. 119 | 120 | ============================================================================== 121 | 2. Requirements *tagbar-requirements* 122 | 123 | The following requirements have to be met in order to be able to use tagbar: 124 | 125 | - Vim 7.0 or higher. Older versions will not work since Tagbar uses data 126 | structures that were only introduced in Vim 7. 127 | - Exuberant ctags 5.5 or higher. Ctags is the program that generates the 128 | tag information that Tagbar uses. It is shipped with most Linux 129 | distributions, otherwise it can be downloaded from the following 130 | website: 131 | 132 | http://ctags.sourceforge.net/ 133 | 134 | Tagbar will work on any platform that ctags runs on -- this includes 135 | UNIX derivatives, Mac OS X and Windows. Note that other versions like 136 | GNU ctags will not work. 137 | Tagbar generates the tag information by itself and doesn't need (or use) 138 | already existing tag files. 139 | - File type detection must be turned on in vim. This can be done with the 140 | following command in your vimrc: 141 | > 142 | filetype on 143 | < 144 | See |filetype| for more information. 145 | - Tagbar will not work in |restricted-mode| or with 'compatible' set. 146 | 147 | ============================================================================== 148 | 3. Installation *tagbar-installation* 149 | 150 | Use the normal Vimball install method for installing tagbar.vba: 151 | > 152 | vim tagbar.vba 153 | :so % 154 | :q 155 | < 156 | Alternatively you can clone the git repository and then add the path to 157 | 'runtimepath' or use the pathogen plugin. Don't forget to run |:helptags|. 158 | 159 | If the ctags executable is not installed in one of the directories in your 160 | $PATH environment variable you have to set the g:tagbar_ctags_bin variable, 161 | see |g:tagbar_ctags_bin|. 162 | 163 | ============================================================================== 164 | 4. Usage *tagbar-usage* 165 | 166 | There are essentially two ways to use Tagbar: 167 | 168 | 1. Have it running all the time in a window on the side of the screen. In 169 | this case Tagbar will update its contents whenever the source file is 170 | changed and highlight the tag the cursor is currently on in the file. If 171 | a tag is selected in Tagbar the file window will jump to the tag and the 172 | Tagbar window will stay open. |g:tagbar_autoclose| has to be unset for 173 | this mode. 174 | 2. Only open Tagbar when you want to jump to a specific tag and have it 175 | close automatically once you have selected one. This can be useful for 176 | example for small screens where a permanent window would take up too much 177 | space. You have to set the option |g:tagbar_autoclose| in this case. The 178 | cursor will also automatically jump to the Tagbar window when opening it. 179 | 180 | Opening and closing the Tagbar window~ 181 | Use |:TagbarOpen| or |:TagbarToggle| to open the Tagbar window if it is 182 | closed. By default the window is opened on the right side, set the option 183 | |g:tagbar_left| to open it on the left instead. If the window is already open, 184 | |:TagbarOpen| will jump to it and |:TagbarToggle| will close it again. 185 | |:TagbarClose| will simply close the window if it is open. 186 | 187 | It is probably a good idea to assign a key to these commands. For example, put 188 | this into your |vimrc|: 189 | > 190 | nnoremap :TagbarToggle 191 | < 192 | You can then open and close Tagbar by simply pressing the key. 193 | 194 | You can also use |:TagbarOpenAutoClose| to open the Tagbar window, jump to it 195 | and have it close automatically on tag selection regardless of the 196 | |g:tagbar_autoclose| setting. 197 | 198 | Pausing the Tagbar window~ 199 | Use |:TagbarTogglePause| to toggle freezing the Tagbar window on its currently 200 | displayed file. Freezing the window stops the Tagbar contents from changing 201 | when switching to a different source file. All Tagbar functionality continues 202 | to work as expected. Unfreezing the window will cause it to load the current 203 | source file. 204 | 205 | Jumping to tags~ 206 | When you're inside the Tagbar window you can jump to the definition of a tag 207 | by moving the cursor to a tag and pressing or double-clicking on it 208 | with the mouse. The source file will then move to the definition and put the 209 | cursor in the corresponding line. This won't work for pseudo-tags. 210 | 211 | Sorting~ 212 | You can sort the tags in the Tagbar window in two ways: by name or by file 213 | order. Sorting them by name simply displays the tags in their alphabetical 214 | order under their corresponding scope. Sorting by file order means that the 215 | tags keep the order they have in the source file, but are still associated 216 | with the correct scope. You can change the sort order by pressing the "s" key 217 | in the Tagbar window. The current sort order is displayed in the statusline of 218 | the Tagbar window. 219 | 220 | Folding~ 221 | The displayed scopes (and unscoped types) can be folded to hide uninteresting 222 | information. Mappings similar to Vim's built-in ones are provided. Folds can 223 | also be opened and closed by clicking on the fold icon with the mouse. 224 | 225 | Highlighting the current tag~ 226 | When the Tagbar window is open the current tag will automatically be 227 | highlighted in it after a short pause if the cursor is not moving. The length 228 | of this pause is determined by the 'updatetime' option. If you want to make 229 | that pause shorter you can change the option, but don't set it too low or 230 | strange things will happen. This is unfortunately unavoidable. 231 | 232 | Displaying the prototype of a tag~ 233 | Tagbar can display the prototype of a tag. More precisely it can display the 234 | line(s) in which the tag is defined. This can be done by either pressing 235 | when on a tag or hovering over a tag with the mouse. In the former 236 | case the prototype will be displayed in the |Command-line|, in the latter case 237 | it will be displayed in a pop-up window. The prototype will also be displayed 238 | if the cursor stays on a tag for 'updatetime' milliseconds. In that case the 239 | prototype may be abbreviated in order to avoid |hit-enter| prompts. 240 | 241 | ------------------------------------------------------------------------------ 242 | COMMANDS *tagbar-commands* 243 | 244 | :TagbarOpen [{flags}] *:TagbarOpen* 245 | Open the Tagbar window if it is closed. 246 | 247 | Additional behaviour can be specified with the optional {flags} argument. 248 | It is a string which can contain these character flags: 249 | 'f' Jump to Tagbar window when opening (just as if |g:tagbar_autofocus| 250 | were set to 1) 251 | 'j' Jump to Tagbar window if already open 252 | 'c' Close Tagbar on tag selection (just as if |g:tagbar_autoclose| were 253 | set to 1, but doesn't imply 'f'), but only if the Tagbar window was 254 | opened using this command. 255 | 256 | For example, the following command would always jump to the Tagbar window, 257 | opening it first if necessary, but keep it open after selecting a tag 258 | (unless |g:tagbar_autoclose| is set): > 259 | :TagbarOpen fj 260 | < 261 | :TagbarClose *:TagbarClose* 262 | Close the Tagbar window if it is open. 263 | 264 | :TagbarToggle *:TagbarToggle* 265 | :Tagbar 266 | Open the Tagbar window if it is closed, or close it if it is open. 267 | 268 | :TagbarOpenAutoClose *:TagbarOpenAutoClose* 269 | Open the Tagbar window, jump to it and close it on tag selection. This is 270 | an alias for ":TagbarOpen fjc". 271 | 272 | :TagbarTogglePause *:TagbarTogglePause* 273 | Freezes/Unfreezes the Tagbar window. Stops the contents of the window 274 | from changing when a different source file is selected. 275 | 276 | :TagbarSetFoldlevel[!] {number} *:TagbarSetFoldlevel* 277 | Set the foldlevel of the tags of the current file to {number}. The 278 | foldlevel of tags in other files remains unaffected. Works in the same way 279 | as 'foldlevel'. Folds that are specified to be closed by default in the 280 | type configuration will not be opened, use a "!" to force applying the new 281 | foldlevel to those folds as well. 282 | 283 | :TagbarShowTag *:TagbarShowTag* 284 | Open the parent folds of the current tag in the file window as much as 285 | needed for the tag to be visible in the Tagbar window. 286 | 287 | :TagbarCurrentTag [{flags}] *:TagbarCurrentTag* 288 | Echo the current tag in the command line. For {flags} see 289 | |tagbar-statusline|. 290 | 291 | :TagbarGetTypeConfig {filetype} *:TagbarGetTypeConfig* 292 | Paste the Tagbar configuration of the vim filetype {filetype} at the 293 | current cursor position (provided that filetype is supported by Tagbar) 294 | for easy customization. The configuration will be ready to use as is but 295 | will only contain the "kinds" entry as that is the only one that really 296 | makes sense to customize. See |tagbar-extend| for more information about 297 | type configurations. 298 | 299 | :TagbarDebug [logfile] *:TagbarDebug* 300 | Start debug mode. This will write debug messages to file [logfile] while 301 | using Tagbar. If no argument is given "tagbardebug.log" in the current 302 | directory is used. Note: an existing file will be overwritten! 303 | Note also that it is usually necessary to call this command before loading 304 | a file that creates problems in order to get all of the needed data. 305 | 306 | :TagbarDebugEnd *:TagbarDebugEnd* 307 | End debug mode, debug messages will no longer be written to the logfile. 308 | 309 | ------------------------------------------------------------------------------ 310 | KEY MAPPINGS *tagbar-keys* 311 | 312 | The following mappings are valid in the Tagbar window: 313 | 314 | Display key mapping help. 315 | Map option: tagbar_map_help 316 | / Jump to the tag under the cursor. Doesn't work for pseudo-tags 317 | or generic headers. 318 | Map option: tagbar_map_jump 319 | p Jump to the tag under the cursor, but stay in the Tagbar window. 320 | Map option: tagbar_map_preview 321 | P Open the tag in a |preview-window|. 322 | Map option: tagbar_map_previewwin 323 | When on a fold icon, open or close the fold depending on the 324 | current state. 325 | <2-LeftMouse> Same as . See |g:tagbar_singleclick| if you want to use a 326 | single- instead of a double-click. 327 | Go to the next top-level tag. 328 | Map option: tagbar_map_nexttag 329 | Go to the previous top-level tag. 330 | Map option: tagbar_map_prevtag 331 | Display the prototype of the current tag (i.e. the line defining 332 | it) in the command line. 333 | Map option: tagbar_map_showproto 334 | +/zo Open the fold under the cursor. 335 | Map option: tagbar_map_openfold 336 | -/zc Close the fold under the cursor or the current one if there is 337 | no fold under the cursor. 338 | Map option: tagbar_map_closefold 339 | o/za Toggle the fold under the cursor or the current one if there is 340 | no fold under the cursor. 341 | Map option: tagbar_map_togglefold 342 | */zR Open all folds by setting foldlevel to 99. 343 | Map option: tagbar_map_openallfolds 344 | =/zM Close all folds by setting foldlevel to 0. 345 | Map option: tagbar_map_closeallfolds 346 | s Toggle sort order between name and file order. 347 | Map option: tagbar_map_togglesort 348 | x Toggle zooming the window. 349 | Map option: tagbar_map_zoomwin 350 | q Close the Tagbar window. 351 | Map option: tagbar_map_close 352 | 353 | These mappings can be redefined with the given map options. The argument can 354 | be either a string or a |List| of strings. In the latter case the 355 | functionality will be assigned to all of the keys in the list. For example, if 356 | you want to remap the sort toggling functionality to "r": 357 | > 358 | let g:tagbar_map_togglesort = "r" 359 | < 360 | See |key-notation| for how to write special keys like or the keypad 361 | keys. 362 | 363 | ============================================================================== 364 | 5. Configuration *tagbar-configuration* 365 | 366 | *g:tagbar_ctags_bin* 367 | g:tagbar_ctags_bin~ 368 | Default: empty 369 | 370 | Use this option to specify the location of your ctags executable. Only needed 371 | if it is not in one of the directories in your $PATH environment variable. 372 | 373 | Example: 374 | > 375 | let g:tagbar_ctags_bin = 'C:\Ctags5.8\ctags.exe' 376 | < 377 | 378 | *g:tagbar_left* 379 | g:tagbar_left~ 380 | Default: 0 381 | 382 | By default the Tagbar window will be opened on the right-hand side of vim. Set 383 | this option to open it on the left instead. 384 | 385 | Example: 386 | > 387 | let g:tagbar_left = 1 388 | < 389 | 390 | *g:tagbar_width* 391 | g:tagbar_width~ 392 | Default: 40 393 | 394 | Width of the Tagbar window in characters. 395 | 396 | Example: 397 | > 398 | let g:tagbar_width = 30 399 | < 400 | 401 | *g:tagbar_autoclose* 402 | g:tagbar_autoclose~ 403 | Default: 0 404 | 405 | If you set this option the Tagbar window will automatically close when you 406 | jump to a tag. This implies |g:tagbar_autofocus|. 407 | 408 | Example: 409 | > 410 | let g:tagbar_autoclose = 1 411 | < 412 | 413 | *g:tagbar_autofocus* 414 | g:tagbar_autofocus~ 415 | Default: 0 416 | 417 | If you set this option the cursor will move to the Tagbar window when it is 418 | opened. 419 | 420 | Example: 421 | > 422 | let g:tagbar_autofocus = 1 423 | < 424 | 425 | *g:tagbar_sort* 426 | g:tagbar_sort~ 427 | Default: 1 428 | 429 | If this option is set the tags are sorted according to their name. If it is 430 | unset they are sorted according to their order in the source file. Note that 431 | in the second case Pseudo-tags are always sorted before normal tags of the 432 | same kind since they don't have a real position in the file. 433 | 434 | Example: 435 | > 436 | let g:tagbar_sort = 0 437 | < 438 | 439 | *g:tagbar_compact* 440 | g:tagbar_compact~ 441 | Default: 0 442 | 443 | Setting this option will result in Tagbar omitting the short help at the 444 | top of the window and the blank lines in between top-level scopes in order to 445 | save screen real estate. 446 | 447 | Example: 448 | > 449 | let g:tagbar_compact = 1 450 | < 451 | 452 | *g:tagbar_indent* 453 | g:tagbar_indent~ 454 | Default: 2 455 | 456 | The number of spaces by which each level is indented. This allows making the 457 | display more compact or more spacious. 458 | 459 | Example: 460 | > 461 | let g:tagbar_indent = 1 462 | < 463 | 464 | *g:tagbar_show_visibility* 465 | g:tagbar_show_visibility~ 466 | Default: 1 467 | 468 | Show the visibility symbols (public/protected/private) to the left of the tag 469 | name. 470 | 471 | Example: 472 | > 473 | let g:tagbar_show_visibility = 0 474 | < 475 | 476 | *g:tagbar_show_linenumbers* 477 | g:tagbar_show_linenumbers~ 478 | Default: 0 479 | 480 | Whether line numbers should be shown in the Tagbar window. 481 | 482 | Possible values are: 483 | 0: Don't show any line numbers. 484 | 1: Show absolute line numbers. 485 | 2: Show relative line numbers. 486 | -1: Use the global line number settings. 487 | 488 | Example: 489 | > 490 | let g:tagbar_show_linenumbers = 2 491 | < 492 | 493 | *g:tagbar_expand* 494 | g:tagbar_expand~ 495 | Default: 0 496 | 497 | If this option is set to 1 the Vim window will be expanded by the width of the 498 | Tagbar window if using a GUI version of Vim. Setting it to 2 will also try 499 | expanding a terminal, but note that this is not supported by all terminals. 500 | See also |xterm-resize|. 501 | 502 | Example: 503 | > 504 | let g:tagbar_expand = 1 505 | < 506 | 507 | *g:tagbar_singleclick* 508 | g:tagbar_singleclick~ 509 | Default: 0 510 | 511 | If this option is set then a single- instead of a double-click is used to jump 512 | to the tag definition. 513 | 514 | Example: 515 | > 516 | let g:tagbar_singleclick = 1 517 | < 518 | 519 | *g:tagbar_foldlevel* 520 | g:tagbar_foldlevel~ 521 | Default: 99 522 | 523 | The initial foldlevel for folds in the Tagbar window. Folds with a level 524 | higher than this number will be closed. 525 | 526 | Example: 527 | > 528 | let g:tagbar_foldlevel = 2 529 | < 530 | 531 | *g:tagbar_iconchars* 532 | g:tagbar_iconchars~ 533 | 534 | Since the display of the icons used to indicate open or closed folds depends 535 | on the actual font used, different characters may be optimal for different 536 | fonts. With this variable you can set the icons to characters of your liking. 537 | The first character in the list specifies the icon to use for a closed fold, 538 | and the second one for an open fold. 539 | 540 | Examples (don't worry if some of the characters aren't displayed correctly, 541 | just choose other characters in that case): 542 | > 543 | let g:tagbar_iconchars = ['▶', '▼'] (default on Linux and Mac OS X) 544 | let g:tagbar_iconchars = ['▸', '▾'] 545 | let g:tagbar_iconchars = ['▷', '◢'] 546 | let g:tagbar_iconchars = ['+', '-'] (default on Windows) 547 | < 548 | 549 | *g:tagbar_autoshowtag* 550 | g:tagbar_autoshowtag~ 551 | Default: 0 552 | 553 | If this variable is set to 1 and the current tag is inside of a closed fold 554 | then the folds will be opened as much as needed for the tag to be visible so 555 | it can be highlighted. If it is set to 0 then the folds will only be opened 556 | when opening the Tagbar window and the current tag is insided a closed fold, 557 | otherwise the folds won't be opened and the parent tag will be highlighted 558 | instead. If it is set to 2 then the folds will never be opened automatically. 559 | 560 | You can use the |:TagbarShowTag| command to open the folds manually. 561 | 562 | Example: 563 | > 564 | let g:tagbar_autoshowtag = 1 565 | < 566 | 567 | *g:tagbar_previewwin_pos* 568 | g:tagbar_previewwin_pos~ 569 | Default: topleft 570 | 571 | The position of the preview window. Valid values are the window splitting 572 | commands that are described starting from |:vertical|. Set it to an empty 573 | string to use the options 'splitbelow' and 'splitright'. 574 | 575 | Example: 576 | > 577 | let g:tagbar_previewwin_pos = "aboveleft" 578 | < 579 | If you want to disable line numbers in the preview window put something like 580 | this into your vimrc: 581 | > 582 | autocmd BufWinEnter * if &previewwindow | setlocal nonumber | endif 583 | < 584 | 585 | *g:tagbar_autopreview* 586 | g:tagbar_autopreview~ 587 | Default: 0 588 | 589 | If this variable is set to 1 then moving the cursor in the Tagbar window will 590 | automatically show the current tag in the preview window. 591 | 592 | Example: 593 | > 594 | let g:tagbar_autopreview = 1 595 | < 596 | 597 | *g:tagbar_updateonsave_maxlines* 598 | g:tagbar_updateonsave_maxlines~ 599 | 600 | Deprecated. Tagbar will now always get updated when the file is being saved. 601 | 602 | 603 | *g:tagbar_systemenc* 604 | g:tagbar_systemenc~ 605 | Default: value of 'encoding' 606 | 607 | This variable is for cases where the character encoding of your operating 608 | system is different from the one set in Vim, i.e. the 'encoding' option. For 609 | example, if you use a Simplified Chinese Windows version that has a system 610 | encoding of "cp936", and you have set 'encoding' to "utf-8", then you would 611 | have to set this variable to "cp936". 612 | Note that this requires Vim to be compiled with the |+multi_byte| and (unless 613 | your encoding is latin1) |+iconv| features to work. 614 | 615 | Example: 616 | > 617 | let g:tagbar_systemenc = 'cp936' 618 | < 619 | 620 | *g:tagbar_status_func* 621 | g:tagbar_status_func~ 622 | Default: undefined 623 | 624 | This is the name of a function whose return value will be used to draw the 625 | statusline of the Tagbar window. 626 | 627 | The function has to take three arguments: 628 | 1. current: Whether Tagbar is the current window; 0 or 1. 629 | 2. sort: The sort order of the tags; 'Name' if they are sorted by name and 630 | 'Order' if they are sorted by their order of appearance in the file. 631 | 3. fname: The name of the file that the tags belong to. 632 | 633 | In order to avoid possible future additions to the arguments resulting in an 634 | error it is recommended to add an additional vararg to the signature (see 635 | |a:0|). 636 | 637 | Here is an example that, when put into your vimrc, will emulate Tagbar's 638 | default statusline: 639 | > 640 | function! TagbarStatusFunc(current, sort, fname, ...) abort 641 | let colour = a:current ? '%#StatusLine#' : '%#StatusLineNC#' 642 | return colour . '[' . a:sort . '] ' . a:fname 643 | endfunction 644 | let g:tagbar_status_func = 'TagbarStatusFunc' 645 | < 646 | 647 | ------------------------------------------------------------------------------ 648 | HIGHLIGHT COLOURS *tagbar-highlight* 649 | 650 | All of the colours used by Tagbar can be customized. Here is a list of the 651 | highlight groups that are defined by Tagbar: 652 | 653 | TagbarComment 654 | The help at the top of the buffer. 655 | 656 | TagbarKind 657 | The header of generic "kinds" like "functions" and "variables". 658 | 659 | TagbarNestedKind 660 | The "kind" headers in square brackets inside of scopes. 661 | 662 | TagbarScope 663 | Tags that define a scope like classes, structs etc. 664 | 665 | TagbarType 666 | The type of a tag or scope if available. 667 | 668 | TagbarSignature 669 | Function signatures. 670 | 671 | TagbarPseudoID 672 | The asterisk (*) that signifies a pseudo-tag. 673 | 674 | TagbarFoldIcon 675 | The fold icon on the left of foldable tags. 676 | 677 | TagbarHighlight 678 | The colour that is used for automatically highlighting the current tag. 679 | 680 | TagbarVisibilityPublic 681 | The "public" visibility symbol. 682 | 683 | TagbarVisibilityProtected 684 | The "protected" visibility symbol. 685 | 686 | TagbarVisibilityPrivate 687 | The "private" visibility symbol. 688 | 689 | If you want to change any of those colours put a line like the following in 690 | your vimrc: 691 | > 692 | highlight TagbarScope guifg=Green ctermfg=Green 693 | < 694 | See |:highlight| for more information. 695 | 696 | ------------------------------------------------------------------------------ 697 | AUTOMATICALLY OPENING TAGBAR *tagbar-autoopen* 698 | 699 | Since there are several different situations in which you might want to open 700 | Tagbar automatically there is no single option to enable automatic opening. 701 | Instead, autocommands can be used together with a convenience function that 702 | opens Tagbar only if a supported file is open(ed). It has a boolean parameter 703 | that specifies whether Tagbar should be opened if any loaded buffer is 704 | supported (in case the parameter is set to true) or only if a supported 705 | file/buffer is currently being shown in a window. This can be useful if you 706 | use multiple tabs and don't edit supported files in all of them. 707 | 708 | If you want to open Tagbar automatically on Vim startup no matter what put 709 | this into your vimrc: 710 | > 711 | autocmd VimEnter * nested :TagbarOpen 712 | < 713 | If you want to open it only if you're opening Vim with a supported file/files 714 | use this instead: 715 | > 716 | autocmd VimEnter * nested :call tagbar#autoopen(1) 717 | < 718 | The above is exactly what the Taglist plugin does if you set the 719 | Tlist_Auto_Open option, in case you want to emulate this behaviour. 720 | 721 | For opening Tagbar also if you open a supported file in an already running 722 | Vim: 723 | > 724 | autocmd FileType * nested :call tagbar#autoopen(0) 725 | < 726 | If you use multiple tabs and want Tagbar to also open in the current tab when 727 | you switch to an already loaded, supported buffer: 728 | > 729 | autocmd BufEnter * nested :call tagbar#autoopen(0) 730 | < 731 | And if you want to open Tagbar only for specific filetypes, not for all of the 732 | supported ones: 733 | > 734 | autocmd FileType c,cpp nested :TagbarOpen 735 | < 736 | Check out |autocmd.txt| if you want it to open automatically in more 737 | complicated cases. 738 | 739 | ------------------------------------------------------------------------------ 740 | SHOWING THE CURRENT TAG IN THE STATUSLINE *tagbar-statusline* 741 | 742 | You can show the current tag in the 'statusline', or in any other place that 743 | you want to, by calling the tagbar#currenttag() function. The current tag is 744 | exactly the same as would be highlighted in the Tagbar window if it is open. 745 | It is defined as the nearest tag upwards in the file starting from the cursor 746 | position. This means that for example in a function it should usually be the 747 | name of the function. You can define which tags will be shown in this manner, 748 | read |tagbar-extend| (especially the "kinds" entry) on how to do that. 749 | 750 | The function has the following signature: 751 | 752 | tagbar#currenttag({format}, {default} [, {flags}]) 753 | {format} is a |printf()|-compatible format string where "%s" will be 754 | replaced by the name of the tag. {default} will be displayed instead of 755 | the format string if no tag can be found. 756 | 757 | The optional {flags} argument specifies some additional properties of the 758 | displayed tags. It is a string which can contain these character flags: 759 | 'f' Display the full hierarchy of the tag, not just the tag itself. 760 | 's' If the tag is a function, the complete signature will be shown, 761 | otherwise just "()" will be appended to distinguish functions from 762 | other tags. 763 | 'p' Display the raw prototype instead of the parsed tag. This can be 764 | useful in cases where ctags doesn't report some information, like 765 | the signature. Note that this can get quite long. 766 | 767 | For example, if you put the following into your statusline: > 768 | %{tagbar#currenttag('[%s] ','')} 769 | < then the function "myfunc" will be shown as "[myfunc()] ". 770 | 771 | Note that if there is an error when processing the current file no error 772 | message will be shown in order to not disrupt the statusline. If the function 773 | doesn't seem to work right open the Tagbar window to see any error messages. 774 | 775 | ------------------------------------------------------------------------------ 776 | IGNORING SPECIFIC FILES *tagbar-ignore* 777 | 778 | You can ignore specific files by setting the |buffer-variable| 779 | "b:tagbar_ignore" to 1. This is best done with an |autocommand|: 780 | > 781 | autocmd BufNewFile,BufReadPost foo.cpp let b:tagbar_ignore = 1 782 | < 783 | Note that autocommands are order-sensitive, so make sure that this autocommand 784 | gets defined before the ones that Tagbar defines so the variable will get 785 | found at the right time. 786 | 787 | ============================================================================== 788 | 6. Extending Tagbar *tagbar-extend* 789 | 790 | Tagbar has a flexible mechanism for extending the existing file type (i.e. 791 | language) definitions. This can be used both to change the settings of the 792 | existing types and to add completely new types. For Tagbar to support a 793 | filetype two things are needed: a program that generates the tag information, 794 | usually Exuberant Ctags, and a Tagbar type definition in your |vimrc| or an 795 | |ftplugin| that tells Tagbar how to interpret the generated tags. 796 | 797 | Note: if you only want to customize an existing definition (like changing the 798 | order in which tag kinds are displayed) see "Changing an existing definition" 799 | below. 800 | 801 | There are two ways to generate the tag information for new filetypes: add a 802 | definition to Exuberant Ctags or create a specialized program for your 803 | language that generates ctags-compatible tag information (see 804 | |tags-file-format| for information about how a "tags" file is structured). The 805 | former allows simple regular expression-based parsing that is easy to get 806 | started with, but doesn't support scopes unless you instead want to write a 807 | C-based parser module for Exuberant Ctags. The regex approach is described in 808 | more detail below. 809 | Writing your own program is the approach used by for example jsctags and can 810 | be useful if your language can best be parsed by a program written in the 811 | language itself, or if you want to provide the program as part of a complete 812 | support package for the language. Some tips on how to write such a program are 813 | given at the end of this section. 814 | 815 | Before writing your own extension have a look at the wiki 816 | (https://github.com/majutsushi/tagbar/wiki) or try googling for existing ones. 817 | If you do end up creating your own extension please consider adding it to the 818 | wiki so that others can benefit from it, too. 819 | 820 | Every type definition in Tagbar is a dictionary with the following keys: 821 | 822 | ctagstype: The name of the language as recognized by ctags. Use the command > 823 | ctags --list-languages 824 | < to get a list of the languages ctags supports. The case doesn't 825 | matter. 826 | kinds: A list of the "language kinds" that should be listed in Tagbar, 827 | ordered by the order they should appear in in the Tagbar window. 828 | Use the command > 829 | ctags --list-kinds={language name} 830 | < to get a list of the kinds ctags supports for a given language. An 831 | entry in this list is a colon-separated string with the following 832 | syntax: > 833 | {short}:{long}[:{fold}[:{stl}]] 834 | < {short} is the one-character abbreviation that ctags uses, and 835 | {long} is an arbitrary string that will be used in Tagbar as the 836 | header for the the tags of this kind that are not listed under a 837 | specific scope. {fold} determines whether tags of this kind should 838 | be folded by default, with 1 meaning they should be folded and 0 839 | they should not. If this part is omitted the tags will not be 840 | folded by default. {stl} is used by the tagbar#currenttag() 841 | function (see |tagbar-statusline|) to decide whether tags of this 842 | kind should be shown in the statusline or not, with 1 meaning they 843 | will be shown and 0 meaning they will be ignored. Omitting this 844 | part means that the tags will be shown. Note that you have to 845 | specify {fold} too if you want to specify {stl}. 846 | For example, the string > 847 | "f:functions:1" 848 | < would list all the function definitions in a file under the header 849 | "functions", fold them, and implicitly show them in the statusline 850 | if tagbar#currenttag() is used. 851 | sro: The scope resolution operator. For example, in C++ it is "::" and 852 | in Java it is ".". If in doubt run ctags as shown below and check 853 | the output. 854 | kind2scope: A dictionary describing the mapping of tag kinds (in their 855 | one-character representation) to the scopes their children will 856 | appear in, for example classes, structs etc. 857 | Unfortunately there is no ctags option to list the scopes, you 858 | have to look at the tags ctags generates manually. For example, 859 | let's say we have a C++ file "test.cpp" with the following 860 | contents: > 861 | class Foo 862 | { 863 | public: 864 | Foo(); 865 | ~Foo(); 866 | private: 867 | int var; 868 | }; 869 | < We then run ctags in the following way: > 870 | ctags -f - --format=2 --excmd=pattern --extra= --fields=nksaSmt test.cpp 871 | < Then the output for the variable "var" would look like this: > 872 | var tmp.cpp /^ int var;$/;" kind:m line:11 class:Foo access:private 873 | < This shows that the scope name for an entry in a C++ class is 874 | simply "class". So this would be the word that the "kind" 875 | character of a class has to be mapped to. 876 | scope2kind: The opposite of the above, mapping scopes to the kinds of their 877 | parents. Most of the time it is the exact inverse of the above, 878 | but in some cases it can be different, for example when more than 879 | one kind maps to the same scope. If it is the exact inverse for 880 | your language you only need to specify one of the two keys. 881 | replace: If you set this entry to 1 your definition will completely replace 882 | {optional} an existing default definition. This is useful if you want to 883 | disable scopes for a file type for some reason. Note that in this 884 | case you have to provide all the needed entries yourself! 885 | sort: This entry can be used to override the global sort setting for 886 | {optional} this specific file type. The meaning of the value is the same as 887 | with the global setting, that is if you want to sort tags by name 888 | set it to 1 and if you want to sort them according to their order 889 | in the file set it to 0. 890 | deffile: The path to a file with additional ctags definitions (see the 891 | {optional} section below on adding a new definition for what exactly that 892 | means). This is especially useful for ftplugins since they can 893 | provide a complete type definition with ctags and Tagbar 894 | configurations without requiring user intervention. 895 | Let's say you have an ftplugin that adds support for the language 896 | "mylang", and your directory structure looks like this: > 897 | ctags/mylang.cnf 898 | ftplugin/mylang.vim 899 | < Then the "deffile" entry would look like this to allow for the 900 | plugin to be installed in an arbitray location (for example 901 | with pathogen): > 902 | 903 | 'deffile' : expand(':p:h:h') . '/ctags/mylang.cnf' 904 | < 905 | ctagsbin: The path to a filetype-specific ctags-compatible program like 906 | {optional} jsctags. Set it in the same way as |g:tagbar_ctags_bin|. jsctags is 907 | used automatically if found in your $PATH and does not have to be 908 | set in that case. If it is not in your path you have to set this 909 | key, the rest of the configuration should not be necessary (unless 910 | you want to change something, of course). Note: if you use this 911 | then the "ctagstype" key is not needed. 912 | ctagsargs: The arguments to be passed to the filetype-specific ctags program 913 | {optional} (without the filename). Make sure you set an option that makes the 914 | program output its data on stdout. Not used for the normal ctags 915 | program. 916 | 917 | The value of ctagsargs may be a |List| of strings (a string for 918 | each argument), or a single string (|expr-string|) of all the 919 | arguments. 920 | 921 | When the value of ctagsargs is a list, tagbar.vim takes care of 922 | escaping each argument in the list as required for the current 923 | 'shell' type. 924 | 925 | When the value of ctagsargs is a string, it must be properly 926 | escaped (if required by the current shell type). The reason 927 | tagbar.vim does not attempt to escape the string in this case is 928 | because if there is a space, it is ambiguous as to whether the 929 | space is delimiting an argument or included in the argument. To 930 | avoid this amiguity, tagbar.vim expects the string to be already 931 | escaped as required. 932 | 933 | If special escaping is required for different OS shell types or if 934 | in doubt, then it is recommended to define ctagsargs with a List. 935 | 936 | 937 | You then have to assign this dictionary to a variable in your vimrc with the 938 | name 939 | > 940 | g:tagbar_type_{vim filetype} 941 | < 942 | For example, for C++ the name would be "g:tagbar_type_cpp". If you don't know 943 | the vim file type then run the following command: 944 | > 945 | :set filetype? 946 | < 947 | and vim will display the file type of the current buffer. 948 | 949 | Example: C++~ 950 | Here is a complete example that shows the default configuration for C++ as 951 | used in Tagbar. This is just for illustration purposes since user 952 | configurations will usually be less complicated. 953 | > 954 | let g:tagbar_type_cpp = { 955 | \ 'ctagstype' : 'c++', 956 | \ 'kinds' : [ 957 | \ 'd:macros:1:0', 958 | \ 'p:prototypes:1:0', 959 | \ 'g:enums', 960 | \ 'e:enumerators:0:0', 961 | \ 't:typedefs:0:0', 962 | \ 'n:namespaces', 963 | \ 'c:classes', 964 | \ 's:structs', 965 | \ 'u:unions', 966 | \ 'f:functions', 967 | \ 'm:members:0:0', 968 | \ 'v:variables:0:0' 969 | \ ], 970 | \ 'sro' : '::', 971 | \ 'kind2scope' : { 972 | \ 'g' : 'enum', 973 | \ 'n' : 'namespace', 974 | \ 'c' : 'class', 975 | \ 's' : 'struct', 976 | \ 'u' : 'union' 977 | \ }, 978 | \ 'scope2kind' : { 979 | \ 'enum' : 'g', 980 | \ 'namespace' : 'n', 981 | \ 'class' : 'c', 982 | \ 'struct' : 's', 983 | \ 'union' : 'u' 984 | \ } 985 | \ } 986 | < 987 | 988 | Which of the keys you have to specify depends on what you want to do. 989 | 990 | Changing an existing definition~ 991 | If you want to change an existing definition you only need to specify the 992 | parts that you want to change. It probably only makes sense to change "kinds", 993 | which would be the case if you wanted to for example change the order of 994 | certain kinds, change their default fold state or exclude them from appearing 995 | in Tagbar. The easiest way to do that is to use the |:TagbarGetTypeConfig| 996 | command, which will paste a ready-to-use configuration with the "kinds" entry 997 | for the specified type at the current cursor position. 998 | 999 | As an example, if you didn't want Tagbar to show prototypes for C++ files, 1000 | switch the order of enums and typedefs, and show macros in the statusline, you 1001 | would first run ":TagbarGetTypeConfig cpp" in your vimrc and then change the 1002 | definition like this: 1003 | > 1004 | let g:tagbar_type_cpp = { 1005 | \ 'kinds' : [ 1006 | \ 'd:macros:1', 1007 | \ 'g:enums', 1008 | \ 't:typedefs:0:0', 1009 | \ 'e:enumerators:0:0', 1010 | \ 'n:namespaces', 1011 | \ 'c:classes', 1012 | \ 's:structs', 1013 | \ 'u:unions', 1014 | \ 'f:functions', 1015 | \ 'm:members:0:0', 1016 | \ 'v:variables:0:0' 1017 | \ ] 1018 | \ } 1019 | < 1020 | Compare with the complete example above to see the difference. 1021 | 1022 | Adding a definition for a new language/file type~ 1023 | In order to be able to add a new language to Tagbar you first have to create a 1024 | configuration for ctags that it can use to parse the files. This can be done 1025 | in two ways: 1026 | 1027 | 1. Use the --regex argument for specifying regular expressions that are used 1028 | to parse the files. An example of this is given below. A disadvantage of 1029 | this approach is that you can't specify scopes. 1030 | 2. Write a parser plugin in C for ctags. This approach is much more powerful 1031 | than the regex approach since you can make use of all of ctags' 1032 | functionality but it also requires much more work. Read the ctags 1033 | documentation for more information about how to do this. 1034 | 1035 | For the first approach the only keys that are needed in the Tagbar definition 1036 | are "ctagstype" and "kinds". A definition that supports scopes has to define 1037 | those two and in addition "scopes", "sro" and at least one of "kind2scope" and 1038 | "scope2kind". 1039 | 1040 | Let's assume we want to add support for LaTeX to Tagbar using the regex 1041 | approach. First we put the following text into ~/.ctags or a file pointed to 1042 | by the "deffile" definition entry: 1043 | > 1044 | --langdef=latex 1045 | --langmap=latex:.tex 1046 | --regex-latex=/^\\tableofcontents/TABLE OF CONTENTS/s,toc/ 1047 | --regex-latex=/^\\frontmatter/FRONTMATTER/s,frontmatter/ 1048 | --regex-latex=/^\\mainmatter/MAINMATTER/s,mainmatter/ 1049 | --regex-latex=/^\\backmatter/BACKMATTER/s,backmatter/ 1050 | --regex-latex=/^\\bibliography\{/BIBLIOGRAPHY/s,bibliography/ 1051 | --regex-latex=/^\\part[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/PART \2/s,part/ 1052 | --regex-latex=/^\\part[[:space:]]*\*[[:space:]]*\{([^}]+)\}/PART \1/s,part/ 1053 | --regex-latex=/^\\chapter[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/CHAP \2/s,chapter/ 1054 | --regex-latex=/^\\chapter[[:space:]]*\*[[:space:]]*\{([^}]+)\}/CHAP \1/s,chapter/ 1055 | --regex-latex=/^\\section[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\. \2/s,section/ 1056 | --regex-latex=/^\\section[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\. \1/s,section/ 1057 | --regex-latex=/^\\subsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\. \2/s,subsection/ 1058 | --regex-latex=/^\\subsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\. \1/s,subsection/ 1059 | --regex-latex=/^\\subsubsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\.\. \2/s,subsubsection/ 1060 | --regex-latex=/^\\subsubsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\.\. \1/s,subsubsection/ 1061 | --regex-latex=/^\\includegraphics[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/ 1062 | --regex-latex=/^\\lstinputlisting[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/ 1063 | --regex-latex=/\\label[[:space:]]*\{([^}]+)\}/\1/l,label/ 1064 | --regex-latex=/\\ref[[:space:]]*\{([^}]+)\}/\1/r,ref/ 1065 | --regex-latex=/\\pageref[[:space:]]*\{([^}]+)\}/\1/p,pageref/ 1066 | < 1067 | This will create a new language definition with the name "latex" and associate 1068 | it with files with the extension ".tex". It will also define the kinds "s" for 1069 | sections, chapters and the like, "g" for included graphics, "l" for labels, 1070 | "r" for references and "p" for page references. See the ctags documentation 1071 | for more information about the exact syntax. 1072 | 1073 | Now we have to create the Tagbar language definition in our vimrc: 1074 | > 1075 | let g:tagbar_type_tex = { 1076 | \ 'ctagstype' : 'latex', 1077 | \ 'kinds' : [ 1078 | \ 's:sections', 1079 | \ 'g:graphics:0:0', 1080 | \ 'l:labels', 1081 | \ 'r:refs:1:0', 1082 | \ 'p:pagerefs:1:0' 1083 | \ ], 1084 | \ 'sort' : 0, 1085 | \ 'deffile' : expand(':p:h:h') . '/ctags/latex.cnf' 1086 | \ } 1087 | < 1088 | The "deffile" field is of course only needed if the ctags definition actually 1089 | is in that file and not in ~/.ctags. 1090 | 1091 | Sort has been disabled for LaTeX so that the sections appear in their correct 1092 | order. They unfortunately can't be shown nested with their correct scopes 1093 | since as already mentioned the regular expression approach doesn't support 1094 | that. 1095 | 1096 | Tagbar should now be able to show the sections and other tags from LaTeX 1097 | files. 1098 | 1099 | Note: As of 2012-05-05 the ctags development version contains an improved 1100 | LaTeX parser that works better than the example configuration presented here. 1101 | So if you are using a development build newer than that or a stable version 1102 | newer than 5.8 you should use the built-in support instead of this example. 1103 | 1104 | Project-specific configuration~ 1105 | 1106 | In addition to the normal global configuration it is also possible to have 1107 | project-specific settings. This is mostly useful for additional ctags options, 1108 | like for example macros to ignore. Or maybe you want to do things like folding 1109 | certain tag kinds in some projects. 1110 | 1111 | In order to use this feature you need to create User |autocommand|s in an 1112 | augroup called "TagbarProjects" and have it create a buffer-local variable 1113 | called "b:tagbar_type". This variable has to hold a type definition just like 1114 | the normal ones described in this chapter. This definition will then be 1115 | applied only to the files matched by the autocommand. 1116 | 1117 | Note that there can be multiple definitions of the augroup with their own 1118 | autocommands (for example in separate project directories); they will get 1119 | merged automatically by Vim. 1120 | 1121 | Example: 1122 | > 1123 | augroup TagbarProjects 1124 | autocmd User ~/myproject/*.c let b:tagbar_type = {'deffile' : '~/myproject/ctags.cnf'} 1125 | augroup END 1126 | < 1127 | 1128 | Writing your own tag-generating program~ 1129 | If you want to write your own program for generating tags then here are some 1130 | imporant tips to get it to integrate well with Tagbar: 1131 | 1132 | - Tagbar supports the same tag format as Vim itself. The format is described 1133 | in |tags-file-format|, the third format mentioned there is the relevant 1134 | one. Note that the {tagaddress} part should be a search pattern since the 1135 | line number can be specified in a field (see below). 1136 | - Tagbar reads the tag information from a program's standard output 1137 | (stdout), it doesn't generate files and reads them in after that. So make 1138 | sure that your program has an option to output the tags on stdout. 1139 | - Some fields are supported for providing additional information about a 1140 | tag. One field is required: the "kind" field as a single letter without 1141 | a "kind:" fieldname. This field has to be the first one in the list. All 1142 | other fields need to have a fieldname in order to determine what they are. 1143 | The following fields are supported for all filetypes: 1144 | 1145 | * line: The line number of the tag. 1146 | * column: The column number of the tag. 1147 | * signature: The signature of a function. 1148 | * access: Visibility information of a tag; the values "public", 1149 | "protected" and "private" will be denoted with a special 1150 | symbol in Tagbar. 1151 | 1152 | In addition fields that describe the surrounding scope of the tag are 1153 | supported if they are specified in the type configuration as explained at 1154 | the beginning of this section. For example, for a tag in class "Foo" this 1155 | could look like "class:Foo". 1156 | Important: the value of such a scope-specifying field should be the entire 1157 | hierarchy of scopes that the tag is in, so if for example in C++ you have 1158 | a member in class "Foo" which is in namespace "Bar" then the scope field 1159 | should be "class:Bar::Foo". 1160 | 1161 | ============================================================================== 1162 | 7. Troubleshooting & Known issues *tagbar-issues* 1163 | 1164 | As a general rule, if the tag information displayed by Tagbar is wrong (for 1165 | example, a method doesn't show up or is in the wrong place) you should first 1166 | try running ctags manually to see whether ctags reports the wrong information 1167 | or whether that information is correct and Tagbar does something wrong. To run 1168 | ctags manually execute the following command in a terminal: 1169 | > 1170 | ctags -f - --format=2 --excmd=pattern --extra= --fields=nksaSmt myfile 1171 | < 1172 | If you set the |g:tagbar_ctags_bin| variable you probably have to use the same 1173 | value here instead of simply "ctags". 1174 | 1175 | If Tagbar doesn't seem to work at all, but you don't get any error messages, 1176 | you can use Tagbar's debug mode to try to find the source of the problem (see 1177 | |tagbar-commands| on how to invoke it). In that case you should especially pay 1178 | attention to the reported file type and the ctags command line in the log 1179 | file. 1180 | 1181 | 1182 | - jsctags has to be newer than 2011-01-06 since it needs the "-f" option to 1183 | work. Also, the output of jsctags seems to be a bit unreliable at the 1184 | moment (especially regarding line numbers), so if you notice some strange 1185 | behaviour with it please run it manually in a terminal to check whether 1186 | the bug is in jsctags or Tagbar. 1187 | 1188 | - Nested pseudo-tags cannot be properly parsed since only the direct parent 1189 | scope of a tag gets assigned a type, the type of the grandparents is not 1190 | reported by ctags (assuming the grandparents don't have direct, real 1191 | children). 1192 | 1193 | For example, if we have a C++ file with the following content: 1194 | > 1195 | foo::Bar::init() 1196 | { 1197 | // ... 1198 | } 1199 | foo::Baz::method() 1200 | { 1201 | // ... 1202 | } 1203 | < 1204 | In this case the type of "foo" is not known. Is it a namespace? A class? 1205 | For this reason the methods are displayed in Tagbar like this: 1206 | > 1207 | foo::Bar* : class 1208 | init() 1209 | foo::Baz* : class 1210 | method() 1211 | < 1212 | - Scope-defining tags at the top level that have the same name but a 1213 | different kind/scope type can lead to an incorrect display. For example, 1214 | the following Python code will incorrectly insert a pseudo-tag "Inner2" 1215 | into the "test" class: 1216 | > 1217 | class test: 1218 | class Inner: 1219 | def foo(self): 1220 | pass 1221 | 1222 | def test(): 1223 | class Inner2: 1224 | def bar(self): 1225 | pass 1226 | < 1227 | I haven't found a proper way around this yet, but it shouldn't be much of 1228 | a problem in practice anyway. Tags with the same name at any other level 1229 | are no problem, though. 1230 | 1231 | ============================================================================== 1232 | 8. History *tagbar-history* 1233 | 1234 | 2.6.1 (2014-01-23) 1235 | - Automatically close the preview window when jumping to a tag 1236 | - Don't forget the previous window in certain situations, which was 1237 | causing problems with for example fugitive 1238 | - Fixed toggling kind-specific folds 1239 | - Fixed ctags error that can happen with Cygwin 1240 | 1241 | 2.6 (2013-12-06) 1242 | - Added possibility to show tags in the preview window, either manually or 1243 | automatically. 1244 | - Allow customizing the statusline, see :help g:tagbar_status_func. 1245 | - Type configuration can now be project-specific. 1246 | - The keybindings in the Tagbar window are now configurable. 1247 | - Improvements to Ctags execution on Windows, thanks to Darcy Parker. 1248 | - Added function tagbar#currentfile() that returns the path to the file 1249 | currently being displayed in Tagbar, thanks to Zhao Cai. 1250 | - Added a :Tagbar command as an alias for :TagbarToggle. 1251 | - Added an way to ignore specific files in case they create problems. 1252 | - Optionally show line numbers in the Tagbar window. 1253 | - The usual bunch of small improvements and bugfixes. 1254 | 1255 | 2.5 (2013-03-25) 1256 | - New command :TagbarTogglePause to freeze Tagbar in its current state so 1257 | you can switch to other files while keeping the old information 1258 | displayed for reference. (Kian Ryan) 1259 | - New command :TagbarCurrentTag which reports the same information as 1260 | currenttag(). 1261 | - New option tagbar_indent to configure the indentation depth of the tags. 1262 | - New option tagbar_show_visibility to allow disabling the visibility 1263 | symbols. 1264 | - Files are now cached locally to avoid additional slowdowns for slow 1265 | connections. This also makes it possible to use Tagbar with files 1266 | accessed through Netrw. 1267 | - Execute ctags again even if the previous run reported errors, in case it 1268 | was a parse error that has since been fixed. If the error persists, 1269 | don't display it again. 1270 | - Improved window switching and Vim exit behaviours. (Techlive Zheng) 1271 | - The currenttag() function now can show the prototype instead of the 1272 | actual tag, which can be useful in some cases where ctags doesn't report 1273 | all the interesting information. 1274 | - The prototype shown in the tooltip or command line should now always be 1275 | complete, even if it is spread out over more than one line in the source 1276 | file. 1277 | - The TagbarAccessPublic etc. highlight groups have been renamed to 1278 | TagbarVisibilityPublic etc. to keep them in line with standard 1279 | terminology. The old names are still supported. 1280 | - Various smaller improvements and bugfixes. 1281 | 1282 | 2.4.1 (2012-07-16) 1283 | - Fixed some bugs related to the currenttag() function when it was called 1284 | before the rest of the plugin was loaded. Also fail silently in case 1285 | something goes wrong so the statusline doesn't get messed up. 1286 | - In certain cases highlighting tags in deeply nested folds could cause an 1287 | error message. 1288 | - Spellchecking is now correctly getting disabled in the Tagbar window. 1289 | 1290 | 2.4 (2012-06-17) 1291 | - New function tagbar#currenttag() that reports the current tag, for 1292 | example for putting it into the statusline. 1293 | - New command TagbarGetTypeConfig for easy customization of an existing 1294 | type. 1295 | - Type definitions now can be loaded from ftplugins. 1296 | - The autoopen() function is now a bit more flexible. 1297 | - Vala is now supported if Anjuta is installed. 1298 | - Various other small improvements and bugfixes. 1299 | 1300 | 2.3 (2011-12-24) 1301 | - Add a convenience function that allows more flexible ways to 1302 | automatically open Tagbar. 1303 | - Replace option tagbar_usearrows with tagbar_iconchars to allow custom 1304 | characters to be specified. This helps with fonts that don't display the 1305 | default characters properly. 1306 | - Remove the need to provide the complete jsctags configuration if jsctags 1307 | is not found in $PATH, now only the concrete path has to be specified. 1308 | - Add debugging functionality. 1309 | 1310 | 2.2 (2011-11-26) 1311 | - Small incompatible change: TagbarOpen now doesn't jump to the Tagbar 1312 | window anymore if it is already open. Use "TagbarOpen j" instead or see 1313 | its documentation for more options. 1314 | - Tags inside of scopes now have a header displaying their "kind". 1315 | - The Tagbar contents are now immediately updated on save for files 1316 | smaller than a configurable size. 1317 | - Tagbar can now be configured to jump to a tag with only a single-click 1318 | instead of a double-click. 1319 | - Most of the script has been moved to the |autoload| directory, so Vim 1320 | startup should be faster (thanks to Kien N). 1321 | - Jumping to tags should work most of the time even if the file has been 1322 | modified and not saved. 1323 | - If Ctags has been installed into the default location using Homebrew or 1324 | MacPorts it should now be found automatically. 1325 | - Several bugfixes. 1326 | 1327 | 2.1 (2011-05-29) 1328 | - Make Tagbar work in (hopefully) all cases under Windows 1329 | - Handle cases where 'encoding' is different from system encoding, for 1330 | example on a Chinese Windows with 'encoding' set to "utf-8" (see manual 1331 | for details in case it doesn't work out-of-the-box) 1332 | - Fixed a bug with the handling of subtypes like "python.django" 1333 | - If a session got saved with Tagbar open it now gets restored properly 1334 | - Locally reset foldmethod/foldexpr in case foldexpr got set to something 1335 | expensive globally 1336 | - Tagbar now tries hard to go to the correct window when jumping to a tag 1337 | - Explain some possible issues with the current jsctags version in the 1338 | manual 1339 | - Explicitly check for some possible configuration problems to be able to 1340 | give better feedback 1341 | - A few other small fixes 1342 | 1343 | 2.0.1 (2011-04-26) 1344 | - Fix sorting bug when 'ignorecase' is set 1345 | 1346 | 2.0 (2011-04-26) 1347 | - Folding now works correctly. Folds will be preserved when leaving the 1348 | Tagbar window and when switching between files. Also tag types can be 1349 | configured to be folded by default, which is useful for things like 1350 | includes and imports. 1351 | - DoctorJS/jsctags and other compatible programs are now supported. 1352 | - All of the highlight groups can now be overridden. 1353 | - Added keybinding to quickly jump to next/previous top-level tag. 1354 | - Added Taglist's "p" keybinding for jumping to a tag without leaving the 1355 | Tagbar window. 1356 | - Several bugfixes and other small improvements. 1357 | 1358 | 1.5 (2011-03-06) 1359 | - Type definitions can now include a path to a file with the ctags 1360 | definition. This is especially useful for ftplugins that can now ship 1361 | with a complete ctags and Tagbar configuration without requiring user 1362 | intervention. Thanks to Jan Christoph Ebersbach for the suggestion. 1363 | - Added autofocus setting by Taybin Rutkin. This will put the cursor in 1364 | the Tagbar window when it is opened. 1365 | - The "scopes" field is no longer needed in type definitions, the 1366 | information is already there in "scope2kind". Existing definitions will 1367 | be ignored. 1368 | - Some fixes and improvements related to redrawing and window switching. 1369 | 1370 | 1.2 (2011-02-28) 1371 | - Fix typo in Ruby definition 1372 | 1373 | 1.1 (2011-02-26) 1374 | - Don't lose syntax highlighting when ':syntax enable' is called 1375 | - Allow expanding the Vim window when Tagbar is opened 1376 | 1377 | 1.0 (2011-02-23) 1378 | - Initial release 1379 | 1380 | ============================================================================== 1381 | 9. Todo *tagbar-todo* 1382 | 1383 | - Allow filtering the Tagbar content by some criteria like tag name, 1384 | visibility, kind ... 1385 | - Integrate Tagbar with the FSwitch plugin to provide header file 1386 | information in C/C++. 1387 | - Allow jumping to a tag in the preview window, a split window or a new tab. 1388 | 1389 | ============================================================================== 1390 | 10. Credits *tagbar-credits* 1391 | 1392 | Tagbar was written by Jan Larres and is released under the Vim licence, see 1393 | |license|. It was heavily inspired by the Taglist plugin by Yegappan 1394 | Lakshmanan and uses a small amount of code from it. 1395 | 1396 | Original taglist copyright notice: 1397 | Permission is hereby granted to use and distribute this code, with or without 1398 | modifications, provided that this copyright notice is copied with it. Like 1399 | anything else that's free, taglist.vim is provided *as is* and comes with no 1400 | warranty of any kind, either expressed or implied. In no event will the 1401 | copyright holder be liable for any damamges resulting from the use of this 1402 | software. 1403 | 1404 | The folding technique was inspired by NERDTree by Martin Grenfell. 1405 | 1406 | Thanks to the following people for code contributions, feature suggestions etc: 1407 | Peter Butkovic 1408 | Zhao Cai 1409 | Jan Christoph Ebersbach 1410 | Vadim Fint 1411 | Leandro Freitas 1412 | Ingo Karkat 1413 | Audrius Kažukauskas 1414 | Michael McClimon 1415 | Seth Milliken 1416 | Kien N 1417 | Darcy Parker 1418 | fritzophrenic 1419 | pielgrzym 1420 | Taybin Rutkin 1421 | Kian Ryan 1422 | John Szakmeister 1423 | Ville Valkonen 1424 | Techlive Zheng 1425 | 1426 | ============================================================================== 1427 | vim: tw=78 ts=8 sw=4 sts=4 et ft=help 1428 | -------------------------------------------------------------------------------- /autoload/tagbar.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: tagbar.vim 3 | " Description: List the current file's tags in a sidebar, ordered by class etc 4 | " Author: Jan Larres 5 | " Licence: Vim licence 6 | " Website: http://majutsushi.github.com/tagbar/ 7 | " Version: 2.6.1 8 | " Note: This plugin was heavily inspired by the 'Taglist' plugin by 9 | " Yegappan Lakshmanan and uses a small amount of code from it. 10 | " 11 | " Original taglist copyright notice: 12 | " Permission is hereby granted to use and distribute this code, 13 | " with or without modifications, provided that this copyright 14 | " notice is copied with it. Like anything else that's free, 15 | " taglist.vim is provided *as is* and comes with no warranty of 16 | " any kind, either expressed or implied. In no event will the 17 | " copyright holder be liable for any damamges resulting from the 18 | " use of this software. 19 | " ============================================================================ 20 | 21 | scriptencoding utf-8 22 | 23 | " Initialization {{{1 24 | 25 | " If another plugin calls an autoloaded Tagbar function on startup before the 26 | " plugin/tagbar.vim file got loaded, load it explicitly 27 | if exists(':Tagbar') == 0 28 | runtime plugin/tagbar.vim 29 | endif 30 | 31 | " Basic init {{{2 32 | 33 | redir => s:ftype_out 34 | silent filetype 35 | redir END 36 | if s:ftype_out !~# 'detection:ON' 37 | echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' 38 | unlet s:ftype_out 39 | finish 40 | endif 41 | unlet s:ftype_out 42 | 43 | let s:icon_closed = g:tagbar_iconchars[0] 44 | let s:icon_open = g:tagbar_iconchars[1] 45 | 46 | let s:type_init_done = 0 47 | let s:autocommands_done = 0 48 | let s:statusline_in_use = 0 49 | 50 | " 0: not checked yet; 1: checked and found; 2: checked and not found 51 | let s:checked_ctags = 0 52 | let s:checked_ctags_types = 0 53 | let s:ctags_types = {} 54 | 55 | let s:new_window = 1 56 | let s:is_maximized = 0 57 | let s:winrestcmd = '' 58 | let s:short_help = 1 59 | let s:nearby_disabled = 0 60 | let s:paused = 0 61 | let s:pwin_by_tagbar = 0 62 | 63 | let s:window_expanded = 0 64 | let s:expand_bufnr = -1 65 | let s:window_pos = { 66 | \ 'pre' : { 'x' : 0, 'y' : 0 }, 67 | \ 'post' : { 'x' : 0, 'y' : 0 } 68 | \} 69 | 70 | " Script-local variable needed since compare functions can't 71 | " take extra arguments 72 | let s:compare_typeinfo = {} 73 | 74 | let s:visibility_symbols = { 75 | \ 'public' : '+', 76 | \ 'protected' : '#', 77 | \ 'private' : '-' 78 | \ } 79 | 80 | let g:loaded_tagbar = 1 81 | 82 | let s:last_highlight_tline = 0 83 | let s:debug = 0 84 | let s:debug_file = '' 85 | 86 | " s:Init() {{{2 87 | function! s:Init(silent) abort 88 | if s:checked_ctags == 2 && a:silent 89 | return 0 90 | elseif s:checked_ctags != 1 91 | if !s:CheckForExCtags(a:silent) 92 | return 0 93 | endif 94 | endif 95 | 96 | if !s:checked_ctags_types 97 | call s:GetSupportedFiletypes() 98 | endif 99 | 100 | if !s:type_init_done 101 | call s:InitTypes() 102 | endif 103 | 104 | if !s:autocommands_done 105 | call s:CreateAutocommands() 106 | call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) 107 | endif 108 | 109 | return 1 110 | endfunction 111 | 112 | " s:InitTypes() {{{2 113 | function! s:InitTypes() abort 114 | call s:LogDebugMessage('Initializing types') 115 | 116 | let s:known_types = {} 117 | 118 | " Ant {{{3 119 | let type_ant = s:TypeInfo.New() 120 | let type_ant.ctagstype = 'ant' 121 | let type_ant.kinds = [ 122 | \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, 123 | \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} 124 | \ ] 125 | let s:known_types.ant = type_ant 126 | " Asm {{{3 127 | let type_asm = s:TypeInfo.New() 128 | let type_asm.ctagstype = 'asm' 129 | let type_asm.kinds = [ 130 | \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, 131 | \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, 132 | \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, 133 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} 134 | \ ] 135 | let s:known_types.asm = type_asm 136 | " ASP {{{3 137 | let type_aspvbs = s:TypeInfo.New() 138 | let type_aspvbs.ctagstype = 'asp' 139 | let type_aspvbs.kinds = [ 140 | \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, 141 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 142 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 143 | \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, 144 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} 145 | \ ] 146 | let s:known_types.aspvbs = type_aspvbs 147 | " Awk {{{3 148 | let type_awk = s:TypeInfo.New() 149 | let type_awk.ctagstype = 'awk' 150 | let type_awk.kinds = [ 151 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 152 | \ ] 153 | let s:known_types.awk = type_awk 154 | " Basic {{{3 155 | let type_basic = s:TypeInfo.New() 156 | let type_basic.ctagstype = 'basic' 157 | let type_basic.kinds = [ 158 | \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, 159 | \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, 160 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 161 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, 162 | \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, 163 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} 164 | \ ] 165 | let s:known_types.basic = type_basic 166 | " BETA {{{3 167 | let type_beta = s:TypeInfo.New() 168 | let type_beta.ctagstype = 'beta' 169 | let type_beta.kinds = [ 170 | \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, 171 | \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, 172 | \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} 173 | \ ] 174 | let s:known_types.beta = type_beta 175 | " C {{{3 176 | let type_c = s:TypeInfo.New() 177 | let type_c.ctagstype = 'c' 178 | let type_c.kinds = [ 179 | \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, 180 | \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, 181 | \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, 182 | \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, 183 | \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, 184 | \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, 185 | \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, 186 | \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, 187 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, 188 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 189 | \ ] 190 | let type_c.sro = '::' 191 | let type_c.kind2scope = { 192 | \ 'g' : 'enum', 193 | \ 's' : 'struct', 194 | \ 'u' : 'union' 195 | \ } 196 | let type_c.scope2kind = { 197 | \ 'enum' : 'g', 198 | \ 'struct' : 's', 199 | \ 'union' : 'u' 200 | \ } 201 | let s:known_types.c = type_c 202 | " C++ {{{3 203 | let type_cpp = s:TypeInfo.New() 204 | let type_cpp.ctagstype = 'c++' 205 | let type_cpp.kinds = [ 206 | \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, 207 | \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, 208 | \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, 209 | \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, 210 | \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, 211 | \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, 212 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 213 | \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, 214 | \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, 215 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 216 | \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, 217 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} 218 | \ ] 219 | let type_cpp.sro = '::' 220 | let type_cpp.kind2scope = { 221 | \ 'g' : 'enum', 222 | \ 'n' : 'namespace', 223 | \ 'c' : 'class', 224 | \ 's' : 'struct', 225 | \ 'u' : 'union' 226 | \ } 227 | let type_cpp.scope2kind = { 228 | \ 'enum' : 'g', 229 | \ 'namespace' : 'n', 230 | \ 'class' : 'c', 231 | \ 'struct' : 's', 232 | \ 'union' : 'u' 233 | \ } 234 | let s:known_types.cpp = type_cpp 235 | " C# {{{3 236 | let type_cs = s:TypeInfo.New() 237 | let type_cs.ctagstype = 'c#' 238 | let type_cs.kinds = [ 239 | \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, 240 | \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, 241 | \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, 242 | \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, 243 | \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, 244 | \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, 245 | \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, 246 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 247 | \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, 248 | \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, 249 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 250 | \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} 251 | \ ] 252 | let type_cs.sro = '.' 253 | let type_cs.kind2scope = { 254 | \ 'n' : 'namespace', 255 | \ 'i' : 'interface', 256 | \ 'c' : 'class', 257 | \ 's' : 'struct', 258 | \ 'g' : 'enum' 259 | \ } 260 | let type_cs.scope2kind = { 261 | \ 'namespace' : 'n', 262 | \ 'interface' : 'i', 263 | \ 'class' : 'c', 264 | \ 'struct' : 's', 265 | \ 'enum' : 'g' 266 | \ } 267 | let s:known_types.cs = type_cs 268 | " COBOL {{{3 269 | let type_cobol = s:TypeInfo.New() 270 | let type_cobol.ctagstype = 'cobol' 271 | let type_cobol.kinds = [ 272 | \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, 273 | \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, 274 | \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, 275 | \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, 276 | \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, 277 | \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} 278 | \ ] 279 | let s:known_types.cobol = type_cobol 280 | " DOS Batch {{{3 281 | let type_dosbatch = s:TypeInfo.New() 282 | let type_dosbatch.ctagstype = 'dosbatch' 283 | let type_dosbatch.kinds = [ 284 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, 285 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} 286 | \ ] 287 | let s:known_types.dosbatch = type_dosbatch 288 | " Eiffel {{{3 289 | let type_eiffel = s:TypeInfo.New() 290 | let type_eiffel.ctagstype = 'eiffel' 291 | let type_eiffel.kinds = [ 292 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 293 | \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} 294 | \ ] 295 | let type_eiffel.sro = '.' " Not sure, is nesting even possible? 296 | let type_eiffel.kind2scope = { 297 | \ 'c' : 'class', 298 | \ 'f' : 'feature' 299 | \ } 300 | let type_eiffel.scope2kind = { 301 | \ 'class' : 'c', 302 | \ 'feature' : 'f' 303 | \ } 304 | let s:known_types.eiffel = type_eiffel 305 | " Erlang {{{3 306 | let type_erlang = s:TypeInfo.New() 307 | let type_erlang.ctagstype = 'erlang' 308 | let type_erlang.kinds = [ 309 | \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, 310 | \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, 311 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 312 | \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} 313 | \ ] 314 | let type_erlang.sro = '.' " Not sure, is nesting even possible? 315 | let type_erlang.kind2scope = { 316 | \ 'm' : 'module' 317 | \ } 318 | let type_erlang.scope2kind = { 319 | \ 'module' : 'm' 320 | \ } 321 | let s:known_types.erlang = type_erlang 322 | " Flex {{{3 323 | " Vim doesn't support Flex out of the box, this is based on rough 324 | " guesses and probably requires 325 | " http://www.vim.org/scripts/script.php?script_id=2909 326 | " Improvements welcome! 327 | let type_as = s:TypeInfo.New() 328 | let type_as.ctagstype = 'flex' 329 | let type_as.kinds = [ 330 | \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, 331 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 332 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 333 | \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, 334 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 335 | \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} 336 | \ ] 337 | let type_as.sro = '.' 338 | let type_as.kind2scope = { 339 | \ 'c' : 'class' 340 | \ } 341 | let type_as.scope2kind = { 342 | \ 'class' : 'c' 343 | \ } 344 | let s:known_types.mxml = type_as 345 | let s:known_types.actionscript = type_as 346 | " Fortran {{{3 347 | let type_fortran = s:TypeInfo.New() 348 | let type_fortran.ctagstype = 'fortran' 349 | let type_fortran.kinds = [ 350 | \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, 351 | \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, 352 | \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, 353 | \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, 354 | \ 'stl' : 1}, 355 | \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, 356 | \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, 357 | \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, 358 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 359 | \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, 360 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, 361 | \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, 362 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} 363 | \ ] 364 | let type_fortran.sro = '.' " Not sure, is nesting even possible? 365 | let type_fortran.kind2scope = { 366 | \ 'm' : 'module', 367 | \ 'p' : 'program', 368 | \ 'f' : 'function', 369 | \ 's' : 'subroutine' 370 | \ } 371 | let type_fortran.scope2kind = { 372 | \ 'module' : 'm', 373 | \ 'program' : 'p', 374 | \ 'function' : 'f', 375 | \ 'subroutine' : 's' 376 | \ } 377 | let s:known_types.fortran = type_fortran 378 | " HTML {{{3 379 | let type_html = s:TypeInfo.New() 380 | let type_html.ctagstype = 'html' 381 | let type_html.kinds = [ 382 | \ {'short' : 'f', 'long' : 'JavaScript funtions', 'fold' : 0, 'stl' : 1}, 383 | \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1} 384 | \ ] 385 | let s:known_types.html = type_html 386 | " Java {{{3 387 | let type_java = s:TypeInfo.New() 388 | let type_java.ctagstype = 'java' 389 | let type_java.kinds = [ 390 | \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, 391 | \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, 392 | \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, 393 | \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, 394 | \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, 395 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 396 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} 397 | \ ] 398 | let type_java.sro = '.' 399 | let type_java.kind2scope = { 400 | \ 'g' : 'enum', 401 | \ 'i' : 'interface', 402 | \ 'c' : 'class' 403 | \ } 404 | let type_java.scope2kind = { 405 | \ 'enum' : 'g', 406 | \ 'interface' : 'i', 407 | \ 'class' : 'c' 408 | \ } 409 | let s:known_types.java = type_java 410 | " JavaScript {{{3 411 | " JavaScript is weird -- it does have scopes, but ctags doesn't seem to 412 | " properly generate the information for them, instead it simply uses the 413 | " complete name. So ctags has to be fixed before I can do anything here. 414 | " Alternatively jsctags/doctorjs will be used if available. 415 | let type_javascript = s:TypeInfo.New() 416 | let type_javascript.ctagstype = 'javascript' 417 | let jsctags = s:CheckFTCtags('jsctags', 'javascript') 418 | if jsctags != '' 419 | let type_javascript.kinds = [ 420 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, 421 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 422 | \ ] 423 | let type_javascript.sro = '.' 424 | let type_javascript.kind2scope = { 425 | \ 'v' : 'namespace', 426 | \ 'f' : 'namespace' 427 | \ } 428 | let type_javascript.scope2kind = { 429 | \ 'namespace' : 'v' 430 | \ } 431 | let type_javascript.ctagsbin = jsctags 432 | let type_javascript.ctagsargs = '-f -' 433 | else 434 | let type_javascript.kinds = [ 435 | \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, 436 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 437 | \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 0}, 438 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 439 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 440 | \ ] 441 | endif 442 | let s:known_types.javascript = type_javascript 443 | " Lisp {{{3 444 | let type_lisp = s:TypeInfo.New() 445 | let type_lisp.ctagstype = 'lisp' 446 | let type_lisp.kinds = [ 447 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 448 | \ ] 449 | let s:known_types.lisp = type_lisp 450 | let s:known_types.clojure = type_lisp 451 | " Lua {{{3 452 | let type_lua = s:TypeInfo.New() 453 | let type_lua.ctagstype = 'lua' 454 | let type_lua.kinds = [ 455 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 456 | \ ] 457 | let s:known_types.lua = type_lua 458 | " Make {{{3 459 | let type_make = s:TypeInfo.New() 460 | let type_make.ctagstype = 'make' 461 | let type_make.kinds = [ 462 | \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} 463 | \ ] 464 | let s:known_types.make = type_make 465 | " Matlab {{{3 466 | let type_matlab = s:TypeInfo.New() 467 | let type_matlab.ctagstype = 'matlab' 468 | let type_matlab.kinds = [ 469 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 470 | \ ] 471 | let s:known_types.matlab = type_matlab 472 | " Ocaml {{{3 473 | let type_ocaml = s:TypeInfo.New() 474 | let type_ocaml.ctagstype = 'ocaml' 475 | let type_ocaml.kinds = [ 476 | \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, 477 | \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, 478 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 479 | \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, 480 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 481 | \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, 482 | \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, 483 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 484 | \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} 485 | \ ] 486 | let type_ocaml.sro = '.' " Not sure, is nesting even possible? 487 | let type_ocaml.kind2scope = { 488 | \ 'M' : 'Module', 489 | \ 'c' : 'class', 490 | \ 't' : 'type' 491 | \ } 492 | let type_ocaml.scope2kind = { 493 | \ 'Module' : 'M', 494 | \ 'class' : 'c', 495 | \ 'type' : 't' 496 | \ } 497 | let s:known_types.ocaml = type_ocaml 498 | " Pascal {{{3 499 | let type_pascal = s:TypeInfo.New() 500 | let type_pascal.ctagstype = 'pascal' 501 | let type_pascal.kinds = [ 502 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 503 | \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} 504 | \ ] 505 | let s:known_types.pascal = type_pascal 506 | " Perl {{{3 507 | let type_perl = s:TypeInfo.New() 508 | let type_perl.ctagstype = 'perl' 509 | let type_perl.kinds = [ 510 | \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, 511 | \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, 512 | \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, 513 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, 514 | \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} 515 | \ ] 516 | let s:known_types.perl = type_perl 517 | " PHP {{{3 518 | let type_php = s:TypeInfo.New() 519 | let type_php.ctagstype = 'php' 520 | let type_php.kinds = [ 521 | \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, 522 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 523 | \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, 524 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 525 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, 526 | \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} 527 | \ ] 528 | let s:known_types.php = type_php 529 | " Python {{{3 530 | let type_python = s:TypeInfo.New() 531 | let type_python.ctagstype = 'python' 532 | let type_python.kinds = [ 533 | \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, 534 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 535 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 536 | \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, 537 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} 538 | \ ] 539 | let type_python.sro = '.' 540 | let type_python.kind2scope = { 541 | \ 'c' : 'class', 542 | \ 'f' : 'function', 543 | \ 'm' : 'function' 544 | \ } 545 | let type_python.scope2kind = { 546 | \ 'class' : 'c', 547 | \ 'function' : 'f' 548 | \ } 549 | let s:known_types.python = type_python 550 | let s:known_types.pyrex = type_python 551 | let s:known_types.cython = type_python 552 | " REXX {{{3 553 | let type_rexx = s:TypeInfo.New() 554 | let type_rexx.ctagstype = 'rexx' 555 | let type_rexx.kinds = [ 556 | \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} 557 | \ ] 558 | let s:known_types.rexx = type_rexx 559 | " Ruby {{{3 560 | let type_ruby = s:TypeInfo.New() 561 | let type_ruby.ctagstype = 'ruby' 562 | let type_ruby.kinds = [ 563 | \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, 564 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 565 | \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 566 | \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} 567 | \ ] 568 | let type_ruby.sro = '.' 569 | let type_ruby.kind2scope = { 570 | \ 'c' : 'class', 571 | \ 'm' : 'class' 572 | \ } 573 | let type_ruby.scope2kind = { 574 | \ 'class' : 'c' 575 | \ } 576 | let s:known_types.ruby = type_ruby 577 | " Scheme {{{3 578 | let type_scheme = s:TypeInfo.New() 579 | let type_scheme.ctagstype = 'scheme' 580 | let type_scheme.kinds = [ 581 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 582 | \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} 583 | \ ] 584 | let s:known_types.scheme = type_scheme 585 | let s:known_types.racket = type_scheme 586 | " Shell script {{{3 587 | let type_sh = s:TypeInfo.New() 588 | let type_sh.ctagstype = 'sh' 589 | let type_sh.kinds = [ 590 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 591 | \ ] 592 | let s:known_types.sh = type_sh 593 | let s:known_types.csh = type_sh 594 | let s:known_types.zsh = type_sh 595 | " SLang {{{3 596 | let type_slang = s:TypeInfo.New() 597 | let type_slang.ctagstype = 'slang' 598 | let type_slang.kinds = [ 599 | \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, 600 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} 601 | \ ] 602 | let s:known_types.slang = type_slang 603 | " SML {{{3 604 | let type_sml = s:TypeInfo.New() 605 | let type_sml.ctagstype = 'sml' 606 | let type_sml.kinds = [ 607 | \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, 608 | \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, 609 | \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, 610 | \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, 611 | \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, 612 | \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, 613 | \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} 614 | \ ] 615 | let s:known_types.sml = type_sml 616 | " SQL {{{3 617 | " The SQL ctags parser seems to be buggy for me, so this just uses the 618 | " normal kinds even though scopes should be available. Improvements 619 | " welcome! 620 | let type_sql = s:TypeInfo.New() 621 | let type_sql.ctagstype = 'sql' 622 | let type_sql.kinds = [ 623 | \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, 624 | \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, 625 | \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, 626 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 627 | \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, 628 | \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, 629 | \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, 630 | \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, 631 | \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, 632 | \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, 633 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, 634 | \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, 635 | \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, 636 | \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, 637 | \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, 638 | \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, 639 | \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, 640 | \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, 641 | \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, 642 | \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, 643 | \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} 644 | \ ] 645 | let s:known_types.sql = type_sql 646 | " Tcl {{{3 647 | let type_tcl = s:TypeInfo.New() 648 | let type_tcl.ctagstype = 'tcl' 649 | let type_tcl.kinds = [ 650 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 651 | \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, 652 | \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} 653 | \ ] 654 | let s:known_types.tcl = type_tcl 655 | " LaTeX {{{3 656 | let type_tex = s:TypeInfo.New() 657 | let type_tex.ctagstype = 'tex' 658 | let type_tex.kinds = [ 659 | \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, 660 | \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, 661 | \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, 662 | \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, 663 | \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, 664 | \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, 665 | \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, 666 | \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, 667 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} 668 | \ ] 669 | let type_tex.sro = '""' 670 | let type_tex.kind2scope = { 671 | \ 'p' : 'part', 672 | \ 'c' : 'chapter', 673 | \ 's' : 'section', 674 | \ 'u' : 'subsection', 675 | \ 'b' : 'subsubsection' 676 | \ } 677 | let type_tex.scope2kind = { 678 | \ 'part' : 'p', 679 | \ 'chapter' : 'c', 680 | \ 'section' : 's', 681 | \ 'subsection' : 'u', 682 | \ 'subsubsection' : 'b' 683 | \ } 684 | let type_tex.sort = 0 685 | let s:known_types.tex = type_tex 686 | " Vala {{{3 687 | " Vala is supported by the ctags fork provided by Anjuta, so only add the 688 | " type if the fork is used to prevent error messages otherwise 689 | if has_key(s:ctags_types, 'vala') || executable('anjuta-tags') 690 | let type_vala = s:TypeInfo.New() 691 | let type_vala.ctagstype = 'vala' 692 | let type_vala.kinds = [ 693 | \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, 694 | \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, 695 | \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, 696 | \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, 697 | \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, 698 | \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, 699 | \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, 700 | \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, 701 | \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, 702 | \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, 703 | \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, 704 | \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} 705 | \ ] 706 | let type_vala.sro = '.' 707 | " 'enum' doesn't seem to be used as a scope, but it can't hurt to have 708 | " it here 709 | let type_vala.kind2scope = { 710 | \ 's' : 'struct', 711 | \ 'i' : 'interface', 712 | \ 'c' : 'class', 713 | \ 'e' : 'enum' 714 | \ } 715 | let type_vala.scope2kind = { 716 | \ 'struct' : 's', 717 | \ 'interface' : 'i', 718 | \ 'class' : 'c', 719 | \ 'enum' : 'e' 720 | \ } 721 | let s:known_types.vala = type_vala 722 | endif 723 | if !has_key(s:ctags_types, 'vala') && executable('anjuta-tags') 724 | let s:known_types.vala.ctagsbin = 'anjuta-tags' 725 | endif 726 | " Vera {{{3 727 | " Why are variables 'virtual'? 728 | let type_vera = s:TypeInfo.New() 729 | let type_vera.ctagstype = 'vera' 730 | let type_vera.kinds = [ 731 | \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, 732 | \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, 733 | \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, 734 | \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, 735 | \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, 736 | \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, 737 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 738 | \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, 739 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, 740 | \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} 741 | \ ] 742 | let type_vera.sro = '.' " Nesting doesn't seem to be possible 743 | let type_vera.kind2scope = { 744 | \ 'g' : 'enum', 745 | \ 'c' : 'class', 746 | \ 'v' : 'virtual' 747 | \ } 748 | let type_vera.scope2kind = { 749 | \ 'enum' : 'g', 750 | \ 'class' : 'c', 751 | \ 'virtual' : 'v' 752 | \ } 753 | let s:known_types.vera = type_vera 754 | " Verilog {{{3 755 | let type_verilog = s:TypeInfo.New() 756 | let type_verilog.ctagstype = 'verilog' 757 | let type_verilog.kinds = [ 758 | \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, 759 | \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, 760 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 761 | \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, 762 | \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, 763 | \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, 764 | \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, 765 | \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} 766 | \ ] 767 | let s:known_types.verilog = type_verilog 768 | " VHDL {{{3 769 | " The VHDL ctags parser unfortunately doesn't generate proper scopes 770 | let type_vhdl = s:TypeInfo.New() 771 | let type_vhdl.ctagstype = 'vhdl' 772 | let type_vhdl.kinds = [ 773 | \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, 774 | \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, 775 | \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, 776 | \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, 777 | \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, 778 | \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, 779 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 780 | \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} 781 | \ ] 782 | let s:known_types.vhdl = type_vhdl 783 | " Vim {{{3 784 | let type_vim = s:TypeInfo.New() 785 | let type_vim.ctagstype = 'vim' 786 | let type_vim.kinds = [ 787 | \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, 788 | \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, 789 | \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, 790 | \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, 791 | \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, 792 | \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} 793 | \ ] 794 | let s:known_types.vim = type_vim 795 | " YACC {{{3 796 | let type_yacc = s:TypeInfo.New() 797 | let type_yacc.ctagstype = 'yacc' 798 | let type_yacc.kinds = [ 799 | \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} 800 | \ ] 801 | let s:known_types.yacc = type_yacc 802 | " }}}3 803 | 804 | call s:LoadUserTypeDefs() 805 | 806 | for typeinfo in values(s:known_types) 807 | call typeinfo.createKinddict() 808 | endfor 809 | 810 | let s:type_init_done = 1 811 | endfunction 812 | 813 | " s:LoadUserTypeDefs() {{{2 814 | function! s:LoadUserTypeDefs(...) abort 815 | if a:0 > 0 816 | let type = a:1 817 | 818 | call s:LogDebugMessage("Initializing user type '" . type . "'") 819 | 820 | let defdict = {} 821 | let defdict[type] = g:tagbar_type_{type} 822 | else 823 | call s:LogDebugMessage('Initializing user types') 824 | 825 | let defdict = tagbar#getusertypes() 826 | endif 827 | 828 | let transformed = {} 829 | for [type, def] in items(defdict) 830 | let transformed[type] = s:TransformUserTypeDef(def) 831 | endfor 832 | 833 | for [key, value] in items(transformed) 834 | if !has_key(s:known_types, key) || get(value, 'replace', 0) 835 | let s:known_types[key] = s:TypeInfo.New(value) 836 | else 837 | call extend(s:known_types[key], value) 838 | endif 839 | endfor 840 | 841 | if a:0 > 0 842 | call s:known_types[type].createKinddict() 843 | endif 844 | endfunction 845 | 846 | " s:TransformUserTypeDef() {{{2 847 | " Transform the user definitions into the internal format 848 | function! s:TransformUserTypeDef(def) abort 849 | let newdef = copy(a:def) 850 | 851 | if has_key(a:def, 'kinds') 852 | let newdef.kinds = [] 853 | let kinds = a:def.kinds 854 | for kind in kinds 855 | let kindlist = split(kind, ':') 856 | let kinddict = {'short' : kindlist[0], 'long' : kindlist[1]} 857 | let kinddict.fold = get(kindlist, 2, 0) 858 | let kinddict.stl = get(kindlist, 3, 1) 859 | call add(newdef.kinds, kinddict) 860 | endfor 861 | endif 862 | 863 | " If the user only specified one of kind2scope and scope2kind then use it 864 | " to generate the respective other 865 | if has_key(a:def, 'kind2scope') && !has_key(a:def, 'scope2kind') 866 | let newdef.scope2kind = {} 867 | for [key, value] in items(a:def.kind2scope) 868 | let newdef.scope2kind[value] = key 869 | endfor 870 | elseif has_key(a:def, 'scope2kind') && !has_key(a:def, 'kind2scope') 871 | let newdef.kind2scope = {} 872 | for [key, value] in items(a:def.scope2kind) 873 | let newdef.kind2scope[value] = key 874 | endfor 875 | endif 876 | 877 | return newdef 878 | endfunction 879 | 880 | " s:RestoreSession() {{{2 881 | " Properly restore Tagbar after a session got loaded 882 | function! s:RestoreSession() abort 883 | call s:LogDebugMessage('Restoring session') 884 | 885 | let curfile = fnamemodify(bufname('%'), ':p') 886 | 887 | let tagbarwinnr = bufwinnr('__Tagbar__') 888 | if tagbarwinnr == -1 889 | " Tagbar wasn't open in the saved session, nothing to do 890 | return 891 | else 892 | let in_tagbar = 1 893 | if winnr() != tagbarwinnr 894 | call s:goto_win(tagbarwinnr) 895 | let in_tagbar = 0 896 | endif 897 | endif 898 | 899 | let s:last_autofocus = 0 900 | 901 | call s:Init(0) 902 | 903 | call s:InitWindow(g:tagbar_autoclose) 904 | 905 | call s:AutoUpdate(curfile, 0) 906 | 907 | if !in_tagbar 908 | call s:goto_win('p') 909 | endif 910 | endfunction 911 | 912 | " s:MapKeys() {{{2 913 | function! s:MapKeys() abort 914 | call s:LogDebugMessage('Mapping keys') 915 | 916 | nnoremap