Files
helix/runtime/queries/templ/highlights.scm
mayandGitHub 5a3edd585e feat(templ): improve the queries (#15668)
* chore(lang/go): update source to the latest revision

* chore(lang/templ): update source to the newest revision

* feat(tags/templ): add tags query

* feat(injections/templ): inherit from go, inject comment

* feat(textobjects/templ): add textobject queries

inherit from go and add the additional templ-only textobject queries for
`@comment` and `@function`.

* fix(highlights/templ): fix and align templ highlight queries

- only mark the names of tags as `@tag`
- also correctly highlight the script tag
- mark <, </, >, /> as `@punctuation.bracket`
- don't mark interpolation expressions as `@function.member`
- highlight {{ and }} as brackets
- mark css properties as members like the css highlights do
- don't highlight the (element_text) nodes
- remove duplicate tags from the go queries

* feat(highlights/templ): add special highlighting to specific elements

this is mostly taken from the html queries, but adjusted to the templ
queries.

* feat(rainbows/templ): add rainbow queries

* chore: cargo xtask docgen
2026-07-04 12:28:19 -05:00

102 lines
2.1 KiB
Scheme

; inherits: go
(css_declaration
name: (css_identifier) @function)
(script_declaration
name: (script_identifier) @function)
(component_declaration
name: (component_identifier) @function)
; Elements
(tag_start name: (_) @tag)
(tag_end name: (_) @tag)
(self_closing_tag name: (_) @tag)
(tag_start ["<" ">"] @punctuation.bracket)
(tag_end ["</" ">"] @punctuation.bracket)
(self_closing_tag ["<" "/>"] @punctuation.bracket)
(style_tag_start "style" @tag)
(style_tag_end "style" @tag)
(self_closing_style_tag "style" @tag)
(style_tag_start ["<" ">"] @punctuation.bracket)
(style_tag_end ["</" ">"] @punctuation.bracket)
(self_closing_style_tag ["<" "/>"] @punctuation.bracket)
(script_tag_start "script" @tag)
(script_tag_end "script" @tag)
(self_closing_script_tag "script" @tag)
(script_tag_start ["<" ">"] @punctuation.bracket)
(script_tag_end ["</" ">"] @punctuation.bracket)
(self_closing_script_tag ["<" "/>"] @punctuation.bracket)
; Attributes
(attribute
name: (attribute_name) @attribute)
(attribute
value: (quoted_attribute_value) @string)
(css_property
name: (css_property_name) @variable.other.member)
(css_property
value: (css_property_value) @constant)
(dynamic_class_attribute_value) @function.method
; Special Elements and Attributes
((attribute
name: (attribute_name) @attribute
value: (quoted_attribute_value (attribute_value) @markup.link.url))
(#any-of? @attribute "href" "src"))
((element
(tag_start
name: (_) @tag)
(element_text) @markup.link.label)
(#eq? @tag "a"))
((element
(tag_start
name: (_) @tag)
(element_text) @markup.bold)
(#any-of? @tag "strong" "b"))
((element
(tag_start
name: (_) @tag)
(element_text) @markup.italic)
(#any-of? @tag "em" "i"))
((element
(tag_start
name: (_) @tag)
(element_text) @markup.strikethrough)
(#any-of? @tag "s" "del"))
; Extra Features
(component_import
name: (component_identifier) @function)
(component_render) @function
"@" @operator
[
"templ"
"css"
"type"
] @keyword.storage.type
(script_declaration "script" @keyword.storage.type)
["{{" "}}"] @punctuation.bracket
; Comments
(element_comment) @comment