Skip to content

Commit

Permalink
feat(pack): remove opinionated config from rust pack (#1111)
Browse files Browse the repository at this point in the history
* feat(pack): remove opinionated config from `rust` pack

* chore(pack): Document `rust-analyzer.check.command` behavior
  • Loading branch information
boraarslan committed Jul 17, 2024
1 parent 5936739 commit c7d3b71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
23 changes: 22 additions & 1 deletion lua/astrocommunity/pack/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This plugin pack does the following:
- Adds [TOML language support](../toml)

> [!NOTE]
> This pack DOES not add `rust_analyzer`. This should be managed by rustup. To add it to rustup, run: `rustup component add rust-analyzer`
> This pack DOES not add `rust_analyzer`. This should be managed by rustup. To add it to rustup, run: `rustup component add rust-analyzer`
## Additional LSP Configuration Tweaks

Expand Down Expand Up @@ -42,3 +42,24 @@ return {
},
}
```

## Use `cargo check` for `rust-analyzer.check.command`

By default, this pack configures `rust-analyzer.check.command` to use `cargo clippy` instead of `cargo check`.

In some cases (for example, on large projects where `cargo clippy` is slow), you may want to use `cargo check` instead.

Currently, `rust-analyzer` itself cannot be configured per project, [adding `rust-analyzer.toml` support is still in progress](https://github.com/rust-lang/rust-analyzer/issues/13529).
However, `rustaceanvim` [supports loading `rust-analyzer.json` files from the root of your project.](https://github.com/mrcjkb/rustaceanvim#how-to-dynamically-load-different-rust-analyzer-settings-per-project)
If you want to use `cargo check` as your default `rust-analyzer.check.command`, you can create a `rust-analyzer.json` file in the root of your project with the following contents:
For more information on the `rust-analyzer` configuration, see the [rust-analyzer documentation](https://rust-analyzer.github.io/manual.html#configuration).

```json
{
"rust-analyzer": {
"check": {
"command": "check"
}
}
}
```
15 changes: 0 additions & 15 deletions lua/astrocommunity/pack/rust/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ return {
"--no-deps",
},
},
assist = {
importEnforceGranularity = true,
importPrefix = "crate",
},
completion = {
postfix = {
enable = false,
},
},
inlayHints = {
lifetimeElisionHints = {
enable = true,
useParameterNames = true,
},
},
},
},
},
Expand Down

0 comments on commit c7d3b71

Please sign in to comment.