Skip to content

Commit

Permalink
Update slint highlight queries for grammar rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmoulton committed Dec 25, 2022
1 parent 4155026 commit 7c45180
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 55 deletions.
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ language-server = { command = "slint-lsp", args = [] }

[[grammar]]
name = "slint"
source = { git = "https://github.com/jrmoulton/tree-sitter-slint", rev = "0d4dda94f96623302dfc234e06be62a5717f47da" }
source = { git = "https://github.com/jrmoulton/tree-sitter-slint", rev = "07547525cdf4627343dca5891f1743ae45e879bb" }

[[language]]
name = "task"
Expand Down
137 changes: 83 additions & 54 deletions runtime/queries/slint/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,77 +1,106 @@
(identifier) @variable
(type_identifier) @type
(comment) @comment
(int_literal) @number
(float_literal) @float
(string_literal) @string
(function_identifier) @function
[
(image_macro)
(children_macro)
(radial_grad_macro)
(linear_grad_macro)
] @function.macro
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
field: (identifier) @function.call))
(vis) @include
(units) @type
(array_literal
(identifier) @type)
(transition_statement state: (identifier) @field)
(state_expression state: (identifier) @field)
(struct_block_definition
(identifier) @field)

; (state_identifier) @field

(user_type_identifier) @type

(var_identifier) @variable
[
"in"
"for"
] @repeat

(state_identifier) @variable.other.member
"@" @keyword

(var_identifier
(post_identifier) @variable)
[
"import"
"from"
] @include

(function_identifier) @function
[
"if"
"else"
] @conditional

(reference_identifier) @keyword.storage.modifier.ref
(visibility_modifier) @keyword.storage.modifier
[
"root"
"parent"
"duration"
"easing"
] @variable.builtin

(comment) @comment
[
"true"
"false"
] @boolean

(string) @string
(int_number) @constant.numeric
(unit_type) @type.builtin

[
"struct"
"property"
"callback"
"import"
"from"
"root"
"parent"
"this"
"for"
"in"
"if"
"else if"
"else"
"animate"
"states"
"when"
"in"
"out"
"transitions"
"global"
] @keyword

[
"black"
"transparent"
"blue"
"ease"
"ease_in"
"ease-in"
"ease_in_out"
"ease-in-out"
"ease_out"
"ease-out"
"end"
"green"
"red"
"red"
"start"
"yellow"
"true"
"false"
] @constant.builtin

"@" @keyword

; ; Punctuation
"black"
"transparent"
"blue"
"ease"
"ease_in"
"ease-in"
"ease_in_out"
"ease-in-out"
"ease_out"
"ease-out"
"end"
"green"
"red"
"red"
"start"
"yellow"
"white"
"gray"
] @constant.builtin


; Punctuation
[
","
"."
","
"."
";"
":"
] @punctuation.delimiter

; ; Brackets
; Brackets
[
"("
")"
Expand All @@ -81,13 +110,13 @@
"}"
] @punctuation.bracket

(define_property ["<" ">"] @punctuation.bracket)

[
"angle"
"bool"
"brush"
; "color" // This causes problems
"duration"
"easing"
"color"
"float"
"image"
"int"
Expand All @@ -100,6 +129,7 @@

[
":="
"<=>"
"!"
"-"
"+"
Expand All @@ -118,8 +148,7 @@
"*="
"/="
"?"

"=>"
] @operator

(ternary_expression [":" "?"] @keyword.control.conditional)
(ternary_expression [":" "?"] @conditional)

0 comments on commit 7c45180

Please sign in to comment.