Skip to content

Commit bdb312b

Browse files
committed
Scope hanging bracket content in plan output
1 parent 500959c commit bdb312b

2 files changed

Lines changed: 95 additions & 13 deletions

File tree

Terraform Plan.sublime-syntax

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ file_extensions:
1111
- tf.plan
1212

1313
contexts:
14+
prototype:
15+
- include: comments
1416

1517
main:
1618
- include: comments
@@ -24,6 +26,15 @@ contexts:
2426
- meta_scope: comment.line.number-sign.terraform
2527
- include: pop-eol
2628

29+
annotations:
30+
- meta_include_prototype: false
31+
- match: ->
32+
scope: keyword.operator.assignment.terraform
33+
- match: \(known after apply\)$
34+
scope: comment.block.terraform
35+
- match: \bnull$
36+
scope: constant.language.null.terraform
37+
2738
diffs:
2839
- match: ^\+/-
2940
scope: punctuation.definition.changed.diff
@@ -40,37 +51,38 @@ contexts:
4051
- match: ^-
4152
scope: punctuation.definition.deleted.diff
4253
push: line-deleted
43-
44-
annotations:
45-
- match: ->
46-
scope: keyword.operator.assignment.terraform
47-
- match: \(known after apply\)$
48-
scope: comment.block.terraform
49-
- match: \bnull$
50-
scope: constant.language.null.terraform
54+
- match: \[$\n?
55+
push: closing-bracket
56+
- match: \{$\n?
57+
push: closing-brace
5158

5259
line-deleted:
5360
- meta_scope: markup.deleted.diff
61+
- include: pop-eol-bracket-deleted
5462
- include: pop-eol
5563
- include: annotations
5664

5765
line-inserted:
5866
- meta_scope: markup.inserted.diff
67+
- include: pop-eol-bracket-inserted
5968
- include: pop-eol
6069
- include: annotations
6170

6271
line-changed:
6372
- meta_scope: markup.changed.updated-in-place.diff
73+
- include: pop-eol-bracket-changed
6474
- include: pop-eol
6575
- include: annotations
6676

6777
line-created-then-destroyed:
6878
- meta_scope: markup.changed.created-then-destroyed.diff
79+
- include: pop-eol-bracket-changed
6980
- include: pop-eol
7081
- include: annotations
7182

7283
line-destroyed-then-created:
7384
- meta_scope: markup.changed.destroyed-then-created.diff
85+
- include: pop-eol-bracket-changed
7486
- include: pop-eol
7587
- include: annotations
7688

@@ -79,6 +91,67 @@ contexts:
7991
- include: pop-eol
8092
- include: annotations
8193

94+
closing-bracket:
95+
- match: ^(?=\s*\])
96+
pop: 1
97+
- include: diffs
98+
99+
closing-brace:
100+
- match: ^\s*\}
101+
pop: 1
102+
- include: diffs
103+
104+
pop-eol-bracket-deleted:
105+
- match: \[$\n?
106+
set: closing-bracket-deleted
107+
- match: \{$\n?
108+
set: closing-brace-deleted
109+
110+
closing-bracket-deleted:
111+
- match: ^(?=\s*\])
112+
set: line-deleted
113+
- include: diffs
114+
115+
closing-brace-deleted:
116+
- match: ^\s*\}
117+
scope: markup.deleted.diff
118+
pop: 1
119+
- include: diffs
120+
121+
pop-eol-bracket-inserted:
122+
- match: \[$\n?
123+
set: closing-bracket-inserted
124+
- match: \{$\n?
125+
set: closing-brace-inserted
126+
127+
closing-bracket-inserted:
128+
- match: ^(?=\s*\])
129+
set: line-inserted
130+
- include: diffs
131+
132+
closing-brace-inserted:
133+
- match: ^(?=\s*\})
134+
set: line-inserted
135+
- include: diffs
136+
137+
pop-eol-bracket-changed:
138+
- match: \[$\n?
139+
set: closing-bracket-changed
140+
- match: \{$\n?
141+
set: closing-brace-changed
142+
143+
closing-bracket-changed:
144+
- match: ^\s*\]
145+
scope: markup.changed.diff
146+
pop: 1
147+
- include: diffs
148+
149+
closing-brace-changed:
150+
- match: ^\s*\}
151+
scope: markup.changed.diff
152+
pop: 1
153+
- include: diffs
154+
82155
summary:
83156
- match: ^(?=Plan:[ ]\d)
84157
push:

tests/syntax_test_scope.tfplan

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Terraform will perform the following actions:
1515
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.destroyed-then-created.diff
1616
#^^ punctuation.definition.changed.diff
1717
+ allow_overwrite = (known after apply)
18-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
18+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff - markup markup
1919
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
2020
! fqdn = "autodiscover.example.com" -> (known after apply)
2121
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
@@ -32,13 +32,13 @@ Terraform will perform the following actions:
3232
# (4 unchanged attributes hidden)
3333
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup
3434
}
35-
# ^^^^ - markup
35+
#^^^^ markup.changed.diff
3636

3737
# aws_route53_record_cname_lyncdiscover_example_com will be destroyed
3838
- resource "aws_route53_record" "cname_lyncdiscover_example_com_old" {
3939
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
4040
- fqdn = "lyncdiscover.example.com" -> null
41-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
41+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff - markup markup
4242
# ^^ keyword.operator.assignment.terraform
4343
# ^^^^ constant.language.null.terraform
4444
- id = "ABCDEABCDEABCDEA_lyncdiscover_CNAME" -> null
@@ -50,15 +50,19 @@ Terraform will perform the following actions:
5050
- "webdir.online.lync.com.",
5151
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
5252
] -> null
53+
#^^^^^^^^^^^^^^^^ markup.deleted.diff - markup markup
54+
# ^^ keyword.operator.assignment.terraform
55+
# ^^^^ constant.language.null.terraform
5356
- ttl = 7200 -> null
5457
- type = "CNAME" -> null
5558
- zone_id = "ABCDEABCDEABCDEA" -> null
5659
}
60+
#^^^^ markup.deleted.diff - markup markup
5761

5862
# aws_route53_record_cname_lyncdiscover_example_com will be created
5963
+ resource "aws_route53_record" "cname_lyncdiscover_example_com_new" {
6064
+ fqdn = (known after apply)
61-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
65+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff - markup markup
6266
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
6367
+ id = (known after apply)
6468
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
@@ -68,12 +72,13 @@ Terraform will perform the following actions:
6872
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
6973
+ records = [
7074
+ "webdir.online.lync.com.",
71-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
75+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff - markup markup
7276
]
7377
+ ttl = 7200
7478
+ type = "CNAME"
7579
+ zone_id = "ABCDEABCDEABCDEA"
7680
}
81+
#^^^^ markup.inserted.diff - markup markup
7782

7883
# aws_route53_record_zone_example_com will be updated in-place
7984
! resource "aws_route53_record" "cname_autodiscover_example_com" {
@@ -84,12 +89,16 @@ Terraform will perform the following actions:
8489
id = "ABCDEABCDEABCDEA"
8590
name = "example.com"
8691
tags = {
92+
#^^^^^^^^^^^^^^^^^^^^^^^^ - markup
8793
"Provisioner" = "Terraform"
8894
"System" = "example"
8995
"Workspace" = "production"
96+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup
9097
}
98+
#^^^^^^^^ - markup
9199
# (3 unchanged attributes hidden)
92100
}
101+
#^^^^ markup.changed.diff - markup markup
93102

94103
Plan: 2 to add, 1 to change, 2 to destroy.
95104
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.summary.terraform

0 commit comments

Comments
 (0)