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

54 lines
1.2 KiB
YAML

name: HCL
scopeName: source.hcl
fileTypes: [hcl, hcldec]
uuid: 55e8075d-e2e3-4e44-8446-744a9860e476
patterns:
- comment: Comments
name: comment.line.hcl
begin: '#|//'
end: $\n?
captures:
'0': {name: punctuation.definition.comment.hcl}
- comment: Block comments
name: comment.block.hcl
begin: /\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.hcl}
- comment: Nested Blocks
name: meta.block.hcl
begin: "{"
beginCaptures:
'0': {name: punctuation.definition.block.hcl}
end: "}"
endCaptures:
'0': {name: punctuation.definition.block.hcl}
patterns:
- include: "$self"
- comment: Quoted Block Labels
match: '(")([^"]+)(")'
captures:
'1': {name: string.hcl punctuation.definition.string.begin.hcl}
'2': {name: string.value.hcl}
'3': {name: string.hcl punctuation.definition.string.end.hcl}
- comment: Attribute Definitions
name: meta.attr.hcl
begin: '(\w+)\s*(=)\s*'
beginCaptures:
'1': {name: variable.other.assignment.hcl}
'2': {name: keyword.operator.hcl}
end: '$'
patterns:
- include: "source.hclexpr"
- comment: Keywords
match: '[-\w]+'
captures:
'0': {name: keyword.other.hcl}