sponsor Vim development Vim logo Vim Book Ad

ctags mtable parser syntax : Syntax file for writing multi-table parsers in *.ctags files

 script karma  Rating 0/0, Downloaded by 86  Comments, bugs, improvements  Vim wiki

created by
Timothy Madden
script type
Syntax file for ctags options from *.ctags, files used to write stateful mtable (multi-table) parsers for ctags, based on regular expression tables.

See https://docs.ctags.io/en/latest/optlib.html for writing ctags parsers.

Only for mtable parsers (the recommended type using `--_mtable-regex-`).

Parses using line regexps `--regex-` and multi-line regexps `--mline-regex-` are not highlighted. Some other `ctags` options are included as well, but unrelated options will not be highlighted.

POSIX Extened Regular expressions (EREs, the default in ctags) are highlighted as plain strings by default. But for any real work on a parser, you should enable highlighting inside the regular expressions with:

    * :let g:ctags_syntax_show_regexp = v:true
    * :let b:ctags_syntax_show_regexp = -1

The buffer variable b:ctags_syntax_show_regex has precedence over the global variable g:ctags_syntax_show_regexp. Use a true value to enable highlighting, as follows:

    * use a negative value (-1) for monochrome highlighting of the regular expressions. Easier to read if you want to browse the source code of a ctags parser
    * use a positive value (v:true or 1) for full-color highlighting of the regular expressions. This is what you usually want to develop a new parser

Non-default regular expressions (POSIX basic RE (BRE) and pcre2) are detected and will not be highlighted.

Some errors in a regular expression can be higlighted by the syntax, and will be shown in the right color (if you enabled regex colors).

Some corner cases for character ranges, usually of the form [^]a-z] or [],|0-9] (notice the closing bracket inside) cannot be fully highlighted yet, so the nested closing bracket will take the color of the delimiter (same as the opening bracket), instead of the content color.

   - night-owl color scheme:  https://ibb.co/ncLpV0B
   - toast color scheme:        https://ibb.co/wRczkGd
   - duoduo color scheme:    https://ibb.co/xhdsdcw

This is only a syntax plugin, not a file type. To avoid manual loading of the syntax, you can add these lines to your vimrc file, after installation:

    autocmd BufNewFile,BufRead *.ctags setfiletype ctags
    autocmd FileType ctags setlocal syntax=ctags

The Ghostscript code blocks for optscript (for --_mtable-regex, --_prelude and --_sequel options) are matched by the regexps, but not currently highlighted as PostScript , because somehow the nested PostScript syntax breaks the main ctags syntax.

You can adjust the highlighting, if it does not look good on your color scheme or your monitor settings:
  - create a new file ~/.vim/after/syntax/ctags.vim
  - check for the specific color scheme using:
       if exists('g:colors_name') && g:colors_name == 'colorscheme'
  - change highlighting for any of the below elements with in the if/endif above:
         highlight link ctagsStatement Statement
         highlight link ctagsLanguageName Type
         highlight link ctagsFlagName Keyword
         highlight link ctagsFlagNameLetter Keyword

See all items to be highlighted at the end for the script file, installed at ~/.vim/syntax/ctags.vim.

The syntax items above will look familiar if you already know about ctags fields, kinds, roles, extras, languages, regex flags
install details
Download the vimball archive, open it in Vim, and source it:

:edit ~/Downloads/ctags-mtable-parser-syntax.vmb
:source %

(you could also install the plugin with the built-in :GetLatestVimScripts command, but you need script #6094 first, to bring the old command up-to-date:

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ctags-mtable-parser-syntax-0.5.vmb 0.5 2024-06-12 7.0 Timothy Madden * Fix error highlight for wrong achor placement (^$) inside regular expression
ctags-mtable-parser-syntax.vmb 0.4 2024-06-11 7.0 Timothy Madden * Highlight --_prelude and --_squel options for optscript (ghostscript)
* Disable inclusion of PostScript syntax as it breaks existing syntax
ctags-mtable-parser-syntax.vmb 0.3 2024-06-11 7.0 Timothy Madden * Option to enable POSIX extended regular expression highlighting
* Add support for postscript code block at the end of the _mtable-regexp command
ctags-mtable-parser-syntax.vmb 0.2 2024-06-09 7.0 Timothy Madden * Fixed highlighting for end brace for {_field=name:value} flag
* Fixed highlighting for regexp separator in --_mtable_regexp-LANG= option
* Add GetLatestVimScripts header with ;:AutoInstall: option
ctags-mtable-parser-syntax.vmb 0.1 2024-06-09 7.0 Timothy Madden Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
Vim at Github