An open API service indexing awesome lists of open source software.

https://github.com/codeitlikemiley/leptos-fmt

vscode extension for formatting rust leptos project
https://github.com/codeitlikemiley/leptos-fmt

Last synced: 3 months ago
JSON representation

vscode extension for formatting rust leptos project

Awesome Lists containing this project

README

        

# leptos-fmt

> Open VSX | Vscode Marketplace

![Open VSX Downloads](https://img.shields.io/open-vsx/dt/masterustacean/leptos-fmt) ![Vscode Marketplace](https://vsmarketplacebadges.dev/downloads/masterustacean.leptos-fmt.svg)

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](https://raw.githubusercontent.com/codeitlikemiley/leptos-fmt/yt/images/demo.gif)](https://youtu.be/dS92U-yv7co)

## Requirements

- **Rust**: Ensure you have Rust installed on your machine.
- **Leptosfmt**: This extension requires `leptosfmt`. Install it using:

```bash
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.procMacro.ignored": {
"leptos_macro": [
"server"
]
},
"rust-analyzer.rustfmt.overrideCommand": [
"leptosfmt",
"--stdin",
"--rustfmt"
],
"rust-analyzer.cargo.features": [
"ssr"
]
}
```

## 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