docs: Add instructions for running leptosfmt in the RustRover IDE (#229)

This commit is contained in:
Spencer Ferris
2025-08-19 07:38:51 -07:00
committed by GitHub
parent ec54e24169
commit 1e9260a0ae

View File

@@ -193,7 +193,7 @@ SublimeText 3,in the user settings for LSP-rust-analyzer-settings.json
``` ```
## 4) Set up `leptosfmt` With Rust Analyzer (optional) ## 4) Set up `leptosfmt` (optional)
`leptosfmt` is a formatter for the Leptos `view!` macro (inside of which you'll typically write your UI code). Because the `view!` macro enables an 'RSX' (like JSX) style of writing your UI's, cargo-fmt has a harder time auto-formatting your code that's inside the `view!` macro. `leptosfmt` is a crate that solves your formatting issues and keeps your RSX-style UI code looking nice and tidy! `leptosfmt` is a formatter for the Leptos `view!` macro (inside of which you'll typically write your UI code). Because the `view!` macro enables an 'RSX' (like JSX) style of writing your UI's, cargo-fmt has a harder time auto-formatting your code that's inside the `view!` macro. `leptosfmt` is a crate that solves your formatting issues and keeps your RSX-style UI code looking nice and tidy!
@@ -203,10 +203,25 @@ First, install the tool with `cargo install leptosfmt`.
If you just want to use the default options from the command line, just run `leptosfmt ./**/*.rs` from the root of your project to format all the rust files using `leptosfmt`. If you just want to use the default options from the command line, just run `leptosfmt ./**/*.rs` from the root of your project to format all the rust files using `leptosfmt`.
### Run automatically in Rust Analyzer IDEs
If you wish to set up your editor to work with `leptosfmt`, or if you wish to customize your `leptosfmt` experience, please see the instructions available on the [`leptosfmt` github repo's README.md page](https://github.com/bram209/leptosfmt). If you wish to set up your editor to work with `leptosfmt`, or if you wish to customize your `leptosfmt` experience, please see the instructions available on the [`leptosfmt` github repo's README.md page](https://github.com/bram209/leptosfmt).
Just note that it's recommended to set up your editor with `leptosfmt` on a per-workspace basis for best results. Just note that it's recommended to set up your editor with `leptosfmt` on a per-workspace basis for best results.
### Run automatically in RustRover
Unfortunately, RustRover does not support Rust Analyzer, so a different approach is required in order to automatically
run `leptosfmt`. One way is to use the [FileWatchers](https://plugins.jetbrains.com/plugin/7177-file-watchers) plugin
with the below configuration:
- Name: Leptosfmt
- File type: Rust files
- Program: `/path/to/leptosfmt` (can simply be `leptosfmt` if it's in your `$PATH` environment variable)
- Arguments: `$FilePath$`
- Output paths to refresh: `$FilePath$`
## 5) Use `--cfg=erase_components` during development ## 5) Use `--cfg=erase_components` during development
Leptos 0.7 made a number of changes to the renderer that relied more heavily on the type system. For larger projects, this can lead to slower compile times. Most of the slowdown in compile times can be alleviated by using the custom configuration flag `--cfg=erase_components` during development. (This erases some of that type information to reduce the amount of work done and debug info emitted by the compiler, at the expense of additional binary size and runtime cost, so its best not to use it in release mode.) Leptos 0.7 made a number of changes to the renderer that relied more heavily on the type system. For larger projects, this can lead to slower compile times. Most of the slowdown in compile times can be alleviated by using the custom configuration flag `--cfg=erase_components` during development. (This erases some of that type information to reduce the amount of work done and debug info emitted by the compiler, at the expense of additional binary size and runtime cost, so its best not to use it in release mode.)