gpt4 book ai didi

visual-studio-code - 覆盖 VS Code 中的默认语法着色

转载 作者:行者123 更新时间:2023-12-02 16:37:40 25 4
gpt4 key购买 nike

我正在尝试覆盖 VS Code 中的默认语法着色。特别是默认主题“Light (Visual Studio)”中的#a31515(红色)颜色我想看到#036A07(绿色)颜色。

为此,在我的用户设置 settings.json 文件的 editor.tokenColorCustomizations 中,我更改了这个默认值:

"editor.tokenColorCustomizations": null

到:

"editor.tokenColorCustomizations": {
"markup.deleted": "#036A07",
"meta.preprocessor.string": "#036A07",
"string": "#036A07",
"entity.name.operator.custom-literal.string": "#036A07",
"meta.embedded.assembly": "#036A07"
}

我保存了 settings.json 文件并重新启动了 VS 代码,但我没有看到代码突出显示有任何变化(与之前相同的红色):

enter image description here




问题:我的代码有什么问题,正确的代码是什么?


根据下面@tHeSiD 的回答,我创建了这段代码并且它有效:

"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Single Quotes",
"scope": "string.quoted.single.python",
"settings": {
"fontStyle": "",
"foreground": "#036A07"
}
}]
}

仅针对特定主题的设置:

"editor.tokenColorCustomizations": {
"[Visual Studio Light]": {
"textMateRules": [
{
"name": "Single Quotes",
"scope": "string.quoted.single.python",
"settings": {
"fontStyle": "",
"foreground": "#036A07"
}
}]
}
}

它也可以在不将 editor.semanticHighlighting.enabled 设置为 false 的情况下工作

最佳答案

您必须像这样添加每个范围定义。

要获得所需范围 - 使用命令面板 (CTRL SHIFT P),然后选择 Developer: Inspect Editor Tokens and Scopes

scopes

  "editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Deleted",
"scope": "markup.deleted",
"settings": {
"fontStyle": "italic",
"foreground": "#036A07"
}
},
{
"name": "Strings",
"scope": "meta.preprocessor.string",
"settings": {
"fontStyle": "italic"
}
},
{
"name": "ThisIsJustANameForReference",
//You can use coma separated scopes to group them into one
"scope": "entity.name.operator.custom-literal.string, meta.embedded.assembly",
"settings": {
"foreground": "#036A07"
}
},
]
},

这些是 textmate 规则,你必须禁用语义突出显示才能工作。为此添加 "editor.semanticHighlighting.enabled": false

如果你想通过语义高亮为所有内容着色,你必须使用这样的东西。

"semanticTokenColors": {
"namespace": "#ffffff",
"type": "#ffffff",
"struct": "#ffffff",
"class": "#ffffff",
"class.readonly": {
"foreground": "#ffffff",
"fontStyle": "bold italic"
},
"*.declaration" : {
"fontStyle": "bold"
},
"*.readonly" : "#ffffff",
}

关于visual-studio-code - 覆盖 VS Code 中的默认语法着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62352436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com