skip to Main Content

I would like to customize my current color scheme and apply a dedicated color and fontstyle italic to Python Decorators. I found out how to do it for comments by editing the settings.json (see example below). What is the correct keyword for the decorators, please?

"editor.tokenColorCustomizations": {
    "comments": "#b249ee",
},

Thanks in advance!

2

Answers


  1. In settings.json:

    "editor.tokenColorCustomizations": {
        "[Your Theme Name Here]": { // remove this wrapper to apply regardless of colour theme
            "textMateRules": [{
                "scope": "punctuation.definition.decorator.python", // for the decorator name. only applies when semantic highlighting from the Python extension is not in effect.
                "settings": {
                    "foreground": "#FF0000",
                    // "fontStyle": "bold"
                }
            },{
                "scope": "meta.function.decorator.python support.type.python", // for the "@" sign
                "settings": {
                    "foreground": "#FF0000",
                    // "fontStyle": "bold"
                }
            }],
        },
    },
    "editor.semanticHighlighting.enabled": false,
    "editor.semanticTokenColorCustomizations": {
        "[Your Theme Name Here]": { // remove this wrapper to apply regardless of colour theme
            "enabled": false,
            "rules": {
                "class.decorator:python": { // remove ":python" to apply to all languages
                    "foreground": "#FF0000",
                    // "fontStyle": "bold",
                },
            },
        }
    },
    
    Login or Signup to reply.
  2. Use the scope checkup to view text information (Developer: Inspect Editor Tokens and Scopes),

    enter image description here

    Then edit the editor.tokenColorCustomizations and editor.semanticTokenColorCustomizations settings to achieve the effect you want.

    https://code.visualstudio.com/docs/getstarted/themes#_editor-syntax-highlighting

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search