Fix Tailwind CSS completions breaking after hyphens#14
Fix Tailwind CSS completions breaking after hyphens#14PiasekDev wants to merge 1 commit intozed-extensions:mainfrom
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @PiasekDev 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 check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Some follow-up context: I chose to submit the smallest code change that fixes the reported hyphen completion reset. RSTML already has I also tried adding Tailwind language-server opt-ins to RSTML string scopes, similar to the earlier Rust-side approach in zed-industries/zed#28674. In local testing, that did not activate |
33998c8 to
3f32420
Compare
|
Ok, I actually didn't know that the If the maintainers would prefer the narrower version, I can refactor it that way. I had tried override-based variants while working through this, but dropped them once they were not needed for the main server-routing/scope issue. |
Fixes Tailwind completions breaking after hyphens in Leptos
class="..."strings inside RSTML.Leptos
view!macro bodies are parsed as injected RSTML inside Rust files. This affects plain class attributes such as:When
tailwindcss-language-serveris available for the Rust buffer, completions can appear in that string, but the completion query can break once a Tailwind hyphen is typed. For example, completions may appear while typingtext, but after typingtext-, the completion query resets. This is the same completion-query behavior described in zed-industries/zed#25670, though that issue was reported for Dioxus and this PR only addresses the Leptos/RSTML case. It also relates to the broader Leptos/Rust Tailwind support request in zed-industries/zed#16371.The issue is not that RSTML lacks
-as a completion query character: it already has this inlanguages/rstml/config.toml:The issue is where the cursor ends up. RSTML parses the value of attributes like
class="..."as a string-like Rust expression, and that expression is currently reinjected as Rust inlanguages/rstml/injections.scm. When the cursor is inside the class string, the active scope is therefore the nested Rust layer rather than the RSTML layer. Tailwind can still provide completions when the server is available, but the active Rust completion scope does not use RSTML's hyphen query behavior.This change keeps string-like RSTML expressions in the RSTML layer by excluding them from the Rust injection:
Non-string Rust expressions inside RSTML are still injected as Rust.
This is intentionally limited to the simple Leptos class attribute form:
class="px-4 text-white bg-blue-600"It does not try to fully support more complex Leptos class syntaxes, such as:
Those cases need more context than this small RSTML injection change provides.
Full support for Leptos-specific syntaxes like tuple classes or
class:*directives likely needs better Zed support for routing language-server requests across nested Rust/RSTML/Rust language layers. Those cases are harder to express cleanly with only more query special cases inlanguages/rstml/injections.scm.