hcl/extras/grammar/HCLTemplate.yaml-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

59 lines
1.4 KiB
YAML

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