4

I'm trying to alter a theme to be more suitable for my daily use but I'm having some trouble trying to customize a specific word or pattern.

I'm using this format at the moment;

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "foreground": "#ff0000",
            }
        },
    ]
}

Is it possible to format specific keywords or patterns rather than scopes?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Darren A.
  • 77
  • 2
  • 6

1 Answers1

4

To apply syntax highlighting to specific keywords and other language constructs you need to write an extension with a grammar to parse the syntax for the language. When you write such an extension you also define the scope for each language construct.

For example, in a language support extension I might match the keyword function and give it the scope entity.name.function:

<key>FunctionKeyword</key>
<dict>
    <key>match</key>
    <string>function</string>
    <key>name</key>
    <string>entity.name.function</string>
</dict>

As an end user you can override how your theme colors a scope, but you don't have a way to change how the language support assigns a scope to a language construct.

TL;DR: no, you can't.

Matt
  • 3,677
  • 1
  • 14
  • 24