asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
323 stars 97 forks source link

Highlighting variables #677

Open mramendi opened 1 year ago

mramendi commented 1 year ago

In Atom, when I write a variable, such as {context}, the variable gets highlighted. In VSCode only the brackets get highlighted. Is it possible to highlight the entire variable?

ggrossetie commented 1 year ago

We currently rely on on a TextMate grammar: https://github.com/asciidoctor/asciidoctor-vscode/blob/master/syntaxes/Asciidoctor.json

More specifically: https://github.com/asciidoctor/asciidoctor-vscode/blob/be5055d2f5f314c865f0b6cd597d2714e0802f4c/syntaxes/Asciidoctor.json#L736-L764

I believe support.constant.attribute-name.asciidoc is not mapped/recognized by TextMate-based themes. We should probably define/contribute custom scope mapping: https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#custom-textmate-scope-mappings

You can use the "Developer: Inspect Editor Tokens and Scopes" command to debug:

image

Please note that you can also extend your theme. Here's an example with "Dark +":

{
    "editor.tokenColorCustomizations": {
            "textMateRules": [
                {
                    "scope": "markup.substitution.attribute-reference.asciidoc",
                    "settings": {
                        "foreground": "#ffd700",
                        "fontStyle": "bold"
                    }
                }
            ],
    }
}

image

References: