Improved yuck highlighting (and parser), and introduced a tag.builtin scope (#6242)
This commit is contained in:
parent
d63e570e0a
commit
98415f288f
4 changed files with 92 additions and 50 deletions
|
@ -215,6 +215,7 @@ We use a similar set of scopes as
|
||||||
- `special` (preprocessor in C)
|
- `special` (preprocessor in C)
|
||||||
|
|
||||||
- `tag` - Tags (e.g. `<body>` in HTML)
|
- `tag` - Tags (e.g. `<body>` in HTML)
|
||||||
|
- `builtin`
|
||||||
|
|
||||||
- `namespace`
|
- `namespace`
|
||||||
|
|
||||||
|
|
|
@ -2206,7 +2206,7 @@ indent = { tab-width = 2, unit = " " }
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "yuck"
|
name = "yuck"
|
||||||
source = { git = "https://github.com/Philipp-M/tree-sitter-yuck", rev = "9e97da5773f82123a8c8cccf8f7e795d140ed7d1" }
|
source = { git = "https://github.com/Philipp-M/tree-sitter-yuck", rev = "e3d91a3c65decdea467adebe4127b8366fa47919" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "prql"
|
name = "prql"
|
||||||
|
|
|
@ -1,66 +1,107 @@
|
||||||
|
; Errors
|
||||||
|
|
||||||
(ERROR) @error
|
(ERROR) @error
|
||||||
|
|
||||||
(line_comment) @comment
|
; Comments
|
||||||
|
|
||||||
; keywords and symbols
|
(comment) @comment
|
||||||
|
|
||||||
(keyword) @keyword
|
; Operators
|
||||||
(symbol) @tag
|
|
||||||
|
|
||||||
; literals
|
[
|
||||||
|
"+"
|
||||||
|
"-"
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"||"
|
||||||
|
"&&"
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
"=~"
|
||||||
|
">"
|
||||||
|
"<"
|
||||||
|
">="
|
||||||
|
"<="
|
||||||
|
"!"
|
||||||
|
"?."
|
||||||
|
"?:"
|
||||||
|
] @operator
|
||||||
|
|
||||||
(bool_literal) @constant.builtin.boolean
|
(ternary_expression
|
||||||
(num_literal) @constant.numeric
|
["?" ":"] @operator)
|
||||||
|
|
||||||
; strings
|
; Punctuation
|
||||||
(string_interpolation
|
|
||||||
(string_interpolation_start) @punctuation.special
|
[ ":" "." "," ] @punctuation.delimiter
|
||||||
(string_interpolation_end) @punctuation.special)
|
|
||||||
|
[ "{" "}" "[" "]" "(" ")" ] @punctuation.bracket
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
|
||||||
|
(number (float)) @constant.numeric.float
|
||||||
|
|
||||||
|
(number (integer)) @constant.numeric.integer
|
||||||
|
|
||||||
|
(boolean) @constant.builtin.boolean
|
||||||
|
|
||||||
|
; Strings
|
||||||
|
|
||||||
(escape_sequence) @constant.character.escape
|
(escape_sequence) @constant.character.escape
|
||||||
|
|
||||||
(string
|
(string_interpolation
|
||||||
[
|
"${" @punctuation.special
|
||||||
(unescaped_single_quote_string_fragment)
|
"}" @punctuation.special)
|
||||||
(unescaped_double_quote_string_fragment)
|
|
||||||
(unescaped_backtick_string_fragment)
|
|
||||||
"\""
|
|
||||||
"'"
|
|
||||||
"`"
|
|
||||||
]) @string
|
|
||||||
|
|
||||||
; operators and general punctuation
|
[ (string_fragment) "\"" "'" "`" ] @string
|
||||||
|
|
||||||
(unary_expression
|
; Attributes & Fields
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
(binary_expression
|
(keyword) @attribute
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
(ternary_expression
|
; Functions
|
||||||
operator: _ @operator)
|
|
||||||
|
|
||||||
[
|
(function_call
|
||||||
":"
|
name: (ident) @function)
|
||||||
"."
|
|
||||||
","
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
[
|
; Variables
|
||||||
"("
|
|
||||||
")"
|
|
||||||
"["
|
|
||||||
"]"
|
|
||||||
"{"
|
|
||||||
"}"
|
|
||||||
] @punctuation.bracket
|
|
||||||
[
|
|
||||||
":"
|
|
||||||
"."
|
|
||||||
","
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
; Rest (general identifiers that are not yet catched)
|
|
||||||
|
|
||||||
(index) @variable
|
|
||||||
(ident) @variable
|
(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
|
||||||
|
|
||||||
|
(ident) @variable
|
||||||
|
(index) @variable
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
((line_comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue