VS Code:如何在颜色主题中使用语义标记?
VS Code : how to use a semantic token in color theme?
我尝试更新我为 VS Code 制作的颜色主题(简单焦点),但我从未找到任何关于如何使用新语义标记的主题创建者指南...
我在我的主题中设置了"semanticHighlighting" : true
例如,我想给 class 上色,class 定义 (entity.name.type.class.js
) 和创建 (entity.name.type.js
) 有特定的 textMate 范围,但是当否则使用 class——比如 MyClass.props = {}
——唯一的作用域是一个通用的 variable.other.object.js
,我不想碰它,因为它会弄乱其他东西。因此,当我检查范围时,我看到语义标记 class
也匹配所有 classes 定义和创建,但我们应该如何使用它?
我天真地尝试只添加一个范围 "class",但它不起作用。
我能找到的关于语义标记的所有信息都与创建自定义语言有关,与主题创建者无关,所以我的猜测是它只是假设像 textMate 范围一样工作,但事实并非如此。请哪位大神赐教!
inspecting scopes
在您的主题文件中,您需要添加 semanticTokenColors
,据我所知,这些将覆盖您在 tokenColors
中设置的颜色。语法类似于 tokenColors
但您还可以为每个标记指定修饰符,例如 class.defaultLibrary
或 class.declaration
您还可以通过设置 *.declaration
[=23= 一次设置所有修饰符]
这是一个示例
"semanticTokenColors": {
"namespace": "#ffffff",
"type": "#ffffff",
"struct": "#ffffff",
"class": "#ffffff",
"class.readonly": {
"foreground": "#ffffff",
"fontStyle": "bold italic"
},
"*.declaration" : {
"fontStyle": "bold"
},
"*.readonly" : "#ffffff",
}
您可以找到所有范围和修饰符 here
Standard semantic token types:
namespace
type, class, enum, interface, struct, typeParameter
parameter, variable, property, enumMember, event
function, member, macro
label
comment, string, keyword, number, regexp, operator
Standard semantic token modifiers:
declaration
readonly, static, deprecated, abstract
async, modification, documentation, defaultLibrary
我尝试更新我为 VS Code 制作的颜色主题(简单焦点),但我从未找到任何关于如何使用新语义标记的主题创建者指南...
我在我的主题中设置了"semanticHighlighting" : true
例如,我想给 class 上色,class 定义 (entity.name.type.class.js
) 和创建 (entity.name.type.js
) 有特定的 textMate 范围,但是当否则使用 class——比如 MyClass.props = {}
——唯一的作用域是一个通用的 variable.other.object.js
,我不想碰它,因为它会弄乱其他东西。因此,当我检查范围时,我看到语义标记 class
也匹配所有 classes 定义和创建,但我们应该如何使用它?
我天真地尝试只添加一个范围 "class",但它不起作用。
我能找到的关于语义标记的所有信息都与创建自定义语言有关,与主题创建者无关,所以我的猜测是它只是假设像 textMate 范围一样工作,但事实并非如此。请哪位大神赐教!
inspecting scopes
在您的主题文件中,您需要添加 semanticTokenColors
,据我所知,这些将覆盖您在 tokenColors
中设置的颜色。语法类似于 tokenColors
但您还可以为每个标记指定修饰符,例如 class.defaultLibrary
或 class.declaration
您还可以通过设置 *.declaration
[=23= 一次设置所有修饰符]
这是一个示例
"semanticTokenColors": {
"namespace": "#ffffff",
"type": "#ffffff",
"struct": "#ffffff",
"class": "#ffffff",
"class.readonly": {
"foreground": "#ffffff",
"fontStyle": "bold italic"
},
"*.declaration" : {
"fontStyle": "bold"
},
"*.readonly" : "#ffffff",
}
您可以找到所有范围和修饰符 here
Standard semantic token types:
namespace
type, class, enum, interface, struct, typeParameter
parameter, variable, property, enumMember, event
function, member, macro
label
comment, string, keyword, number, regexp, operator
Standard semantic token modifiers:
declaration
readonly, static, deprecated, abstract
async, modification, documentation, defaultLibrary