我创建自定义语言
abc
,来自教程
https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide
,因此我的文件包含:
{
"contributes": {
"languages": [
{
"id": "abc",
"extensions": [".abc"]
}
],
"grammars": [
{
"language": "abc",
"scopeName": "source.abc",
"path": "./syntaxes/abc.tmGrammar.json"
}
]
}
}
abc.tmGrammar.json:
{
"scopeName": "source.abc",
"patterns": [{ "include": "#expression" }],
"repository": {
"expression": {
"patterns": [{ "include": "#letter" }, { "include": "#paren-expression" }]
},
"letter": {
"match": "a|b|c",
"name": "keyword.letter"
},
"paren-expression": {
"begin": "\\(",
"end": "\\)",
"beginCaptures": {
"0": { "name": "punctuation.paren.open" }
},
"endCaptures": {
"0": { "name": "punctuation.paren.close" }
},
"name": "expression.group",
"patterns": [{ "include": "#expression" }]
}
}
}
这是可行的,因为当我打开VSC时,我可以看到并拾取
abc
语言现在如何上色
expression.group
到#ff0000的代币?在哪里为它定义颜色?在里面
package.json
colors
贡献点?