From f1e5e2796f307c2cf3bcfbb7fb703c60ef3bef2c Mon Sep 17 00:00:00 2001 From: Michael Netshipise Date: Mon, 19 Jan 2026 07:12:58 +0200 Subject: [PATCH] Fix comment highlighting and precedence issues --- queries/highlights.scm | 278 +++++++++++++++++------------------------ 1 file changed, 113 insertions(+), 165 deletions(-) diff --git a/queries/highlights.scm b/queries/highlights.scm index 542f815..b7e11d9 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,11 +1,20 @@ ; Waltzing Template Highlights -; Comprehensive query file for tree-sitter-waltzing +; Tree-sitter query file - order matters for precedence + +; ==================== +; COMMENTS (highest priority - must come first) +; ==================== + +(template_comment) @comment +(html_comment) @comment +(comment_content) @comment +(html_comment_content) @comment ; ==================== ; KEYWORDS ; ==================== -; Template keywords (with @ prefix) +; Template keywords "@use" @keyword.import "@import" @keyword.import "@struct" @keyword.type @@ -18,67 +27,91 @@ "@continue" @keyword.control ; Control flow keywords -"else" @keyword.conditional -"if" @keyword.conditional +"else" @keyword +"if" @keyword "let" @keyword "in" @keyword "as" @keyword "mut" @keyword - -; Safe output keyword -"safe" @keyword.function +"safe" @keyword ; ==================== -; OPERATORS +; DEFINITIONS ; ==================== -(binary_operator) @operator -(unary_operator) @operator +; Struct definitions +(struct_definition + (identifier) @type.definition) +(struct_field + (identifier) @property) -; Specific operators -"=>" @operator -"=" @operator -"!" @operator -"!=" @operator -"==" @operator -"<" @operator -"<=" @operator -">" @operator -">=" @operator -"<<" @operator -">>" @operator -"+" @operator -"-" @operator -"*" @operator -"/" @operator -"%" @operator -"&" @operator -"&&" @operator -"|" @operator -"||" @operator -"^" @operator -".." @operator +; Enum definitions +(enum_definition + (identifier) @type.definition) +(enum_variant + (identifier) @constructor) + +; Function definitions +(function_definition + (identifier) @function.definition) +(parameter + (identifier) @variable.parameter) ; ==================== -; PUNCTUATION +; FUNCTION TAGS ; ==================== -; Brackets -"{" @punctuation.bracket -"}" @punctuation.bracket -"(" @punctuation.bracket -")" @punctuation.bracket -"[" @punctuation.bracket -"]" @punctuation.bracket +(function_path) @function +"<@" @tag.delimiter +"" @operator +"=" @operator +".." @operator ; ==================== -; DEFINITIONS +; PUNCTUATION ; ==================== -; Struct definitions -(struct_definition (identifier) @type.definition) -(struct_field (identifier) @property.definition) - -; Enum definitions -(enum_definition (identifier) @type.definition) -(enum_variant (identifier) @constructor) - -; Function definitions -(function_definition (identifier) @function.definition) -(parameter (identifier) @variable.parameter) - -; ==================== -; FUNCTION TAGS (Components) -; ==================== - -(function_path) @function -(self_closing_function_tag) @tag -(container_function_tag) @tag - -; Function tag delimiters -"<@" @tag.delimiter -"" @tag.delimiter - -; ==================== -; HTML ELEMENTS -; ==================== - -(tag_name) @tag -(attribute_name) @attribute -(attribute_value) @string - -; HTML tag delimiters -"<" @tag.delimiter -">" @tag.delimiter -"" @comment - -; ==================== -; ATTRIBUTES (derive, etc.) +; ATTRIBUTES ; ==================== (attribute_list) @attribute -(attribute (identifier) @attribute) +(attribute + (identifier) @attribute) ; ==================== -; ESCAPE SEQUENCES +; ESCAPE ; ==================== (escape_at) @string.escape @@ -222,28 +183,15 @@ (embedded_language) @embedded (language_name) @label -; Language name keywords -"css" @label -"style" @label -"javascript" @label -"js" @label -"json" @label -"alpine" @label -"html" @label - -; Embedded block delimiters -"@```" @punctuation.special -"```@" @punctuation.special - ; ==================== -; TEXT CONTENT +; TEXT ; ==================== -(text_content) @text +(text_content) @none ; ==================== -; FALLBACK +; FALLBACK (lowest priority - must come last) ; ==================== -; Catch-all for identifiers not matched above +(rust_path) @module (identifier) @variable