feat: add gotemplate and helm parser support

This commit is contained in:
qvalentin 2024-02-04 11:23:23 +01:00 committed by Christian Clason
parent f8d4e5c1ba
commit 9e1f3c3369
7 changed files with 252 additions and 0 deletions

View file

@ -0,0 +1,46 @@
; inherits: gotmpl
; Builtin functions
(function_call
function: (identifier) @function.builtin
(#any-of? @function.builtin
"and" "or" "not" "eq" "ne" "lt" "le" "gt" "ge" "default" "required" "empty" "fail" "coalesce"
"ternary" "print" "println" "printf" "trim" "trimAll" "trimPrefix" "trimSuffix" "lower" "upper"
"title" "untitle" "repeat" "substr" "nospace" "trunc" "abbrev" "abbrevboth" "initials"
"randAlphaNum" "randAlpha" "randNumeric" "randAscii" "wrap" "wrapWith" "contains" "hasPrefix"
"hasSuffix" "quote" "squote" "cat" "indent" "nindent" "replace" "plural" "snakecase" "camelcase"
"kebabcase" "swapcase" "shuffle" "toStrings" "toDecimal" "toJson" "mustToJson" "toPrettyJson"
"mustToPrettyJson" "toRawJson" "mustToRawJson" "fromYaml" "fromJson" "fromJsonArray"
"fromYamlArray" "toYaml" "regexMatch" "mustRegexMatch" "regexFindAll" "mustRegexFinDall"
"regexFind" "mustRegexFind" "regexReplaceAll" "mustRegexReplaceAll" "regexReplaceAllLiteral"
"mustRegexReplaceAllLiteral" "regexSplit" "mustRegexSplit" "sha1sum" "sha256sum" "adler32sum"
"htpasswd" "derivePassword" "genPrivateKey" "buildCustomCert" "genCA" "genSelfSignedCert"
"genSignedCert" "encryptAES" "decryptAES" "now" "ago" "date" "dateInZone" "duration"
"durationRound" "unixEpoch" "dateModify" "mustDateModify" "htmlDate" "htmlDateInZone" "toDate"
"mustToDate" "dict" "get" "set" "unset" "hasKey" "pluck" "dig" "merge" "mustMerge"
"mergeOverwrite" "mustMergeOverwrite" "keys" "pick" "omit" "values" "deepCopy" "mustDeepCopy"
"b64enc" "b64dec" "b32enc" "b32dec" "list" "first" "mustFirst" "rest" "mustRest" "last"
"mustLast" "initial" "mustInitial" "append" "mustAppend" "prepend" "mustPrepend" "concat"
"reverse" "mustReverse" "uniq" "mustUniq" "without" "mustWithout" "has" "mustHas" "compact"
"mustCompact" "index" "slice" "mustSlice" "until" "untilStep" "seq" "add" "add1" "sub" "div"
"mod" "mul" "max" "min" "len" "addf" "add1f" "subf" "divf" "mulf" "maxf" "minf" "floor" "ceil"
"round" "getHostByName" "base" "dir" "clean" "ext" "isAbs" "kindOf" "kindIs" "typeOf" "typeIs"
"typeIsLike" "deepequal" "semver" "semverCompare" "urlParse" "urlJoin" "urlquery" "lookup"
"include")
)
; {{ .Values.test }}
(selector_expression
operand:
(field
name: (identifier) @constant.builtin
(#any-of? @constant.builtin
"Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template"))
(field_identifier))
; {{ $.Values.test }}
(selector_expression
operand: (variable)
field: (field_identifier) @constant.builtin
(#any-of? @constant.builtin
"Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template"))

View file

@ -0,0 +1,39 @@
; inherits: gotmpl
((text) @injection.content
(#set! injection.language "yaml")
(#set! injection.combined))
; {{ regexFind "[a-zA-Z][1-9]" "abcd1234" }}
(function_call
function: (identifier) @_function
arguments:
(argument_list
.
(interpreted_string_literal) @injection.content)
(#any-of? @_function
"regexMatch" "mustRegexMatch" "regexFindAll" "mustRegexFinDall" "regexFind" "mustRegexFind"
"regexReplaceAll" "mustRegexReplaceAll" "regexReplaceAllLiteral" "mustRegexReplaceAllLiteral"
"regexSplit" "mustRegexSplit")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "regex"))
(function_call
function: (identifier) @_function
arguments:
(argument_list
.
(interpreted_string_literal) @injection.content)
(#any-of? @_function "fromYaml" "fromYamlArray")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "yaml"))
(function_call
function: (identifier) @_function
arguments:
(argument_list
.
(interpreted_string_literal) @injection.content)
(#any-of? @_function "fromJson" "fromJsonArray")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "json"))