Himujjal / tree-sitter-svelte

Tree sitter grammar for Svelte
MIT License
81 stars 14 forks source link

Support actions #36

Open matthewmueller opened 1 year ago

matthewmueller commented 1 year ago

Hi @Himujjal, thanks for the great library!

I was wondering if you would consider supporting Svelte actions? https://svelte.dev/docs#template-syntax-element-directives-use-action

Currently they're just treated as attribute names, but it's be nice to parse them further. Here's some examples of what's possible:

https://astexplorer.net/#/gist/ae11d23cc35d98746f3fa5469d625491/5a57c9897eec94076c38f0673c1eeaa5aae89cb8

Himujjal commented 1 year ago

So, I looked over at the code. I need to change attribute_value for the actions to be separated out. This also applies to other element directives like bind:, use:, on:, transition:, use:, in:, out:, animate:, style: etc.

Now, the question is should I use this as a generic syntax expression: <directive>:<dir_value> and keep future directives also intact with one single commit or should I use only the above I mentioned?

As far as the AST implementation goes, directives are separated out into various groups. I think I should follow the svelte official AST.

Will fix this ASAP