preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.1k stars 485 forks source link

Fixes #811, #799: Add language specific regex support for custom tag kinds #812

Closed raven42 closed 2 years ago

raven42 commented 2 years ago

Fixes #811 and #799

This will add custom tag kind support on a per-language level. It is not feasible to provide a global definition as the tag kind identifier must be unique, and each language has a different set of kinds defined for it. So this way we can at least allow a per-language custom definition for any custom tags that the user may wish to add using a --regex-<lang>=<regex> option for the ctags command. This will be flexible enough to allow adding the TODO type tag kinds as requested in #811, but will also provide a framework for a more general approach to allow any custom tag kinds to be added based on what the user is needing.

For the case in #799, we can add the following regex definition. Note: this does not allow for scope information for the function, but it does at least provide an option for the async <function> (<args>) type syntax which is better than what we have today.

let g:tagbar_type_javascript = {
        \ 'ctagstype'   : 'javascript',
        \ 'regex'       : [
            \ '/async[ \t]+(.*)[ \t]*\(.*\)/\1/f/func/function/',
        \ ],
        ... # Rest of the definition here
    \ }