diff --git a/src/terraform.yml b/src/terraform.yml index 5602e33..eff0d96 100644 --- a/src/terraform.yml +++ b/src/terraform.yml @@ -39,7 +39,7 @@ repository: - include: "#expressions" functions: - begin: (\w+)(\() + begin: (\w+|(?:provider::\w+::\w+))(\() name: meta.function-call.hcl comment: Built-in function calls beginCaptures: @@ -47,6 +47,8 @@ repository: patterns: - 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 name: support.function.builtin.terraform + - match: \bprovider::(?!null|false|true)[[:alpha:]][[:alnum:]_-]*::(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\b + name: support.function.provider "2": name: punctuation.section.parens.begin.hcl end: \) diff --git a/syntaxes/terraform.tmGrammar.json b/syntaxes/terraform.tmGrammar.json index 6e165bb..b51adc0 100644 --- a/syntaxes/terraform.tmGrammar.json +++ b/syntaxes/terraform.tmGrammar.json @@ -284,7 +284,7 @@ }, "functions": { "name": "meta.function-call.hcl", - "begin": "(\\w+)(\\()", + "begin": "(\\w+|(?:provider::\\w+::\\w+))(\\()", "end": "\\)", "comment": "Built-in function calls", "beginCaptures": { @@ -293,6 +293,10 @@ { "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", "name": "support.function.builtin.terraform" + }, + { + "match": "\\bprovider::(?!null|false|true)[[:alpha:]][[:alnum:]_-]*::(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\\b", + "name": "support.function.provider" } ] }, diff --git a/tests/snapshot/terraform/expressions_functions.tf b/tests/snapshot/terraform/expressions_functions.tf index 227e0d4..438c808 100644 --- a/tests/snapshot/terraform/expressions_functions.tf +++ b/tests/snapshot/terraform/expressions_functions.tf @@ -35,3 +35,8 @@ upper("hello") # known foo("bar") + +# provider defined functions + +provider::framework::example("hi") +invalid::namespaced::function("bye") diff --git a/tests/snapshot/terraform/expressions_functions.tf.snap b/tests/snapshot/terraform/expressions_functions.tf.snap index 479533c..18b873e 100644 --- a/tests/snapshot/terraform/expressions_functions.tf.snap +++ b/tests/snapshot/terraform/expressions_functions.tf.snap @@ -356,4 +356,29 @@ # ^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl # ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl # ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl +> +># provider defined functions +#^ source.hcl.terraform comment.line.number-sign.hcl punctuation.definition.comment.hcl +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl.terraform comment.line.number-sign.hcl +> +>provider::framework::example("hi") +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl.terraform meta.function-call.hcl support.function.provider +# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl +# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl +# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl +>invalid::namespaced::function("bye") +#^^^^^^^ source.hcl.terraform +# ^ source.hcl.terraform +# ^ source.hcl.terraform +# ^^^^^^^^^^ source.hcl.terraform +# ^ source.hcl.terraform +# ^ source.hcl.terraform +# ^^^^^^^^ source.hcl.terraform meta.function-call.hcl +# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.begin.hcl +# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl +# ^ source.hcl.terraform meta.function-call.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl.terraform meta.function-call.hcl punctuation.section.parens.end.hcl > \ No newline at end of file