Awesome
leptos-fmt
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.
Demo
Requirements
- Rust: Ensure you have Rust installed on your machine.
- Leptosfmt: This extension requires
leptosfmt
. Install it using:
cargo install leptosfmt
Using built in Rust Analyzer (rust-lang.rust-analyzer)
- Press
Ctrl+Shift+P
to open the command palette. - Type
Leptos Init
to any Leptos project.
{
"rust-analyzer.rustfmt.overrideCommand": [
"leptosfmt",
"--stdin",
"--rustfmt"
]
}
</details>
Using Leptos FMT with Custom Key Bindings
<img width="1084" alt="Screenshot 2024-11-12 at 7 29 24 PM" src="https://github.com/user-attachments/assets/36e2a98f-f475-43d8-932e-a7567c68e8a1">- 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. <kbd>OPT</kbd> + <kbd>SHIFT</kbd> + <kbd>F</kbd>
Custom Paths
<img width="1084" alt="Screenshot 2024-11-12 at 7 28 03 PM" src="https://github.com/user-attachments/assets/b9a1b953-2e63-4996-81e4-55879f14cbb3">- Press <kbd>CMD or CTRL</kbd> + <kbd>,</kbd> 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