Pre-commit & Editor Setup
Local tooling catches fmt and clippy issues before CI. rust-analyzer plus format-on-save and optional pre-commit hooks keep feedback instant.
Search across all documentation pages
Local tooling catches fmt and clippy issues before CI. rust-analyzer plus format-on-save and optional pre-commit hooks keep feedback instant.
// .vscode/settings.json
{
"editor.formatOnSave": true,
"rust-analyzer.check.command": "clippy",
"rust-analyzer.rustfmt.extraArgs": ["+nightly"]
}# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: cargo-fmt
entry: cargo fmt --all -- --check
language: system
pass_filenames: false
- id: cargo-clippy
entry: cargo clippy --workspace --all-targets -- -D warnings
language: system
pass_filenames: falseWhen to reach for this: Onboarding developers and reducing CI churn from style-only failures.
# rust-toolchain.toml
[toolchain]
channel = "1.97.0"
components = ["rustfmt", "clippy"]rustup component add rustfmt clippy
pre-commit installWhat this demonstrates:
components ensures fmt/clippy available offline| Setting | Effect |
|---|---|
check.command = "clippy" | Inline clippy hints |
cargo.features | Active feature set for analysis |
linkedProjects | Workspace member selection |
inlayHints | Type/lifetime hints (optional) |
cargo test (slower)rustup toolchain on cdrust-toolchain.toml in repo root; reload RA.rustup component add rustfmt.cargo clippy -p scripts.| Alternative | Use When | Don't Use When |
|---|---|---|
lefthook / husky | Polyglot repos | Simple Rust-only |
| CI only | Solo hacker prototype | Teams with PR volume |
cargo watch -x check | Long coding sessions | Replacing fmt on save |
Same rust-analyzer extension and settings.json keys.
rust-analyzer.linkedProjects or Cargo: Open Cargo.toml picks crate context.
language: system hooks need cargo on PATH; use same rust-toolchain.toml.
rustfmt handles imports; enable formatOnSave only.
Not default; run cargo clippy --fix manually with review.
Commit .vscode/settings.json with team defaults; optional personal overrides gitignored.
Exclude target/ from file watcher; use cargo clean if metadata corrupt; split large workspace.
Both pin toolchain; rust-toolchain.toml is canonical for rustup; mise can read it.
Rust fmt/clippy are crate-wide; full workspace check is safer for type errors across files.
EditorConfig for non-Rust files; rustfmt.toml owns Rust formatting.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Reviewed by Chris St. John·Last updated Jul 16, 2026