How to format the code in vscode-editor

I have tried to format my code use the rust analyser, but it didn't works.
image
image
The code stay unformatted.
image

Rustfmt, which is used by rust-analyzer, can't format the code inside macros (at least if it's not valid Rust).

Well, i am a beginner of rust and yew, Could someone tell me how to format yew html macros?

This might be possible to add as the extension's feature (to use another formatter for some part of the code) - pinging @matklad for wherever it's possible/feasible.

Thanks.

You can use another formatter, there is a setting for that, but I doubt you'll find a formatter that formats yew code.

Set rust-analyzer.rustfmt.overrideCommand if you find something. User Manual

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.