From 19c0a0ed5a9bd807c8d8b798d53a85ccd2c2034d Mon Sep 17 00:00:00 2001 From: Leon Matthes Date: Tue, 21 Jul 2026 17:03:48 +0200 Subject: [PATCH] Update Slint Tree-Sitter grammar for 1.17 (#16054) --- languages.toml | 2 +- runtime/queries/slint/highlights.scm | 83 +++++++++++++++++++++------ runtime/queries/slint/injections.scm | 2 +- runtime/queries/slint/textobjects.scm | 2 +- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/languages.toml b/languages.toml index cf7e13ad..938f6a94 100644 --- a/languages.toml +++ b/languages.toml @@ -3070,7 +3070,7 @@ language-servers = [ "slint-lsp" ] [[grammar]] name = "slint" -source = { git = "https://github.com/slint-ui/tree-sitter-slint", rev = "68b25244cec6eb9d7f8f790ef781c29c822d8f84" } +source = { git = "https://github.com/slint-ui/tree-sitter-slint", rev = "f94f96ce093ec153f037228ac2fac5f1a3cd9ac6" } [[language]] name = "task" diff --git a/runtime/queries/slint/highlights.scm b/runtime/queries/slint/highlights.scm index 9b133723..7ea1f55b 100644 --- a/runtime/queries/slint/highlights.scm +++ b/runtime/queries/slint/highlights.scm @@ -1,4 +1,4 @@ -(comment) @comment +[(line_comment) (block_comment)] @comment ; Different types: (string_value) @string @@ -70,6 +70,9 @@ (function_definition name: (_) @function) +(function_declaration + name: (_) @function) + (struct_definition name: (_) @type) @@ -129,20 +132,18 @@ (binding_alias name: (simple_identifier) @variable) -(binding - name: (simple_identifier) @variable) - -(struct_block - (simple_identifier) @variable.other.member) +(struct_field_definition + name: (simple_identifier) @variable.other.member) -(anon_struct_block - (simple_identifier) @variable.other.member) +(anon_struct_assignment + member: (simple_identifier) @variable.other.member) (property_assignment property: (simple_identifier) @variable) -(states_definition - name: (simple_identifier) @variable) +(state_definition + name: (simple_identifier) @variable + "when" @keyword) (callback name: (simple_identifier) @variable) @@ -161,6 +162,7 @@ (linear_gradient_identifier) (radial_gradient_identifier) (radial_gradient_kind) + (conic_gradient_identifier) ] @attribute (image_call @@ -169,10 +171,29 @@ (tr "@tr" @attribute) +(rust_attr + "@rust-attr" @attribute) + +(keys + "@keys" @attribute) + +(markdown + "@markdown" @attribute) + +(keys + (simple_identifier) @constant) + +(keys + "+" @operator) + ; Keywords (animate_option_identifier) @keyword -(export) @keyword.control.import +(export_statement + "export" @keyword.control.import) + +(exported_definition + "export" @keyword.control.import) (if_statement "if" @keyword.control.conditional) @@ -196,10 +217,29 @@ "callback" @keyword.function) (component_definition + "component" @keyword.storage.type) + +(component_modifier + "inherits" @keyword.storage.type) + +(uses_clause + "uses" @keyword.storage.type) + +(implements_clause + "implements" @keyword.storage.type) + +(used_interface + "from" @keyword.control.import + source: (_) @variable) + +(changed_event + "changed" @keyword) + +(gradient_call [ - "component" - "inherits" - ] @keyword.storage.type) + "at" + "from" + ] @keyword) (enum_definition "enum" @keyword.storage.type) @@ -213,10 +253,18 @@ (function_definition "function" @keyword.function) +(function_declaration + "function" @keyword.function) + +(let_statement + "let" @keyword.storage.type + name: (_) @variable + "=" @operator) + (global_definition "global" @keyword.storage.type) -(imperative_block +(return_statement "return" @keyword.control.return) (import_statement @@ -232,10 +280,7 @@ "property" @keyword.storage.type) (states_definition - [ - "states" - "when" - ] @keyword) + "states" @keyword) (struct_definition "struct" @keyword.storage.type) diff --git a/runtime/queries/slint/injections.scm b/runtime/queries/slint/injections.scm index 321c90ad..e4509a5f 100644 --- a/runtime/queries/slint/injections.scm +++ b/runtime/queries/slint/injections.scm @@ -1,2 +1,2 @@ -((comment) @injection.content +([(line_comment) (block_comment)] @injection.content (#set! injection.language "comment")) diff --git a/runtime/queries/slint/textobjects.scm b/runtime/queries/slint/textobjects.scm index ef8c2a2c..106c3d66 100644 --- a/runtime/queries/slint/textobjects.scm +++ b/runtime/queries/slint/textobjects.scm @@ -22,7 +22,7 @@ (component_definition (block) @class.inside) @class.around -(comment) @comment.around +[(line_comment) (block_comment)] @comment.around (typed_identifier name: (_) @parameter.inside) @parameter.around -- 2.51.2