Skip to content

rust: Fix rstml injection inside Leptos view! macros#45952

Merged
MrSubidubi merged 1 commit intozed-industries:mainfrom
ArhanChaudhary:fix-leptos-treesitter
Jan 2, 2026
Merged

rust: Fix rstml injection inside Leptos view! macros#45952
MrSubidubi merged 1 commit intozed-industries:mainfrom
ArhanChaudhary:fix-leptos-treesitter

Conversation

@ArhanChaudhary
Copy link
Contributor

@ArhanChaudhary ArhanChaudhary commented Jan 2, 2026

Fix the Rust tree-sitter language injection to syntax highlight HTML in Leptos view! macros.

A cleanup commit erroneously removed the (#not-any-of? @_macro_name "view" "html") filter from a query that injects Rust into macro invocations. This causes the query to always match with higher precedence over another one that sets the view! macro language to rstml. I have verified that my fix works locally.

On a related note, I am not sure why language injection for the sql macro is there, which is not even exported by sqlx. The commit author mentions that it is for sqlez, a Go library, not a Rust crate.

Release Notes:

  • Fixed rstml injection not working inside Leptos view! macros.

@cla-bot
Copy link

cla-bot bot commented Jan 2, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @ArhanChaudhary on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@ArhanChaudhary
Copy link
Contributor Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Jan 2, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @ArhanChaudhary on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link

cla-bot bot commented Jan 2, 2026

The cla-bot has been summoned, and re-checked this pull request!

@ArhanChaudhary
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 2, 2026
@cla-bot
Copy link

cla-bot bot commented Jan 2, 2026

The cla-bot has been summoned, and re-checked this pull request!

@MrSubidubi MrSubidubi changed the title Properly inject rstml inside Leptos view! macros rust: Fix rshtml injection inside Leptos view! macros Jan 2, 2026
Copy link
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice digging and sorry for breaking this, looks good! Thank you for the fix.

As for

On a related note, I am not sure why language injection for the sql macro is there, which is not even exported by sqlx. The commit author #41258 (comment) that it is for sqlez, a Go library, not a Rust crate.

We have a sqlez crate living within this very repo that this injection is for. E.g.,

const MIGRATIONS: &[&str] = &[sql!(
CREATE TABLE component_previews (
workspace_id INTEGER,
item_id INTEGER UNIQUE,
active_page_id TEXT,
PRIMARY KEY(workspace_id, item_id),
FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)
ON DELETE CASCADE
) STRICT;
)];
benefits from that 😄

Lastly, congratulations to your first contribution! 🎉

@MrSubidubi MrSubidubi enabled auto-merge (squash) January 2, 2026 12:01
@MrSubidubi MrSubidubi merged commit e1a09e2 into zed-industries:main Jan 2, 2026
27 checks passed
@ArhanChaudhary ArhanChaudhary changed the title rust: Fix rshtml injection inside Leptos view! macros rust: Fix rstml injection inside Leptos view! macros Jan 3, 2026
rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
Fix the Rust tree-sitter language injection to syntax highlight HTML in
Leptos `view!` macros.

A [cleanup
commit](00278f4#diff-15e953fedef2880e09d9e57c8bddf9af5eb583b141fe7d2069c8e579378f4fccL6)
erroneously removed the `(#not-any-of? @_macro_name "view" "html")`
filter from a query that injects Rust into macro invocations. This
causes the query to always match with higher precedence over another one
that sets the `view!` macro language to `rstml`. I have verified that my
fix works locally.

On a related note, I am not sure why language injection for the `sql`
macro is there, which is not even exported by
[sqlx](https://docs.rs/sqlx/latest/sqlx/). The commit author
[mentions](#41258 (comment))
that it is for `sqlez`, a Go library, not a Rust crate.

Release Notes:

- Fixed rshtml injection not working inside Leptos `view!` macros.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ries#45952)

Fix the Rust tree-sitter language injection to syntax highlight HTML in
Leptos `view!` macros.

A [cleanup
commit](zed-industries@00278f4#diff-15e953fedef2880e09d9e57c8bddf9af5eb583b141fe7d2069c8e579378f4fccL6)
erroneously removed the `(#not-any-of? @_macro_name "view" "html")`
filter from a query that injects Rust into macro invocations. This
causes the query to always match with higher precedence over another one
that sets the `view!` macro language to `rstml`. I have verified that my
fix works locally.

On a related note, I am not sure why language injection for the `sql`
macro is there, which is not even exported by
[sqlx](https://docs.rs/sqlx/latest/sqlx/). The commit author
[mentions](zed-industries#41258 (comment))
that it is for `sqlez`, a Go library, not a Rust crate.

Release Notes:

- Fixed rshtml injection not working inside Leptos `view!` macros.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ries#45952)

Fix the Rust tree-sitter language injection to syntax highlight HTML in
Leptos `view!` macros.

A [cleanup
commit](zed-industries@00278f4#diff-15e953fedef2880e09d9e57c8bddf9af5eb583b141fe7d2069c8e579378f4fccL6)
erroneously removed the `(#not-any-of? @_macro_name "view" "html")`
filter from a query that injects Rust into macro invocations. This
causes the query to always match with higher precedence over another one
that sets the `view!` macro language to `rstml`. I have verified that my
fix works locally.

On a related note, I am not sure why language injection for the `sql`
macro is there, which is not even exported by
[sqlx](https://docs.rs/sqlx/latest/sqlx/). The commit author
[mentions](zed-industries#41258 (comment))
that it is for `sqlez`, a Go library, not a Rust crate.

Release Notes:

- Fixed rshtml injection not working inside Leptos `view!` macros.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants