如何在 VS Code 中自定义 Python 装饰器的颜色和字体样式?

问题描述 投票:0回答:1

我想自定义当前的配色方案,并将专用的颜色和字体样式斜体应用于Python装饰器。我通过编辑 settings.json 找到了如何进行评论(请参见下面的示例)。请问装饰器的正确关键字是什么?

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

提前致谢!

json visual-studio-code theming
1个回答
0
投票

settings.json:

"editor.tokenColorCustomizations": {
    "[Monokai]": { // 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": {
    "[Monokai]": { // 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",
            },
        },
    }
},
© www.soinside.com 2019 - 2024. All rights reserved.