Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update grammar and highlight queries for slint grammar rewrite #5290

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)