Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables with no space between them break syntax highlighting #34

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ repository:
- include: "#string_interpolation"
- include: "#char_escapes"
string_interpolation:
begin: (\G|[^%$])([%$]{)
begin: '(?<![%$])([%$]{)'
comment: String interpolation
name: meta.interpolation.hcl
beginCaptures:
"2":
"1":
name: keyword.other.interpolation.begin.hcl
end: \}
endCaptures:
Expand Down
4 changes: 2 additions & 2 deletions syntaxes/hcl.tmGrammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,11 @@
},
"string_interpolation": {
"name": "meta.interpolation.hcl",
"begin": "(\\G|[^%$])([%$]{)",
"begin": "(?<![%$])([%$]{)",
"end": "\\}",
"comment": "String interpolation",
"beginCaptures": {
"2": {
"1": {
"name": "keyword.other.interpolation.begin.hcl"
}
},
Expand Down
4 changes: 2 additions & 2 deletions syntaxes/terraform.tmGrammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,11 @@
},
"string_interpolation": {
"name": "meta.interpolation.hcl",
"begin": "(\\G|[^%$])([%$]{)",
"begin": "(?<![%$])([%$]{)",
"end": "\\}",
"comment": "String interpolation",
"beginCaptures": {
"2": {
"1": {
"name": "keyword.other.interpolation.begin.hcl"
}
},
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshot/hcl/basic.hcl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
# ^ source.hcl variable.declaration.hcl keyword.operator.assignment.hcl
# ^ source.hcl variable.declaration.hcl
# ^ source.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshot/hcl/expressions_for.hcl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshot/hcl/expressions_functions.hcl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.end.hcl
>" items: ${indent(2, "[\n foo,\n bar,\n]\n")}"
#^ source.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl meta.function-call.hcl support.function.builtin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl meta.function-call.hcl punctuation.section.parens.begin.hcl
Expand Down
22 changes: 10 additions & 12 deletions tests/snapshot/hcl/expressions_strings.hcl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
>
>"Hello, ${var.name}!"
#^ source.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.operator.accessor.hcl
Expand All @@ -92,8 +91,7 @@
>
>"Hello, %{ if var.name != "" }${var.name}%{ else }unnamed%{ endif }!"
#^ source.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
Expand All @@ -108,15 +106,17 @@
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^^^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.operator.accessor.hcl
# ^^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl variable.other.member.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^^^^ source.hcl string.quoted.double.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl string.quoted.double.hcl
# ^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^ source.hcl string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
Expand Down Expand Up @@ -146,8 +146,7 @@
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
>server ${ip}
#^^^^^^ source.hcl string.unquoted.heredoc.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl
#^^^^^^^ source.hcl string.unquoted.heredoc.hcl
# ^^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down Expand Up @@ -181,8 +180,7 @@
# ^^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.operator.template.right.trim.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
>server ${ip}
#^^^^^^ source.hcl string.unquoted.heredoc.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl
#^^^^^^^ source.hcl string.unquoted.heredoc.hcl
# ^^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshot/terraform/expressions_for.tf.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^ source.hcl.terraform string.quoted.double.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down
3 changes: 1 addition & 2 deletions tests/snapshot/terraform/expressions_functions.tf.snap
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl
>" items: ${indent(2, "[\n foo,\n bar,\n]\n")}"
#^ source.hcl.terraform string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl meta.function-call.hcl support.function.builtin.terraform
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl meta.function-call.hcl punctuation.section.parens.begin.hcl
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshot/terraform/expressions_strings.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ block {
EOT
}

"Hello, ${var.name}!"
"Hello, ${var.name}${var.name}!"

"Hello, %{ if var.name != "" }${var.name}%{ else }unnamed%{ endif }!"

Expand Down
33 changes: 18 additions & 15 deletions tests/snapshot/terraform/expressions_strings.tf.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@
>}
#^ source.hcl.terraform meta.block.hcl punctuation.section.block.end.hcl
>
>"Hello, ${var.name}!"
>"Hello, ${var.name}${var.name}!"
#^ source.hcl.terraform string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.terraform
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.operator.accessor.hcl
# ^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.member.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl punctuation.definition.string.end.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.terraform
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.operator.accessor.hcl
# ^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.member.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl punctuation.definition.string.end.hcl
>
>"Hello, %{ if var.name != "" }${var.name}%{ else }unnamed%{ endif }!"
#^ source.hcl.terraform string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
Expand All @@ -108,15 +111,17 @@
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.readwrite.terraform
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.operator.accessor.hcl
# ^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl variable.other.member.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
# ^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^^^ source.hcl.terraform string.quoted.double.hcl
# ^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl
# ^^^^^ source.hcl.terraform string.quoted.double.hcl meta.interpolation.hcl keyword.control.hcl
Expand Down Expand Up @@ -146,8 +151,7 @@
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
>server ${ip}
#^^^^^^ source.hcl.terraform string.unquoted.heredoc.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl
#^^^^^^^ source.hcl.terraform string.unquoted.heredoc.hcl
# ^^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down Expand Up @@ -181,8 +185,7 @@
# ^^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.operator.template.right.trim.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
>server ${ip}
#^^^^^^ source.hcl.terraform string.unquoted.heredoc.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl
#^^^^^^^ source.hcl.terraform string.unquoted.heredoc.hcl
# ^^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.begin.hcl
# ^^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl variable.other.readwrite.hcl
# ^ source.hcl.terraform string.unquoted.heredoc.hcl meta.interpolation.hcl keyword.other.interpolation.end.hcl
Expand Down