Skip to content

Latest commit

 

History

History
102 lines (95 loc) · 3.5 KB

Overriding_Syntax.md

File metadata and controls

102 lines (95 loc) · 3.5 KB

Overriding Styles

If you like the syntax colours overall, but would like to tweak some aspect of it to your liking, here are the instructions to do so.

Important Note

Semantic highlighting only works if, a) the language extension supports it and, b) the code is in full context, i.e. within the main editor pane. Semantic highlighting does not work in places without context, such as the documentation hover widget, the git diff pane, etc. In such places, only the Textmate theming applies.

For a full list of scopes for each language, see Styles.md.

Font styles

These are the accepted font styles (make sure to get the exact spelling correct):

  • "bold"
  • "italic"
  • "underline"
  • "bold underline"
  • "italic underline"
  • "italic bold underline"
  • "strikethrough"
  • "" (empty; this clears any styles)

Semantic Overrides

Inside of your settings.json, you can insert the following snippet:

"editor.semanticTokenColorCustomizations": {
    "rules": {
        "SCOPE": {
            "foreground": "#00FFAA",  // This specifies the colour.
            "fontStyle": "FONT_STYLE" // This specifies the font style.
        }
    }
},

SCOPE refers to the semantic keyword, for example punctuation. If you want to only style a certain language, you can append the language name after the scope, like so: punctuation:rust.

Textmate Overrides

Inside of your settings.json, you can insert the following snippet:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "SCOPE"
            ],
            "settings": {
                "foreground": "#00FFAA",  // This specifies the colour.
                "fontStyle": "FONT_STYLE" // This specifies the font style.
            }
        }
    ]
}

SCOPE refers to the full scope of the token, for example punctuation.definition.string.rust.

Example

You don't want C# static functions to be underlined. You open Styles.md and navigate to the C Sharp section. Inside, you will find a sub-section Static Function, and in it there is the following line:

- s: "member.static"

Now, inside of your settings.json, you write:

"editor.semanticTokenColorCustomizations": {
    "rules": {
        "member.static:csharp": {
            "fontStyle": "" // Removes the underline.
        }
    }
},

In this example, we only modified the semantic highlighting because the textmate theming does not support static functions.

Example

You want Rust lifetime annotations to be a different colour. You open Styles.md and navigate to the Rust section. Inside, you will find a sub-section Lifetimes, and in it there are the following lines:

- s: "lifetime"
- tm: "punctuation.definition.lifetime.rust"
- tm: "entity.name.type.lifetime.rust"
- tm: "storage.modifier.lifetime.rust"

Now, inside of your settings.json, you write:

"editor.semanticTokenColorCustomizations": {
    "rules": {
        "lifetime:rust": {
            "foreground": "#00FF00"
        }
    }
},
"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "punctuation.definition.lifetime.rust",
                "entity.name.type.lifetime.rust",
                "storage.modifier.lifetime.rust"
            ],
            "settings": {
                "foreground": "#00FF00"
            }
        }
    ]
}

In this example, we had to modify the semantic and textmate scopes since both support styling lifetime annotations.