hcl/extras/grammar/HCLTemplate.json-tmLanguage
Martin Atkins 1718a963e6 extras: initial TextMate-style grammar for HCL
This is for the core HCL syntax, so it doesn't include any
application-specific keyword highlighting, etc.

The structural, expression, and template languages are separated into
different grammar definitions so that they can be used independently, but
they embed each other as needed to complete the language.

This is just a first pass, really. There are probably some bugs here, and
also some missing features.
2018-07-07 12:36:52 -07:00

107 lines
2.2 KiB
JSON
Executable File

{
"fileTypes": [
"tmpl"
],
"name": "HCL Template",
"patterns": [
{
"begin": "[^\\$]?(\\$\\{~?)",
"beginCaptures": {
"1": {
"name": "entity.tag.embedded.start.hcltemplate"
}
},
"comment": "Interpolation Sequences",
"end": "~?}",
"endCaptures": {
"0": {
"name": "entity.tag.embedded.end.hcltemplate"
}
},
"name": "meta.interp.hcltemplate",
"patterns": [
{
"include": "source.hclexpr"
}
]
},
{
"begin": "[^\\%]?(\\%\\{~?)",
"beginCaptures": {
"1": {
"name": "entity.tag.embedded.start.hcltemplate"
}
},
"comment": "Control Sequences",
"end": "~?}",
"endCaptures": {
"0": {
"name": "entity.tag.embedded.end.hcltemplate"
}
},
"name": "meta.control.hcltemplate",
"patterns": [
{
"include": "#templateif"
},
{
"include": "#templatefor"
},
{
"include": "#templatesimplekw"
}
]
}
],
"repository": {
"templatefor": {
"begin": "(for)\\s*(\\w+)\\s*(,\\s*(\\w+)\\s*)?(in)",
"beginCaptures": {
"1": {
"name": "keyword.control.hcltemplate"
},
"2": {
"name": "variable.other.hcl"
},
"4": {
"name": "variable.other.hcl"
},
"5": {
"name": "keyword.control.hcltemplate"
}
},
"end": "(?=~?\\})",
"name": "meta.templatefor.hcltemplate",
"patterns": [
{
"include": "source.hclexpr"
}
]
},
"templateif": {
"begin": "(if)\\s*",
"beginCaptures": {
"1": {
"name": "keyword.control.hcltemplate"
}
},
"end": "(?=~?\\})",
"name": "meta.templateif.hcltemplate",
"patterns": [
{
"include": "source.hclexpr"
}
]
},
"templatesimplekw": {
"captures": {
"0": {
"name": "keyword.control.hcl"
}
},
"match": "(else|endif|endfor)"
}
},
"scopeName": "source.hcltemplate",
"uuid": "ac6be18e-d44f-4a73-bd8f-b973fd26df05"
}