forked from SublimeText/Terraform
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTerraform.sublime-syntax
202 lines (201 loc) · 7.09 KB
/
Terraform.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Terraform
file_extensions:
- tf
- tfvars
- .terragrunt
scope: source.terraform
contexts:
main:
- match: "#"
comment: Comments
captures:
0: punctuation.definition.comment.terraform
push:
- meta_scope: comment.line.number-sign.terraform
- match: $\n?
captures:
0: punctuation.definition.comment.terraform
pop: true
- match: /\*
comment: Block comments
captures:
0: punctuation.definition.comment.terraform
push:
- meta_scope: comment.block.terraform
- match: \*/
captures:
0: punctuation.definition.comment.terraform
pop: true
- match: //
comment: Line comment
scope: punctuation.definition.comment.terraform
push:
- meta_scope: comment.line.double-slash.terraform
- match: $\n?
captures:
0: punctuation.definition.comment.terraform
pop: true
- match: \b(true|false|yes|no|on|off)\b
comment: Language constants (true, false, yes, no, on, off)
scope: constant.language.terraform
- match: '\b([0-9]+)([kKmMgG]b?)?\b'
comment: Numbers
scope: constant.numeric.terraform
- match: '\b(0x[0-9A-Fa-f]+)([kKmMgG]b?)?\b'
comment: Hex numbers
scope: constant.numeric.terraform
- match: '((resource)\s+((")(\w+)?("))\s+((")([\w-]+)?(")))\s*\{'
scope: meta.resource.terraform
captures:
1: entity.name.resource.terraform
2: storage.type.function.terraform
3: string.quoted.double.terraform
4: punctuation.definition.string.begin.terraform
5: meta.resource.type.terraform
6: punctuation.definition.string.end.terraform
7: string.quoted.double.terraform
8: punctuation.definition.string.begin.terraform
9: meta.resource.name.terraform
10: punctuation.definition.string.end.terraform
- match: '((data)\s+((")(\w+)?("))\s+((")([\w-]+)?(")))\s*\{'
scope: meta.data-source.terraform
captures:
1: entity.name.resource.terraform
2: storage.type.function.terraform
3: string.quoted.double.terraform
4: punctuation.definition.string.begin.terraform
5: meta.data-source.type.terraform
6: punctuation.definition.string.end.terraform
7: string.quoted.double.terraform
8: punctuation.definition.string.begin.terraform
9: meta.data-source.name.terraform
10: punctuation.definition.string.end.terraform
- match: '((provider|provisioner|variable|module|atlas)\s+(")([\w-]+)?("))\s*{'
captures:
1: entity.name.resource.terraform
2: storage.type.function.terraform
3: string.terraform punctuation.definition.string.begin.terraform
4: string.quoted.double.terraform
5: string.terraform punctuation.definition.string.end.terraform
- match: '((output)\s+(")([-\w\.]+)("))\s*{'
captures:
1: entity.name.resource.terraform
2: storage.type.function.terraform
3: string.terraform punctuation.definition.string.begin.terraform
4: string.quoted.double.terraform
5: string.terraform punctuation.definition.string.end.terraform
- match: ^\s*(locals|terraform)\s*{
captures:
1: storage.type.function.terraform
push:
- meta_content_scope: meta.block.terraform
- match: '^\s*}'
pop: true
- include: main
- match: '([\w_-]+)\s*(=)\s*'
comment: Value assignments (left hand side not in double quotes)
scope: meta.identifier.terraform
captures:
1: variable.assignment.terraform
2: keyword.operator.terraform
- match: '(")([\w_-]+)(")\s*(=)\s*'
comment: Value assignments (left hand side in double quotes)
scope: meta.identifier.terraform
captures:
1: punctuation.quote.double.terraform
2: variable.assignment.terraform
3: punctuation.quote.double.terraform
4: keyword.operator.terraform
- include: strings
- include: operators
- match: '\b(var|local|module|data|path|count)\b'
scope: keyword.other.terraform
- match: '\bnull\b'
scope: variable.language.terraform
strings:
- match: '"'
comment: Strings
scope: punctuation.definition.string.begin.terraform
push:
- meta_scope: string.quoted.double.terraform
- match: '"'
scope: punctuation.definition.string.end.terraform
pop: true
- include: interpolation
- include: string_placeholder
- include: string_escaped_char
- match: '<<(\w+)'
scope: punctuation.definition.string.begin.terraform
comment: Heredoc
push:
- meta_scope: string.heredoc.terraform
- match: '^\1'
scope: punctuation.definition.string.end.terraform
pop: true
- include: interpolation
- match: <<-(\w+)
scope: punctuation.definition.string.begin.terraform
comment: Indented heredoc
push:
- meta_scope: string.heredoc.terraform
- match: ^\s*\1
scope: punctuation.definition.string.end.terraform
pop: true
- include: interpolation
interpolation:
- match: '\$\{'
scope: punctuation.section.embed.begin.terraform
push:
- meta_scope: meta.embed.terraform
- match: '\}'
scope: punctuation.section.embed.end.terraform
pop: true
- include: interpolated_terraform
interpolated_terraform:
- include: variable_reference
- include: function
- include: operators
- include: interpolation
- include: strings
function:
- match: '(\w+)\('
comment: functions in interpolations
captures:
1: support.function.terraform
push:
- include: variable_reference
- include: function
- include: main
- match: '\)'
pop: true
operators:
- match: '\?|:'
scope: keyword.operator.conditional.terraform
- match: '==|!=|>|<|>=|<=|&&|\|\||!'
scope: keyword.operator.comparison.terraform
- match: (%|&|\*|\+|\-|/)
scope: keyword.operator.arithmetic.terraform
variable_reference:
- match: '\b(self|count|path|var|local)\b\.?'
captures:
1: keyword.other.terraform
string_placeholder:
- match: |-
(?x)%
[#0\- +']* # flags
(\[\d+\])? # field (argument #)
[,;:_]? # separator character (AltiVec)
((-?\d+)|(\[\d+\])?\*)? # minimum field width
(\.((-?\d+)|(\[\d+\])?\*)?)? # precision
[diouxXDOUeEfFgGaAcCsSpqnvtTbyYhHmMzZ%] # conversion type
scope: constant.other.placeholder.terraform
- match: "%"
scope: invalid.illegal.placeholder.terraform
string_escaped_char:
- match: '\\(\\|[abfnrutv''"]|x\h{2}|u\h{4}|U\h{8}|[0-7]{3})'
scope: constant.character.escape.terraform
- match: \\.
scope: invalid.illegal.unknown-escape.terraform