diff --git a/JSON (Terraform).sublime-syntax b/JSON (Terraform).sublime-syntax index b6db95f..2042522 100644 --- a/JSON (Terraform).sublime-syntax +++ b/JSON (Terraform).sublime-syntax @@ -15,3 +15,7 @@ contexts: - meta_prepend: true - include: Packages/Terraform/Terraform.sublime-syntax#string-interpolation - include: Packages/Terraform/Terraform.sublime-syntax#aws-acl + + line-comments: + - meta_append: true + - include: Packages/Terraform/Terraform.sublime-syntax#inline-comments diff --git a/Terraform.sublime-syntax b/Terraform.sublime-syntax index 65ee72a..62048ae 100644 --- a/Terraform.sublime-syntax +++ b/Terraform.sublime-syntax @@ -160,6 +160,7 @@ contexts: - include: functions - include: parens - include: identifiers + - include: illegal-strays comma: - match: \, @@ -279,6 +280,9 @@ contexts: - match: \" scope: punctuation.definition.string.end.terraform pop: 1 + - match: \n + scope: invalid.illegal.unclosed-string.terraform + pop: 1 - include: character-escapes - include: string-interpolation - include: aws-acl @@ -514,7 +518,6 @@ contexts: # https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#collection-values object-value: - include: comments - - include: expressions - match: \, comment: Pop scope on comma. scope: punctuation.separator.terraform @@ -526,6 +529,7 @@ contexts: comment: Lookahead (don't consume) and pop scope on a bracket. scope: punctuation.section.braces.end.terraform pop: 1 + - include: expressions # Attribute Access: "." Identifier # @@ -689,6 +693,10 @@ contexts: - match: '{{identifier}}' scope: variable.other.readwrite.terraform + illegal-strays: + - match: '[\])}]' + scope: invalid.illegal.stray.python + # Blocks: Identifier (StringLit|Identifier)* "{" Newline Body "}" Newline; # # https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#structural-elements diff --git a/tests/syntax_test_scope.tf b/tests/syntax_test_scope.tf index aba43d7..2db1de7 100644 --- a/tests/syntax_test_scope.tf +++ b/tests/syntax_test_scope.tf @@ -256,6 +256,14 @@ # ^^^^^^^^^^ constant.character.escape.terraform # ^ punctuation.definition.string.end.terraform +///// +// Unclosed strings +///// + + " +# ^ meta.string.terraform string.quoted.double.terraform punctuation.definition.string.begin.terraform +# ^ invalid.illegal.unclosed-string.terraform + ///////////////////////////////////////////////////////////////////// // Identifiers ///////////////////////////////////////////////////////////////////// @@ -3386,6 +3394,8 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" { # ^^^^^^^^^^^^ meta.string.terraform string.quoted.double.terraform # ^ punctuation.definition.string.begin.terraform # ^ punctuation.definition.string.end.terraform + # comment +# ^^^^^^^^^^ comment.line.terraform "Statement": [ #^^^^^^^^^^^^^^^^^^^^^ meta.block.body.terraform meta.function-call.arguments.terraform #^^^^^^^ meta.braces.terraform @@ -3395,6 +3405,8 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" { # ^^ meta.braces.terraform # ^ punctuation.separator.key-value.json # ^ meta.mapping.value.json meta.sequence.json punctuation.section.sequence.begin.json + # comment +# ^^^^^^^^^^ comment.line.terraform { "Action": [ "lambda:InvokeFunction", @@ -3427,3 +3439,12 @@ resource "aws_iam_role_policy" "attach-inline-policy-1" { ] }) } + +] +# <- invalid.illegal.stray.python + +} +# <- invalid.illegal.stray.python + +) +# <- invalid.illegal.stray.python