Skip to content

Commit 5fc0bcb

Browse files
committed
Added syntax hightlighting and snippets for moved blocks
1 parent 9cb54fc commit 5fc0bcb

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

examples/moved.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
moved {
2+
from = "aws_instance.ec2"
3+
to = "aws_instance.ec2[0]"
4+
}
5+
6+
moved {
7+
from = aws_instance.a
8+
to = aws_instance.b
9+
}
10+
11+
moved {
12+
from = aws_instance.a
13+
to = aws_instance.a["small"]
14+
}

grammars/tf.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ patterns:
102102
2: { name: keyword.operator.assignment.tf }
103103
- include: "#definition-right"
104104

105+
- name: "meta.moved.tf"
106+
begin: '\b(moved)([\w\-\"$])?(?:\s+)?({)'
107+
beginCaptures:
108+
1: { name: keyword.declaration.$1.tf }
109+
2: { name: invalid.illegal.keyword.$1.tf }
110+
3: { name: punctuation.declaration.block.begin.tf }
111+
end: "}"
112+
endCaptures:
113+
0: { name: punctuation.declaration.block.end.tf }
114+
patterns:
115+
- match: '\b([\-\w]+)(?:\s+)?(=)(?!=|>|<)'
116+
captures:
117+
1: { name: variable.other.readwrite.tf }
118+
2: { name: keyword.operator.assignment.tf }
119+
- include: "#definition-right"
120+
105121
- name: "meta.module.tf"
106122
begin: '\b(module)([\w\-\"$])?(?:\s+)?(")?([^\"\n]+)?(")?(?:\s+)?({)'
107123
beginCaptures:

snippets/tf.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ Local values:
4141
${1:name} = ${2:value}
4242
}
4343
44+
Moved block:
45+
scope: source.tf
46+
prefix: moved
47+
description: Used to refactor or rename existing resources safely.
48+
body: |
49+
moved {
50+
from = "${1:old}"
51+
to = "${2:new}"
52+
}
53+
4454
Variable:
4555
scope: source.tf
4656
prefix: variable

0 commit comments

Comments
 (0)