Set up rust-analyzer LSP integration and install all cargo tools required by the hooks in this project.
Sets up rust-analyzer LSP and installs cargo tools for Rust hooks (audit, deny, outdated, machete, semver-checks, geiger, expand, bloat, mutants, udeps). Use this to configure your Rust development environment before running project hooks.
/plugin marketplace add zircote/rust-lsp/plugin install zircote-rust-lsp@zircote/rust-lspSet up rust-analyzer LSP integration and install all cargo tools required by the hooks in this project.
Execute the following setup steps in order:
Check that rustup and cargo are installed:
rustup --version && cargo --version
If not installed, guide the user to https://rustup.rs/
Check if rust-analyzer is available:
which rust-analyzer || rustup component add rust-analyzer
rustup toolchain install nightly
Install all tools used by the hooks in hooks/hooks.json:
# Core tools (required)
cargo install cargo-audit # Security vulnerability scanning
cargo install cargo-deny # License and security policy enforcement
cargo install cargo-outdated # Dependency freshness check
# Enhanced analysis (recommended)
cargo install cargo-machete # Unused dependency detection (fast)
cargo install cargo-semver-checks # API compatibility verification
cargo install cargo-geiger # Unsafe code metrics
# Development aids (optional)
cargo install cargo-expand # Macro expansion viewer
cargo install cargo-bloat # Binary size analysis
cargo install cargo-mutants # Mutation testing
# Nightly-only tools
cargo +nightly install cargo-udeps # Unused dependencies (comprehensive)
Check that .lsp.json exists and is properly configured:
cat .lsp.json
Expected configuration:
{
"rust": {
"command": "rust-analyzer",
"args": [],
"extensionToLanguage": {
".rs": "rust"
},
"transport": "stdio"
}
}
If this project uses cargo deny, ensure deny.toml exists:
[ -f deny.toml ] || cargo deny init
Confirm hooks are loaded:
cat hooks/hooks.json | head -50
| Tool | Purpose | Hook |
|---|---|---|
rust-analyzer | LSP server for IDE features | Core |
cargo-audit | CVE vulnerability scanning | rust-audit |
cargo-deny | License/security policy | rust-deny-check |
cargo-outdated | Outdated deps | rust-outdated |
cargo-machete | Unused deps (fast) | rust-machete |
cargo-udeps | Unused deps (thorough) | rust-unused-deps |
cargo-semver-checks | API compat | rust-semver-check |
cargo-geiger | Unsafe metrics | rust-geiger |
cargo-expand | Macro viewer | rust-expand-hint |
cargo-bloat | Size analysis | rust-bloat-hint |
cargo-mutants | Mutation testing | rust-mutants-hint |
Cargo.toml exists in project rootcargo check to generate build artifactsrust-analyzer --versioncargo +nightly udepsrustup component add rust-src --toolchain nightlycargo deny initcargo deny fetchOne-liner to install everything:
rustup component add rust-analyzer && \
rustup toolchain install nightly && \
cargo install cargo-audit cargo-deny cargo-outdated cargo-machete \
cargo-semver-checks cargo-geiger cargo-expand cargo-bloat \
cargo-mutants && \
cargo +nightly install cargo-udeps
After running this command, provide a status summary showing which tools were installed successfully and any that failed.