Himujjal / tree-sitter-svelte

Tree sitter grammar for Svelte
MIT License
77 stars 15 forks source link

Patterns for matching typescript code inside <script> tags #42

Closed josean-dev closed 9 months ago

josean-dev commented 9 months ago

Hello!

I'm currently trying to add support for Neovim text objects by creating a textobjects.scm file for the neovim treesitter text objects plugin. To add support for this, I need to define this textobjects.scm file for svelte and specify the capture groups I want to use for the text objects I want to define. I'm able to target svelte specific patterns to define these capture groups like for example:

(each_statement) @loop.outer

The above works fine.

But if I try to target a typescript/javascript specific pattern to create a text object definition for it, it doesn't seem to work and shows up as an error:

(function_declaration) @function.outer

The example above doesn't work.

I'm a beginner when it comes to writing queries and might be missing something important or should be doing a different approach in order to target the typescript/javascript specific patterns and define text objects for them. Maybe some way to inherit from the text object query files that already exist for these languages.

My apologies if this is the wrong place to ask this question. Any feedback from you would be greatly appreciated. Thank you!