我有一个包含以下组件的脚本:
- 条款:
/[a-z][a-z0-9]*(?:-[a-z0-9]+)*/
- 字符串:
<.+>
- 数字:
\d+
但是,字符串也可以是“模板字符串”,并且在内部具有嵌套的术语/字符串/数字。它们由{...}
大括号分隔,如下所示:
term <string {term(another-term, 123)}>
如何让 VSCode 正确突出显示模板字符串内大括号内的内容?我用它来生成一个项目,它给了我这个<mystring>.tmLanguage.json
:
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "myscript",
"patterns": [
{
"include": "#terms"
},
{
"include": "#strings"
},
{
"include": "#numbers"
}
],
"repository": {
"terms": {
"patterns": [
{
"name": "term.control.myscript",
"match": "\\b([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\\b"
},
{
"name": "term.context.myscript",
"match": "\\b(\\{[^\\}]+\\})\\b"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.integer.myscript",
"match": "\\b(\\d+)\\b"
},
{
"name": "constant.numeric.decimal.myscript",
"match": "\\b(\\d+\\.\\d+)\\b"
}
]
},
"strings": {
"name": "string.quoted.double.myscript",
"begin": "<",
"end": ">",
"patterns": [
{
"name": "constant.character.escape.myscript",
"match": "\\\\."
}
]
}
},
"scopeName": "source.myscript"
}
但是,我得到了这个:
我以前从未为编辑器做过语法高亮,所以不确定在哪里真正调试。