-
I noticed that the tree-sitter-svelte queries in Helix Editor (found at runtime/queries/svelte are different from the ones defined in the tree-sitter-svelte grammar itself. Using the ones in the grammar does not appear to work. I’m wondering if the queries in the grammar itself are incorrect or if there is a difference in syntax for some reason (different version of tree-sitter used by Helix, perhaps?) To illustrate, here are the injection definitions from Helix (which work): ; injections.scm
; --------------
((style_element
(raw_text) @injection.content)
(#set! injection.language "css"))
((attribute
(attribute_name) @_attr
(quoted_attribute_value (attribute_value) @css))
(#eq? @_attr "style"))
((script_element
(raw_text) @injection.content)
(#set! injection.language "javascript"))
((raw_text_expr) @injection.content
(#set! injection.language "javascript"))
(
(script_element
(start_tag
(attribute
(quoted_attribute_value (attribute_value) @_lang)))
(raw_text) @injection.content)
(#match? @_lang "(ts|typescript)")
(#set! injection.language "typescript")
)
((comment) @injection.content
(#set! injection.language "comment")) And here are the ones defined in the original grammar (which don’t work): ; injections.scm
; --------------
((style_element
(raw_text) @css))
((attribute
(attribute_name) @_attr
(quoted_attribute_value (attribute_value) @css))
(#eq? @_attr "style"))
((script_element
(raw_text) @javascript))
((raw_text_expr) @javascript)
(
(script_element
(start_tag
(attribute
(quoted_attribute_value (attribute_value) @_lang)))
(raw_text) @typescript)
(#match? @_lang "(ts|typescript)")
)
(comment) @comment This is related to an issue I opened asking for Helix Editor to automatically copy tree-sitter queries from a tree-sitter grammar when running |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
To somewhat answer my own question. Based on the Tree Sitter documentation, it would appear that the injection syntax in tree-sitter-svelte is incorrect (?) https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection If someone can confirm this, I’ll go ahead and prepare a pull request for them to fix it based on the queries in Helix. |
Beta Was this translation helpful? Give feedback.
-
These queries look to match |
Beta Was this translation helpful? Give feedback.
-
To add to the previous answers, usually the grammar itself provides some simple queries, but we have our own list of scopes based on sublime/textmate grammars to offer a lot of granularity for styling. Some query files also use editor-specific predicates, for example neovim uses |
Beta Was this translation helpful? Give feedback.
These queries look to match
nvim-treesitter
, which has an order of precedence reverse oftree-sitter cli
(which Helix follows).