feat(gotmpl,helm): raise highlight priorities (#6712)

This commit is contained in:
Kai Moschcau 2024-07-03 09:59:18 +02:00 committed by GitHub
parent 0209151fd2
commit f1a4a75005
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 21 deletions

View file

@ -1,39 +1,49 @@
; Priorities of the highlight queries are raised, so that they overrule the
; often surrounding and overlapping highlights from the non-gotmpl injections.
;
; Identifiers ; Identifiers
[ ([
(field) (field)
(field_identifier) (field_identifier)
] @variable.member ] @variable.member
(#set! priority 110))
(variable) @variable ((variable) @variable
(#set! priority 110))
; Function calls ; Function calls
(function_call (function_call
function: (identifier) @function) function: (identifier) @function
(#set! priority 110))
(method_call (method_call
method: (selector_expression method: (selector_expression
field: (field_identifier) @function)) field: (field_identifier) @function
(#set! priority 110)))
; Builtin functions ; Builtin functions
(function_call (function_call
function: (identifier) @function.builtin function: (identifier) @function.builtin
(#set! priority 110)
(#any-of? @function.builtin (#any-of? @function.builtin
"and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery" "and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery"
"eq" "ne" "lt" "ge" "gt" "ge")) "eq" "ne" "lt" "ge" "gt" "ge"))
; Operators ; Operators
[ ([
"|" "|"
":=" ":="
] @operator ] @operator
(#set! priority 110))
; Delimiters ; Delimiters
[ ([
"." "."
"," ","
] @punctuation.delimiter ] @punctuation.delimiter
(#set! priority 110))
[ ([
"{{" "{{"
"}}" "}}"
"{{-" "{{-"
@ -41,6 +51,7 @@
")" ")"
"(" "("
] @punctuation.bracket ] @punctuation.bracket
(#set! priority 110))
; Actions ; Actions
(if_action (if_action
@ -49,59 +60,73 @@
"else" "else"
"else if" "else if"
"end" "end"
] @keyword.conditional) ] @keyword.conditional
(#set! priority 110))
(range_action (range_action
[ [
"range" "range"
"else" "else"
"end" "end"
] @keyword.repeat) ] @keyword.repeat
(#set! priority 110))
(template_action (template_action
"template" @function.builtin) "template" @function.builtin
(#set! priority 110))
(block_action (block_action
[ [
"block" "block"
"end" "end"
] @keyword.directive) ] @keyword.directive
(#set! priority 110))
(define_action (define_action
[ [
"define" "define"
"end" "end"
] @keyword.directive.define) ] @keyword.directive.define
(#set! priority 110))
(with_action (with_action
[ [
"with" "with"
"else" "else"
"end" "end"
] @keyword.conditional) ] @keyword.conditional
(#set! priority 110))
; Literals ; Literals
[ ([
(interpreted_string_literal) (interpreted_string_literal)
(raw_string_literal) (raw_string_literal)
] @string ] @string
(#set! priority 110))
(rune_literal) @string.special.symbol ((rune_literal) @string.special.symbol
(#set! priority 110))
(escape_sequence) @string.escape ((escape_sequence) @string.escape
(#set! priority 110))
[ ([
(int_literal) (int_literal)
(imaginary_literal) (imaginary_literal)
] @number ] @number
(#set! priority 110))
(float_literal) @number.float ((float_literal) @number.float
(#set! priority 110))
[ ([
(true) (true)
(false) (false)
] @boolean ] @boolean
(#set! priority 110))
(nil) @constant.builtin ((nil) @constant.builtin
(#set! priority 110))
(comment) @comment @spell ((comment) @comment @spell
(#set! priority 110))

View file

@ -1,8 +1,11 @@
; inherits: gotmpl ; inherits: gotmpl
; For the reasoning concerning the priorities, see gotmpl highlights.
;
; Builtin functions ; Builtin functions
(function_call (function_call
function: (identifier) @function.builtin function: (identifier) @function.builtin
(#set! priority 110)
(#any-of? @function.builtin (#any-of? @function.builtin
"and" "or" "not" "eq" "ne" "lt" "le" "gt" "ge" "default" "required" "empty" "fail" "coalesce" "and" "or" "not" "eq" "ne" "lt" "le" "gt" "ge" "default" "required" "empty" "fail" "coalesce"
"ternary" "print" "println" "printf" "trim" "trimAll" "trimPrefix" "trimSuffix" "lower" "upper" "ternary" "print" "println" "printf" "trim" "trimAll" "trimPrefix" "trimSuffix" "lower" "upper"
@ -33,6 +36,7 @@
(selector_expression (selector_expression
operand: (field operand: (field
name: (identifier) @constant.builtin name: (identifier) @constant.builtin
(#set! priority 110)
(#any-of? @constant.builtin (#any-of? @constant.builtin
"Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template")) "Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template"))
(field_identifier)) (field_identifier))
@ -41,5 +45,6 @@
(selector_expression (selector_expression
operand: (variable) operand: (variable)
field: (field_identifier) @constant.builtin field: (field_identifier) @constant.builtin
(#set! priority 110)
(#any-of? @constant.builtin (#any-of? @constant.builtin
"Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template")) "Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template"))