rust-lsp

A Claude Code plugin providing comprehensive Rust development support through:
- rust-analyzer LSP integration for IDE-like features
- 16 automated hooks for code quality, security, and analysis
- Cargo tool ecosystem integration
Quick Setup
# Run the setup command (after installing the plugin)
/setup
Or manually:
# Install rust-analyzer
rustup component add rust-analyzer
# Install nightly toolchain (required for some tools)
rustup toolchain install nightly
# Install all cargo tools
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
Features
LSP Integration
The plugin configures rust-analyzer for Claude Code via .lsp.json:
{
"rust": {
"command": "rust-analyzer",
"args": [],
"extensionToLanguage": { ".rs": "rust" },
"transport": "stdio"
}
}
Capabilities:
- Go to definition / references
- Hover documentation
- Code actions and quick fixes
- Workspace symbol search
- Real-time diagnostics
Automated Hooks
All hooks run afterWrite and are configured in hooks/hooks.json.
Core Rust Hooks
| Hook | Trigger | Description |
|---|
rust-format-on-edit | **/*.rs | Auto-format with rustfmt |
rust-check-on-edit | **/*.rs | Compile check with cargo check |
rust-clippy-on-edit | **/*.rs | Lint with cargo clippy |
rust-test-compile-on-edit | **/*.rs | Verify tests compile (cargo test --no-run) |
Documentation & Quality
| Hook | Trigger | Description |
|---|
rust-doc-check | **/src/**/*.rs | Check rustdoc for warnings/errors |
rust-todo-fixme | **/*.rs | Surface TODO/FIXME/XXX/HACK comments |
rust-unsafe-detector | **/*.rs | Flag unsafe blocks for review |
Dependency Management
| Hook | Trigger | Tool Required | Description |
|---|
rust-audit | **/Cargo.lock | cargo-audit | CVE vulnerability scanning |
rust-deny-check | **/Cargo.toml | cargo-deny | License/security policy enforcement |
rust-outdated | **/Cargo.toml | cargo-outdated | Check for outdated dependencies |
rust-machete | **/Cargo.toml | cargo-machete | Fast unused dependency detection |
rust-unused-deps | **/Cargo.toml | cargo-udeps | Thorough unused dependency check (nightly) |
Advanced Analysis
| Hook | Trigger | Tool Required | Description |
|---|
rust-semver-check | **/src/lib.rs | cargo-semver-checks | API compatibility verification |
rust-geiger | **/Cargo.toml | cargo-geiger | Unsafe code ratio in dependencies |
Contextual Hints
| Hook | Trigger | Description |
|---|
rust-mutants-hint | **/src/**/*.rs | Suggests mutation testing when available |
rust-bloat-hint | **/Cargo.toml | Suggests binary size analysis |
rust-expand-hint | **/*.rs | Suggests macro expansion when macros detected |
rust-bench-hint | **/*.rs | Suggests benchmark run when benchmarks detected |
Other
| Hook | Trigger | Description |
|---|
markdown-lint-on-edit | **/*.md | Lint markdown files |
Required Tools
Core (Included with Rust)
| Tool | Installation | Purpose |
|---|
rustfmt | rustup component add rustfmt | Code formatting |
clippy | rustup component add clippy | Linting |
rust-analyzer | rustup component add rust-analyzer | LSP server |
Recommended Cargo Extensions
| Tool | Installation | Purpose |
|---|
cargo-audit | cargo install cargo-audit | Security vulnerability database |
cargo-deny | cargo install cargo-deny | License and security policy |
cargo-outdated | cargo install cargo-outdated | Dependency freshness |
cargo-machete | cargo install cargo-machete | Unused dependencies (fast) |
Optional Cargo Extensions