mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add gotemplate and helm parser support
This commit is contained in:
parent
f8d4e5c1ba
commit
9e1f3c3369
7 changed files with 252 additions and 0 deletions
|
|
@ -254,6 +254,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [gomod](https://github.com/camdencheek/tree-sitter-go-mod) (maintained by @camdencheek)
|
||||
- [x] [gosum](https://github.com/amaanq/tree-sitter-go-sum) (maintained by @amaanq)
|
||||
- [x] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc)
|
||||
- [x] [gotmpl](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin)
|
||||
- [x] [gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) (maintained by @ObserverOfTime)
|
||||
- [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley)
|
||||
- [x] [groovy](https://github.com/murtaza64/tree-sitter-groovy) (maintained by @murtaza64)
|
||||
|
|
@ -264,6 +265,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) (maintained by @lykahb)
|
||||
- [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
|
||||
- [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay)
|
||||
- [x] [helm](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin)
|
||||
- [x] [hjson](https://github.com/winston0410/tree-sitter-hjson) (maintained by @winston0410)
|
||||
- [x] [hlsl](https://github.com/theHamsta/tree-sitter-hlsl) (maintained by @theHamsta)
|
||||
- [x] [hlsplaylist](https://github.com/Freed-Wu/tree-sitter-hlsplaylist) (maintained by @Freed-Wu)
|
||||
|
|
|
|||
|
|
@ -242,6 +242,9 @@
|
|||
"gowork": {
|
||||
"revision": "949a8a470559543857a62102c84700d291fc984c"
|
||||
},
|
||||
"gotmpl": {
|
||||
"revision": "17144a77be0acdecebd9d557398883569fed41de"
|
||||
},
|
||||
"gpg": {
|
||||
"revision": "f99323fb8f3f10b6c69db0c2f6d0a14bd7330675"
|
||||
},
|
||||
|
|
@ -272,6 +275,9 @@
|
|||
"heex": {
|
||||
"revision": "4a36c9a388505180da6ee0eda1d8afb8c83481c8"
|
||||
},
|
||||
"helm": {
|
||||
"revision": "17144a77be0acdecebd9d557398883569fed41de"
|
||||
},
|
||||
"hjson": {
|
||||
"revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -758,6 +758,14 @@ list.gowork = {
|
|||
maintainers = { "@omertuc" },
|
||||
}
|
||||
|
||||
list.gotmpl = {
|
||||
install_info = {
|
||||
url = "https://github.com/ngalaiko/tree-sitter-go-template",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@qvalentin" },
|
||||
}
|
||||
|
||||
list.gpg = {
|
||||
install_info = {
|
||||
url = "https://github.com/ObserverOfTime/tree-sitter-gpg-config",
|
||||
|
|
@ -838,6 +846,15 @@ list.heex = {
|
|||
maintainers = { "@connorlay" },
|
||||
}
|
||||
|
||||
list.helm = {
|
||||
install_info = {
|
||||
url = "https://github.com/ngalaiko/tree-sitter-go-template",
|
||||
location = "dialects/helm",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@qvalentin" },
|
||||
}
|
||||
|
||||
list.hjson = {
|
||||
install_info = {
|
||||
url = "https://github.com/winston0410/tree-sitter-hjson",
|
||||
|
|
|
|||
108
queries/gotmpl/highlights.scm
Normal file
108
queries/gotmpl/highlights.scm
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
; Identifiers
|
||||
[
|
||||
(field)
|
||||
(field_identifier)
|
||||
] @variable.member
|
||||
|
||||
(variable) @variable
|
||||
|
||||
; Function calls
|
||||
(function_call
|
||||
function: (identifier) @function)
|
||||
|
||||
(method_call
|
||||
method:
|
||||
(selector_expression
|
||||
field: (field_identifier) @function))
|
||||
|
||||
; Builtin functions
|
||||
(function_call
|
||||
function: (identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery"
|
||||
"eq" "ne" "lt" "ge" "gt" "ge"))
|
||||
|
||||
; Operators
|
||||
[
|
||||
"|"
|
||||
":="
|
||||
] @operator
|
||||
|
||||
; Delimiters
|
||||
[
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{{"
|
||||
"}}"
|
||||
"{{-"
|
||||
"-}}"
|
||||
")"
|
||||
"("
|
||||
] @punctuation.bracket
|
||||
|
||||
; Actions
|
||||
(if_action
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"else if"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
(range_action
|
||||
[
|
||||
"range"
|
||||
"else"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
(template_action
|
||||
"template" @function.builtin)
|
||||
|
||||
(block_action
|
||||
[
|
||||
"block"
|
||||
"end"
|
||||
] @keyword.directive)
|
||||
|
||||
(define_action
|
||||
[
|
||||
"define"
|
||||
"end"
|
||||
] @keyword.directive.define)
|
||||
|
||||
(with_action
|
||||
[
|
||||
"with"
|
||||
"else"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
; Literals
|
||||
[
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
] @string
|
||||
|
||||
(rune_literal) @string.special.symbol
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
(int_literal)
|
||||
(imaginary_literal)
|
||||
] @number
|
||||
|
||||
(float_literal) @number.float
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
(comment) @comment @spell
|
||||
34
queries/gotmpl/injections.scm
Normal file
34
queries/gotmpl/injections.scm
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; {{"put" | printf "%s%s" "out" | printf "%q"}}
|
||||
(function_call
|
||||
function: (identifier) @_function
|
||||
arguments:
|
||||
(argument_list
|
||||
.
|
||||
(interpreted_string_literal) @injection.content)
|
||||
(#eq? @_function "printf")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
; {{ js "var a = 1 + 1" }}
|
||||
(function_call
|
||||
function: (identifier) @_function
|
||||
arguments:
|
||||
(argument_list
|
||||
.
|
||||
(interpreted_string_literal) @injection.content)
|
||||
(#eq? @_function "js")
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
; {{ html "<h1>hello</h1>" }}
|
||||
(function_call
|
||||
function: (identifier) @_function
|
||||
arguments:
|
||||
(argument_list
|
||||
.
|
||||
(interpreted_string_literal) @injection.content)
|
||||
(#eq? @_function "html")
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "html"))
|
||||
46
queries/helm/highlights.scm
Normal file
46
queries/helm/highlights.scm
Normal 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"))
|
||||
39
queries/helm/injections.scm
Normal file
39
queries/helm/injections.scm
Normal 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"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue