Skip to content

Commit 9b7c792

Browse files
Move comments to a prototype context (#104)
1 parent e03a17e commit 9b7c792

2 files changed

Lines changed: 40 additions & 7 deletions

File tree

Terraform.sublime-syntax

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ variables:
166166
)
167167
168168
contexts:
169-
main:
169+
prototype:
170170
- include: comments
171+
172+
main:
171173
- include: attribute-definition
172174
- include: imports
173175
- include: blocks
@@ -306,6 +308,7 @@ contexts:
306308
push: string-body
307309

308310
string-body:
311+
- meta_include_prototype: false
309312
- meta_scope: meta.string.terraform string.quoted.double.terraform
310313
- match: \"
311314
scope: punctuation.definition.string.end.terraform
@@ -524,7 +527,6 @@ contexts:
524527
1: keyword.operator.splat.terraform
525528
pop: 1
526529
- include: comma
527-
- include: comments
528530
- include: tuple-for-expression
529531
- include: expressions
530532

@@ -544,7 +546,6 @@ contexts:
544546
scope: punctuation.section.braces.end.terraform
545547
pop: 1
546548
- include: object-for-expression
547-
- include: comments
548549
- match: (?=({{identifier}}|\".*?\")\s*=)
549550
push:
550551
- object-value
@@ -585,7 +586,6 @@ contexts:
585586
#
586587
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#collection-values
587588
object-value:
588-
- include: comments
589589
- match: \,
590590
comment: Pop scope on comma.
591591
scope: punctuation.separator.terraform
@@ -608,7 +608,6 @@ contexts:
608608
push: member
609609

610610
member:
611-
- include: comments
612611
- match: '{{identifier}}'
613612
comment: Attribute access
614613
scope: variable.other.member.terraform
@@ -693,7 +692,6 @@ contexts:
693692
- match: \)
694693
scope: punctuation.section.parens.end.terraform
695694
pop: 1
696-
- include: comments
697695
- include: expressions
698696
- include: comma
699697

@@ -748,7 +746,6 @@ contexts:
748746
- match: '\:'
749747
scope: punctuation.section.block.loop.for.terraform
750748
- include: expressions
751-
- include: comments
752749
- include: comma
753750

754751
namespaces:

tests/syntax_test_scope.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,17 @@
240240
# ^ punctuation.definition.string.end.terraform
241241
# ^ - punctuation - string
242242

243+
/////
244+
// Does not include comments.
245+
/////
246+
247+
"a string // with double-slash"
248+
# ^ - punctuation - string
249+
# ^ punctuation.definition.string.begin.terraform
250+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.terraform - comment
251+
# ^ punctuation.definition.string.end.terraform
252+
# ^ - punctuation - string
253+
243254
/////
244255
// Matches character escapes.
245256
/////
@@ -1306,6 +1317,31 @@
13061317
# ^ punctuation.accessor.dot.terraform
13071318
# ^^^^^^^^^^^^ variable.other.member.terraform
13081319

1320+
/////
1321+
// Parenthesized assignment
1322+
/////
1323+
1324+
attribute = (
1325+
# ^^^^^^^^^ variable.declaration.terraform variable.other.readwrite.terraform
1326+
# ^ keyword.operator.assignment.terraform
1327+
# ^^ meta.parens.terraform
1328+
# ^ punctuation.section.parens.begin.terraform
1329+
local.var1 != ""
1330+
? local.var1
1331+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.terraform
1332+
# ^ keyword.operator.ternary.terraform
1333+
# ^^^^^ variable.language.terraform
1334+
# ^ punctuation.accessor.dot.terraform
1335+
# ^^^^ variable.other.member.terraform
1336+
// A comment
1337+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.terraform
1338+
# ^^^^^^^^^^^^^ comment.line.terraform
1339+
# ^^ punctuation.definition.comment.terraform
1340+
# ^ punctuation.definition.comment.terraform
1341+
: uuidv4()
1342+
)
1343+
#^^^^^^ meta.parens.terraform
1344+
# ^ punctuation.section.parens.end.terraform
13091345

13101346
/////
13111347
// Meta-arguments

0 commit comments

Comments
 (0)