feat(svelte)!: switch parser repo and update queries

Breaking change: switch to themixednuts/tree-sitter-htmlx.

Update Svelte queries for the new node names.
This commit is contained in:
themixednuts 2026-03-24 15:55:05 -05:00
parent 6620ae1c44
commit a1bee9959b
7 changed files with 228 additions and 94 deletions

View file

@ -280,7 +280,7 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | @steelsojka
[supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) | unstable | `HFIJL` | @madskjeldgaard, @elgiano [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) | unstable | `HFIJL` | @madskjeldgaard, @elgiano
[superhtml](https://github.com/kristoff-it/superhtml) | unstable | `H  J ` | @rockorager [superhtml](https://github.com/kristoff-it/superhtml) | unstable | `H  J ` | @rockorager
[surface](https://github.com/connorlay/tree-sitter-surface) | unstable | `HFIJ ` | @connorlay [surface](https://github.com/connorlay/tree-sitter-surface) | unstable | `HFIJ ` | @connorlay
[svelte](https://github.com/tree-sitter-grammars/tree-sitter-svelte) | unstable | `HFIJL` | @amaanq [svelte](https://github.com/themixednuts/tree-sitter-htmlx) | unstable | `HFIJL` | @amaanq
[sway](https://github.com/FuelLabs/tree-sitter-sway.git) | unstable | `HFIJL` | @ribru17 [sway](https://github.com/FuelLabs/tree-sitter-sway.git) | unstable | `HFIJL` | @ribru17
[swift](https://github.com/alex-pinkus/tree-sitter-swift) | unstable | `HFIJL` | @alex-pinkus [swift](https://github.com/alex-pinkus/tree-sitter-swift) | unstable | `HFIJL` | @alex-pinkus
[sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) | unstable | `HF J ` | @RaafatTurki [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) | unstable | `HF J ` | @RaafatTurki

View file

@ -2208,8 +2208,9 @@ return {
}, },
svelte = { svelte = {
install_info = { install_info = {
revision = 'ae5199db47757f785e43a14b332118a5474de1a2', location = 'crates/tree-sitter-svelte',
url = 'https://github.com/tree-sitter-grammars/tree-sitter-svelte', revision = '3be6db3dc94478b089a64e59e4d855fc3041a7be',
url = 'https://github.com/themixednuts/tree-sitter-htmlx',
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'html_tags' }, requires = { 'html_tags' },

View file

@ -1,13 +1,12 @@
; inherits: html ; inherits: html
[ [
(if_statement) (if_block)
(else_if_block) (else_if_clause)
(else_block) (else_clause)
(each_statement) (each_block)
(await_statement) (await_block)
(then_block) (await_branch)
(catch_block) (key_block)
(key_statement) (snippet_block)
(snippet_statement)
] @fold ] @fold

View file

@ -2,42 +2,83 @@
(raw_text) @none (raw_text) @none
[ ((tag_name) @type
"as" (#match? @type "^[A-Z]"))
"key"
"html"
"snippet"
"render"
] @keyword
"const" @keyword.modifier (tag_name
namespace: (tag_namespace) @keyword
":" @punctuation.delimiter
name: (tag_local_name) @tag)
[ (tag_name
"if" object: (tag_member) @type
"else if" "." @punctuation.delimiter
"else" property: (tag_member) @tag)
"then"
] @keyword.conditional
"each" @keyword.repeat (attribute_directive) @keyword
(attribute_name ":" @punctuation.delimiter)
(attribute_identifier) @property
(attribute_modifier) @attribute
(attribute_modifiers "|" @punctuation.delimiter)
[ (expression) @embedded
"await" (expression_value) @embedded
"then"
] @keyword.coroutine
"catch" @keyword.exception (shorthand_attribute content: (_) @variable)
"debug" @keyword.debug
[ [
"{" "{"
"}" "}"
] @punctuation.bracket ] @punctuation.bracket
"|" @punctuation.delimiter
(tag_comment kind: (line_comment) @comment)
(tag_comment kind: (block_comment) @comment)
[ [
"#" "if"
":" "each"
"/" "await"
"@" "key"
] @tag.delimiter "snippet"
"else"
"html"
"debug"
"const"
"render"
"attach"
"as"
] @keyword.control
(block_keyword) @keyword.control
(block_open) @tag.delimiter
(block_close) @tag.delimiter
(shorthand_kind) @keyword.control
(branch_kind) @keyword.control
(block_sigil) @keyword.control
(if_block expression: (expression) @embedded)
(else_if_clause expression: (expression_value) @embedded)
(each_block expression: (expression) @embedded)
(each_block binding: (pattern) @variable)
(each_block index: (pattern) @variable)
(each_block key: (expression) @embedded)
(await_block expression: (expression) @embedded)
(await_branch (pattern) @variable)
(await_block (pattern) @variable)
(orphan_branch (pattern) @variable)
(key_block expression: (expression) @embedded)
(snippet_block name: (snippet_name) @function)
(snippet_parameters parameter: (pattern) @variable)
(snippet_type_parameters) @type
[
"("
")"
","
] @punctuation.delimiter

View file

@ -1,34 +1,19 @@
; inherits: html ; inherits: html
[ [
(if_statement) (if_block)
(each_statement) (each_block)
(await_statement) (await_block)
(key_statement) (key_block)
(snippet_statement) (snippet_block)
] @indent.begin ] @indent.begin
(if_end (block_end
"}" @indent.end) (block_close) @indent.end)
(each_end
"}" @indent.end)
(await_end
"}" @indent.end)
(key_end
"}" @indent.end)
(snippet_end
"}" @indent.end)
[ [
(if_end) (block_end)
(else_if_block) (else_if_clause)
(else_block) (else_clause)
(each_end) (await_branch)
(await_end)
(key_end)
(snippet_end)
] @indent.branch ] @indent.branch

View file

@ -1,47 +1,141 @@
; inherits: html_tags ((comment) @injection.content
(#set! injection.language "comment"))
((style_element ((element
(start_tag (start_tag
(tag_name) @_tag
(attribute (attribute
(attribute_name) @_attr (attribute_name) @_lang
(quoted_attribute_value (quoted_attribute_value
(attribute_value) @_lang))) (attribute_value) @_value)))
(raw_text) @injection.content) (raw_text) @injection.content)
(#eq? @_attr "lang") (#eq? @_tag "script")
(#any-of? @_lang "scss" "postcss" "less") (#eq? @_lang "lang")
(#set! injection.language "scss")) (#any-of? @_value "ts" "typescript" "text/typescript")
((svelte_raw_text) @injection.content
(#set! injection.language "javascript"))
((script_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @_lang)))
(raw_text) @injection.content)
(#eq? @_attr "lang")
(#any-of? @_lang "ts" "typescript")
(#set! injection.language "typescript")) (#set! injection.language "typescript"))
((script_element ((element
(start_tag (start_tag
(tag_name) @_tag
(attribute (attribute
(attribute_name) @_attr (attribute_name) @_lang
(quoted_attribute_value (quoted_attribute_value
(attribute_value) @_lang))) (attribute_value) @injection.language)))
(raw_text) @injection.content) (raw_text) @injection.content)
(#eq? @_attr "lang") (#eq? @_tag "script")
(#any-of? @_lang "js" "javascript") (#eq? @_lang "lang")
(#not-any-of? @injection.language
"ts"
"typescript"
"text/typescript"
"js"
"javascript"
"text/javascript"))
((element
(start_tag
(tag_name) @_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value
(attribute_value) @_value)))
(raw_text) @injection.content)
(#eq? @_tag "script")
(#eq? @_lang "lang")
(#any-of? @_value "js" "javascript" "text/javascript")
(#set! injection.language "javascript")) (#set! injection.language "javascript"))
((element ((element
(start_tag (start_tag
(tag_name) @_tag
(attribute (attribute
(attribute_name) @_attr (attribute_name) @_script_attr)*)
(raw_text) @injection.content)
(#eq? @_tag "script")
(#not-any-of? @_script_attr "lang")
(#set! injection.language "javascript"))
((element
(start_tag
(tag_name) @_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value
(attribute_value) @_value)))
(raw_text) @injection.content)
(#eq? @_tag "style")
(#eq? @_lang "lang")
(#any-of? @_value "scss" "sass" "less" "postcss")
(#set! injection.language "scss"))
((element
(start_tag
(tag_name) @_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value (quoted_attribute_value
(attribute_value) @injection.language))) (attribute_value) @injection.language)))
(text) @injection.content) (raw_text) @injection.content)
(#eq? @_attr "lang") (#eq? @_tag "style")
(#eq? @injection.language "pug")) (#eq? @_lang "lang")
(#not-any-of? @injection.language "scss" "sass" "less" "postcss"))
((element
(start_tag
(tag_name) @_tag
(attribute
(attribute_name) @_style_attr)*)
(raw_text) @injection.content)
(#eq? @_tag "style")
(#not-any-of? @_style_attr "lang")
(#set! injection.language "css"))
((attribute
(attribute_name) @_style_name
(quoted_attribute_value (attribute_value) @injection.content))
(#eq? @_style_name "style")
(#set! injection.language "css"))
(element
(start_tag
(tag_name) @_tag
(#eq? @_tag "input")
(attribute
(attribute_name) @_attr
[
(quoted_attribute_value
(attribute_value) @injection.content)
(attribute_value) @injection.content
]
(#eq? @_attr "pattern")))
(#set! injection.language "regex"))
(attribute
(attribute_name) @_name
(#lua-match? @_name "^on[a-z]+$")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
((expression content: (js) @injection.content)
(#set! injection.language "javascript"))
((expression content: (ts) @injection.content)
(#set! injection.language "typescript"))
((shorthand_attribute content: (js) @injection.content)
(#set! injection.language "javascript"))
((shorthand_attribute content: (ts) @injection.content)
(#set! injection.language "typescript"))
((expression_value content: (js) @injection.content)
(#set! injection.language "javascript"))
((expression_value content: (ts) @injection.content)
(#set! injection.language "typescript"))
((pattern content: (js) @injection.content)
(#set! injection.language "javascript"))
((pattern content: (ts) @injection.content)
(#set! injection.language "typescript"))
((snippet_type_parameters) @injection.content
(#set! injection.language "typescript"))

View file

@ -1 +1,15 @@
; inherits: html ; inherits: html
(snippet_block) @local.scope
(snippet_parameters
parameter: (pattern) @local.definition.parameter)
(snippet_name) @local.definition.function
((tag_name) @local.reference
(#lua-match? @local.reference "^[A-Z]"))
(tag_name
object: (tag_member) @local.reference
property: (tag_member) @local.reference)