Skip to content

Commit 8c14ad4

Browse files
Add highlighting for Plan output (#68)
1 parent 0eca4f2 commit 8c14ad4

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed

Terraform Plan.sublime-syntax

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
%YAML 1.2
2+
---
3+
# http://www.sublimetext.com/docs/syntax.html
4+
# https://github.com/hashicorp/terraform/blob/337bf8e11b75dff87509455cabee60b023dd586e/internal/command/jsonformat/plan.go#L201
5+
name: Terraform Plan
6+
scope: source.diff.terraform
7+
8+
file_extensions:
9+
- tfplan
10+
- tf.plan
11+
12+
contexts:
13+
14+
main:
15+
- include: comments
16+
- include: diffs
17+
- include: summary
18+
19+
comments:
20+
- match: '#'
21+
scope: punctuation.definition.comment.terraform
22+
push:
23+
- meta_scope: comment.line.number-sign.terraform
24+
- include: pop-eol
25+
26+
diffs:
27+
- match: ^\+/-
28+
scope: punctuation.definition.changed.diff
29+
push: line-created-then-destroyed
30+
- match: ^-/\+
31+
scope: punctuation.definition.changed.diff
32+
push: line-destroyed-then-created
33+
- match: ^!
34+
scope: punctuation.definition.changed.diff
35+
push: line-changed
36+
- match: ^\+
37+
scope: punctuation.definition.inserted.diff
38+
push: line-inserted
39+
- match: ^-
40+
scope: punctuation.definition.deleted.diff
41+
push: line-deleted
42+
43+
annotations:
44+
- match: ->
45+
scope: keyword.operator.assignment.terraform
46+
- match: \(known after apply\)$
47+
scope: comment.block.terraform
48+
- match: \bnull$
49+
scope: constant.language.null.terraform
50+
51+
line-deleted:
52+
- meta_scope: markup.deleted.diff
53+
- include: pop-eol
54+
- include: annotations
55+
56+
line-inserted:
57+
- meta_scope: markup.inserted.diff
58+
- include: pop-eol
59+
- include: annotations
60+
61+
line-changed:
62+
- meta_scope: markup.changed.updated-in-place.diff
63+
- include: pop-eol
64+
- include: annotations
65+
66+
line-created-then-destroyed:
67+
- meta_scope: markup.changed.created-then-destroyed.diff
68+
- include: pop-eol
69+
- include: annotations
70+
71+
line-destroyed-then-created:
72+
- meta_scope: markup.changed.destroyed-then-created.diff
73+
- include: pop-eol
74+
- include: annotations
75+
76+
line-ignored:
77+
- meta_scope: comment.line.diff
78+
- include: pop-eol
79+
- include: annotations
80+
81+
summary:
82+
- match: ^(?=Plan:[ ]\d)
83+
push:
84+
- meta_scope: meta.block.summary.terraform
85+
- include: pop-eol
86+
- match: ','
87+
scope: punctuation.separator.sequence.terraform
88+
- match: \.
89+
scope: punctuation.terminator.terraform
90+
- match: (\d+) to add
91+
scope: markup.inserted.terraform
92+
captures:
93+
1: meta.number.integer.decimal.terraform constant.numeric.value.terraform
94+
- match: (\d+) to change
95+
scope: markup.changed.terraform
96+
captures:
97+
1: meta.number.integer.decimal.terraform constant.numeric.value.terraform
98+
- match: (\d+) to destroy
99+
scope: markup.deleted.terraform
100+
captures:
101+
1: meta.number.integer.decimal.terraform constant.numeric.value.terraform
102+
103+
pop-eol:
104+
- match: \n|$
105+
pop: 1

syntax_test_terraform_plan.tfplan

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# SYNTAX TEST "Terraform Plan.sublime-syntax"
2+
3+
Terraform used the selected providers to generate the following execution
4+
plan. Resource actions are indicated with the following symbols:
5+
6+
+ create
7+
! update-in-place
8+
- destroy
9+
-/+ destroy and then create replacement
10+
11+
Terraform will perform the following actions:
12+
13+
# aws_route53_record_cname_autodiscover_example_com must be replaced
14+
-/+ resource "aws_route53_record" "cname_autodiscover_example_com" {
15+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.destroyed-then-created.diff
16+
#^^ punctuation.definition.changed.diff
17+
+ allow_overwrite = (known after apply)
18+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
19+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
20+
! fqdn = "autodiscover.example.com" -> (known after apply)
21+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
22+
# ^^ keyword.operator.assignment.terraform
23+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
24+
! id = "ABCDEABCDEABCDEA_autodiscover_CNAME" -> (known after apply)
25+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
26+
# ^^ keyword.operator.assignment.terraform
27+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
28+
! name = "autodiscover.example.com" -> (known after apply)
29+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
30+
# ^^ keyword.operator.assignment.terraform
31+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
32+
# (4 unchanged attributes hidden)
33+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup
34+
}
35+
# ^^^^ - markup
36+
37+
# aws_route53_record_cname_lyncdiscover_example_com will be destroyed
38+
- resource "aws_route53_record" "cname_lyncdiscover_example_com_old" {
39+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
40+
- fqdn = "lyncdiscover.example.com" -> null
41+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
42+
# ^^ keyword.operator.assignment.terraform
43+
# ^^^^ constant.language.null.terraform
44+
- id = "ABCDEABCDEABCDEA_lyncdiscover_CNAME" -> null
45+
- name = "lyncdiscover" -> null
46+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
47+
# ^^ keyword.operator.assignment.terraform
48+
# ^^^^ constant.language.null.terraform
49+
- records = [
50+
- "webdir.online.lync.com.",
51+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff
52+
] -> null
53+
- ttl = 7200 -> null
54+
- type = "CNAME" -> null
55+
- zone_id = "ABCDEABCDEABCDEA" -> null
56+
}
57+
58+
# aws_route53_record_cname_lyncdiscover_example_com will be created
59+
+ resource "aws_route53_record" "cname_lyncdiscover_example_com_new" {
60+
+ fqdn = (known after apply)
61+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
62+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
63+
+ id = (known after apply)
64+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
65+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
66+
+ name = (known after apply)
67+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
68+
# ^^^^^^^^^^^^^^^^^^^ comment.block.terraform
69+
+ records = [
70+
+ "webdir.online.lync.com.",
71+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff
72+
]
73+
+ ttl = 7200
74+
+ type = "CNAME"
75+
+ zone_id = "ABCDEABCDEABCDEA"
76+
}
77+
78+
# aws_route53_record_zone_example_com will be updated in-place
79+
! resource "aws_route53_record" "cname_autodiscover_example_com" {
80+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
81+
! comment = "Records for the example.com domain" -> "Records for the example.com domains"
82+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.updated-in-place.diff
83+
# ^^ keyword.operator.assignment.terraform
84+
id = "ABCDEABCDEABCDEA"
85+
name = "example.com"
86+
tags = {
87+
"Provisioner" = "Terraform"
88+
"System" = "example"
89+
"Workspace" = "production"
90+
}
91+
# (3 unchanged attributes hidden)
92+
}
93+
94+
Plan: 2 to add, 1 to change, 2 to destroy.
95+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.summary.terraform
96+
# ^^^^^^^^ markup.inserted.terraform
97+
# ^ meta.number.integer.decimal.terraform constant.numeric.value.terraform
98+
# ^ punctuation.separator.sequence.terraform
99+
# ^^^^^^^^^^^ markup.changed.terraform
100+
# ^ meta.number.integer.decimal.terraform constant.numeric.value.terraform
101+
# ^ punctuation.separator.sequence.terraform
102+
# ^^^^^^^^^^^^ markup.deleted.terraform
103+
# ^ meta.number.integer.decimal.terraform constant.numeric.value.terraform
104+
# ^ punctuation.terminator.terraform

0 commit comments

Comments
 (0)