feat: improve yuck highlighting

This commit is contained in:
Philipp Mildenberger 2023-03-10 03:04:16 +01:00 committed by Amaan Qureshi
parent fc1ca10bfb
commit 1de237d10d
2 changed files with 85 additions and 144 deletions

View file

@ -516,7 +516,7 @@
"revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502"
},
"yuck": {
"revision": "fefe8e32ac5306b261af6af52571e13edf7b420c"
"revision": "e3d91a3c65decdea467adebe4127b8366fa47919"
},
"zig": {
"revision": "f3bc9ffe9ca10f52dee01999b5b6ce9a4074b0ac"

View file

@ -1,148 +1,96 @@
; Tags
; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list
(list
(symbol) @tag)
; Includes
((symbol) @include
(#match? @include "include"))
(list .
((symbol) @include
(#eq? @include "include")))
; Keywords
((symbol) @keyword
(#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "for" "geometry" "children" "struts"))
; I think there's a bug in tree-sitter the anchor doesn't seem to be working, see
; https://github.com/tree-sitter/tree-sitter/pull/2107
(list .
((symbol) @keyword
(#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts")))
; Loop
(loop_widget . "for" @repeat . (symbol) @variable . "in" @keyword.operator)
(loop_widget . "for" @repeat . (symbol) @variable . "in" @keyword.operator . (symbol) @variable)
; Builtin widgets
(list .
((symbol) @tag.builtin
(#any-of? @tag.builtin
"box"
"button"
"calendar"
"centerbox"
"checkbox"
"circular-progress"
"color-button"
"color-chooser"
"combo-box-text"
"eventbox"
"expander"
"graph"
"image"
"input"
"label"
"literal"
"overlay"
"progress"
"revealer"
"scale"
"scroll"
"transform")))
; Variables
(ident) @variable
(array
(symbol) @variable)
; Properties & Fields
(keyword) @property
(json_access
(_)
"["
(simplexpr
(ident) @property))
(json_safe_access
(_)
"?."
"["
(simplexpr
(ident) @property))
(json_dot_access
(index) @property)
(json_safe_dot_access
(index) @property)
(json_object
(simplexpr
(ident) @field))
; Functions
(function_call
name: (ident) @function.call)
; Variables
(array
(symbol) @variable)
(binary_expression
(simplexpr
(ident) @variable))
(unary_expression
(simplexpr
(ident) @variable))
(ternary_expression
(simplexpr
(ident) @variable))
(array
(symbol) @variable)
(json_access
(simplexpr
(ident) @variable))
(json_safe_access
(simplexpr
(ident) @variable))
(json_array
(simplexpr
(ident) @variable))
(json_dot_access
(simplexpr
(ident) @variable))
(json_safe_dot_access
(simplexpr
(ident) @variable))
(json_object
(_)
":"
(simplexpr
(ident) @variable))
; Properties & Fields
(keyword) @property
(json_access
(_)
"["
(simplexpr
(ident) @property))
(json_safe_access
(_)
"?."
"["
(simplexpr
(ident) @property))
(json_dot_access
(index) @property)
(json_safe_dot_access
(index) @property)
(json_object
(simplexpr
(ident) @field))
; Operators
[
"+"
"-"
"*"
"/"
"%"
"&&"
"||"
"=="
"!="
"=~"
">="
"<="
">"
"<"
"?:"
"?."
"!"
] @operator
(ternary_expression
["?" ":"] @conditional.ternary)
; Properties & Fields
(keyword) @property
(json_access
(_)
"["
(simplexpr
(ident) @property))
(json_safe_access
(_)
"?."
"["
(simplexpr
(ident) @property))
(json_dot_access
(index) @property)
(json_safe_dot_access
(index) @property)
(json_object
(simplexpr
(ident) @field))
; Operators
[
@ -162,21 +110,19 @@
"<="
"!"
"?."
"?:"
] @operator
(ternary_expression
["?" ":"] @conditional.ternary)
; Punctuation
[
":"
"."
","
] @punctuation.delimiter
[":" "." ","] @punctuation.delimiter
["{" "}" "[" "]" "(" ")"] @punctuation.bracket
; Ternary expression
(ternary_expression
["?" ":"] @conditional.ternary)
; Literals
(number) @number
@ -199,11 +145,6 @@
(comment) @comment @spell
; Other stuff that has not been catched by the previous queries yet
(ident) @variable
(index) @property
; Errors
(ERROR) @error