diff --git a/Terraform.sublime-syntax b/Terraform.sublime-syntax index 4950127..02ca3ea 100644 --- a/Terraform.sublime-syntax +++ b/Terraform.sublime-syntax @@ -74,8 +74,38 @@ variables: # Built-In Functions # - # https://www.terraform.io/docs/language/functions/index.html - predeclared_funcs: abs|ceil|floor|log|max|min|pow|signum|chomp|format|formatlist|indent|join|lower|regex|regexall|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalesce|coalescelist|compact|concat|contains|distinct|element|flatten|index|keys|length|list|lookup|map|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring + # https://developer.hashicorp.com/terraform/language/functions + predeclared_funcs: |- + \b(?x: + # numbers + abs|ceil|floor|log|max|min|parseint|pow|signum + # string + |chomp|endswith|format|formatlist|indent|join|lower|regex|regexall|replace + |split|startswith|strcontains|strrev|substr + |templatestring|title|trim|trimprefix|trimsuffix|trimspace|upper + # collection + |alltrue|anytrue|chunklist|coalesce|coalescelist|compact|concat|contains + |distinct|element|flatten|index|keys|length|list|lookup + |map|matchkeys|merge|one|range|reverse + |setintersection|setproduct|setsubtract|setunion|slice|sort|sum + |transpose|values|zipmap + # encoding + |base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|textdecodebase64|textencodebase64|urlencode|yamldecode|yamlencode + # filesystem + |abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile + # date and time + |formatdate|plantimestamp|timeadd|timecmp|timestamp + # hash and crypto + |base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filesha1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5 + # ip network + |cidrhost|cidrnetmask|cidrsubnet|cidrsubnets + # type conversion + |can|issensitive|nonsensitive|sensitive|tobool|tolist|tomap|tonumber|toset|tostring|try|type + # terraform-specific + |provider::terraform::(?:encode_tfvars|decode_tfvars|encode_expr) + # deprecated/old + |filemd1 + )\b contexts: main: @@ -479,12 +509,12 @@ contexts: # https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#functions-and-function-calls # https://www.terraform.io/docs/language/expressions/function-calls.html functions: - - match: (({{predeclared_funcs}})|\b({{identifer}})\b)(\() + - match: (?:({{predeclared_funcs}})|\b({{identifer}})\b)(\() comment: Built-in function calls captures: - 2: support.function.builtin.terraform - 3: variable.function.terraform - 4: punctuation.section.parens.begin.terraform + 1: support.function.builtin.terraform + 2: variable.function.terraform + 3: punctuation.section.parens.begin.terraform push: - meta_scope: meta.function-call.terraform - match: \) diff --git a/syntax_test_terraform.tf b/syntax_test_terraform.tf index 855c676..c3cad27 100644 --- a/syntax_test_terraform.tf +++ b/syntax_test_terraform.tf @@ -2430,6 +2430,15 @@ # ^^^^^^ meta.function-call.terraform string.quoted.double.terraform # ^ meta.function-call.terraform punctuation.section.parens.end.terraform + + provider::terraform::encode_tfvars({ +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.terraform +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.function.builtin.terraform +# ^ punctuation.section.parens.begin.terraform +# ^ meta.braces.terraform punctuation.section.braces.begin.terraform + example = "Hello!" + }) + ///////////////////////////////////////////////////////////////////// // TUPLE FOR-EXPRESSIONS /////////////////////////////////////////////////////////////////////