Skip to content

FR: syntax inclusions when using the LaTeX package 'robust-externalize' #2977

Closed
@kiryph

Description

Is your feature request related to a problem? Please describe it.

I would like to have syntax highlighting for parts in a different language than LaTeX when using the LaTeX package "robust-externalize" (ctan, github).

Example file: https://github.com/jlelong/vscode-latex-basics/blob/main/test/colorize-fixtures/robust-externalize.tex

The test file misses \usepackage{robust-externalize} which is probably important for vimtex. Hence I added it manually:

Screenshot 2024-07-10 at 09 48 48

VimTeX misses highlighting for c, bash and python.

Describe the solution you'd like
A similar solution to the way support was added in LaTeX Workshop in its Textmate LaTeX grammar:

jlelong/vscode-latex-basics#79

which renders the file in Visual Studio Code as following:

Screenshot 2024-07-10 at 09 42 20

To recap the most important things:

  1. 'robust-externalize' allows user to define custom presets for any language. This means the inclusion mechanism must work similar to fenced code in markdown files by matching the specified language.
  2. The environments are CacheMeCode, PlaceholderPathFromCode, PlaceholderFromCode, SetPlaceholderCode.
  3. The naming scheme of presets or placeholders should follow this
    • <lang> (example python)
    • <lang> <variant> (example python print code and result)
    • <version> <lang> <variant> (example my python matplotlib)
    • __<LANG>_<STRING>__
  4. The names occur as the first argument in the curly braces after the opening of an environment.

Describe alternatives you've considered

Switching editor or using tree-sitter injections. Both are not viable. The latter does not work with vimtex.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions