codeitlikemiley / leptos-fmt

vscode extension for formatting rust leptos project
MIT License
1 stars 0 forks source link

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

Demo

Requirements

cargo install leptosfmt

Using built in Rust Analyzer (rust-lang.rust-analyzer)

  1. Press Ctrl+Shift+P to open the command palette.
  2. Type Leptos Init to any Leptos project.
Note: it would generate this on `.vscode/settings.json` ```json { "rust-analyzer.rustfmt.overrideCommand": [ "leptosfmt", "--stdin", "--rustfmt" ] } ```

Using Leptos FMT with Custom Key Bindings

Screenshot 2024-11-12 at 7 29 24 PM
  1. Press Ctrl+Shift+P to open the command palette.
  2. Type Keyboard Shortcuts to open the keyboard shortcuts settings.
  3. Search for leptos-fmt.format
  4. Bind it to a keybinding to your preference e.g. OPT + SHIFT + F

Custom Paths

Screenshot 2024-11-12 at 7 28 03 PM
  1. Press CMD or CTRL + , to open the settings.
  2. type leptos
  3. find leptos-fmt.path and set it to the path of your leptosfmt binary
  4. find leptos-fmt.cargoHome and set it to the path of your cargo home directory