feat: add yuck

This commit is contained in:
Philipp Mildenberger 2023-02-20 17:55:06 +01:00 committed by Amaan Qureshi
parent 04b87c7b6e
commit b9a7591b6c
8 changed files with 278 additions and 0 deletions

9
queries/yuck/folds.scm Normal file
View file

@ -0,0 +1,9 @@
[
(ast_block)
(list)
(array)
(expr)
(json_array)
(json_object)
(parenthesized_expression)
] @fold

209
queries/yuck/highlights.scm Normal file
View file

@ -0,0 +1,209 @@
; Tags
(list
(symbol) @tag)
; Includes
((symbol) @include
(#match? @include "include"))
; Keywords
((symbol) @keyword
(#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "for" "geometry" "children" "struts"))
; 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
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"=="
"!="
"=~"
">"
"<"
">="
"<="
"!"
"?."
] @operator
(ternary_expression
["?" ":"] @conditional.ternary)
; Punctuation
[
":"
"."
","
] @punctuation.delimiter
["{" "}" "[" "]" "(" ")"] @punctuation.bracket
; Literals
(number) @number
(float) @float
(boolean) @boolean
; Strings
[ (string_fragment) "\"" "'" "`" ] @string
(string_interpolation
"${" @punctuation.special
"}" @punctuation.special)
(escape_sequence) @string.escape
; Comments
(comment) @comment @spell
; Other stuff that has not been catched by the previous queries yet
(ident) @variable
(index) @property
; Errors
(ERROR) @error

25
queries/yuck/indents.scm Normal file
View file

@ -0,0 +1,25 @@
[
(ast_block)
(array)
(expr)
(json_array)
(json_object)
(parenthesized_expression)
] @indent
; TODO: can't get this to work, goal is to indent at the property ":" prefix
; ((list (identifier) (property)) @aligned_indent
; (#set! "delimiter" ":"))
[")" "}" "]"] @indent_end
[ "{" "}" ] @branch
[ "(" ")" ] @branch
[ "[" "]" ] @branch
[
(ERROR)
(comment)
] @auto

View file

@ -0,0 +1 @@
(comment) @comment

21
queries/yuck/locals.scm Normal file
View file

@ -0,0 +1,21 @@
[
(ast_block)
(list)
(array)
(expr)
(json_array)
(json_object)
(parenthesized_expression)
] @scope
(symbol) @reference
(keyword) @definition.field
(json_object
(simplexpr
(ident) @definition.field))
(ast_block
(symbol)
(ident) @definition.type)