VSCode TextMate 颜色规则被覆盖,我不知道被什么覆盖了

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

我正在尝试更改 Python 中

==
!=
比较运算符的颜色,但即使正确设置了 textMate 规则(如下图所示),颜色也不会改变,并且范围具有我以前从未见过的奇怪的覆盖属性。

接下来,我四处搜索,发现这可能是由语义突出显示引起的,事实上,当关闭它时,它会停止覆盖 textMate (也很奇怪地注意到,它只在语义突出显示覆盖的特定范围内),所以我尝试将以下规则添加到我的

settings.json
并将语义突出显示设置为 `configuredByTheme:

"editor.semanticTokenColorCustomizations": {
        "[One Dark Pro Flat]": {
            "rules": {
                "keyword.operator.comparison.python": "#00cf80"
            }
        }
    }

但这没有用,现在我没有主意了。有人可以帮我吗?

visual-studio-code themes syntax-highlighting
1个回答
0
投票

当语义突出显示由语言支持扩展提供,并且启用语义突出显示(默认设置

"editor.semanticHighlighting.enabled": "configuredByTheme"
),并且为标记提供语义突出显示时,它将优先于任何基于 TextMate 的语法突出显示进行突出显示。这正是这里发生的事情。

Python 扩展提供的语义标记是

operator
,带有修饰符
overridden
==
运算符 test_matrix
 变量的类覆盖)。要么禁用语义突出显示(可能不是您想要的),要么将以下内容添加到您的settings.json:

"editor.semanticTokenColorCustomizations": { "[Your Theme Name Here]": { // remove wrapper to apply regardless of colour theme. "rules": { "operator:python": { // remove ":python" to apply regardless of language "foreground": "#FF0000", // TODO // "fontStyle": "bold", }, }, }, },
以上内容适用于 Python 文件中的任何 

operator

 语义标记。如果您想单独为覆盖的运算符着色,请使用 
operator.overridden:python
 代替。另请参阅
https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide

© www.soinside.com 2019 - 2024. All rights reserved.