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

View file

@ -336,6 +336,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta)
- [x] [yaml](https://github.com/ikatyang/tree-sitter-yaml) (maintained by @stsewd)
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq)
- [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino)
<!--parserinfo-->

View file

@ -488,6 +488,9 @@
"yang": {
"revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502"
},
"yuck": {
"revision": "607bf03cc78912cbaa85a3d373af21ddeaef5b41"
},
"zig": {
"revision": "6b3f5788f38be900b45f5af5a753bf6a37d614b8"
}

View file

@ -1551,6 +1551,15 @@ list.yang = {
filetype = "yang",
}
list.yuck = {
install_info = {
url = "https://github.com/Philipp-M/tree-sitter-yuck",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@Philipp-M", "@amaanq" },
filetype = "yuck",
}
list.zig = {
install_info = {
url = "https://github.com/maxxnino/tree-sitter-zig",

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)