-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved yuck highlighting (and parser), and introduced a tag.builtin…
… scope (#6242)
- Loading branch information
Showing
4 changed files
with
91 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,107 @@ | ||
; Errors | ||
|
||
(ERROR) @error | ||
|
||
(line_comment) @comment | ||
; Comments | ||
|
||
; keywords and symbols | ||
(comment) @comment | ||
|
||
(keyword) @keyword | ||
(symbol) @tag | ||
; Operators | ||
|
||
; literals | ||
[ | ||
"+" | ||
"-" | ||
"*" | ||
"/" | ||
"%" | ||
"||" | ||
"&&" | ||
"==" | ||
"!=" | ||
"=~" | ||
">" | ||
"<" | ||
">=" | ||
"<=" | ||
"!" | ||
"?." | ||
"?:" | ||
] @operator | ||
|
||
(bool_literal) @constant.builtin.boolean | ||
(num_literal) @constant.numeric | ||
(ternary_expression | ||
["?" ":"] @operator) | ||
|
||
; strings | ||
(string_interpolation | ||
(string_interpolation_start) @punctuation.special | ||
(string_interpolation_end) @punctuation.special) | ||
; Punctuation | ||
|
||
[ ":" "." "," ] @punctuation.delimiter | ||
|
||
[ "{" "}" "[" "]" "(" ")" ] @punctuation.bracket | ||
|
||
; Literals | ||
|
||
(number (float)) @constant.numeric.float | ||
|
||
(number (integer)) @constant.numeric.integer | ||
|
||
(boolean) @constant.builtin.boolean | ||
|
||
; Strings | ||
|
||
(escape_sequence) @constant.character.escape | ||
|
||
(string | ||
[ | ||
(unescaped_single_quote_string_fragment) | ||
(unescaped_double_quote_string_fragment) | ||
(unescaped_backtick_string_fragment) | ||
"\"" | ||
"'" | ||
"`" | ||
]) @string | ||
(string_interpolation | ||
"${" @punctuation.special | ||
"}" @punctuation.special) | ||
|
||
; operators and general punctuation | ||
[ (string_fragment) "\"" "'" "`" ] @string | ||
|
||
(unary_expression | ||
operator: _ @operator) | ||
; Attributes & Fields | ||
|
||
(binary_expression | ||
operator: _ @operator) | ||
(keyword) @attribute | ||
|
||
(ternary_expression | ||
operator: _ @operator) | ||
; Functions | ||
|
||
[ | ||
":" | ||
"." | ||
"," | ||
] @punctuation.delimiter | ||
(function_call | ||
name: (ident) @function) | ||
|
||
[ | ||
"(" | ||
")" | ||
"[" | ||
"]" | ||
"{" | ||
"}" | ||
] @punctuation.bracket | ||
[ | ||
":" | ||
"." | ||
"," | ||
] @punctuation.delimiter | ||
; Variables | ||
|
||
; Rest (general identifiers that are not yet catched) | ||
(ident) @variable | ||
|
||
(array | ||
(symbol) @variable) | ||
|
||
; Builtin widgets | ||
|
||
(list . | ||
((symbol) @tag.builtin | ||
(#match? @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)$"))) | ||
|
||
; Keywords | ||
|
||
; 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 | ||
(#match? @keyword "^(defwindow|defwidget|defvar|defpoll|deflisten|geometry|children|struts)$"))) | ||
|
||
(list . | ||
((symbol) @keyword.control.import | ||
(#eq? @keyword.control.import "include"))) | ||
|
||
; Loop | ||
|
||
(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator . (symbol) @variable) | ||
|
||
(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator) | ||
|
||
; 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) | ||
|
||
; Other stuff that has not been catched by the previous queries yet | ||
|
||
(index) @variable | ||
(ident) @variable | ||
(index) @variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
((line_comment) @injection.content | ||
((comment) @injection.content | ||
(#set! injection.language "comment")) |