Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a tree-sitter grammar for RSX/RSTML? #43

Open
aguynamedben opened this issue Dec 15, 2023 · 1 comment
Open

Is there a tree-sitter grammar for RSX/RSTML? #43

aguynamedben opened this issue Dec 15, 2023 · 1 comment

Comments

@aguynamedben
Copy link

It seems the only attempt at a tree-sitter grammar for RSX/RSTLM was: https://github.com/tjdevries/tree-sitter-rsx

Are there any plans to extend/fork the tree-sitter-rust grammar to add support for RSX?

What editor/extension do you use for actually building things with RSX?

Context: leptos-rs/leptos#2108

@vldm
Copy link
Collaborator

vldm commented Dec 18, 2023

Hi!

What editor/extension do you use for actually building things with RSX?

Currently during proc macro expanding - rstml preserve original spans, so any IDE with "semantic highlight" and proc-macro support should work well.

I tested it with rust-analyzer (on vscode) and IDEA Rust plugin.

Is there a tree-sitter grammar for RSX/RSTML?

I dont think so.

Are there any plans to extend/fork the tree-sitter-rust grammar to add support for RSX?

I had no plans for this, and see the following problems with it:

  1. The needs to support two sets of rules (one in rstml code itself, and one specific for tree-sitter)
  2. as you mention in original issue: js and ts parser are both embed jsx/tsx implementation, which is good for new users, since they don't need to install any specific grammar/plugin for html in js.
    But rstml is just a syntax for macro, and it differ with yew's implementation, so it no chance that Rust original grammar will embed it at some time, is there a way in tree-sitter to extend existing grammar dynamically?
  3. Also rstml is library for parsing, not a macro implementation, so other libraries could name entrypoint in different ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants