Skip to content

Commit

Permalink
Add support for import block
Browse files Browse the repository at this point in the history
  • Loading branch information
John Long committed Jun 30, 2023
1 parent d71a974 commit a94d93f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions grammars/tf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ patterns:
2: { name: keyword.operator.assignment.tf }
- include: "#definition-right"

- name: "meta.import.tf"
begin: '\b(import)([\w\-\"$])?(?:\s+)?({)'
beginCaptures:
1: { name: keyword.declaration.$1.tf }
2: { name: invalid.illegal.keyword.$1.tf }
3: { name: punctuation.declaration.block.begin.tf }
end: "}"
endCaptures:
0: { name: punctuation.declaration.block.end.tf }
patterns:
- match: '\b([\-\w]+)(?:\s+)?(=)(?!=|>|<)'
captures:
1: { name: variable.other.readwrite.tf }
2: { name: keyword.operator.assignment.tf }
- include: "#definition-right"


- name: "meta.module.tf"
begin: '\b(module)([\w\-\"$])?(?:\s+)?(")?([^\"\n]+)?(")?(?:\s+)?({)'
beginCaptures:
Expand Down
10 changes: 10 additions & 0 deletions snippets/tf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ Moved block:
to = "${2:new}"
}
Import block:
scope: source.tf
prefix: import
description: Used to import existing resources into Terraform state.
body: |
import {
to = ${1:resource}
id = "${2:resource_id}"
}
Variable:
scope: source.tf
prefix: variable
Expand Down

0 comments on commit a94d93f

Please sign in to comment.