Skip to content

Commit 27a2468

Browse files
committed
Reorganize built-in function list
1 parent 6a20313 commit 27a2468

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

Terraform.sublime-syntax

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,38 @@ variables:
7474

7575
# Built-In Functions
7676
#
77-
# https://www.terraform.io/docs/language/functions/index.html
78-
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
77+
# https://developer.hashicorp.com/terraform/language/functions
78+
predeclared_funcs: |-
79+
\b(?x:
80+
# numbers
81+
abs|ceil|floor|log|max|min|parseint|pow|signum
82+
# string
83+
|chomp|endswith|format|formatlist|indent|join|lower|regex|regexall|replace
84+
|split|startswith|strcontains|strrev|substr
85+
|templatestring|title|trim|trimprefix|trimsuffix|trimspace|upper
86+
# collection
87+
|alltrue|anytrue|chunklist|coalesce|coalescelist|compact|concat|contains
88+
|distinct|element|flatten|index|keys|length|list|lookup
89+
|map|matchkeys|merge|one|range|reverse
90+
|setintersection|setproduct|setsubtract|setunion|slice|sort|sum
91+
|transpose|values|zipmap
92+
# encoding
93+
|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|textdecodebase64|textencodebase64|urlencode|yamldecode|yamlencode
94+
# filesystem
95+
|abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile
96+
# date and time
97+
|formatdate|plantimestamp|timeadd|timecmp|timestamp
98+
# hash and crypto
99+
|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filesha1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5
100+
# ip network
101+
|cidrhost|cidrnetmask|cidrsubnet|cidrsubnets
102+
# type conversion
103+
|can|issensitive|nonsensitive|sensitive|tobool|tolist|tomap|tonumber|toset|tostring|try|type
104+
# terraform-specific
105+
|provider::terraform::(?:encode_tfvars|decode_tfvars|encode_expr)
106+
# deprecated/old
107+
|filemd1
108+
)\b
79109
80110
contexts:
81111
main:
@@ -479,12 +509,12 @@ contexts:
479509
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#functions-and-function-calls
480510
# https://www.terraform.io/docs/language/expressions/function-calls.html
481511
functions:
482-
- match: (({{predeclared_funcs}})|\b({{identifer}})\b)(\()
512+
- match: (?:({{predeclared_funcs}})|\b({{identifer}})\b)(\()
483513
comment: Built-in function calls
484514
captures:
485-
2: support.function.builtin.terraform
486-
3: variable.function.terraform
487-
4: punctuation.section.parens.begin.terraform
515+
1: support.function.builtin.terraform
516+
2: variable.function.terraform
517+
3: punctuation.section.parens.begin.terraform
488518
push:
489519
- meta_scope: meta.function-call.terraform
490520
- match: \)

syntax_test_terraform.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,6 +2430,15 @@
24302430
# ^^^^^^ meta.function-call.terraform string.quoted.double.terraform
24312431
# ^ meta.function-call.terraform punctuation.section.parens.end.terraform
24322432

2433+
2434+
provider::terraform::encode_tfvars({
2435+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.terraform
2436+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.function.builtin.terraform
2437+
# ^ punctuation.section.parens.begin.terraform
2438+
# ^ meta.braces.terraform punctuation.section.braces.begin.terraform
2439+
example = "Hello!"
2440+
})
2441+
24332442
/////////////////////////////////////////////////////////////////////
24342443
// TUPLE FOR-EXPRESSIONS
24352444
/////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)