如何在下图中突出显示此部分:
函数foo 输入x,默认 123 输入y 调用z , x , y
基本上,任何嵌套在其他东西中的东西都应该是黑色的,而“父”对象应该是其他颜色(理想情况下是灰色,但可以是任何其他颜色)。我如何告诉它“模式:[#terms.gray,后跟#terms.black 或#strings]”之类的东西?
到目前为止我有这个:
鉴于此语法:
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "myscript",
"patterns": [
{
"include": "#terms"
},
{
"include": "#punctuations"
},
{
"include": "#strings"
},
{
"include": "#numbers"
},
{
"include": "#codes"
}
],
"repository": {
"codes": {
"patterns": [
{
"name": "constant.character.escape.language.myscript",
"match": "\\#\\w+"
}
]
},
"terms": {
"patterns": [
{
"name": "term.language.myscript",
"match": "([a-z][a-z0-9]*(?:-[a-z0-9]+)*)"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.integer.myscript",
"match": "\\b(\\d+)\\b"
},
{
"name": "constant.numeric.decimal.myscript",
"match": "\\b(\\d+\\.\\d+)\\b"
}
]
},
"punctuations": {
"patterns": [
{
"name": "punctuation.separator.parameter.myscript",
"match": ","
},
{
"name": "punctuation.curly.open.myscript",
"match": "\\{"
},
{
"name": "punctuation.curly.close.myscript",
"match": "\\}"
}
]
},
"strings": {
"name": "template.myscript",
"begin": "\\<",
"beginCaptures": {
"0": {
"name": "string.quoted.other.myscript"
}
},
"end": "\\>",
"endCaptures": {
"0": {
"name": "string.quoted.other.myscript"
}
},
"patterns": [
{
"name": "constant.character.escape.myscript",
"match": "\\\\."
},
{
"include": "#codes"
},
{
"name": "punctuation.term.myscript",
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "string.quoted.other.myscript"
}
},
"end": "\\}",
"endCaptures": {
"0": {
"name": "string.quoted.other.myscript"
}
},
"patterns": [
{
"include": "#terms"
},
{
"include": "#numbers"
},
{
"include": "#strings"
},
{
"include": "#punctuations"
},
{
"include": "#codes"
}
]
},
{
"name": "string.quoted.other",
"match": "[^\\#\\{\\}\\>]+"
}
]
}
},
"scopeName": "source.myscript"
}
我可以开始这样做:
"terms": {
"patterns": [
{
"name": "term.language.myscript",
"match": "([a-z][a-z0-9]*(?:-[a-z0-9]+)*) ([a-z][a-z0-9]*(?:-[a-z0-9]+)*)",
"captures": {
"1": {
"name": "entity.name.function.myscript"
},
"2": {
"name": "term.language.myscript"
}
}
},
{
"name": "term.language.myscript",
"match": "([a-z][a-z0-9]*(?:-[a-z0-9]+)*) (\\d+)",
"captures": {
"1": {
"name": "entity.name.function.myscript"
},
"2": {
"name": "constant.numeric.integer.myscript"
}
}
},
但这感觉就像一个黑客,我到处复制代码。