From aab5f214c567e7aaed8b122beab4a1a9a925d35d Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 11 Feb 2017 17:40:24 +1300 Subject: [PATCH 01/43] Save ctags output in separate file when debugging --- autoload/tagbar.vim | 6 ++++++ doc/tagbar.txt | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 5dae9ec..a6c17a9 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2438,6 +2438,12 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort endif call s:debug('Ctags executed successfully') + if s:debug + exe 'redir! > ' . s:debug_file . '.ctags_out' + silent echon ctags_output + redir END + endif + return ctags_output endfunction diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 63b6883..4adbd02 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -1269,8 +1269,9 @@ have been missed. If the bug does seem to be in Tagbar then you can use Tagbar's debug mode to try to find the source of the problem. Usually you would use it like this: - 1. Remove the |tagbar-statusline| support from your vimrc if you use it, and - make sure you don't have any autocommands that load Tagbar on startup. + 1. Remove the |tagbar-statusline| support from your vimrc if you use it + unless the problem is with this functionality, and make sure you don't + have any autocommands that load Tagbar on startup. 2. Open Vim without loading any files. 3. Run :TagbarDebug. 4. Open the file you are having problems with. @@ -1282,7 +1283,12 @@ Note that it is important that the "TagbarDebug" command gets called before any other call to a Tagbar command or function, so step 1 is important to get a complete log. -This should leave a file called "tagbardebug.log" in the current directory. +This should leave a file called "tagbardebug.log" in the current directory. If +ctags got executed successfully then there should also be a file called +"tagbardebug.log.ctags_out" which contains the full output of the last ctags +invocation. This can be very helpful when debugging but may contain sensitive +information and is therefore kept in a separate file. + See |tagbar-commands| for more information on the debug commands. When you look at the file you should especially pay attention to the reported file type and the ctags command line in the log file. From 9d051c1e2d9f3dc88d3ae00485e55934b06d42f7 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sun, 12 Feb 2017 21:39:13 +1300 Subject: [PATCH 02/43] Handle cases where parent is below child tag, closes #396 --- autoload/tagbar.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index a6c17a9..2d54fc3 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2654,6 +2654,8 @@ function! s:add_tag_recursive(parent, taginfo, pathlist) abort else call grandparent.addChild(parent) endif + elseif len(parents) == 1 + let parent = parents[0] else " If there are multiple possible parents (c.f. issue #139, or tags " with the same name but a different kind) then we will pick the one @@ -2668,6 +2670,20 @@ function! s:add_tag_recursive(parent, taginfo, pathlist) abort let minline = candidate.fields.line endif endfor + + if !exists('parent') + " If we still haven't found a parent it must be below the current + " tag, so find the closest parent below the tag. This can happen + " for example in Go. + let maxline = line('$') + for candidate in parents + if candidate.fields.line >= a:taginfo.fields.line && + \ candidate.fields.line <= maxline + let parent = candidate + let maxline = candidate.fields.line + endif + endfor + endif endif " If the parent is a pseudotag it may have gotten created as an in-between From e089b61e257c39c1cf5a90cf945a062839b1dca1 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 18 Feb 2017 16:32:30 +1300 Subject: [PATCH 03/43] Don't error on incorrect ctags scope info, ref #397 --- autoload/tagbar.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 2d54fc3..5177f28 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2706,7 +2706,9 @@ endfunction function! s:create_pseudotag(name, parent, kind, typeinfo, fileinfo) abort if !empty(a:parent) let curpath = a:parent.fullpath - let pscope = a:typeinfo.kind2scope[a:parent.fields.kind] + " If the kind is not present in the kind2scope dictionary, return an + " empty scope. This can happen due to incorrect ctags output as in #397. + let pscope = get(a:typeinfo.kind2scope, a:parent.fields.kind, '') else let curpath = '' let pscope = '' From 959f48798136bfd4ce60075d3c86c580fcf5e5c5 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 18 Feb 2017 16:43:16 +1300 Subject: [PATCH 04/43] Functions create class scope in exctags, ref #397 --- autoload/tagbar.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 5177f28..c1f6914 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -636,7 +636,8 @@ function! s:InitTypes() abort let type_ruby.sro = '.' let type_ruby.kind2scope = { \ 'c' : 'class', - \ 'm' : 'class' + \ 'm' : 'class', + \ 'f' : 'class' \ } let type_ruby.scope2kind = { \ 'class' : 'c' From 87a1263f5d8b3623bee5e6036254480e668b5f74 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 5 Jun 2017 17:21:56 +1200 Subject: [PATCH 05/43] Don't try to restore session on 'loadview', closes #382 The view files created with the 'mkview' command run the 'SessionLoadPost' autocommand at the end, which creates problems if Tagbar has alread been initialized. Add a new variable so that we can detect this situation. --- autoload/tagbar.vim | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index c1f6914..bf5445e 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -51,6 +51,7 @@ let s:icon_open = g:tagbar_iconchars[1] let s:type_init_done = 0 let s:autocommands_done = 0 let s:statusline_in_use = 0 +let s:init_done = 0 " 0: not checked yet; 1: checked and found; 2: checked and not found let s:checked_ctags = 0 @@ -122,6 +123,7 @@ function! s:Init(silent) abort call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) endif + let s:init_done = 1 return 1 endfunction @@ -967,6 +969,11 @@ endfunction " s:RestoreSession() {{{2 " Properly restore Tagbar after a session got loaded function! s:RestoreSession() abort + if s:init_done + call s:debug('Tagbar already initialized; not restoring session') + return + endif + call s:debug('Restoring session') let curfile = fnamemodify(bufname('%'), ':p') @@ -975,12 +982,12 @@ function! s:RestoreSession() abort if tagbarwinnr == -1 " Tagbar wasn't open in the saved session, nothing to do return - else - let in_tagbar = 1 - if winnr() != tagbarwinnr - call s:goto_win(tagbarwinnr) - let in_tagbar = 0 - endif + endif + + let in_tagbar = 1 + if winnr() != tagbarwinnr + call s:goto_win(tagbarwinnr, 1) + let in_tagbar = 0 endif let s:last_autofocus = 0 From b9e7b51ea5c1dbca8390adac7483b68afc49da85 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 15 Jun 2017 17:24:32 +1200 Subject: [PATCH 06/43] Fix jsctags config, closes #421 This seems to be different for the tern-based jsctags, and the old one is deprecated anyway. --- autoload/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index bf5445e..016f9e5 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -479,7 +479,7 @@ function! s:InitTypes() abort \ 'f' : 'namespace' \ } let type_javascript.scope2kind = { - \ 'namespace' : 'v' + \ 'namespace' : 'f' \ } let type_javascript.ctagsbin = jsctags let type_javascript.ctagsargs = '-f -' From 41ee79fc0f7fba095cd43a8bde0a834305a16a84 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 15 Jun 2017 17:26:16 +1200 Subject: [PATCH 07/43] Escape tag search pattern with \M instead of \V This follows the Vim manual in |tag-search|, which says that searches are executed as if 'magic' was off. --- autoload/tagbar.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 016f9e5..fde6f37 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1563,7 +1563,7 @@ function! s:NormalTag.getPrototype(short) abort dict if self.fields.line == 0 || !bufloaded(bufnr) " No linenumber available or buffer not loaded (probably due to " 'nohidden'), try the pattern instead - return substitute(self.pattern, '^\\V\\^\\C\s*\(.*\)\\$$', '\1', '') + return substitute(self.pattern, '^\\M\\^\\C\s*\(.*\)\\$$', '\1', '') endif let line = getbufline(bufnr, self.fields.line)[0] @@ -2478,7 +2478,7 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort let dollar = '' endif let pattern = strpart(pattern, start, end - start) - let taginfo.pattern = '\V\^\C' . pattern . dollar + let taginfo.pattern = '\M\^\C' . pattern . dollar " When splitting fields make sure not to create empty keys or values in " case a value illegally contains tabs From b1c6cbc2d8d3ce7999645653987de05112b8e71d Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 15 Jun 2017 17:27:30 +1200 Subject: [PATCH 08/43] Short-circuit parent searches if tag doesn't have line number --- autoload/tagbar.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index fde6f37..cd65fd0 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2672,6 +2672,14 @@ function! s:add_tag_recursive(parent, taginfo, pathlist) abort " Start at line 0 so that pseudotags get included let minline = 0 for candidate in parents + " If the line number of the current tag is 0 then we have no way + " of determining the best candidate by comparing line numbers. + " Just use the first one we have. + if a:taginfo.fields.line == 0 + let parent = candidate + break + endif + if candidate.fields.line <= a:taginfo.fields.line && \ candidate.fields.line >= minline let parent = candidate From f5792732de16b8a2cc202f920e363eb413d7241d Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 15 Jun 2017 17:28:33 +1200 Subject: [PATCH 09/43] Escape tag name when removing it from a pseudo tag's scope path --- autoload/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index cd65fd0..dc927d6 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2733,7 +2733,7 @@ function! s:create_pseudotag(name, parent, kind, typeinfo, fileinfo) abort let pseudotag = s:PseudoTag.New(a:name) let pseudotag.fields.kind = a:kind - let parentscope = substitute(curpath, a:name . '$', '', '') + let parentscope = substitute(curpath, '\V' . a:name . '$', '', '') let parentscope = substitute(parentscope, \ '\V\^' . a:typeinfo.sro . '\$', '', '') From e3732091bfceb74bc8d6915cc6823115308005cc Mon Sep 17 00:00:00 2001 From: AdnoC Date: Wed, 26 Jul 2017 10:18:18 -0400 Subject: [PATCH 10/43] Add ability to open or close folds a single level --- autoload/tagbar.vim | 61 +++++++++++++++++++++++++++++++++++++++++++++ doc/tagbar.txt | 6 +++++ plugin/tagbar.vim | 2 ++ 3 files changed, 69 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index dc927d6..787407b 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1031,6 +1031,8 @@ function! s:MapKeys() abort \ ['togglefold', 'ToggleFold()'], \ ['openallfolds', 'SetFoldLevel(99, 1)'], \ ['closeallfolds', 'SetFoldLevel(0, 1)'], + \ ['incrementfolds', 'ChangeFoldLevel(1, 1)'], + \ ['decrementfolds', 'ChangeFoldLevel(-1, 1)'], \ ['nextfold', 'GotoNextFold()'], \ ['prevfold', 'GotoPrevFold()'], \ @@ -3097,6 +3099,8 @@ function! s:PrintHelp() abort silent put ='\" ' . s:get_map_str('togglefold') . ': Toggle fold' silent put ='\" ' . s:get_map_str('openallfolds') . ': Open all folds' silent put ='\" ' . s:get_map_str('closeallfolds') . ': Close all folds' + silent put ='\" ' . s:get_map_str('incrementfolds') . ': Increment fold level by 1' + silent put ='\" ' . s:get_map_str('decrementfolds') . ': Decrement fold level by 1' silent put ='\" ' . s:get_map_str('nextfold') . ': Go to next fold' silent put ='\" ' . s:get_map_str('prevfold') . ': Go to previous fold' silent put ='\"' @@ -3494,6 +3498,46 @@ function! s:ToggleFold() abort call s:RenderKeepView(newline) endfunction +" s:ChangeFoldLevel() {{{2 +function! s:ChangeFoldLevel(diff, force) abort + let fileinfo = s:TagbarState().getCurrent(0) + if empty(fileinfo) + return + endif + + if fileinfo.foldlevel == 99 + call s:MinimizeMaxFoldLevel(fileinfo, fileinfo.getTags()) + endif + + let level = fileinfo.foldlevel + let level = level + a:diff + if level < 0 + call s:warning('Foldlevel can''t be negative') + return + endif + + call s:SetFoldLevelRecursive(fileinfo, fileinfo.getTags(), level) + + let typeinfo = fileinfo.typeinfo + + " Apply foldlevel to 'kind's + if level == 0 + for kind in typeinfo.kinds + call fileinfo.closeKindFold(kind) + endfor + else + for kind in typeinfo.kinds + if a:force || !kind.fold + call fileinfo.openKindFold(kind) + endif + endfor + endif + + let fileinfo.foldlevel = level + + call s:RenderContent() +endfunction + " s:SetFoldLevel() {{{2 function! s:SetFoldLevel(level, force) abort if a:level < 0 @@ -3544,6 +3588,23 @@ function! s:SetFoldLevelRecursive(fileinfo, tags, level) abort endfor endfunction +" s:MinimizeMaxFoldLevel() {{{2 +" Set the file's fold level to the lowest value that still shows all tags +function! s:MinimizeMaxFoldLevel(fileinfo, tags) abort + let maxlvl = 0 + let tags = copy(a:tags) + + for tag in tags + if maxlvl < tag.depth + let maxlvl = tag.depth + endif + call tag.setFolded(0) + call extend(tags, tag.getChildren()) + endfor + + let a:fileinfo.foldlevel = maxlvl +endfunction + " s:OpenParents() {{{2 function! s:OpenParents(...) abort if a:0 == 1 diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 4adbd02..51b71f0 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -346,6 +346,12 @@ o/za Toggle the fold under the cursor or the current one if there is Map option: tagbar_map_openallfolds =/zM Close all folds by setting foldlevel to 0. Map option: tagbar_map_closeallfolds +zr Increase the fold level of the buffer by 1. Opens all folds one + level. + Map option: tagbar_map_incrementfolds +zm Decrease the fold level of the buffer by 1. Closes all folds one + level. + Map option: tagbar_map_decrementfolds zj Go to the start of the next fold, like the standard Vim |zj|. Map option: tagbar_map_nextfold zk Go to the end of the previous fold, like the standard Vim |zk|. diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index cc03e38..e921def 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -108,6 +108,8 @@ function! s:setup_keymaps() abort \ ['togglefold', ['o', 'za']], \ ['openallfolds', ['*', '', 'zR']], \ ['closeallfolds', ['=', 'zM']], + \ ['incrementfolds', ['zr']], + \ ['decrementfolds', ['zm']], \ ['nextfold', 'zj'], \ ['prevfold', 'zk'], \ From 96275e3921bf10e09f113afbfc0445792d03d954 Mon Sep 17 00:00:00 2001 From: AdnoC Date: Sun, 30 Jul 2017 12:11:31 -0400 Subject: [PATCH 11/43] Reduce code dupication in ChangeFoldLevel --- autoload/tagbar.vim | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 787407b..4b74d46 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3511,31 +3511,7 @@ function! s:ChangeFoldLevel(diff, force) abort let level = fileinfo.foldlevel let level = level + a:diff - if level < 0 - call s:warning('Foldlevel can''t be negative') - return - endif - - call s:SetFoldLevelRecursive(fileinfo, fileinfo.getTags(), level) - - let typeinfo = fileinfo.typeinfo - - " Apply foldlevel to 'kind's - if level == 0 - for kind in typeinfo.kinds - call fileinfo.closeKindFold(kind) - endfor - else - for kind in typeinfo.kinds - if a:force || !kind.fold - call fileinfo.openKindFold(kind) - endif - endfor - endif - - let fileinfo.foldlevel = level - - call s:RenderContent() + call s:SetFoldLevel(level, a:force) endfunction " s:SetFoldLevel() {{{2 From 2abcbf33f05b3455ade1a73e50b5c5803db0e900 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sun, 13 Aug 2017 18:55:28 +1200 Subject: [PATCH 12/43] Extract prototypes to separate autoload files --- autoload/tagbar.vim | 833 +++---------------- autoload/tagbar/prototypes/basetag.vim | 214 +++++ autoload/tagbar/prototypes/fileinfo.vim | 130 +++ autoload/tagbar/prototypes/kindheadertag.vim | 49 ++ autoload/tagbar/prototypes/normaltag.vim | 110 +++ autoload/tagbar/prototypes/pseudotag.vim | 29 + autoload/tagbar/prototypes/typeinfo.vim | 33 + autoload/tagbar/sorting.vim | 57 ++ autoload/tagbar/state.vim | 51 ++ 9 files changed, 775 insertions(+), 731 deletions(-) create mode 100644 autoload/tagbar/prototypes/basetag.vim create mode 100644 autoload/tagbar/prototypes/fileinfo.vim create mode 100644 autoload/tagbar/prototypes/kindheadertag.vim create mode 100644 autoload/tagbar/prototypes/normaltag.vim create mode 100644 autoload/tagbar/prototypes/pseudotag.vim create mode 100644 autoload/tagbar/prototypes/typeinfo.vim create mode 100644 autoload/tagbar/sorting.vim create mode 100644 autoload/tagbar/state.vim diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4b74d46..99990a4 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -45,8 +45,8 @@ if s:ftype_out !~# 'detection:ON' endif unlet s:ftype_out -let s:icon_closed = g:tagbar_iconchars[0] -let s:icon_open = g:tagbar_iconchars[1] +let g:tagbar#icon_closed = g:tagbar_iconchars[0] +let g:tagbar#icon_open = g:tagbar_iconchars[1] let s:type_init_done = 0 let s:autocommands_done = 0 @@ -79,16 +79,6 @@ let s:window_pos = { let s:delayed_update_files = [] -" Script-local variable needed since compare functions can't -" take extra arguments -let s:compare_typeinfo = {} - -let s:visibility_symbols = { - \ 'public' : '+', - \ 'protected' : '#', - \ 'private' : '-' -\ } - let g:loaded_tagbar = 1 let s:last_highlight_tline = 0 @@ -134,7 +124,7 @@ function! s:InitTypes() abort let s:known_types = {} " Ant {{{3 - let type_ant = s:TypeInfo.New() + let type_ant = tagbar#prototypes#typeinfo#new() let type_ant.ctagstype = 'ant' let type_ant.kinds = [ \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, @@ -142,7 +132,7 @@ function! s:InitTypes() abort \ ] let s:known_types.ant = type_ant " Asm {{{3 - let type_asm = s:TypeInfo.New() + let type_asm = tagbar#prototypes#typeinfo#new() let type_asm.ctagstype = 'asm' let type_asm.kinds = [ \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, @@ -152,7 +142,7 @@ function! s:InitTypes() abort \ ] let s:known_types.asm = type_asm " ASP {{{3 - let type_aspvbs = s:TypeInfo.New() + let type_aspvbs = tagbar#prototypes#typeinfo#new() let type_aspvbs.ctagstype = 'asp' let type_aspvbs.kinds = [ \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, @@ -164,7 +154,7 @@ function! s:InitTypes() abort let s:known_types.aspvbs = type_aspvbs " Asymptote {{{3 " Asymptote gets parsed well using filetype = c - let type_asy = s:TypeInfo.New() + let type_asy = tagbar#prototypes#typeinfo#new() let type_asy.ctagstype = 'c' let type_asy.kinds = [ \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, @@ -191,14 +181,14 @@ function! s:InitTypes() abort \ } let s:known_types.asy = type_asy " Awk {{{3 - let type_awk = s:TypeInfo.New() + let type_awk = tagbar#prototypes#typeinfo#new() let type_awk.ctagstype = 'awk' let type_awk.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.awk = type_awk " Basic {{{3 - let type_basic = s:TypeInfo.New() + let type_basic = tagbar#prototypes#typeinfo#new() let type_basic.ctagstype = 'basic' let type_basic.kinds = [ \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, @@ -210,7 +200,7 @@ function! s:InitTypes() abort \ ] let s:known_types.basic = type_basic " BETA {{{3 - let type_beta = s:TypeInfo.New() + let type_beta = tagbar#prototypes#typeinfo#new() let type_beta.ctagstype = 'beta' let type_beta.kinds = [ \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, @@ -219,7 +209,7 @@ function! s:InitTypes() abort \ ] let s:known_types.beta = type_beta " C {{{3 - let type_c = s:TypeInfo.New() + let type_c = tagbar#prototypes#typeinfo#new() let type_c.ctagstype = 'c' let type_c.kinds = [ \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, @@ -246,7 +236,7 @@ function! s:InitTypes() abort \ } let s:known_types.c = type_c " C++ {{{3 - let type_cpp = s:TypeInfo.New() + let type_cpp = tagbar#prototypes#typeinfo#new() let type_cpp.ctagstype = 'c++' let type_cpp.kinds = [ \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, @@ -280,7 +270,7 @@ function! s:InitTypes() abort let s:known_types.cpp = type_cpp let s:known_types.cuda = type_cpp " C# {{{3 - let type_cs = s:TypeInfo.New() + let type_cs = tagbar#prototypes#typeinfo#new() let type_cs.ctagstype = 'c#' let type_cs.kinds = [ \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, @@ -313,7 +303,7 @@ function! s:InitTypes() abort \ } let s:known_types.cs = type_cs " COBOL {{{3 - let type_cobol = s:TypeInfo.New() + let type_cobol = tagbar#prototypes#typeinfo#new() let type_cobol.ctagstype = 'cobol' let type_cobol.kinds = [ \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, @@ -325,7 +315,7 @@ function! s:InitTypes() abort \ ] let s:known_types.cobol = type_cobol " DOS Batch {{{3 - let type_dosbatch = s:TypeInfo.New() + let type_dosbatch = tagbar#prototypes#typeinfo#new() let type_dosbatch.ctagstype = 'dosbatch' let type_dosbatch.kinds = [ \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, @@ -333,7 +323,7 @@ function! s:InitTypes() abort \ ] let s:known_types.dosbatch = type_dosbatch " Eiffel {{{3 - let type_eiffel = s:TypeInfo.New() + let type_eiffel = tagbar#prototypes#typeinfo#new() let type_eiffel.ctagstype = 'eiffel' let type_eiffel.kinds = [ \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, @@ -350,7 +340,7 @@ function! s:InitTypes() abort \ } let s:known_types.eiffel = type_eiffel " Erlang {{{3 - let type_erlang = s:TypeInfo.New() + let type_erlang = tagbar#prototypes#typeinfo#new() let type_erlang.ctagstype = 'erlang' let type_erlang.kinds = [ \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, @@ -371,7 +361,7 @@ function! s:InitTypes() abort " guesses and probably requires " http://www.vim.org/scripts/script.php?script_id=2909 " Improvements welcome! - let type_as = s:TypeInfo.New() + let type_as = tagbar#prototypes#typeinfo#new() let type_as.ctagstype = 'flex' let type_as.kinds = [ \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, @@ -391,7 +381,7 @@ function! s:InitTypes() abort let s:known_types.mxml = type_as let s:known_types.actionscript = type_as " Fortran {{{3 - let type_fortran = s:TypeInfo.New() + let type_fortran = tagbar#prototypes#typeinfo#new() let type_fortran.ctagstype = 'fortran' let type_fortran.kinds = [ \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, @@ -423,7 +413,7 @@ function! s:InitTypes() abort \ } let s:known_types.fortran = type_fortran " HTML {{{3 - let type_html = s:TypeInfo.New() + let type_html = tagbar#prototypes#typeinfo#new() let type_html.ctagstype = 'html' if s:ctags_is_uctags let type_html.kinds = [ @@ -440,7 +430,7 @@ function! s:InitTypes() abort endif let s:known_types.html = type_html " Java {{{3 - let type_java = s:TypeInfo.New() + let type_java = tagbar#prototypes#typeinfo#new() let type_java.ctagstype = 'java' let type_java.kinds = [ \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, @@ -465,7 +455,7 @@ function! s:InitTypes() abort let s:known_types.java = type_java " JavaScript {{{3 " jsctags/doctorjs will be used if available. - let type_javascript = s:TypeInfo.New() + let type_javascript = tagbar#prototypes#typeinfo#new() let type_javascript.ctagstype = 'javascript' let jsctags = s:CheckFTCtags('jsctags', 'javascript') if jsctags != '' @@ -505,7 +495,7 @@ function! s:InitTypes() abort endif let s:known_types.javascript = type_javascript " Lisp {{{3 - let type_lisp = s:TypeInfo.New() + let type_lisp = tagbar#prototypes#typeinfo#new() let type_lisp.ctagstype = 'lisp' let type_lisp.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} @@ -513,28 +503,28 @@ function! s:InitTypes() abort let s:known_types.lisp = type_lisp let s:known_types.clojure = type_lisp " Lua {{{3 - let type_lua = s:TypeInfo.New() + let type_lua = tagbar#prototypes#typeinfo#new() let type_lua.ctagstype = 'lua' let type_lua.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.lua = type_lua " Make {{{3 - let type_make = s:TypeInfo.New() + let type_make = tagbar#prototypes#typeinfo#new() let type_make.ctagstype = 'make' let type_make.kinds = [ \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.make = type_make " Matlab {{{3 - let type_matlab = s:TypeInfo.New() + let type_matlab = tagbar#prototypes#typeinfo#new() let type_matlab.ctagstype = 'matlab' let type_matlab.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.matlab = type_matlab " Ocaml {{{3 - let type_ocaml = s:TypeInfo.New() + let type_ocaml = tagbar#prototypes#typeinfo#new() let type_ocaml.ctagstype = 'ocaml' let type_ocaml.kinds = [ \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, @@ -560,7 +550,7 @@ function! s:InitTypes() abort \ } let s:known_types.ocaml = type_ocaml " Pascal {{{3 - let type_pascal = s:TypeInfo.New() + let type_pascal = tagbar#prototypes#typeinfo#new() let type_pascal.ctagstype = 'pascal' let type_pascal.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, @@ -568,7 +558,7 @@ function! s:InitTypes() abort \ ] let s:known_types.pascal = type_pascal " Perl {{{3 - let type_perl = s:TypeInfo.New() + let type_perl = tagbar#prototypes#typeinfo#new() let type_perl.ctagstype = 'perl' let type_perl.kinds = [ \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, @@ -579,7 +569,7 @@ function! s:InitTypes() abort \ ] let s:known_types.perl = type_perl " PHP {{{3 - let type_php = s:TypeInfo.New() + let type_php = tagbar#prototypes#typeinfo#new() let type_php.ctagstype = 'php' let type_php.kinds = [ \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, @@ -591,7 +581,7 @@ function! s:InitTypes() abort \ ] let s:known_types.php = type_php " Python {{{3 - let type_python = s:TypeInfo.New() + let type_python = tagbar#prototypes#typeinfo#new() let type_python.ctagstype = 'python' let type_python.kinds = [ \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, @@ -620,14 +610,14 @@ function! s:InitTypes() abort let s:known_types.pyrex = type_python let s:known_types.cython = type_python " REXX {{{3 - let type_rexx = s:TypeInfo.New() + let type_rexx = tagbar#prototypes#typeinfo#new() let type_rexx.ctagstype = 'rexx' let type_rexx.kinds = [ \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.rexx = type_rexx " Ruby {{{3 - let type_ruby = s:TypeInfo.New() + let type_ruby = tagbar#prototypes#typeinfo#new() let type_ruby.ctagstype = 'ruby' let type_ruby.kinds = [ \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, @@ -646,7 +636,7 @@ function! s:InitTypes() abort \ } let s:known_types.ruby = type_ruby " Scheme {{{3 - let type_scheme = s:TypeInfo.New() + let type_scheme = tagbar#prototypes#typeinfo#new() let type_scheme.ctagstype = 'scheme' let type_scheme.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, @@ -655,7 +645,7 @@ function! s:InitTypes() abort let s:known_types.scheme = type_scheme let s:known_types.racket = type_scheme " Shell script {{{3 - let type_sh = s:TypeInfo.New() + let type_sh = tagbar#prototypes#typeinfo#new() let type_sh.ctagstype = 'sh' let type_sh.kinds = [ \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} @@ -664,7 +654,7 @@ function! s:InitTypes() abort let s:known_types.csh = type_sh let s:known_types.zsh = type_sh " SLang {{{3 - let type_slang = s:TypeInfo.New() + let type_slang = tagbar#prototypes#typeinfo#new() let type_slang.ctagstype = 'slang' let type_slang.kinds = [ \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, @@ -672,7 +662,7 @@ function! s:InitTypes() abort \ ] let s:known_types.slang = type_slang " SML {{{3 - let type_sml = s:TypeInfo.New() + let type_sml = tagbar#prototypes#typeinfo#new() let type_sml.ctagstype = 'sml' let type_sml.kinds = [ \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, @@ -688,7 +678,7 @@ function! s:InitTypes() abort " The SQL ctags parser seems to be buggy for me, so this just uses the " normal kinds even though scopes should be available. Improvements " welcome! - let type_sql = s:TypeInfo.New() + let type_sql = tagbar#prototypes#typeinfo#new() let type_sql.ctagstype = 'sql' let type_sql.kinds = [ \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, @@ -715,7 +705,7 @@ function! s:InitTypes() abort \ ] let s:known_types.sql = type_sql " Tcl {{{3 - let type_tcl = s:TypeInfo.New() + let type_tcl = tagbar#prototypes#typeinfo#new() let type_tcl.ctagstype = 'tcl' let type_tcl.kinds = [ \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, @@ -724,7 +714,7 @@ function! s:InitTypes() abort \ ] let s:known_types.tcl = type_tcl " LaTeX {{{3 - let type_tex = s:TypeInfo.New() + let type_tex = tagbar#prototypes#typeinfo#new() let type_tex.ctagstype = 'tex' let type_tex.kinds = [ \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, @@ -758,7 +748,7 @@ function! s:InitTypes() abort " Vala is supported by the ctags fork provided by Anjuta, so only add the " type if the fork is used to prevent error messages otherwise if has_key(s:ctags_types, 'vala') || executable('anjuta-tags') - let type_vala = s:TypeInfo.New() + let type_vala = tagbar#prototypes#typeinfo#new() let type_vala.ctagstype = 'vala' let type_vala.kinds = [ \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, @@ -796,7 +786,7 @@ function! s:InitTypes() abort endif " Vera {{{3 " Why are variables 'virtual'? - let type_vera = s:TypeInfo.New() + let type_vera = tagbar#prototypes#typeinfo#new() let type_vera.ctagstype = 'vera' let type_vera.kinds = [ \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, @@ -823,7 +813,7 @@ function! s:InitTypes() abort \ } let s:known_types.vera = type_vera " Verilog {{{3 - let type_verilog = s:TypeInfo.New() + let type_verilog = tagbar#prototypes#typeinfo#new() let type_verilog.ctagstype = 'verilog' let type_verilog.kinds = [ \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, @@ -838,7 +828,7 @@ function! s:InitTypes() abort let s:known_types.verilog = type_verilog " VHDL {{{3 " The VHDL ctags parser unfortunately doesn't generate proper scopes - let type_vhdl = s:TypeInfo.New() + let type_vhdl = tagbar#prototypes#typeinfo#new() let type_vhdl.ctagstype = 'vhdl' let type_vhdl.kinds = [ \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, @@ -852,7 +842,7 @@ function! s:InitTypes() abort \ ] let s:known_types.vhdl = type_vhdl " Vim {{{3 - let type_vim = s:TypeInfo.New() + let type_vim = tagbar#prototypes#typeinfo#new() let type_vim.ctagstype = 'vim' let type_vim.kinds = [ \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, @@ -864,7 +854,7 @@ function! s:InitTypes() abort \ ] let s:known_types.vim = type_vim " YACC {{{3 - let type_yacc = s:TypeInfo.New() + let type_yacc = tagbar#prototypes#typeinfo#new() let type_yacc.ctagstype = 'yacc' let type_yacc.kinds = [ \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} @@ -924,7 +914,7 @@ function! s:LoadUserTypeDefs(...) abort for [key, value] in items(transformed) if !has_key(s:known_types, key) || get(value, 'replace', 0) - let s:known_types[key] = s:TypeInfo.New(value) + let s:known_types[key] = tagbar#prototypes#typeinfo#new(value) else call extend(s:known_types[key], value) endif @@ -1307,580 +1297,17 @@ function! s:GetSupportedFiletypes() abort let s:checked_ctags_types = 1 endfunction -" Prototypes {{{1 -" Base tag {{{2 -let s:BaseTag = {} - -" s:BaseTag.New() {{{3 -function! s:BaseTag.New(name) abort dict - let newobj = copy(self) - - call newobj._init(a:name) - - return newobj -endfunction - -" s:BaseTag._init() {{{3 -function! s:BaseTag._init(name) abort dict - let self.name = a:name - let self.fields = {} - let self.fields.line = 0 - let self.fields.column = 0 - let self.prototype = '' - let self.path = '' - let self.fullpath = a:name - let self.depth = 0 - let self.parent = {} - let self.tline = -1 - let self.fileinfo = {} - let self.typeinfo = {} - let self._childlist = [] - let self._childdict = {} -endfunction - -" s:BaseTag.isNormalTag() {{{3 -function! s:BaseTag.isNormalTag() abort dict - return 0 -endfunction - -" s:BaseTag.isPseudoTag() {{{3 -function! s:BaseTag.isPseudoTag() abort dict - return 0 -endfunction - -" s:BaseTag.isKindheader() {{{3 -function! s:BaseTag.isKindheader() abort dict - return 0 -endfunction - -" s:BaseTag.getPrototype() {{{3 -function! s:BaseTag.getPrototype(short) abort dict - return self.prototype -endfunction - -" s:BaseTag._getPrefix() {{{3 -function! s:BaseTag._getPrefix() abort dict - let fileinfo = self.fileinfo - - if !empty(self._childlist) - if fileinfo.tagfolds[self.fields.kind][self.fullpath] - let prefix = s:icon_closed - else - let prefix = s:icon_open - endif - else - let prefix = ' ' - endif - " Visibility is called 'access' in the ctags output - if g:tagbar_show_visibility - if has_key(self.fields, 'access') - let prefix .= get(s:visibility_symbols, self.fields.access, ' ') - elseif has_key(self.fields, 'file') - let prefix .= s:visibility_symbols.private - else - let prefix .= ' ' - endif - endif - - return prefix -endfunction - -" s:BaseTag.initFoldState() {{{3 -function! s:BaseTag.initFoldState() abort dict - let fileinfo = self.fileinfo - - if s:known_files.has(fileinfo.fpath) && - \ has_key(fileinfo, '_tagfolds_old') && - \ has_key(fileinfo._tagfolds_old[self.fields.kind], self.fullpath) - " The file has been updated and the tag was there before, so copy its - " old fold state - let fileinfo.tagfolds[self.fields.kind][self.fullpath] = - \ fileinfo._tagfolds_old[self.fields.kind][self.fullpath] - elseif self.depth >= fileinfo.foldlevel - let fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1 - else - let fileinfo.tagfolds[self.fields.kind][self.fullpath] = - \ fileinfo.kindfolds[self.fields.kind] - endif -endfunction - -" s:BaseTag.getClosedParentTline() {{{3 -function! s:BaseTag.getClosedParentTline() abort dict - let tagline = self.tline - - " Find the first closed parent, starting from the top of the hierarchy. - let parents = [] - let curparent = self.parent - while !empty(curparent) - call add(parents, curparent) - let curparent = curparent.parent - endwhile - for parent in reverse(parents) - if parent.isFolded() - let tagline = parent.tline - break - endif - endfor - - return tagline -endfunction - -" s:BaseTag.isFoldable() {{{3 -function! s:BaseTag.isFoldable() abort dict - return !empty(self._childlist) -endfunction - -" s:BaseTag.isFolded() {{{3 -function! s:BaseTag.isFolded() abort dict - return self.fileinfo.tagfolds[self.fields.kind][self.fullpath] -endfunction - -" s:BaseTag.openFold() {{{3 -function! s:BaseTag.openFold() abort dict - if self.isFoldable() - let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 0 - endif -endfunction - -" s:BaseTag.closeFold() {{{3 -function! s:BaseTag.closeFold() abort dict - let newline = line('.') - - if !empty(self.parent) && self.parent.isKindheader() - " Tag is child of generic 'kind' - call self.parent.closeFold() - let newline = self.parent.tline - elseif self.isFoldable() && !self.isFolded() - " Tag is parent of a scope and is not folded - let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1 - let newline = self.tline - elseif !empty(self.parent) - " Tag is normal child, so close parent - let parent = self.parent - let self.fileinfo.tagfolds[parent.fields.kind][parent.fullpath] = 1 - let newline = parent.tline - endif - - return newline -endfunction - -" s:BaseTag.setFolded() {{{3 -function! s:BaseTag.setFolded(folded) abort dict - let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = a:folded -endfunction - -" s:BaseTag.openParents() {{{3 -function! s:BaseTag.openParents() abort dict - let parent = self.parent - - while !empty(parent) - call parent.openFold() - let parent = parent.parent - endwhile -endfunction - -" s:BaseTag.addChild() {{{3 -function! s:BaseTag.addChild(tag) abort dict - call add(self._childlist, a:tag) - - if has_key(self._childdict, a:tag.name) - call add(self._childdict[a:tag.name], a:tag) - else - let self._childdict[a:tag.name] = [a:tag] - endif -endfunction - -" s:BaseTag.getChildren() {{{3 -function! s:BaseTag.getChildren() dict abort - return self._childlist -endfunction - -" s:BaseTag.getChildrenByName() {{{3 -function! s:BaseTag.getChildrenByName(tagname) dict abort - return get(self._childdict, a:tagname, []) -endfunction - -" s:BaseTag.removeChild() {{{3 -function! s:BaseTag.removeChild(tag) dict abort - let idx = index(self._childlist, a:tag) - if idx >= 0 - call remove(self._childlist, idx) - endif - - let namelist = get(self._childdict, a:tag.name, []) - let idx = index(namelist, a:tag) - if idx >= 0 - call remove(namelist, idx) - endif -endfunction - -" Normal tag {{{2 -let s:NormalTag = copy(s:BaseTag) - -" s:NormalTag.isNormalTag() {{{3 -function! s:NormalTag.isNormalTag() abort dict - return 1 -endfunction - -" s:NormalTag.strfmt() {{{3 -function! s:NormalTag.strfmt() abort dict - let typeinfo = self.typeinfo - - let suffix = get(self.fields, 'signature', '') - if has_key(self.fields, 'type') - let suffix .= ' : ' . self.fields.type - elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind) - let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] - endif - - return self._getPrefix() . self.name . suffix -endfunction - -" s:NormalTag.str() {{{3 -function! s:NormalTag.str(longsig, full) abort dict - if a:full && self.path != '' - let str = self.path . self.typeinfo.sro . self.name - else - let str = self.name - endif - - if has_key(self.fields, 'signature') - if a:longsig - let str .= self.fields.signature - else - let str .= '()' - endif - endif - - return str -endfunction - -" s:NormalTag.getPrototype() {{{3 -function! s:NormalTag.getPrototype(short) abort dict - if self.prototype != '' - let prototype = self.prototype - else - let bufnr = self.fileinfo.bufnr - - if self.fields.line == 0 || !bufloaded(bufnr) - " No linenumber available or buffer not loaded (probably due to - " 'nohidden'), try the pattern instead - return substitute(self.pattern, '^\\M\\^\\C\s*\(.*\)\\$$', '\1', '') - endif - - let line = getbufline(bufnr, self.fields.line)[0] - let list = split(line, '\zs') - - let start = index(list, '(') - if start == -1 - return substitute(line, '^\s\+', '', '') - endif - - let opening = count(list, '(', 0, start) - let closing = count(list, ')', 0, start) - if closing >= opening - return substitute(line, '^\s\+', '', '') - endif - - let balance = opening - closing - - let prototype = line - let curlinenr = self.fields.line + 1 - while balance > 0 - let curline = getbufline(bufnr, curlinenr)[0] - let curlist = split(curline, '\zs') - let balance += count(curlist, '(') - let balance -= count(curlist, ')') - let prototype .= "\n" . curline - let curlinenr += 1 - endwhile - - let self.prototype = prototype - endif - - if a:short - " join all lines and remove superfluous spaces - let prototype = substitute(prototype, '^\s\+', '', '') - let prototype = substitute(prototype, '\_s\+', ' ', 'g') - let prototype = substitute(prototype, '(\s\+', '(', 'g') - let prototype = substitute(prototype, '\s\+)', ')', 'g') - " Avoid hit-enter prompts - let maxlen = &columns - 12 - if len(prototype) > maxlen - let prototype = prototype[:maxlen - 1 - 3] - let prototype .= '...' - endif - endif - - return prototype -endfunction - -" Pseudo tag {{{2 -let s:PseudoTag = copy(s:BaseTag) - -" s:PseudoTag.isPseudoTag() {{{3 -function! s:PseudoTag.isPseudoTag() abort dict - return 1 -endfunction - -" s:PseudoTag.strfmt() {{{3 -function! s:PseudoTag.strfmt() abort dict - let typeinfo = self.typeinfo - - let suffix = get(self.fields, 'signature', '') - if has_key(typeinfo.kind2scope, self.fields.kind) - let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] - endif - - return self._getPrefix() . self.name . '*' . suffix -endfunction - -" Kind header {{{2 -let s:KindheaderTag = copy(s:BaseTag) - -" s:KindheaderTag.isKindheader() {{{3 -function! s:KindheaderTag.isKindheader() abort dict - return 1 -endfunction - -" s:KindheaderTag.getPrototype() {{{3 -function! s:KindheaderTag.getPrototype(short) abort dict - return self.name . ': ' . - \ self.numtags . ' ' . (self.numtags > 1 ? 'tags' : 'tag') -endfunction - -" s:KindheaderTag.isFoldable() {{{3 -function! s:KindheaderTag.isFoldable() abort dict - return 1 -endfunction - -" s:KindheaderTag.isFolded() {{{3 -function! s:KindheaderTag.isFolded() abort dict - return self.fileinfo.kindfolds[self.short] -endfunction - -" s:KindheaderTag.openFold() {{{3 -function! s:KindheaderTag.openFold() abort dict - let self.fileinfo.kindfolds[self.short] = 0 -endfunction - -" s:KindheaderTag.closeFold() {{{3 -function! s:KindheaderTag.closeFold() abort dict - let self.fileinfo.kindfolds[self.short] = 1 - return line('.') -endfunction - -" s:KindheaderTag.toggleFold() {{{3 -function! s:KindheaderTag.toggleFold() abort dict - let fileinfo = s:TagbarState().getCurrent(0) - - let fileinfo.kindfolds[self.short] = !fileinfo.kindfolds[self.short] -endfunction - -" Type info {{{2 -let s:TypeInfo = {} - -" s:TypeInfo.New() {{{3 -function! s:TypeInfo.New(...) abort dict - let newobj = copy(self) - - let newobj.kinddict = {} - - if a:0 > 0 - call extend(newobj, a:1) - endif - - return newobj -endfunction - -" s:TypeInfo.getKind() {{{3 -function! s:TypeInfo.getKind(kind) abort dict - let idx = self.kinddict[a:kind] - return self.kinds[idx] -endfunction - -" s:TypeInfo.createKinddict() {{{3 -" Create a dictionary of the kind order for fast access in sorting functions -function! s:TypeInfo.createKinddict() abort dict - let i = 0 - for kind in self.kinds - let self.kinddict[kind.short] = i - let i += 1 - endfor - let self.kinddict['?'] = i -endfunction - -" File info {{{2 -let s:FileInfo = {} - -" s:FileInfo.New() {{{3 -function! s:FileInfo.New(fname, ftype, typeinfo) abort dict - let newobj = copy(self) - - " The complete file path - let newobj.fpath = a:fname - - let newobj.bufnr = bufnr(a:fname) - - " File modification time - let newobj.mtime = getftime(a:fname) - - " The vim file type - let newobj.ftype = a:ftype - - " List of the tags that are present in the file, sorted according to the - " value of 'g:tagbar_sort' - let newobj._taglist = [] - let newobj._tagdict = {} - - " Dictionary of the tags, indexed by line number in the file - let newobj.fline = {} - - " Dictionary of the tags, indexed by line number in the tagbar - let newobj.tline = {} - - " Dictionary of the folding state of 'kind's, indexed by short name - let newobj.kindfolds = {} - let newobj.typeinfo = a:typeinfo - " copy the default fold state from the type info - for kind in a:typeinfo.kinds - let newobj.kindfolds[kind.short] = - \ g:tagbar_foldlevel == 0 ? 1 : kind.fold - endfor - - " Dictionary of dictionaries of the folding state of individual tags, - " indexed by kind and full path - let newobj.tagfolds = {} - for kind in a:typeinfo.kinds - let newobj.tagfolds[kind.short] = {} - endfor - - " The current foldlevel of the file - let newobj.foldlevel = g:tagbar_foldlevel - - return newobj -endfunction - -" s:FileInfo.addTag() {{{3 -function! s:FileInfo.addTag(tag) abort dict - call add(self._taglist, a:tag) - - if has_key(self._tagdict, a:tag.name) - call add(self._tagdict[a:tag.name], a:tag) - else - let self._tagdict[a:tag.name] = [a:tag] - endif -endfunction - -" s:FileInfo.getTags() {{{3 -function! s:FileInfo.getTags() dict abort - return self._taglist -endfunction - -" s:FileInfo.getTagsByName() {{{3 -function! s:FileInfo.getTagsByName(tagname) dict abort - return get(self._tagdict, a:tagname, []) -endfunction - -" s:FileInfo.removeTag() {{{3 -function! s:FileInfo.removeTag(tag) dict abort - let idx = index(self._taglist, a:tag) - if idx >= 0 - call remove(self._taglist, idx) - endif - - let namelist = get(self._tagdict, a:tag.name, []) - let idx = index(namelist, a:tag) - if idx >= 0 - call remove(namelist, idx) - endif -endfunction - -" s:FileInfo.reset() {{{3 -" Reset stuff that gets regenerated while processing a file and save the old -" tag folds -function! s:FileInfo.reset() abort dict - let self.mtime = getftime(self.fpath) - let self._taglist = [] - let self._tagdict = {} - let self.fline = {} - let self.tline = {} - - let self._tagfolds_old = self.tagfolds - let self.tagfolds = {} - - for kind in self.typeinfo.kinds - let self.tagfolds[kind.short] = {} - endfor -endfunction - -" s:FileInfo.clearOldFolds() {{{3 -function! s:FileInfo.clearOldFolds() abort dict - if exists('self._tagfolds_old') - unlet self._tagfolds_old - endif -endfunction - -" s:FileInfo.sortTags() {{{3 -function! s:FileInfo.sortTags() abort dict - if get(s:compare_typeinfo, 'sort', g:tagbar_sort) - call s:SortTags(self._taglist, 's:CompareByKind') - else - call s:SortTags(self._taglist, 's:CompareByLine') - endif -endfunction - -" s:FileInfo.openKindFold() {{{3 -function! s:FileInfo.openKindFold(kind) abort dict - let self.kindfolds[a:kind.short] = 0 -endfunction - -" s:FileInfo.closeKindFold() {{{3 -function! s:FileInfo.closeKindFold(kind) abort dict - let self.kindfolds[a:kind.short] = 1 -endfunction - -" Per-tagbar instance state prototype {{{2 -let s:state = { - \ '_current' : {}, - \ '_paused' : {}, -\ } - -" s:state.New() {{{3 -function! s:state.New() abort dict - return deepcopy(self) -endfunction - -" s:state.getCurrent() {{{3 -function! s:state.getCurrent(forcecurrent) abort dict - if !s:paused || a:forcecurrent - return self._current - else - return self._paused - endif -endfunction - -" s:state.setCurrent() {{{3 -function! s:state.setCurrent(fileinfo) abort dict - let self._current = a:fileinfo -endfunction - -" s:state.setPaused() {{{3 -function! s:state.setPaused() abort dict - let self._paused = self._current -endfunction - -" Known files {{{2 +" Known files {{{1 let s:known_files = { \ '_files' : {} \ } -" s:known_files.get() {{{3 +" s:known_files.get() {{{2 function! s:known_files.get(fname) abort dict return get(self._files, a:fname, {}) endfunction -" s:known_files.put() {{{3 +" s:known_files.put() {{{2 " Optional second argument is the filename function! s:known_files.put(fileinfo, ...) abort dict if a:0 == 1 @@ -1891,12 +1318,12 @@ function! s:known_files.put(fileinfo, ...) abort dict endif endfunction -" s:known_files.has() {{{3 +" s:known_files.has() {{{2 function! s:known_files.has(fname) abort dict return has_key(self._files, a:fname) endfunction -" s:known_files.rm() {{{3 +" s:known_files.rm() {{{2 function! s:known_files.rm(fname) abort dict if s:known_files.has(a:fname) call s:debug('Removing fileinfo for [' . a:fname . ']') @@ -2128,7 +1555,7 @@ function! s:CloseWindow() abort if winbufnr(2) != -1 " Other windows are open, only close the tagbar one - let curfile = s:TagbarState().getCurrent(0) + let curfile = tagbar#state#get_current_file(0) close @@ -2230,7 +1657,7 @@ endfunction " the current file after startup. function! s:CorrectFocusOnStartup() abort if bufwinnr(s:TagbarBufName()) != -1 && !g:tagbar_autofocus && !s:last_autofocus - let curfile = s:TagbarState().getCurrent(1) + let curfile = tagbar#state#get_current_file(1) if !empty(curfile) && curfile.fpath != fnamemodify(bufname('%'), ':p') let winnr = bufwinnr(curfile.fpath) if winnr != -1 @@ -2269,7 +1696,7 @@ function! s:ProcessFile(fname, ftype) abort call typeinfo.createKinddict() endif endif - let fileinfo = s:FileInfo.New(a:fname, a:ftype, typeinfo) + let fileinfo = tagbar#prototypes#fileinfo#new(a:fname, a:ftype, typeinfo) endif call s:debug('typeinfo for file to process: ' . string(typeinfo)) @@ -2300,7 +1727,7 @@ function! s:ProcessFile(fname, ftype) abort call s:debug('Ctags output empty') " No need to go through the tag processing if there are no tags, and " preserving the old fold state isn't necessary either - call s:known_files.put(s:FileInfo.New(a:fname, a:ftype, + call s:known_files.put(tagbar#prototypes#fileinfo#new(a:fname, a:ftype, \ s:known_types[a:ftype]), a:fname) return endif @@ -2339,7 +1766,7 @@ function! s:ProcessFile(fname, ftype) abort continue endif - let kindtag = s:KindheaderTag.New(kind.long) + let kindtag = tagbar#prototypes#kindheadertag#new(kind.long) let kindtag.short = kind.short let kindtag.numtags = len(curtags) let kindtag.fileinfo = fileinfo @@ -2353,8 +1780,7 @@ function! s:ProcessFile(fname, ftype) abort call fileinfo.clearOldFolds() " Sort the tags - let s:compare_typeinfo = typeinfo - call fileinfo.sortTags() + call fileinfo.sortTags(typeinfo) call s:known_files.put(fileinfo) endfunction @@ -2465,7 +1891,7 @@ endfunction function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort let basic_info = split(a:part1, '\t') - let taginfo = s:NormalTag.New(basic_info[0]) + let taginfo = tagbar#prototypes#normaltag#new(basic_info[0]) let taginfo.file = basic_info[1] " the pattern can contain tabs and thus may have been split up, so join @@ -2554,7 +1980,7 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort " Needed for folding try - call taginfo.initFoldState() + call taginfo.initFoldState(s:known_files) catch /^Vim(\a\+):E716:/ " 'Key not present in Dictionary' " The tag has a 'kind' that doesn't exist in the type definition call s:debug('Warning: Unknown tag kind: ' . taginfo.fields.kind) @@ -2713,7 +2139,7 @@ function! s:add_tag_recursive(parent, taginfo, pathlist) abort let parentkind = a:taginfo.typeinfo.scope2kind[a:taginfo.scope] if parent.fields.kind ==# '?' || parentkind !=# parent.fields.kind let parent.fields.kind = parentkind - call parent.initFoldState() + call parent.initFoldState(s:known_files) endif endif @@ -2732,7 +2158,7 @@ function! s:create_pseudotag(name, parent, kind, typeinfo, fileinfo) abort let pscope = '' endif - let pseudotag = s:PseudoTag.New(a:name) + let pseudotag = tagbar#prototypes#pseudotag#new(a:name) let pseudotag.fields.kind = a:kind let parentscope = substitute(curpath, '\V' . a:name . '$', '', '') @@ -2753,64 +2179,14 @@ function! s:create_pseudotag(name, parent, kind, typeinfo, fileinfo) abort let pseudotag.fileinfo = a:fileinfo let pseudotag.typeinfo = a:typeinfo - call pseudotag.initFoldState() + call pseudotag.initFoldState(s:known_files) return pseudotag endfunction -" Sorting {{{1 -" s:SortTags() {{{2 -function! s:SortTags(tags, comparemethod) abort - call sort(a:tags, a:comparemethod) - - for tag in a:tags - if !empty(tag.getChildren()) - call s:SortTags(tag.getChildren(), a:comparemethod) - endif - endfor -endfunction - -" s:CompareByKind() {{{2 -function! s:CompareByKind(tag1, tag2) abort - let typeinfo = s:compare_typeinfo - - if typeinfo.kinddict[a:tag1.fields.kind] <# - \ typeinfo.kinddict[a:tag2.fields.kind] - return -1 - elseif typeinfo.kinddict[a:tag1.fields.kind] ># - \ typeinfo.kinddict[a:tag2.fields.kind] - return 1 - else - " Ignore '~' prefix for C++ destructors to sort them directly under - " the constructors - if a:tag1.name[0] ==# '~' - let name1 = a:tag1.name[1:] - else - let name1 = a:tag1.name - endif - if a:tag2.name[0] ==# '~' - let name2 = a:tag2.name[1:] - else - let name2 = a:tag2.name - endif - - let ci = g:tagbar_case_insensitive - if (((!ci) && (name1 <=# name2)) || (ci && (name1 <=? name2))) - return -1 - else - return 1 - endif - endif -endfunction - -" s:CompareByLine() {{{2 -function! s:CompareByLine(tag1, tag2) abort - return a:tag1.fields.line - a:tag2.fields.line -endfunction - " s:ToggleSort() {{{2 function! s:ToggleSort() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -2821,15 +2197,15 @@ function! s:ToggleSort() abort match none - let s:compare_typeinfo = s:known_types[fileinfo.ftype] + let compare_typeinfo = s:known_types[fileinfo.ftype] - if has_key(s:compare_typeinfo, 'sort') - let s:compare_typeinfo.sort = !s:compare_typeinfo.sort + if has_key(compare_typeinfo, 'sort') + let compare_typeinfo.sort = !compare_typeinfo.sort else let g:tagbar_sort = !g:tagbar_sort endif - call fileinfo.sortTags() + call fileinfo.sortTags(compare_typeinfo) call s:RenderContent() call s:SetStatusLine() @@ -2852,7 +2228,7 @@ function! s:RenderContent(...) abort if a:0 == 1 let fileinfo = a:1 else - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) endif if empty(fileinfo) @@ -2877,8 +2253,8 @@ function! s:RenderContent(...) abort call s:goto_win(tagbarwinnr, 1) endif - if !empty(s:TagbarState().getCurrent(0)) && - \ fileinfo.fpath ==# s:TagbarState().getCurrent(0).fpath + if !empty(tagbar#state#get_current_file(0)) && + \ fileinfo.fpath ==# tagbar#state#get_current_file(0).fpath " We're redisplaying the same file, so save the view call s:debug('Redisplaying file [' . fileinfo.fpath . ']') let saveline = line('.') @@ -2922,8 +2298,8 @@ function! s:RenderContent(...) abort setlocal nomodifiable - if !empty(s:TagbarState().getCurrent(0)) && - \ fileinfo.fpath ==# s:TagbarState().getCurrent(0).fpath + if !empty(tagbar#state#get_current_file(0)) && + \ fileinfo.fpath ==# tagbar#state#get_current_file(0).fpath let scrolloff_save = &scrolloff set scrolloff=0 @@ -2984,9 +2360,9 @@ function! s:PrintKinds(typeinfo, fileinfo) abort let kindtag = curtags[0].parent if kindtag.isFolded() - let foldmarker = s:icon_closed + let foldmarker = g:tagbar#icon_closed else - let foldmarker = s:icon_open + let foldmarker = g:tagbar#icon_open endif let padding = g:tagbar_show_visibility ? ' ' : '' @@ -3061,7 +2437,7 @@ function! s:PrintTag(tag, depth, output, fileinfo, typeinfo) abort let indent += 1 " fold symbol call add(a:output, repeat(' ', indent) . '[' . ckind.long . ']') " Add basic tag to allow folding when on the header line - let headertag = s:BaseTag.New(ckind.long) + let headertag = tagbar#prototypes#basetag#new(ckind.long) let headertag.parent = a:tag let headertag.fileinfo = a:tag.fileinfo let a:fileinfo.tline[len(a:output) + offset] = headertag @@ -3216,7 +2592,7 @@ function! s:HighlightTag(openfolds, ...) abort " Make sure the tag is visible in the window call winline() - let foldpat = '[' . s:icon_open . s:icon_closed . ' ]' + let foldpat = '[' . g:tagbar#icon_open . g:tagbar#icon_closed . ' ]' let pattern = '/^\%' . tagline . 'l\s*' . foldpat . '[-+# ]\zs[^( ]\+\ze/' call s:debug("Highlight pattern: '" . pattern . "'") if hlexists('TagbarHighlight') " Safeguard in case syntax highlighting is disabled @@ -3429,7 +2805,7 @@ endfunction " Folding {{{1 " s:OpenFold() {{{2 function! s:OpenFold() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -3448,7 +2824,7 @@ endfunction " s:CloseFold() {{{2 function! s:CloseFold() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -3469,7 +2845,7 @@ endfunction " s:ToggleFold() {{{2 function! s:ToggleFold() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -3484,7 +2860,7 @@ function! s:ToggleFold() abort let newline = line('.') if curtag.isKindheader() - call curtag.toggleFold() + call curtag.toggleFold(tagbar#state#get_current_file(0)) elseif curtag.isFoldable() if curtag.isFolded() call curtag.openFold() @@ -3500,7 +2876,7 @@ endfunction " s:ChangeFoldLevel() {{{2 function! s:ChangeFoldLevel(diff, force) abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -3521,7 +2897,7 @@ function! s:SetFoldLevel(level, force) abort return endif - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -3742,8 +3118,8 @@ function! s:AutoUpdate(fname, force, ...) abort " file is being displayed if bufwinnr(s:TagbarBufName()) != -1 && !s:paused && \ (s:new_window || updated || - \ (!empty(s:TagbarState().getCurrent(0)) && - \ a:fname != s:TagbarState().getCurrent(0).fpath)) + \ (!empty(tagbar#state#get_current_file(0)) && + \ a:fname != tagbar#state#get_current_file(0).fpath)) call s:RenderContent(fileinfo) endif @@ -3751,7 +3127,7 @@ function! s:AutoUpdate(fname, force, ...) abort " same file is being redisplayed if !empty(fileinfo) call s:debug('Setting current file [' . a:fname . ']') - call s:TagbarState().setCurrent(fileinfo) + call tagbar#state#set_current_file(fileinfo) let s:nearby_disabled = 0 endif @@ -3765,9 +3141,9 @@ function! s:CheckMouseClick() abort let line = getline('.') let curcol = col('.') - if (match(line, s:icon_open . '[-+ ]') + 1) == curcol + if (match(line, g:tagbar#icon_open . '[-+ ]') + 1) == curcol call s:CloseFold() - elseif (match(line, s:icon_closed . '[-+ ]') + 1) == curcol + elseif (match(line, g:tagbar#icon_closed . '[-+ ]') + 1) == curcol call s:OpenFold() elseif g:tagbar_singleclick call s:JumpToTag(0) @@ -3968,7 +3344,7 @@ function! s:GetNearbyTag(all, forcecurrent, ...) abort return {} endif - let fileinfo = s:TagbarState().getCurrent(a:forcecurrent) + let fileinfo = tagbar#state#get_current_file(a:forcecurrent) if empty(fileinfo) return {} endif @@ -4004,7 +3380,7 @@ endfunction " does not contain a valid tag (for example because it is empty or only " contains a pseudo-tag) return an empty dictionary. function! s:GetTagInfo(linenr, ignorepseudo) abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return {} @@ -4090,7 +3466,7 @@ endfunction " s:ToggleHideNonPublicTags() {{{2 function! s:ToggleHideNonPublicTags() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -4116,7 +3492,7 @@ endfunction " s:ToggleCaseInsensitive() {{{2 function! s:ToggleCaseInsensitive() abort - let fileinfo = s:TagbarState().getCurrent(0) + let fileinfo = tagbar#state#get_current_file(0) if empty(fileinfo) return endif @@ -4129,7 +3505,7 @@ function! s:ToggleCaseInsensitive() abort let g:tagbar_case_insensitive = !g:tagbar_case_insensitive - call fileinfo.sortTags() + call fileinfo.sortTags(fileinfo.typeinfo) call s:RenderKeepView() call s:SetStatusLine() @@ -4211,8 +3587,8 @@ function! s:SetStatusLine() let in_tagbar = 1 endif - if !empty(s:TagbarState().getCurrent(0)) - let fileinfo = s:TagbarState().getCurrent(0) + if !empty(tagbar#state#get_current_file(0)) + let fileinfo = tagbar#state#get_current_file(0) let fname = fnamemodify(fileinfo.fpath, ':t') let sorted = get(fileinfo.typeinfo, 'sort', g:tagbar_sort) else @@ -4347,7 +3723,7 @@ endfunction " s:do_delayed_update() {{{2 function! s:do_delayed_update() abort - let curfile = s:TagbarState().getCurrent(0) + let curfile = tagbar#state#get_current_file(0) if empty(curfile) let curfname = '' else @@ -4407,15 +3783,6 @@ function! s:TagbarBufName() abort return t:tagbar_buf_name endfunction -" s:TagbarState() {{{2 -function! s:TagbarState() abort - if !exists('t:tagbar_state') - let t:tagbar_state = s:state.New() - endif - - return t:tagbar_state -endfunction - " s:goto_win() {{{2 function! s:goto_win(winnr, ...) abort let cmd = type(a:winnr) == type(0) ? a:winnr . 'wincmd w' @@ -4575,12 +3942,16 @@ function! tagbar#toggle_pause() abort let s:paused = !s:paused if s:paused - call s:TagbarState().setPaused() + call tagbar#state#set_paused() else call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 1) endif endfunction +function! tagbar#is_paused() abort + return s:paused +endfunction + " tagbar#getusertypes() {{{2 function! tagbar#getusertypes() abort let userdefs = filter(copy(g:), 'v:key =~ "^tagbar_type_"') @@ -4656,8 +4027,8 @@ endfunction function! tagbar#currentfile() abort let filename = '' - if !empty(s:TagbarState().getCurrent(1)) - let filename = fnamemodify(s:TagbarState().getCurrent(1).fpath, ':t') + if !empty(tagbar#state#get_current_file(1)) + let filename = fnamemodify(tagbar#state#get_current_file(1).fpath, ':t') endif return filename diff --git a/autoload/tagbar/prototypes/basetag.vim b/autoload/tagbar/prototypes/basetag.vim new file mode 100644 index 0000000..570a78a --- /dev/null +++ b/autoload/tagbar/prototypes/basetag.vim @@ -0,0 +1,214 @@ +let s:visibility_symbols = { + \ 'public' : '+', + \ 'protected' : '#', + \ 'private' : '-' +\ } + +let s:BaseTag = {} + +let g:tagbar#prototypes#basetag#BaseTag = s:BaseTag + +function! tagbar#prototypes#basetag#new(name) abort + let newobj = copy(s:BaseTag) + + call newobj._init(a:name) + + return newobj +endfunction + +" s:BaseTag._init() {{{1 +function! s:BaseTag._init(name) abort dict + let self.name = a:name + let self.fields = {} + let self.fields.line = 0 + let self.fields.column = 0 + let self.prototype = '' + let self.path = '' + let self.fullpath = a:name + let self.depth = 0 + let self.parent = {} + let self.tline = -1 + let self.fileinfo = {} + let self.typeinfo = {} + let self._childlist = [] + let self._childdict = {} +endfunction + +" s:BaseTag.isNormalTag() {{{1 +function! s:BaseTag.isNormalTag() abort dict + return 0 +endfunction + +" s:BaseTag.isPseudoTag() {{{1 +function! s:BaseTag.isPseudoTag() abort dict + return 0 +endfunction + +" s:BaseTag.isKindheader() {{{1 +function! s:BaseTag.isKindheader() abort dict + return 0 +endfunction + +" s:BaseTag.getPrototype() {{{1 +function! s:BaseTag.getPrototype(short) abort dict + return self.prototype +endfunction + +" s:BaseTag._getPrefix() {{{1 +function! s:BaseTag._getPrefix() abort dict + let fileinfo = self.fileinfo + + if !empty(self._childlist) + if fileinfo.tagfolds[self.fields.kind][self.fullpath] + let prefix = g:tagbar#icon_closed + else + let prefix = g:tagbar#icon_open + endif + else + let prefix = ' ' + endif + " Visibility is called 'access' in the ctags output + if g:tagbar_show_visibility + if has_key(self.fields, 'access') + let prefix .= get(s:visibility_symbols, self.fields.access, ' ') + elseif has_key(self.fields, 'file') + let prefix .= s:visibility_symbols.private + else + let prefix .= ' ' + endif + endif + + return prefix +endfunction + +" s:BaseTag.initFoldState() {{{1 +function! s:BaseTag.initFoldState(known_files) abort dict + let fileinfo = self.fileinfo + + if a:known_files.has(fileinfo.fpath) && + \ has_key(fileinfo, '_tagfolds_old') && + \ has_key(fileinfo._tagfolds_old[self.fields.kind], self.fullpath) + " The file has been updated and the tag was there before, so copy its + " old fold state + let fileinfo.tagfolds[self.fields.kind][self.fullpath] = + \ fileinfo._tagfolds_old[self.fields.kind][self.fullpath] + elseif self.depth >= fileinfo.foldlevel + let fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1 + else + let fileinfo.tagfolds[self.fields.kind][self.fullpath] = + \ fileinfo.kindfolds[self.fields.kind] + endif +endfunction + +" s:BaseTag.getClosedParentTline() {{{1 +function! s:BaseTag.getClosedParentTline() abort dict + let tagline = self.tline + + " Find the first closed parent, starting from the top of the hierarchy. + let parents = [] + let curparent = self.parent + while !empty(curparent) + call add(parents, curparent) + let curparent = curparent.parent + endwhile + for parent in reverse(parents) + if parent.isFolded() + let tagline = parent.tline + break + endif + endfor + + return tagline +endfunction + +" s:BaseTag.isFoldable() {{{1 +function! s:BaseTag.isFoldable() abort dict + return !empty(self._childlist) +endfunction + +" s:BaseTag.isFolded() {{{1 +function! s:BaseTag.isFolded() abort dict + return self.fileinfo.tagfolds[self.fields.kind][self.fullpath] +endfunction + +" s:BaseTag.openFold() {{{1 +function! s:BaseTag.openFold() abort dict + if self.isFoldable() + let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 0 + endif +endfunction + +" s:BaseTag.closeFold() {{{1 +function! s:BaseTag.closeFold() abort dict + let newline = line('.') + + if !empty(self.parent) && self.parent.isKindheader() + " Tag is child of generic 'kind' + call self.parent.closeFold() + let newline = self.parent.tline + elseif self.isFoldable() && !self.isFolded() + " Tag is parent of a scope and is not folded + let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1 + let newline = self.tline + elseif !empty(self.parent) + " Tag is normal child, so close parent + let parent = self.parent + let self.fileinfo.tagfolds[parent.fields.kind][parent.fullpath] = 1 + let newline = parent.tline + endif + + return newline +endfunction + +" s:BaseTag.setFolded() {{{1 +function! s:BaseTag.setFolded(folded) abort dict + let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = a:folded +endfunction + +" s:BaseTag.openParents() {{{1 +function! s:BaseTag.openParents() abort dict + let parent = self.parent + + while !empty(parent) + call parent.openFold() + let parent = parent.parent + endwhile +endfunction + +" s:BaseTag.addChild() {{{1 +function! s:BaseTag.addChild(tag) abort dict + call add(self._childlist, a:tag) + + if has_key(self._childdict, a:tag.name) + call add(self._childdict[a:tag.name], a:tag) + else + let self._childdict[a:tag.name] = [a:tag] + endif +endfunction + +" s:BaseTag.getChildren() {{{1 +function! s:BaseTag.getChildren() dict abort + return self._childlist +endfunction + +" s:BaseTag.getChildrenByName() {{{1 +function! s:BaseTag.getChildrenByName(tagname) dict abort + return get(self._childdict, a:tagname, []) +endfunction + +" s:BaseTag.removeChild() {{{1 +function! s:BaseTag.removeChild(tag) dict abort + let idx = index(self._childlist, a:tag) + if idx >= 0 + call remove(self._childlist, idx) + endif + + let namelist = get(self._childdict, a:tag.name, []) + let idx = index(namelist, a:tag) + if idx >= 0 + call remove(namelist, idx) + endif +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/prototypes/fileinfo.vim b/autoload/tagbar/prototypes/fileinfo.vim new file mode 100644 index 0000000..a75e1ff --- /dev/null +++ b/autoload/tagbar/prototypes/fileinfo.vim @@ -0,0 +1,130 @@ +let s:FileInfo = {} + +function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort + let newobj = copy(s:FileInfo) + + " The complete file path + let newobj.fpath = a:fname + + let newobj.bufnr = bufnr(a:fname) + + " File modification time + let newobj.mtime = getftime(a:fname) + + " The vim file type + let newobj.ftype = a:ftype + + " List of the tags that are present in the file, sorted according to the + " value of 'g:tagbar_sort' + let newobj._taglist = [] + let newobj._tagdict = {} + + " Dictionary of the tags, indexed by line number in the file + let newobj.fline = {} + + " Dictionary of the tags, indexed by line number in the tagbar + let newobj.tline = {} + + " Dictionary of the folding state of 'kind's, indexed by short name + let newobj.kindfolds = {} + let newobj.typeinfo = a:typeinfo + " copy the default fold state from the type info + for kind in a:typeinfo.kinds + let newobj.kindfolds[kind.short] = + \ g:tagbar_foldlevel == 0 ? 1 : kind.fold + endfor + + " Dictionary of dictionaries of the folding state of individual tags, + " indexed by kind and full path + let newobj.tagfolds = {} + for kind in a:typeinfo.kinds + let newobj.tagfolds[kind.short] = {} + endfor + + " The current foldlevel of the file + let newobj.foldlevel = g:tagbar_foldlevel + + return newobj +endfunction + +" s:FileInfo.addTag() {{{1 +function! s:FileInfo.addTag(tag) abort dict + call add(self._taglist, a:tag) + + if has_key(self._tagdict, a:tag.name) + call add(self._tagdict[a:tag.name], a:tag) + else + let self._tagdict[a:tag.name] = [a:tag] + endif +endfunction + +" s:FileInfo.getTags() {{{1 +function! s:FileInfo.getTags() dict abort + return self._taglist +endfunction + +" s:FileInfo.getTagsByName() {{{1 +function! s:FileInfo.getTagsByName(tagname) dict abort + return get(self._tagdict, a:tagname, []) +endfunction + +" s:FileInfo.removeTag() {{{1 +function! s:FileInfo.removeTag(tag) dict abort + let idx = index(self._taglist, a:tag) + if idx >= 0 + call remove(self._taglist, idx) + endif + + let namelist = get(self._tagdict, a:tag.name, []) + let idx = index(namelist, a:tag) + if idx >= 0 + call remove(namelist, idx) + endif +endfunction + +" s:FileInfo.reset() {{{1 +" Reset stuff that gets regenerated while processing a file and save the old +" tag folds +function! s:FileInfo.reset() abort dict + let self.mtime = getftime(self.fpath) + let self._taglist = [] + let self._tagdict = {} + let self.fline = {} + let self.tline = {} + + let self._tagfolds_old = self.tagfolds + let self.tagfolds = {} + + for kind in self.typeinfo.kinds + let self.tagfolds[kind.short] = {} + endfor +endfunction + +" s:FileInfo.clearOldFolds() {{{1 +function! s:FileInfo.clearOldFolds() abort dict + if exists('self._tagfolds_old') + unlet self._tagfolds_old + endif +endfunction + +" s:FileInfo.sortTags() {{{1 +function! s:FileInfo.sortTags(compare_typeinfo) abort dict + if get(a:compare_typeinfo, 'sort', g:tagbar_sort) + call tagbar#sorting#sort(self._taglist, 'kind', a:compare_typeinfo) + else + call tagbar#sorting#sort(self._taglist, 'line', a:compare_typeinfo) + endif +endfunction + +" s:FileInfo.openKindFold() {{{1 +function! s:FileInfo.openKindFold(kind) abort dict + let self.kindfolds[a:kind.short] = 0 +endfunction + +" s:FileInfo.closeKindFold() {{{1 +function! s:FileInfo.closeKindFold(kind) abort dict + let self.kindfolds[a:kind.short] = 1 +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/prototypes/kindheadertag.vim b/autoload/tagbar/prototypes/kindheadertag.vim new file mode 100644 index 0000000..b489167 --- /dev/null +++ b/autoload/tagbar/prototypes/kindheadertag.vim @@ -0,0 +1,49 @@ +let s:KindheaderTag = copy(g:tagbar#prototypes#basetag#BaseTag) + +function! tagbar#prototypes#kindheadertag#new(name) abort + let newobj = copy(s:KindheaderTag) + + call newobj._init(a:name) + + return newobj +endfunction + +" s:KindheaderTag.isKindheader() {{{1 +function! s:KindheaderTag.isKindheader() abort dict + return 1 +endfunction + +" s:KindheaderTag.getPrototype() {{{1 +function! s:KindheaderTag.getPrototype(short) abort dict + return self.name . ': ' . + \ self.numtags . ' ' . (self.numtags > 1 ? 'tags' : 'tag') +endfunction + +" s:KindheaderTag.isFoldable() {{{1 +function! s:KindheaderTag.isFoldable() abort dict + return 1 +endfunction + +" s:KindheaderTag.isFolded() {{{1 +function! s:KindheaderTag.isFolded() abort dict + return self.fileinfo.kindfolds[self.short] +endfunction + +" s:KindheaderTag.openFold() {{{1 +function! s:KindheaderTag.openFold() abort dict + let self.fileinfo.kindfolds[self.short] = 0 +endfunction + +" s:KindheaderTag.closeFold() {{{1 +function! s:KindheaderTag.closeFold() abort dict + let self.fileinfo.kindfolds[self.short] = 1 + return line('.') +endfunction + +" s:KindheaderTag.toggleFold() {{{1 +function! s:KindheaderTag.toggleFold(fileinfo) abort dict + let a:fileinfo.kindfolds[self.short] = !a:fileinfo.kindfolds[self.short] +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/prototypes/normaltag.vim b/autoload/tagbar/prototypes/normaltag.vim new file mode 100644 index 0000000..ccaf380 --- /dev/null +++ b/autoload/tagbar/prototypes/normaltag.vim @@ -0,0 +1,110 @@ +let s:NormalTag = copy(g:tagbar#prototypes#basetag#BaseTag) + +function! tagbar#prototypes#normaltag#new(name) abort + let newobj = copy(s:NormalTag) + + call newobj._init(a:name) + + return newobj +endfunction + +" s:NormalTag.isNormalTag() {{{1 +function! s:NormalTag.isNormalTag() abort dict + return 1 +endfunction + +" s:NormalTag.strfmt() {{{1 +function! s:NormalTag.strfmt() abort dict + let typeinfo = self.typeinfo + + let suffix = get(self.fields, 'signature', '') + if has_key(self.fields, 'type') + let suffix .= ' : ' . self.fields.type + elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind) + let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] + endif + + return self._getPrefix() . self.name . suffix +endfunction + +" s:NormalTag.str() {{{1 +function! s:NormalTag.str(longsig, full) abort dict + if a:full && self.path != '' + let str = self.path . self.typeinfo.sro . self.name + else + let str = self.name + endif + + if has_key(self.fields, 'signature') + if a:longsig + let str .= self.fields.signature + else + let str .= '()' + endif + endif + + return str +endfunction + +" s:NormalTag.getPrototype() {{{1 +function! s:NormalTag.getPrototype(short) abort dict + if self.prototype != '' + let prototype = self.prototype + else + let bufnr = self.fileinfo.bufnr + + if self.fields.line == 0 || !bufloaded(bufnr) + " No linenumber available or buffer not loaded (probably due to + " 'nohidden'), try the pattern instead + return substitute(self.pattern, '^\\M\\^\\C\s*\(.*\)\\$$', '\1', '') + endif + + let line = getbufline(bufnr, self.fields.line)[0] + let list = split(line, '\zs') + + let start = index(list, '(') + if start == -1 + return substitute(line, '^\s\+', '', '') + endif + + let opening = count(list, '(', 0, start) + let closing = count(list, ')', 0, start) + if closing >= opening + return substitute(line, '^\s\+', '', '') + endif + + let balance = opening - closing + + let prototype = line + let curlinenr = self.fields.line + 1 + while balance > 0 + let curline = getbufline(bufnr, curlinenr)[0] + let curlist = split(curline, '\zs') + let balance += count(curlist, '(') + let balance -= count(curlist, ')') + let prototype .= "\n" . curline + let curlinenr += 1 + endwhile + + let self.prototype = prototype + endif + + if a:short + " join all lines and remove superfluous spaces + let prototype = substitute(prototype, '^\s\+', '', '') + let prototype = substitute(prototype, '\_s\+', ' ', 'g') + let prototype = substitute(prototype, '(\s\+', '(', 'g') + let prototype = substitute(prototype, '\s\+)', ')', 'g') + " Avoid hit-enter prompts + let maxlen = &columns - 12 + if len(prototype) > maxlen + let prototype = prototype[:maxlen - 1 - 3] + let prototype .= '...' + endif + endif + + return prototype +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/prototypes/pseudotag.vim b/autoload/tagbar/prototypes/pseudotag.vim new file mode 100644 index 0000000..a99863e --- /dev/null +++ b/autoload/tagbar/prototypes/pseudotag.vim @@ -0,0 +1,29 @@ +let s:PseudoTag = copy(g:tagbar#prototypes#basetag#BaseTag) + +function! tagbar#prototypes#pseudotag#new(name) abort + let newobj = copy(s:PseudoTag) + + call newobj._init(a:name) + + return newobj +endfunction + +" s:PseudoTag.isPseudoTag() {{{1 +function! s:PseudoTag.isPseudoTag() abort dict + return 1 +endfunction + +" s:PseudoTag.strfmt() {{{1 +function! s:PseudoTag.strfmt() abort dict + let typeinfo = self.typeinfo + + let suffix = get(self.fields, 'signature', '') + if has_key(typeinfo.kind2scope, self.fields.kind) + let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] + endif + + return self._getPrefix() . self.name . '*' . suffix +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/prototypes/typeinfo.vim b/autoload/tagbar/prototypes/typeinfo.vim new file mode 100644 index 0000000..8ef3791 --- /dev/null +++ b/autoload/tagbar/prototypes/typeinfo.vim @@ -0,0 +1,33 @@ +let s:TypeInfo = {} + +function! tagbar#prototypes#typeinfo#new(...) abort + let newobj = copy(s:TypeInfo) + + let newobj.kinddict = {} + + if a:0 > 0 + call extend(newobj, a:1) + endif + + return newobj +endfunction + +" s:TypeInfo.getKind() {{{1 +function! s:TypeInfo.getKind(kind) abort dict + let idx = self.kinddict[a:kind] + return self.kinds[idx] +endfunction + +" s:TypeInfo.createKinddict() {{{1 +" Create a dictionary of the kind order for fast access in sorting functions +function! s:TypeInfo.createKinddict() abort dict + let i = 0 + for kind in self.kinds + let self.kinddict[kind.short] = i + let i += 1 + endfor + let self.kinddict['?'] = i +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/sorting.vim b/autoload/tagbar/sorting.vim new file mode 100644 index 0000000..ab9b179 --- /dev/null +++ b/autoload/tagbar/sorting.vim @@ -0,0 +1,57 @@ +" Script-local variable needed since compare functions can't +" take additional arguments +let s:compare_typeinfo = {} + +function! tagbar#sorting#sort(tags, compareby, compare_typeinfo) abort + let s:compare_typeinfo = a:compare_typeinfo + + let comparemethod = + \ a:compareby == 'kind' ? 's:compare_by_kind' : 's:compare_by_line' + + call sort(a:tags, comparemethod) + + for tag in a:tags + if !empty(tag.getChildren()) + call tagbar#sorting#sort(tag.getChildren(), a:compareby, + \ a:compare_typeinfo) + endif + endfor +endfunction + +function! s:compare_by_kind(tag1, tag2) abort + let typeinfo = s:compare_typeinfo + + if typeinfo.kinddict[a:tag1.fields.kind] <# + \ typeinfo.kinddict[a:tag2.fields.kind] + return -1 + elseif typeinfo.kinddict[a:tag1.fields.kind] ># + \ typeinfo.kinddict[a:tag2.fields.kind] + return 1 + else + " Ignore '~' prefix for C++ destructors to sort them directly under + " the constructors + if a:tag1.name[0] ==# '~' + let name1 = a:tag1.name[1:] + else + let name1 = a:tag1.name + endif + if a:tag2.name[0] ==# '~' + let name2 = a:tag2.name[1:] + else + let name2 = a:tag2.name + endif + + let ci = g:tagbar_case_insensitive + if (((!ci) && (name1 <=# name2)) || (ci && (name1 <=? name2))) + return -1 + else + return 1 + endif + endif +endfunction + +function! s:compare_by_line(tag1, tag2) abort + return a:tag1.fields.line - a:tag2.fields.line +endfunction + +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/state.vim b/autoload/tagbar/state.vim new file mode 100644 index 0000000..261bcfc --- /dev/null +++ b/autoload/tagbar/state.vim @@ -0,0 +1,51 @@ +function! tagbar#state#get_current_file(force_current) abort + return s:get().getCurrent(a:force_current) +endfunction + +function! tagbar#state#set_current_file(fileinfo) abort + call s:get().setCurrentFile(a:fileinfo) +endfunction + +function! tagbar#state#set_paused() abort + call s:get().setPaused() +endfunction + +function! s:get() abort + if !exists('t:tagbar_state') + let t:tagbar_state = s:State.New() + endif + + return t:tagbar_state +endfunction + +let s:State = { + \ '_current' : {}, + \ '_paused' : {}, +\ } + +" s:state.New() {{{1 +function! s:State.New() abort dict + return deepcopy(self) +endfunction + +" s:state.getCurrent() {{{1 +function! s:State.getCurrent(force_current) abort dict + if !tagbar#is_paused() || a:force_current + return self._current + else + return self._paused + endif +endfunction + +" s:state.setCurrentFile() {{{1 +function! s:State.setCurrentFile(fileinfo) abort dict + let self._current = a:fileinfo +endfunction + +" s:state.setPaused() {{{1 +function! s:State.setPaused() abort dict + let self._paused = self._current +endfunction + +" Modeline {{{1 +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 From fef07323944f61c20722c006e194b9f84442fa98 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 14 Aug 2017 21:13:50 +1200 Subject: [PATCH 13/43] Separate {ex,u}ctags definitions out into individual files --- autoload/tagbar.vim | 745 +--------------------------- autoload/tagbar/typedefs/ctags.vim | 722 +++++++++++++++++++++++++++ autoload/tagbar/typedefs/uctags.vim | 726 +++++++++++++++++++++++++++ 3 files changed, 1459 insertions(+), 734 deletions(-) create mode 100644 autoload/tagbar/typedefs/ctags.vim create mode 100644 autoload/tagbar/typedefs/uctags.vim diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 99990a4..d159bf7 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -57,7 +57,6 @@ let s:init_done = 0 let s:checked_ctags = 0 let s:checked_ctags_types = 0 let s:ctags_is_uctags = 0 -let s:ctags_types = {} let s:new_window = 1 let s:is_maximized = 0 @@ -100,10 +99,6 @@ function! s:Init(silent) abort endif endif - if !s:checked_ctags_types - call s:GetSupportedFiletypes() - endif - if !s:type_init_done call s:InitTypes() endif @@ -121,344 +116,19 @@ endfunction function! s:InitTypes() abort call s:debug('Initializing types') - let s:known_types = {} + let supported_types = s:GetSupportedFiletypes() - " Ant {{{3 - let type_ant = tagbar#prototypes#typeinfo#new() - let type_ant.ctagstype = 'ant' - let type_ant.kinds = [ - \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.ant = type_ant - " Asm {{{3 - let type_asm = tagbar#prototypes#typeinfo#new() - let type_asm.ctagstype = 'asm' - let type_asm.kinds = [ - \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.asm = type_asm - " ASP {{{3 - let type_aspvbs = tagbar#prototypes#typeinfo#new() - let type_aspvbs.ctagstype = 'asp' - let type_aspvbs.kinds = [ - \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.aspvbs = type_aspvbs - " Asymptote {{{3 - " Asymptote gets parsed well using filetype = c - let type_asy = tagbar#prototypes#typeinfo#new() - let type_asy.ctagstype = 'c' - let type_asy.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let type_asy.sro = '::' - let type_asy.kind2scope = { - \ 'g' : 'enum', - \ 's' : 'struct', - \ 'u' : 'union' - \ } - let type_asy.scope2kind = { - \ 'enum' : 'g', - \ 'struct' : 's', - \ 'union' : 'u' - \ } - let s:known_types.asy = type_asy - " Awk {{{3 - let type_awk = tagbar#prototypes#typeinfo#new() - let type_awk.ctagstype = 'awk' - let type_awk.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.awk = type_awk - " Basic {{{3 - let type_basic = tagbar#prototypes#typeinfo#new() - let type_basic.ctagstype = 'basic' - let type_basic.kinds = [ - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.basic = type_basic - " BETA {{{3 - let type_beta = tagbar#prototypes#typeinfo#new() - let type_beta.ctagstype = 'beta' - let type_beta.kinds = [ - \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.beta = type_beta - " C {{{3 - let type_c = tagbar#prototypes#typeinfo#new() - let type_c.ctagstype = 'c' - let type_c.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let type_c.sro = '::' - let type_c.kind2scope = { - \ 'g' : 'enum', - \ 's' : 'struct', - \ 'u' : 'union' - \ } - let type_c.scope2kind = { - \ 'enum' : 'g', - \ 'struct' : 's', - \ 'union' : 'u' - \ } - let s:known_types.c = type_c - " C++ {{{3 - let type_cpp = tagbar#prototypes#typeinfo#new() - let type_cpp.ctagstype = 'c++' - let type_cpp.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_cpp.sro = '::' - let type_cpp.kind2scope = { - \ 'g' : 'enum', - \ 'n' : 'namespace', - \ 'c' : 'class', - \ 's' : 'struct', - \ 'u' : 'union' - \ } - let type_cpp.scope2kind = { - \ 'enum' : 'g', - \ 'namespace' : 'n', - \ 'class' : 'c', - \ 'struct' : 's', - \ 'union' : 'u' - \ } - let s:known_types.cpp = type_cpp - let s:known_types.cuda = type_cpp - " C# {{{3 - let type_cs = tagbar#prototypes#typeinfo#new() - let type_cs.ctagstype = 'c#' - let type_cs.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} - \ ] - let type_cs.sro = '.' - let type_cs.kind2scope = { - \ 'n' : 'namespace', - \ 'i' : 'interface', - \ 'c' : 'class', - \ 's' : 'struct', - \ 'g' : 'enum' - \ } - let type_cs.scope2kind = { - \ 'namespace' : 'n', - \ 'interface' : 'i', - \ 'class' : 'c', - \ 'struct' : 's', - \ 'enum' : 'g' - \ } - let s:known_types.cs = type_cs - " COBOL {{{3 - let type_cobol = tagbar#prototypes#typeinfo#new() - let type_cobol.ctagstype = 'cobol' - let type_cobol.kinds = [ - \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.cobol = type_cobol - " DOS Batch {{{3 - let type_dosbatch = tagbar#prototypes#typeinfo#new() - let type_dosbatch.ctagstype = 'dosbatch' - let type_dosbatch.kinds = [ - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.dosbatch = type_dosbatch - " Eiffel {{{3 - let type_eiffel = tagbar#prototypes#typeinfo#new() - let type_eiffel.ctagstype = 'eiffel' - let type_eiffel.kinds = [ - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} - \ ] - let type_eiffel.sro = '.' " Not sure, is nesting even possible? - let type_eiffel.kind2scope = { - \ 'c' : 'class', - \ 'f' : 'feature' - \ } - let type_eiffel.scope2kind = { - \ 'class' : 'c', - \ 'feature' : 'f' - \ } - let s:known_types.eiffel = type_eiffel - " Erlang {{{3 - let type_erlang = tagbar#prototypes#typeinfo#new() - let type_erlang.ctagstype = 'erlang' - let type_erlang.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} - \ ] - let type_erlang.sro = '.' " Not sure, is nesting even possible? - let type_erlang.kind2scope = { - \ 'm' : 'module' - \ } - let type_erlang.scope2kind = { - \ 'module' : 'm' - \ } - let s:known_types.erlang = type_erlang - " Flex {{{3 - " Vim doesn't support Flex out of the box, this is based on rough - " guesses and probably requires - " http://www.vim.org/scripts/script.php?script_id=2909 - " Improvements welcome! - let type_as = tagbar#prototypes#typeinfo#new() - let type_as.ctagstype = 'flex' - let type_as.kinds = [ - \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} - \ ] - let type_as.sro = '.' - let type_as.kind2scope = { - \ 'c' : 'class' - \ } - let type_as.scope2kind = { - \ 'class' : 'c' - \ } - let s:known_types.mxml = type_as - let s:known_types.actionscript = type_as - " Fortran {{{3 - let type_fortran = tagbar#prototypes#typeinfo#new() - let type_fortran.ctagstype = 'fortran' - let type_fortran.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, - \ 'stl' : 1}, - \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_fortran.sro = '.' " Not sure, is nesting even possible? - let type_fortran.kind2scope = { - \ 'm' : 'module', - \ 'p' : 'program', - \ 'f' : 'function', - \ 's' : 'subroutine' - \ } - let type_fortran.scope2kind = { - \ 'module' : 'm', - \ 'program' : 'p', - \ 'function' : 'f', - \ 'subroutine' : 's' - \ } - let s:known_types.fortran = type_fortran - " HTML {{{3 - let type_html = tagbar#prototypes#typeinfo#new() - let type_html.ctagstype = 'html' if s:ctags_is_uctags - let type_html.kinds = [ - \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'h', 'long' : 'H1 headings', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'H2 headings', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'j', 'long' : 'H3 headings', 'fold' : 0, 'stl' : 1}, - \ ] + let s:known_types = tagbar#typedefs#uctags#init(supported_types) else - let type_html.kinds = [ - \ {'short' : 'f', 'long' : 'JavaScript functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1} - \ ] + let s:known_types = tagbar#typedefs#ctags#init(supported_types) endif - let s:known_types.html = type_html - " Java {{{3 - let type_java = tagbar#prototypes#typeinfo#new() - let type_java.ctagstype = 'java' - let type_java.kinds = [ - \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} - \ ] - let type_java.sro = '.' - let type_java.kind2scope = { - \ 'g' : 'enum', - \ 'i' : 'interface', - \ 'c' : 'class' - \ } - let type_java.scope2kind = { - \ 'enum' : 'g', - \ 'interface' : 'i', - \ 'class' : 'c' - \ } - let s:known_types.java = type_java - " JavaScript {{{3 - " jsctags/doctorjs will be used if available. - let type_javascript = tagbar#prototypes#typeinfo#new() - let type_javascript.ctagstype = 'javascript' + + " Use jsctags/doctorjs if available let jsctags = s:CheckFTCtags('jsctags', 'javascript') if jsctags != '' + let type_javascript = tagbar#prototypes#typeinfo#new() + let type_javascript.ctagstype = 'javascript' let type_javascript.kinds = [ \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} @@ -473,402 +143,8 @@ function! s:InitTypes() abort \ } let type_javascript.ctagsbin = jsctags let type_javascript.ctagsargs = '-f -' - else - let type_javascript.kinds = [ - \ {'short': 'v', 'long': 'global variables', 'fold': 0, 'stl': 0}, - \ {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1}, - \ {'short': 'p', 'long': 'properties', 'fold': 0, 'stl': 0}, - \ {'short': 'm', 'long': 'methods', 'fold': 0, 'stl': 1}, - \ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1}, - \ ] - let type_javascript.sro = '.' - let type_javascript.kind2scope = { - \ 'c' : 'class', - \ 'f' : 'function', - \ 'm' : 'method', - \ 'p' : 'property', - \ } - let type_javascript.scope2kind = { - \ 'class' : 'c', - \ 'function' : 'f', - \ } + let s:known_types.javascript = type_javascript endif - let s:known_types.javascript = type_javascript - " Lisp {{{3 - let type_lisp = tagbar#prototypes#typeinfo#new() - let type_lisp.ctagstype = 'lisp' - let type_lisp.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.lisp = type_lisp - let s:known_types.clojure = type_lisp - " Lua {{{3 - let type_lua = tagbar#prototypes#typeinfo#new() - let type_lua.ctagstype = 'lua' - let type_lua.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.lua = type_lua - " Make {{{3 - let type_make = tagbar#prototypes#typeinfo#new() - let type_make.ctagstype = 'make' - let type_make.kinds = [ - \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.make = type_make - " Matlab {{{3 - let type_matlab = tagbar#prototypes#typeinfo#new() - let type_matlab.ctagstype = 'matlab' - let type_matlab.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.matlab = type_matlab - " Ocaml {{{3 - let type_ocaml = tagbar#prototypes#typeinfo#new() - let type_ocaml.ctagstype = 'ocaml' - let type_ocaml.kinds = [ - \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} - \ ] - let type_ocaml.sro = '.' " Not sure, is nesting even possible? - let type_ocaml.kind2scope = { - \ 'M' : 'Module', - \ 'c' : 'class', - \ 't' : 'type' - \ } - let type_ocaml.scope2kind = { - \ 'Module' : 'M', - \ 'class' : 'c', - \ 'type' : 't' - \ } - let s:known_types.ocaml = type_ocaml - " Pascal {{{3 - let type_pascal = tagbar#prototypes#typeinfo#new() - let type_pascal.ctagstype = 'pascal' - let type_pascal.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.pascal = type_pascal - " Perl {{{3 - let type_perl = tagbar#prototypes#typeinfo#new() - let type_perl.ctagstype = 'perl' - let type_perl.kinds = [ - \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.perl = type_perl - " PHP {{{3 - let type_php = tagbar#prototypes#typeinfo#new() - let type_php.ctagstype = 'php' - let type_php.kinds = [ - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.php = type_php - " Python {{{3 - let type_python = tagbar#prototypes#typeinfo#new() - let type_python.ctagstype = 'python' - let type_python.kinds = [ - \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_python.sro = '.' - let type_python.kind2scope = { - \ 'c' : 'class', - \ 'f' : 'function', - \ 'm' : 'function' - \ } - let type_python.scope2kind = { - \ 'class' : 'c', - \ 'function' : 'f' - \ } - if s:ctags_is_uctags - " Universal Ctags treats member functions differently from normal - " functions - let type_python.kind2scope.m = 'member' - let type_python.scope2kind.member = 'm' - endif - let s:known_types.python = type_python - let s:known_types.pyrex = type_python - let s:known_types.cython = type_python - " REXX {{{3 - let type_rexx = tagbar#prototypes#typeinfo#new() - let type_rexx.ctagstype = 'rexx' - let type_rexx.kinds = [ - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.rexx = type_rexx - " Ruby {{{3 - let type_ruby = tagbar#prototypes#typeinfo#new() - let type_ruby.ctagstype = 'ruby' - let type_ruby.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} - \ ] - let type_ruby.sro = '.' - let type_ruby.kind2scope = { - \ 'c' : 'class', - \ 'm' : 'class', - \ 'f' : 'class' - \ } - let type_ruby.scope2kind = { - \ 'class' : 'c' - \ } - let s:known_types.ruby = type_ruby - " Scheme {{{3 - let type_scheme = tagbar#prototypes#typeinfo#new() - let type_scheme.ctagstype = 'scheme' - let type_scheme.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.scheme = type_scheme - let s:known_types.racket = type_scheme - " Shell script {{{3 - let type_sh = tagbar#prototypes#typeinfo#new() - let type_sh.ctagstype = 'sh' - let type_sh.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.sh = type_sh - let s:known_types.csh = type_sh - let s:known_types.zsh = type_sh - " SLang {{{3 - let type_slang = tagbar#prototypes#typeinfo#new() - let type_slang.ctagstype = 'slang' - let type_slang.kinds = [ - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.slang = type_slang - " SML {{{3 - let type_sml = tagbar#prototypes#typeinfo#new() - let type_sml.ctagstype = 'sml' - let type_sml.kinds = [ - \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} - \ ] - let s:known_types.sml = type_sml - " SQL {{{3 - " The SQL ctags parser seems to be buggy for me, so this just uses the - " normal kinds even though scopes should be available. Improvements - " welcome! - let type_sql = tagbar#prototypes#typeinfo#new() - let type_sql.ctagstype = 'sql' - let type_sql.kinds = [ - \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.sql = type_sql - " Tcl {{{3 - let type_tcl = tagbar#prototypes#typeinfo#new() - let type_tcl.ctagstype = 'tcl' - let type_tcl.kinds = [ - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.tcl = type_tcl - " LaTeX {{{3 - let type_tex = tagbar#prototypes#typeinfo#new() - let type_tex.ctagstype = 'tex' - let type_tex.kinds = [ - \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} - \ ] - let type_tex.sro = '""' - let type_tex.kind2scope = { - \ 'p' : 'part', - \ 'c' : 'chapter', - \ 's' : 'section', - \ 'u' : 'subsection', - \ 'b' : 'subsubsection' - \ } - let type_tex.scope2kind = { - \ 'part' : 'p', - \ 'chapter' : 'c', - \ 'section' : 's', - \ 'subsection' : 'u', - \ 'subsubsection' : 'b' - \ } - let type_tex.sort = 0 - let s:known_types.tex = type_tex - " Vala {{{3 - " Vala is supported by the ctags fork provided by Anjuta, so only add the - " type if the fork is used to prevent error messages otherwise - if has_key(s:ctags_types, 'vala') || executable('anjuta-tags') - let type_vala = tagbar#prototypes#typeinfo#new() - let type_vala.ctagstype = 'vala' - let type_vala.kinds = [ - \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, - \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} - \ ] - let type_vala.sro = '.' - " 'enum' doesn't seem to be used as a scope, but it can't hurt to have - " it here - let type_vala.kind2scope = { - \ 's' : 'struct', - \ 'i' : 'interface', - \ 'c' : 'class', - \ 'e' : 'enum' - \ } - let type_vala.scope2kind = { - \ 'struct' : 's', - \ 'interface' : 'i', - \ 'class' : 'c', - \ 'enum' : 'e' - \ } - let s:known_types.vala = type_vala - endif - if !has_key(s:ctags_types, 'vala') && executable('anjuta-tags') - let s:known_types.vala.ctagsbin = 'anjuta-tags' - endif - " Vera {{{3 - " Why are variables 'virtual'? - let type_vera = tagbar#prototypes#typeinfo#new() - let type_vera.ctagstype = 'vera' - let type_vera.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} - \ ] - let type_vera.sro = '.' " Nesting doesn't seem to be possible - let type_vera.kind2scope = { - \ 'g' : 'enum', - \ 'c' : 'class', - \ 'v' : 'virtual' - \ } - let type_vera.scope2kind = { - \ 'enum' : 'g', - \ 'class' : 'c', - \ 'virtual' : 'v' - \ } - let s:known_types.vera = type_vera - " Verilog {{{3 - let type_verilog = tagbar#prototypes#typeinfo#new() - let type_verilog.ctagstype = 'verilog' - let type_verilog.kinds = [ - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.verilog = type_verilog - " VHDL {{{3 - " The VHDL ctags parser unfortunately doesn't generate proper scopes - let type_vhdl = tagbar#prototypes#typeinfo#new() - let type_vhdl.ctagstype = 'vhdl' - let type_vhdl.kinds = [ - \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.vhdl = type_vhdl - " Vim {{{3 - let type_vim = tagbar#prototypes#typeinfo#new() - let type_vim.ctagstype = 'vim' - let type_vim.kinds = [ - \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} - \ ] - let s:known_types.vim = type_vim - " YACC {{{3 - let type_yacc = tagbar#prototypes#typeinfo#new() - let type_yacc.ctagstype = 'yacc' - let type_yacc.kinds = [ - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.yacc = type_yacc - " }}}3 - - for [type, typeinfo] in items(s:known_types) - let typeinfo.ftype = type - endfor - - for typeinfo in values(s:known_types) - call typeinfo.createKinddict() - endfor call s:LoadUserTypeDefs() @@ -1288,13 +564,14 @@ function! s:GetSupportedFiletypes() abort let types = split(ctags_output, '\n\+') + let supported_types = {} for type in types if match(type, '\[disabled\]') == -1 - let s:ctags_types[tolower(type)] = 1 + let supported_types[tolower(type)] = 1 endif endfor - let s:checked_ctags_types = 1 + return supported_types endfunction " Known files {{{1 diff --git a/autoload/tagbar/typedefs/ctags.vim b/autoload/tagbar/typedefs/ctags.vim new file mode 100644 index 0000000..612c3d5 --- /dev/null +++ b/autoload/tagbar/typedefs/ctags.vim @@ -0,0 +1,722 @@ +" Type definitions for standard Exuberant Ctags + +function! tagbar#typedefs#ctags#init(supported_types) abort + let types = {} + + " Ant {{{1 + let type_ant = tagbar#prototypes#typeinfo#new() + let type_ant.ctagstype = 'ant' + let type_ant.kinds = [ + \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} + \ ] + let types.ant = type_ant + " Asm {{{1 + let type_asm = tagbar#prototypes#typeinfo#new() + let type_asm.ctagstype = 'asm' + let type_asm.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let types.asm = type_asm + " ASP {{{1 + let type_aspvbs = tagbar#prototypes#typeinfo#new() + let type_aspvbs.ctagstype = 'asp' + let type_aspvbs.kinds = [ + \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.aspvbs = type_aspvbs + " Asymptote {{{1 + " Asymptote gets parsed well using filetype = c + let type_asy = tagbar#prototypes#typeinfo#new() + let type_asy.ctagstype = 'c' + let type_asy.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_asy.sro = '::' + let type_asy.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_asy.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.asy = type_asy + " Awk {{{1 + let type_awk = tagbar#prototypes#typeinfo#new() + let type_awk.ctagstype = 'awk' + let type_awk.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.awk = type_awk + " Basic {{{1 + let type_basic = tagbar#prototypes#typeinfo#new() + let type_basic.ctagstype = 'basic' + let type_basic.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.basic = type_basic + " BETA {{{1 + let type_beta = tagbar#prototypes#typeinfo#new() + let type_beta.ctagstype = 'beta' + let type_beta.kinds = [ + \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} + \ ] + let types.beta = type_beta + " C {{{1 + let type_c = tagbar#prototypes#typeinfo#new() + let type_c.ctagstype = 'c' + let type_c.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_c.sro = '::' + let type_c.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_c.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.c = type_c + " C++ {{{1 + let type_cpp = tagbar#prototypes#typeinfo#new() + let type_cpp.ctagstype = 'c++' + let type_cpp.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_cpp.sro = '::' + let type_cpp.kind2scope = { + \ 'g' : 'enum', + \ 'n' : 'namespace', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_cpp.scope2kind = { + \ 'enum' : 'g', + \ 'namespace' : 'n', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.cpp = type_cpp + let types.cuda = type_cpp + " C# {{{1 + let type_cs = tagbar#prototypes#typeinfo#new() + let type_cs.ctagstype = 'c#' + let type_cs.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} + \ ] + let type_cs.sro = '.' + let type_cs.kind2scope = { + \ 'n' : 'namespace', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'g' : 'enum' + \ } + let type_cs.scope2kind = { + \ 'namespace' : 'n', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'enum' : 'g' + \ } + let types.cs = type_cs + " COBOL {{{1 + let type_cobol = tagbar#prototypes#typeinfo#new() + let type_cobol.ctagstype = 'cobol' + let type_cobol.kinds = [ + \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} + \ ] + let types.cobol = type_cobol + " DOS Batch {{{1 + let type_dosbatch = tagbar#prototypes#typeinfo#new() + let type_dosbatch.ctagstype = 'dosbatch' + let type_dosbatch.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.dosbatch = type_dosbatch + " Eiffel {{{1 + let type_eiffel = tagbar#prototypes#typeinfo#new() + let type_eiffel.ctagstype = 'eiffel' + let type_eiffel.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} + \ ] + let type_eiffel.sro = '.' " Not sure, is nesting even possible? + let type_eiffel.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'feature' + \ } + let type_eiffel.scope2kind = { + \ 'class' : 'c', + \ 'feature' : 'f' + \ } + let types.eiffel = type_eiffel + " Erlang {{{1 + let type_erlang = tagbar#prototypes#typeinfo#new() + let type_erlang.ctagstype = 'erlang' + let type_erlang.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} + \ ] + let type_erlang.sro = '.' " Not sure, is nesting even possible? + let type_erlang.kind2scope = { + \ 'm' : 'module' + \ } + let type_erlang.scope2kind = { + \ 'module' : 'm' + \ } + let types.erlang = type_erlang + " Flex {{{1 + " Vim doesn't support Flex out of the box, this is based on rough + " guesses and probably requires + " http://www.vim.org/scripts/script.php?script_id=2909 + " Improvements welcome! + let type_as = tagbar#prototypes#typeinfo#new() + let type_as.ctagstype = 'flex' + let type_as.kinds = [ + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} + \ ] + let type_as.sro = '.' + let type_as.kind2scope = { + \ 'c' : 'class' + \ } + let type_as.scope2kind = { + \ 'class' : 'c' + \ } + let types.mxml = type_as + let types.actionscript = type_as + " Fortran {{{1 + let type_fortran = tagbar#prototypes#typeinfo#new() + let type_fortran.ctagstype = 'fortran' + let type_fortran.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, + \ 'stl' : 1}, + \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_fortran.sro = '.' " Not sure, is nesting even possible? + let type_fortran.kind2scope = { + \ 'm' : 'module', + \ 'p' : 'program', + \ 'f' : 'function', + \ 's' : 'subroutine' + \ } + let type_fortran.scope2kind = { + \ 'module' : 'm', + \ 'program' : 'p', + \ 'function' : 'f', + \ 'subroutine' : 's' + \ } + let types.fortran = type_fortran + " HTML {{{1 + let type_html = tagbar#prototypes#typeinfo#new() + let type_html.ctagstype = 'html' + let type_html.kinds = [ + \ {'short' : 'f', 'long' : 'JavaScript functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1} + \ ] + let types.html = type_html + " Java {{{1 + let type_java = tagbar#prototypes#typeinfo#new() + let type_java.ctagstype = 'java' + let type_java.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_java.sro = '.' + let type_java.kind2scope = { + \ 'g' : 'enum', + \ 'i' : 'interface', + \ 'c' : 'class' + \ } + let type_java.scope2kind = { + \ 'enum' : 'g', + \ 'interface' : 'i', + \ 'class' : 'c' + \ } + let types.java = type_java + " JavaScript {{{1 + let type_javascript = tagbar#prototypes#typeinfo#new() + let type_javascript.ctagstype = 'javascript' + let type_javascript.kinds = [ + \ {'short': 'v', 'long': 'global variables', 'fold': 0, 'stl': 0}, + \ {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1}, + \ {'short': 'p', 'long': 'properties', 'fold': 0, 'stl': 0}, + \ {'short': 'm', 'long': 'methods', 'fold': 0, 'stl': 1}, + \ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1}, + \ ] + let type_javascript.sro = '.' + let type_javascript.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'method', + \ 'p' : 'property', + \ } + let type_javascript.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f', + \ } + let types.javascript = type_javascript + " Lisp {{{1 + let type_lisp = tagbar#prototypes#typeinfo#new() + let type_lisp.ctagstype = 'lisp' + let type_lisp.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.lisp = type_lisp + let types.clojure = type_lisp + " Lua {{{1 + let type_lua = tagbar#prototypes#typeinfo#new() + let type_lua.ctagstype = 'lua' + let type_lua.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.lua = type_lua + " Make {{{1 + let type_make = tagbar#prototypes#typeinfo#new() + let type_make.ctagstype = 'make' + let type_make.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} + \ ] + let types.make = type_make + " Matlab {{{1 + let type_matlab = tagbar#prototypes#typeinfo#new() + let type_matlab.ctagstype = 'matlab' + let type_matlab.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.matlab = type_matlab + " Ocaml {{{1 + let type_ocaml = tagbar#prototypes#typeinfo#new() + let type_ocaml.ctagstype = 'ocaml' + let type_ocaml.kinds = [ + \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} + \ ] + let type_ocaml.sro = '.' " Not sure, is nesting even possible? + let type_ocaml.kind2scope = { + \ 'M' : 'Module', + \ 'c' : 'class', + \ 't' : 'type' + \ } + let type_ocaml.scope2kind = { + \ 'Module' : 'M', + \ 'class' : 'c', + \ 'type' : 't' + \ } + let types.ocaml = type_ocaml + " Pascal {{{1 + let type_pascal = tagbar#prototypes#typeinfo#new() + let type_pascal.ctagstype = 'pascal' + let type_pascal.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.pascal = type_pascal + " Perl {{{1 + let type_perl = tagbar#prototypes#typeinfo#new() + let type_perl.ctagstype = 'perl' + let type_perl.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let types.perl = type_perl + " PHP {{{1 + let type_php = tagbar#prototypes#typeinfo#new() + let type_php.ctagstype = 'php' + let type_php.kinds = [ + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.php = type_php + " Python {{{1 + let type_python = tagbar#prototypes#typeinfo#new() + let type_python.ctagstype = 'python' + let type_python.kinds = [ + \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_python.sro = '.' + let type_python.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'function' + \ } + let type_python.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f' + \ } + let types.python = type_python + let types.pyrex = type_python + let types.cython = type_python + " REXX {{{1 + let type_rexx = tagbar#prototypes#typeinfo#new() + let type_rexx.ctagstype = 'rexx' + let type_rexx.kinds = [ + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let types.rexx = type_rexx + " Ruby {{{1 + let type_ruby = tagbar#prototypes#typeinfo#new() + let type_ruby.ctagstype = 'ruby' + let type_ruby.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_ruby.sro = '.' + let type_ruby.kind2scope = { + \ 'c' : 'class', + \ 'm' : 'class', + \ 'f' : 'class' + \ } + let type_ruby.scope2kind = { + \ 'class' : 'c' + \ } + let types.ruby = type_ruby + " Scheme {{{1 + let type_scheme = tagbar#prototypes#typeinfo#new() + let type_scheme.ctagstype = 'scheme' + let type_scheme.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} + \ ] + let types.scheme = type_scheme + let types.racket = type_scheme + " Shell script {{{1 + let type_sh = tagbar#prototypes#typeinfo#new() + let type_sh.ctagstype = 'sh' + let type_sh.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.sh = type_sh + let types.csh = type_sh + let types.zsh = type_sh + " SLang {{{1 + let type_slang = tagbar#prototypes#typeinfo#new() + let type_slang.ctagstype = 'slang' + let type_slang.kinds = [ + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.slang = type_slang + " SML {{{1 + let type_sml = tagbar#prototypes#typeinfo#new() + let type_sml.ctagstype = 'sml' + let type_sml.kinds = [ + \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} + \ ] + let types.sml = type_sml + " SQL {{{1 + " The SQL ctags parser seems to be buggy for me, so this just uses the + " normal kinds even though scopes should be available. Improvements + " welcome! + let type_sql = tagbar#prototypes#typeinfo#new() + let type_sql.ctagstype = 'sql' + let type_sql.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} + \ ] + let types.sql = type_sql + " Tcl {{{1 + let type_tcl = tagbar#prototypes#typeinfo#new() + let type_tcl.ctagstype = 'tcl' + let type_tcl.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.tcl = type_tcl + " LaTeX {{{1 + let type_tex = tagbar#prototypes#typeinfo#new() + let type_tex.ctagstype = 'tex' + let type_tex.kinds = [ + \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} + \ ] + let type_tex.sro = '""' + let type_tex.kind2scope = { + \ 'p' : 'part', + \ 'c' : 'chapter', + \ 's' : 'section', + \ 'u' : 'subsection', + \ 'b' : 'subsubsection' + \ } + let type_tex.scope2kind = { + \ 'part' : 'p', + \ 'chapter' : 'c', + \ 'section' : 's', + \ 'subsection' : 'u', + \ 'subsubsection' : 'b' + \ } + let type_tex.sort = 0 + let types.tex = type_tex + " Vala {{{1 + " Vala is supported by the ctags fork provided by Anjuta, so only add the + " type if the fork is used to prevent error messages otherwise + if has_key(a:supported_types, 'vala') || executable('anjuta-tags') + let type_vala = tagbar#prototypes#typeinfo#new() + let type_vala.ctagstype = 'vala' + let type_vala.kinds = [ + \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} + \ ] + let type_vala.sro = '.' + " 'enum' doesn't seem to be used as a scope, but it can't hurt to have + " it here + let type_vala.kind2scope = { + \ 's' : 'struct', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 'e' : 'enum' + \ } + let type_vala.scope2kind = { + \ 'struct' : 's', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'enum' : 'e' + \ } + let types.vala = type_vala + endif + if !has_key(a:supported_types, 'vala') && executable('anjuta-tags') + let types.vala.ctagsbin = 'anjuta-tags' + endif + " Vera {{{1 + " Why are variables 'virtual'? + let type_vera = tagbar#prototypes#typeinfo#new() + let type_vera.ctagstype = 'vera' + let type_vera.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} + \ ] + let type_vera.sro = '.' " Nesting doesn't seem to be possible + let type_vera.kind2scope = { + \ 'g' : 'enum', + \ 'c' : 'class', + \ 'v' : 'virtual' + \ } + let type_vera.scope2kind = { + \ 'enum' : 'g', + \ 'class' : 'c', + \ 'virtual' : 'v' + \ } + let types.vera = type_vera + " Verilog {{{1 + let type_verilog = tagbar#prototypes#typeinfo#new() + let type_verilog.ctagstype = 'verilog' + let type_verilog.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} + \ ] + let types.verilog = type_verilog + " VHDL {{{1 + " The VHDL ctags parser unfortunately doesn't generate proper scopes + let type_vhdl = tagbar#prototypes#typeinfo#new() + let type_vhdl.ctagstype = 'vhdl' + let type_vhdl.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.vhdl = type_vhdl + " Vim {{{1 + let type_vim = tagbar#prototypes#typeinfo#new() + let type_vim.ctagstype = 'vim' + let type_vim.kinds = [ + \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} + \ ] + let types.vim = type_vim + " YACC {{{1 + let type_yacc = tagbar#prototypes#typeinfo#new() + let type_yacc.ctagstype = 'yacc' + let type_yacc.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let types.yacc = type_yacc + " }}}1 + + for [type, typeinfo] in items(types) + let typeinfo.ftype = type + endfor + + for typeinfo in values(types) + call typeinfo.createKinddict() + endfor + + return types +endfunction + +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/autoload/tagbar/typedefs/uctags.vim b/autoload/tagbar/typedefs/uctags.vim new file mode 100644 index 0000000..5aead15 --- /dev/null +++ b/autoload/tagbar/typedefs/uctags.vim @@ -0,0 +1,726 @@ +" Type definitions for Universal Ctags + +function! tagbar#typedefs#uctags#init(supported_types) abort + let types = {} + + " Ant {{{1 + let type_ant = tagbar#prototypes#typeinfo#new() + let type_ant.ctagstype = 'ant' + let type_ant.kinds = [ + \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} + \ ] + let types.ant = type_ant + " Asm {{{1 + let type_asm = tagbar#prototypes#typeinfo#new() + let type_asm.ctagstype = 'asm' + let type_asm.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let types.asm = type_asm + " ASP {{{1 + let type_aspvbs = tagbar#prototypes#typeinfo#new() + let type_aspvbs.ctagstype = 'asp' + let type_aspvbs.kinds = [ + \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.aspvbs = type_aspvbs + " Asymptote {{{1 + " Asymptote gets parsed well using filetype = c + let type_asy = tagbar#prototypes#typeinfo#new() + let type_asy.ctagstype = 'c' + let type_asy.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_asy.sro = '::' + let type_asy.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_asy.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.asy = type_asy + " Awk {{{1 + let type_awk = tagbar#prototypes#typeinfo#new() + let type_awk.ctagstype = 'awk' + let type_awk.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.awk = type_awk + " Basic {{{1 + let type_basic = tagbar#prototypes#typeinfo#new() + let type_basic.ctagstype = 'basic' + let type_basic.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.basic = type_basic + " BETA {{{1 + let type_beta = tagbar#prototypes#typeinfo#new() + let type_beta.ctagstype = 'beta' + let type_beta.kinds = [ + \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} + \ ] + let types.beta = type_beta + " C {{{1 + let type_c = tagbar#prototypes#typeinfo#new() + let type_c.ctagstype = 'c' + let type_c.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let type_c.sro = '::' + let type_c.kind2scope = { + \ 'g' : 'enum', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_c.scope2kind = { + \ 'enum' : 'g', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.c = type_c + " C++ {{{1 + let type_cpp = tagbar#prototypes#typeinfo#new() + let type_cpp.ctagstype = 'c++' + let type_cpp.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_cpp.sro = '::' + let type_cpp.kind2scope = { + \ 'g' : 'enum', + \ 'n' : 'namespace', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'u' : 'union' + \ } + let type_cpp.scope2kind = { + \ 'enum' : 'g', + \ 'namespace' : 'n', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'union' : 'u' + \ } + let types.cpp = type_cpp + let types.cuda = type_cpp + " C# {{{1 + let type_cs = tagbar#prototypes#typeinfo#new() + let type_cs.ctagstype = 'c#' + let type_cs.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} + \ ] + let type_cs.sro = '.' + let type_cs.kind2scope = { + \ 'n' : 'namespace', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 's' : 'struct', + \ 'g' : 'enum' + \ } + let type_cs.scope2kind = { + \ 'namespace' : 'n', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'struct' : 's', + \ 'enum' : 'g' + \ } + let types.cs = type_cs + " COBOL {{{1 + let type_cobol = tagbar#prototypes#typeinfo#new() + let type_cobol.ctagstype = 'cobol' + let type_cobol.kinds = [ + \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} + \ ] + let types.cobol = type_cobol + " DOS Batch {{{1 + let type_dosbatch = tagbar#prototypes#typeinfo#new() + let type_dosbatch.ctagstype = 'dosbatch' + let type_dosbatch.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} + \ ] + let types.dosbatch = type_dosbatch + " Eiffel {{{1 + let type_eiffel = tagbar#prototypes#typeinfo#new() + let type_eiffel.ctagstype = 'eiffel' + let type_eiffel.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} + \ ] + let type_eiffel.sro = '.' " Not sure, is nesting even possible? + let type_eiffel.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'feature' + \ } + let type_eiffel.scope2kind = { + \ 'class' : 'c', + \ 'feature' : 'f' + \ } + let types.eiffel = type_eiffel + " Erlang {{{1 + let type_erlang = tagbar#prototypes#typeinfo#new() + let type_erlang.ctagstype = 'erlang' + let type_erlang.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} + \ ] + let type_erlang.sro = '.' " Not sure, is nesting even possible? + let type_erlang.kind2scope = { + \ 'm' : 'module' + \ } + let type_erlang.scope2kind = { + \ 'module' : 'm' + \ } + let types.erlang = type_erlang + " Flex {{{1 + " Vim doesn't support Flex out of the box, this is based on rough + " guesses and probably requires + " http://www.vim.org/scripts/script.php?script_id=2909 + " Improvements welcome! + let type_as = tagbar#prototypes#typeinfo#new() + let type_as.ctagstype = 'flex' + let type_as.kinds = [ + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} + \ ] + let type_as.sro = '.' + let type_as.kind2scope = { + \ 'c' : 'class' + \ } + let type_as.scope2kind = { + \ 'class' : 'c' + \ } + let types.mxml = type_as + let types.actionscript = type_as + " Fortran {{{1 + let type_fortran = tagbar#prototypes#typeinfo#new() + let type_fortran.ctagstype = 'fortran' + let type_fortran.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, + \ 'stl' : 1}, + \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_fortran.sro = '.' " Not sure, is nesting even possible? + let type_fortran.kind2scope = { + \ 'm' : 'module', + \ 'p' : 'program', + \ 'f' : 'function', + \ 's' : 'subroutine' + \ } + let type_fortran.scope2kind = { + \ 'module' : 'm', + \ 'program' : 'p', + \ 'function' : 'f', + \ 'subroutine' : 's' + \ } + let types.fortran = type_fortran + " HTML {{{1 + let type_html = tagbar#prototypes#typeinfo#new() + let type_html.ctagstype = 'html' + let type_html.kinds = [ + \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'h', 'long' : 'H1 headings', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'H2 headings', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'j', 'long' : 'H3 headings', 'fold' : 0, 'stl' : 1}, + \ ] + let types.html = type_html + " Java {{{1 + let type_java = tagbar#prototypes#typeinfo#new() + let type_java.ctagstype = 'java' + let type_java.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_java.sro = '.' + let type_java.kind2scope = { + \ 'g' : 'enum', + \ 'i' : 'interface', + \ 'c' : 'class' + \ } + let type_java.scope2kind = { + \ 'enum' : 'g', + \ 'interface' : 'i', + \ 'class' : 'c' + \ } + let types.java = type_java + " JavaScript {{{1 + let type_javascript = tagbar#prototypes#typeinfo#new() + let type_javascript.ctagstype = 'javascript' + let type_javascript.kinds = [ + \ {'short': 'v', 'long': 'global variables', 'fold': 0, 'stl': 0}, + \ {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1}, + \ {'short': 'p', 'long': 'properties', 'fold': 0, 'stl': 0}, + \ {'short': 'm', 'long': 'methods', 'fold': 0, 'stl': 1}, + \ {'short': 'f', 'long': 'functions', 'fold': 0, 'stl': 1}, + \ ] + let type_javascript.sro = '.' + let type_javascript.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'method', + \ 'p' : 'property', + \ } + let type_javascript.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f', + \ } + let types.javascript = type_javascript + " Lisp {{{1 + let type_lisp = tagbar#prototypes#typeinfo#new() + let type_lisp.ctagstype = 'lisp' + let type_lisp.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.lisp = type_lisp + let types.clojure = type_lisp + " Lua {{{1 + let type_lua = tagbar#prototypes#typeinfo#new() + let type_lua.ctagstype = 'lua' + let type_lua.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.lua = type_lua + " Make {{{1 + let type_make = tagbar#prototypes#typeinfo#new() + let type_make.ctagstype = 'make' + let type_make.kinds = [ + \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} + \ ] + let types.make = type_make + " Matlab {{{1 + let type_matlab = tagbar#prototypes#typeinfo#new() + let type_matlab.ctagstype = 'matlab' + let type_matlab.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.matlab = type_matlab + " Ocaml {{{1 + let type_ocaml = tagbar#prototypes#typeinfo#new() + let type_ocaml.ctagstype = 'ocaml' + let type_ocaml.kinds = [ + \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} + \ ] + let type_ocaml.sro = '.' " Not sure, is nesting even possible? + let type_ocaml.kind2scope = { + \ 'M' : 'Module', + \ 'c' : 'class', + \ 't' : 'type' + \ } + let type_ocaml.scope2kind = { + \ 'Module' : 'M', + \ 'class' : 'c', + \ 'type' : 't' + \ } + let types.ocaml = type_ocaml + " Pascal {{{1 + let type_pascal = tagbar#prototypes#typeinfo#new() + let type_pascal.ctagstype = 'pascal' + let type_pascal.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.pascal = type_pascal + " Perl {{{1 + let type_perl = tagbar#prototypes#typeinfo#new() + let type_perl.ctagstype = 'perl' + let type_perl.kinds = [ + \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let types.perl = type_perl + " PHP {{{1 + let type_php = tagbar#prototypes#typeinfo#new() + let type_php.ctagstype = 'php' + let type_php.kinds = [ + \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.php = type_php + " Python {{{1 + let type_python = tagbar#prototypes#typeinfo#new() + let type_python.ctagstype = 'python' + let type_python.kinds = [ + \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} + \ ] + let type_python.sro = '.' + let type_python.kind2scope = { + \ 'c' : 'class', + \ 'f' : 'function', + \ 'm' : 'function' + \ } + let type_python.scope2kind = { + \ 'class' : 'c', + \ 'function' : 'f' + \ } + let type_python.kind2scope.m = 'member' + let type_python.scope2kind.member = 'm' + let types.python = type_python + let types.pyrex = type_python + let types.cython = type_python + " REXX {{{1 + let type_rexx = tagbar#prototypes#typeinfo#new() + let type_rexx.ctagstype = 'rexx' + let type_rexx.kinds = [ + \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} + \ ] + let types.rexx = type_rexx + " Ruby {{{1 + let type_ruby = tagbar#prototypes#typeinfo#new() + let type_ruby.ctagstype = 'ruby' + let type_ruby.kinds = [ + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} + \ ] + let type_ruby.sro = '.' + let type_ruby.kind2scope = { + \ 'c' : 'class', + \ 'm' : 'class', + \ 'f' : 'class' + \ } + let type_ruby.scope2kind = { + \ 'class' : 'c' + \ } + let types.ruby = type_ruby + " Scheme {{{1 + let type_scheme = tagbar#prototypes#typeinfo#new() + let type_scheme.ctagstype = 'scheme' + let type_scheme.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} + \ ] + let types.scheme = type_scheme + let types.racket = type_scheme + " Shell script {{{1 + let type_sh = tagbar#prototypes#typeinfo#new() + let type_sh.ctagstype = 'sh' + let type_sh.kinds = [ + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.sh = type_sh + let types.csh = type_sh + let types.zsh = type_sh + " SLang {{{1 + let type_slang = tagbar#prototypes#typeinfo#new() + let type_slang.ctagstype = 'slang' + let type_slang.kinds = [ + \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} + \ ] + let types.slang = type_slang + " SML {{{1 + let type_sml = tagbar#prototypes#typeinfo#new() + let type_sml.ctagstype = 'sml' + let type_sml.kinds = [ + \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} + \ ] + let types.sml = type_sml + " SQL {{{1 + " The SQL ctags parser seems to be buggy for me, so this just uses the + " normal kinds even though scopes should be available. Improvements + " welcome! + let type_sql = tagbar#prototypes#typeinfo#new() + let type_sql.ctagstype = 'sql' + let type_sql.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} + \ ] + let types.sql = type_sql + " Tcl {{{1 + let type_tcl = tagbar#prototypes#typeinfo#new() + let type_tcl.ctagstype = 'tcl' + let type_tcl.kinds = [ + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.tcl = type_tcl + " LaTeX {{{1 + let type_tex = tagbar#prototypes#typeinfo#new() + let type_tex.ctagstype = 'tex' + let type_tex.kinds = [ + \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, + \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} + \ ] + let type_tex.sro = '""' + let type_tex.kind2scope = { + \ 'p' : 'part', + \ 'c' : 'chapter', + \ 's' : 'section', + \ 'u' : 'subsection', + \ 'b' : 'subsubsection' + \ } + let type_tex.scope2kind = { + \ 'part' : 'p', + \ 'chapter' : 'c', + \ 'section' : 's', + \ 'subsection' : 'u', + \ 'subsubsection' : 'b' + \ } + let type_tex.sort = 0 + let types.tex = type_tex + " Vala {{{1 + " Vala is supported by the ctags fork provided by Anjuta, so only add the + " type if the fork is used to prevent error messages otherwise + if has_key(a:supported_types, 'vala') || executable('anjuta-tags') + let type_vala = tagbar#prototypes#typeinfo#new() + let type_vala.ctagstype = 'vala' + let type_vala.kinds = [ + \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, + \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} + \ ] + let type_vala.sro = '.' + " 'enum' doesn't seem to be used as a scope, but it can't hurt to have + " it here + let type_vala.kind2scope = { + \ 's' : 'struct', + \ 'i' : 'interface', + \ 'c' : 'class', + \ 'e' : 'enum' + \ } + let type_vala.scope2kind = { + \ 'struct' : 's', + \ 'interface' : 'i', + \ 'class' : 'c', + \ 'enum' : 'e' + \ } + let types.vala = type_vala + endif + if !has_key(a:supported_types, 'vala') && executable('anjuta-tags') + let types.vala.ctagsbin = 'anjuta-tags' + endif + " Vera {{{1 + " Why are variables 'virtual'? + let type_vera = tagbar#prototypes#typeinfo#new() + let type_vera.ctagstype = 'vera' + let type_vera.kinds = [ + \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} + \ ] + let type_vera.sro = '.' " Nesting doesn't seem to be possible + let type_vera.kind2scope = { + \ 'g' : 'enum', + \ 'c' : 'class', + \ 'v' : 'virtual' + \ } + let type_vera.scope2kind = { + \ 'enum' : 'g', + \ 'class' : 'c', + \ 'virtual' : 'v' + \ } + let types.vera = type_vera + " Verilog {{{1 + let type_verilog = tagbar#prototypes#typeinfo#new() + let type_verilog.ctagstype = 'verilog' + let type_verilog.kinds = [ + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} + \ ] + let types.verilog = type_verilog + " VHDL {{{1 + " The VHDL ctags parser unfortunately doesn't generate proper scopes + let type_vhdl = tagbar#prototypes#typeinfo#new() + let type_vhdl.ctagstype = 'vhdl' + let type_vhdl.kinds = [ + \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, + \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} + \ ] + let types.vhdl = type_vhdl + " Vim {{{1 + let type_vim = tagbar#prototypes#typeinfo#new() + let type_vim.ctagstype = 'vim' + let type_vim.kinds = [ + \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, + \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, + \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} + \ ] + let types.vim = type_vim + " YACC {{{1 + let type_yacc = tagbar#prototypes#typeinfo#new() + let type_yacc.ctagstype = 'yacc' + let type_yacc.kinds = [ + \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} + \ ] + let types.yacc = type_yacc + " }}}1 + + for [type, typeinfo] in items(types) + let typeinfo.ftype = type + endfor + + for typeinfo in values(types) + call typeinfo.createKinddict() + endfor + + return types +endfunction + +" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 From 8a1bbcb4200bd170191531d427b0436b31eda211 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 19 Aug 2017 18:14:21 +1200 Subject: [PATCH 14/43] Create kinddict for jsctags type def Closes #431 Closes #432 --- autoload/tagbar.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index d159bf7..42d10cb 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -127,6 +127,7 @@ function! s:InitTypes() abort " Use jsctags/doctorjs if available let jsctags = s:CheckFTCtags('jsctags', 'javascript') if jsctags != '' + call s:debug('Detected jsctags, overriding typedef') let type_javascript = tagbar#prototypes#typeinfo#new() let type_javascript.ctagstype = 'javascript' let type_javascript.kinds = [ @@ -143,6 +144,7 @@ function! s:InitTypes() abort \ } let type_javascript.ctagsbin = jsctags let type_javascript.ctagsargs = '-f -' + call type_javascript.createKinddict() let s:known_types.javascript = type_javascript endif From 877a4a939cdf2d14f5b49543e4331c6ba4012d20 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sun, 20 Aug 2017 17:02:36 +1200 Subject: [PATCH 15/43] Extract debug functionality into separate file --- autoload/tagbar.vim | 225 ++++++++++++++------------------------ autoload/tagbar/debug.vim | 61 +++++++++++ plugin/tagbar.vim | 4 +- 3 files changed, 144 insertions(+), 146 deletions(-) create mode 100644 autoload/tagbar/debug.vim diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 42d10cb..483d9d6 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -81,8 +81,6 @@ let s:delayed_update_files = [] let g:loaded_tagbar = 1 let s:last_highlight_tline = 0 -let s:debug = 0 -let s:debug_file = '' let s:warnings = { \ 'type': [], @@ -114,7 +112,7 @@ endfunction " s:InitTypes() {{{2 function! s:InitTypes() abort - call s:debug('Initializing types') + call tagbar#debug#log('Initializing types') let supported_types = s:GetSupportedFiletypes() @@ -127,7 +125,7 @@ function! s:InitTypes() abort " Use jsctags/doctorjs if available let jsctags = s:CheckFTCtags('jsctags', 'javascript') if jsctags != '' - call s:debug('Detected jsctags, overriding typedef') + call tagbar#debug#log('Detected jsctags, overriding typedef') let type_javascript = tagbar#prototypes#typeinfo#new() let type_javascript.ctagstype = 'javascript' let type_javascript.kinds = [ @@ -174,12 +172,12 @@ function! s:LoadUserTypeDefs(...) abort if a:0 > 0 let type = a:1 - call s:debug("Initializing user type '" . type . "'") + call tagbar#debug#log("Initializing user type '" . type . "'") let defdict = {} let defdict[type] = g:tagbar_type_{type} else - call s:debug('Initializing user types') + call tagbar#debug#log('Initializing user types') let defdict = tagbar#getusertypes() endif @@ -238,11 +236,11 @@ endfunction " Properly restore Tagbar after a session got loaded function! s:RestoreSession() abort if s:init_done - call s:debug('Tagbar already initialized; not restoring session') + call tagbar#debug#log('Tagbar already initialized; not restoring session') return endif - call s:debug('Restoring session') + call tagbar#debug#log('Restoring session') let curfile = fnamemodify(bufname('%'), ':p') @@ -273,7 +271,7 @@ endfunction " s:MapKeys() {{{2 function! s:MapKeys() abort - call s:debug('Mapping keys') + call tagbar#debug#log('Mapping keys') nnoremap