Open VSX | Vscode Marketplace
Uses the built in Rust analyzer to auto-format your Leptos code. You can invoke command palette command with Leptos Init
to generate the override command on your .vscode/settings.json
file.
For Complex Project , and you dont want to override fmt on workspace level, and avoid pulluting override command on other projects.
You can invoke command palette command with Format with Leptosfmt
or bind it to a key.
- Rust: Ensure you have Rust installed on your machine.
- Leptosfmt: This extension requires
leptosfmt
. Install it using:
cargo install leptosfmt
- Press
Ctrl+Shift+P
to open the command palette. - Type
Leptos Init
to any Leptos project.
Note: it would generate this on `.vscode/settings.json`
{
"rust-analyzer.procMacro.ignored": {
"leptos_macro": [
"server"
]
},
"rust-analyzer.rustfmt.overrideCommand": [
"leptosfmt",
"--stdin",
"--rustfmt"
],
"rust-analyzer.cargo.features": [
"ssr"
]
}
- Press
Ctrl+Shift+P
to open the command palette. - Type
Keyboard Shortcuts
to open the keyboard shortcuts settings. - Search for
leptos-fmt.format
- Bind it to a keybinding to your preference e.g. OPT + SHIFT + F
- Press CMD or CTRL + , to open the settings.
- type
leptos
- find
leptos-fmt.path
and set it to the path of yourleptosfmt
binary - find
leptos-fmt.cargoHome
and set it to the path of yourcargo
home directory