Skip to content

Commit

Permalink
docs: directory-based rust-analyzer configuration (#127)
Browse files Browse the repository at this point in the history
* Document another way to use with rust-analyzer

* Fixes from pr feedback
  • Loading branch information
lukashermansson authored Jul 10, 2024
1 parent 926b642 commit d968d00
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ edition = "2021"

> Note: For VSCode users, I recommend to use workpsace settings (CMD + shift + p -> Open workspace settings), so that you can only configure `leptosfmt` for workpsaces that are using leptos. For Neovim users, I recommend using [neoconf.nvim](https://github.com/folke/neoconf.nvim) for managing project-local LSP configuration.
### Setting up with unstable directory based rust-analyzer configuration
An alternative way to configure `rust-analyzer` to use `leptosfmt` is to use directory based `rust-analyzer` configuration.

To do this, create a file named `rust-analyzer.toml` in the root of your project with the following content:
```toml
[rustfmt]
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]
# (optional) other config...
```

This method of setting up rust-analyzer is editor agnostic to any editor that uses `rust-analyzer` for formatting rust code

> Note: This feature of `rust-analyzer` is currently unstable and no guarantees are made that this will continue to work across versions. You have to use a recent version of `rust-analyzer` ([2024-06-10](https://github.com/rust-lang/rust-analyzer/releases/tag/2024-06-10) or newer).
## Configuration

You can configure all settings through a `leptosfmt.toml` file.
Expand Down

0 comments on commit d968d00

Please sign in to comment.