Skip to content

Commit 13b5b4f

Browse files
authored
Reflect Terraform 1.4 and 1.5 language changes (#78)
* sort patterns alphabetically * Recognise check and import blocks * Reflect latest function names * builder: go run ./main.go build * Adjust pattern to avoid mismatching Without this change, we'd do "lazy matching", e.g. abs only in abspath(...) * update tests
1 parent b30903f commit 13b5b4f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/terraform.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repository:
1515
beginCaptures:
1616
"1":
1717
patterns:
18-
- match: \bresource|provider|variable|output|locals|module|data|terraform\b
18+
- match: \bdata|check|import|locals|module|output|provider|resource|terraform|variable\b
1919
comment: Known block type
2020
name: entity.name.type.terraform
2121
- match: \b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\b
@@ -45,7 +45,7 @@ repository:
4545
beginCaptures:
4646
"1":
4747
patterns:
48-
- match: abspath|abs|ceil|floor|log|max|min|pow|signum|chomp|formatlist|indent|join|lower|regexall|regex|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalescelist|coalesce|compact|concat|contains|distinct|element|flatten|index|keys|length|lookup|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|dirname|pathexpand|basename|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuidv5|uuid|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring|file|format
48+
- match: \b(abs|abspath|alltrue|anytrue|base64decode|base64encode|base64gzip|base64sha256|base64sha512|basename|bcrypt|can|ceil|chomp|chunklist|cidrhost|cidrnetmask|cidrsubnet|cidrsubnets|coalesce|coalescelist|compact|concat|contains|csvdecode|dirname|distinct|element|endswith|file|filebase64|filebase64sha256|filebase64sha512|fileexists|filemd5|fileset|filesha1|filesha256|filesha512|flatten|floor|format|formatdate|formatlist|indent|index|join|jsondecode|jsonencode|keys|length|log|lookup|lower|matchkeys|max|md5|merge|min|nonsensitive|one|parseint|pathexpand|plantimestamp|pow|range|regex|regexall|replace|reverse|rsadecrypt|sensitive|setintersection|setproduct|setsubtract|setunion|sha1|sha256|sha512|signum|slice|sort|split|startswith|strcontains|strrev|substr|sum|templatefile|textdecodebase64|textencodebase64|timeadd|timecmp|timestamp|title|tobool|tolist|tomap|tonumber|toset|tostring|transpose|trim|trimprefix|trimspace|trimsuffix|try|upper|urlencode|uuid|uuidv5|values|yamldecode|yamlencode|zipmap)\b
4949
name: support.function.builtin.terraform
5050
"2":
5151
name: punctuation.section.parens.begin.hcl

syntaxes/terraform.tmGrammar.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"1": {
9191
"patterns": [
9292
{
93-
"match": "\\bresource|provider|variable|output|locals|module|data|terraform\\b",
93+
"match": "\\bdata|check|import|locals|module|output|provider|resource|terraform|variable\\b",
9494
"comment": "Known block type",
9595
"name": "entity.name.type.terraform"
9696
},
@@ -291,7 +291,7 @@
291291
"1": {
292292
"patterns": [
293293
{
294-
"match": "abspath|abs|ceil|floor|log|max|min|pow|signum|chomp|formatlist|indent|join|lower|regexall|regex|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalescelist|coalesce|compact|concat|contains|distinct|element|flatten|index|keys|length|lookup|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|dirname|pathexpand|basename|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuidv5|uuid|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring|file|format",
294+
"match": "\\b(abs|abspath|alltrue|anytrue|base64decode|base64encode|base64gzip|base64sha256|base64sha512|basename|bcrypt|can|ceil|chomp|chunklist|cidrhost|cidrnetmask|cidrsubnet|cidrsubnets|coalesce|coalescelist|compact|concat|contains|csvdecode|dirname|distinct|element|endswith|file|filebase64|filebase64sha256|filebase64sha512|fileexists|filemd5|fileset|filesha1|filesha256|filesha512|flatten|floor|format|formatdate|formatlist|indent|index|join|jsondecode|jsonencode|keys|length|log|lookup|lower|matchkeys|max|md5|merge|min|nonsensitive|one|parseint|pathexpand|plantimestamp|pow|range|regex|regexall|replace|reverse|rsadecrypt|sensitive|setintersection|setproduct|setsubtract|setunion|sha1|sha256|sha512|signum|slice|sort|split|startswith|strcontains|strrev|substr|sum|templatefile|textdecodebase64|textencodebase64|timeadd|timecmp|timestamp|title|tobool|tolist|tomap|tonumber|toset|tostring|transpose|trim|trimprefix|trimspace|trimsuffix|try|upper|urlencode|uuid|uuidv5|values|yamldecode|yamlencode|zipmap)\\b",
295295
"name": "support.function.builtin.terraform"
296296
}
297297
]

tests/snapshot/terraform/expressions_functions.tf.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# ^ source.hcl.terraform meta.function-call.hcl constant.numeric.integer.hcl
4949
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl
5050
>parseint("100", 10)
51-
#^^^^^^^^ source.hcl.terraform meta.function-call.hcl
51+
#^^^^^^^^ source.hcl.terraform meta.function-call.hcl support.function.builtin.terraform
5252
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl
5353
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
5454
# ^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl
@@ -293,7 +293,7 @@
293293
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
294294
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl
295295
>trim("?!hello?!", "!?")
296-
#^^^^ source.hcl.terraform meta.function-call.hcl
296+
#^^^^ source.hcl.terraform meta.function-call.hcl support.function.builtin.terraform
297297
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl
298298
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
299299
# ^^^^^^^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl
@@ -305,7 +305,7 @@
305305
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
306306
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl
307307
>trimprefix("helloworld", "hello")
308-
#^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl
308+
#^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl support.function.builtin.terraform
309309
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl
310310
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
311311
# ^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl
@@ -317,7 +317,7 @@
317317
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
318318
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl
319319
>trimsuffix("helloworld", "world")
320-
#^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl
320+
#^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl support.function.builtin.terraform
321321
# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl
322322
# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
323323
# ^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl

0 commit comments

Comments
 (0)