Another VSCode extension for working with Yew html macro, with love. 💞
Humble beginnings.
- Huge thanks for this prior post. Which gave me some necessary guidance to dive into vscode extension-making. This project might not even be started without it!
Where's the gold? (Features)
- Highlights
html! {}macros. And rust inside{}nested brackets. (Similar to Alexandre's extension) - HTML hover.
- HTML completion.
- VSCode auto indentation on
Enter(not document formatting). - Partial document symbol support (known bug).
Operation plan (Approach)
A detailed explanation is here. But in brief, I've extracted the HTML only code into a virtual document. From this:
pub fn _index() -> Html {
let test = true;
html! {
<main class={classes!("bg-slate-100","flex", "flex-col", "bg-gradient-to-br", "from-slate-100", "to-slate-400")}>
{
\tif test {
\t
\t\thtml! {
\t\t
\t\t<div>{"Testing"}</div>
\t\t
\t\t}
\t
\t} else {
\t
\t\thtml! {
\t\t
\t\t<div>{"Production"}</div>
\t\t
\t\t}
\t
\t}
}
</main>
To this:
<main class=
>
\t
\t\t
\t\t<div> </div>
\t\t
\t
\t
\t
\t\t
\t\t<div> </div>
\t\t
\t\t
\t
\t
</main>
Then pass it to the HTML Language Server to get a response for each feature.
Side quests unlocked. (Assistance required)
There is still at least two features that should be straight forward. But I've run into issues that right now I have no idea how to diagnose and/or fix:
- Providing rename edits (
F2) on HTML tag names:rust-analyzerseems to have a priority in the rename call, thus it returned early without a chance for mymiddlemanto work.- Even when
rust-analyzeris disabled, rename calls seems to exit with a type error on theHTML Language Serverend. And since this extension only provide request forwarding, I have no idea how to fix
- Providing full document symbols support:
- Document support seems to sometimes work, and other times just returns
undefined. - And when it works, the symbols array returned is incomplete.
- Document support seems to sometimes work, and other times just returns
If these problems interest you, please come to the repository's issue tab where I'll add in-depth details and what I've tried to solve the issue. 🔥
Thank you all for reaching this far, love you all, and happy rusting!
TechTheAwesome