Skip to content

Semantic Highlighting

0dinD edited this page Sep 14, 2020 · 6 revisions

Semantic Highlighting is a new feature introduced in VS Code 1.43. It allows color themes to use information from a language server in addition to TextMate grammars. Since VS Code 1.44, theme authors can write rules to color semantic tokens provided by language extensions like this one. If your current color theme does not provide any semantic highlighting rules, you can define your own in the user settings, e.g.

"editor.semanticTokenColorCustomizations": {
    "enabled": true, // If not already enabled by your color theme
    "rules": {
        "class": "#ff0000", // Change color for tokens of type 'class'
        "parameter": {
            "foreground": "#00ff0d" // Change color for tokens of type 'parameter'
        },
        "*.static": {
            "fontStyle": "italic" // All tokens with modifier 'static' should be of italic style
        },
        "*.readonly": {
            "fontStyle": "bold" // All tokens with modifier 'readonly' (final) should be of bold style
        }
    }
}

More details can be found on the Semantic Highlighting Wiki Page.

Note

Semantic Highlighting is enabled by default, and fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience a few minor issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server when opening a new file or when typing. The feature can be disabled by setting the java.semanticHighlighting.enabled preference to false.

Clone this wiki locally