async-rust-lsp
A standalone LSP server that provides real-time diagnostics for async Rust antipatterns — focusing on patterns that clippy and rust-analyzer miss.
Problem
Existing Rust tooling has a blind spot for tokio-specific async antipatterns:
- clippy only checks
std::sync::Mutexacross.await, nottokio::sync::Mutex - rust-analyzer has no plugin system for custom diagnostics
- Runtime tools (tokio-console) only help during execution, not during editing
This LSP fills the gap with real-time editor feedback for async lock patterns.
Current rules
async-rust/mutex-across-await
Warns when tokio::sync::Mutex or RwLock guards are held across .await points — a pattern that can deadlock under tokio's cooperative scheduling.
// BAD — guard lives across the await
let guard = mutex.lock.await;
do_something;
some_future.await; // WARNING: deadlock risk
// OK — guard scoped before the await
let value = ;
some_future.await; // fine
The rule tracks guard liveness through:
drop(guard)calls (including inside conditional branches)letshadowing that kills the guard binding- Block scoping (guard dropped at end of block)
Installation
Or build from source:
# binary at ./target/release/async-rust-lsp
Editor setup
Neovim (nvim-lspconfig)
local lspconfig = require
local configs = require
if not configs.
lspconfig..
VS Code
Use a generic LSP client extension and add to .vscode/settings.json:
Zed
Add to ~/.config/zed/settings.json:
Claude Code
Diagnostics appear automatically in Claude's context when editing .rs files.
Logging
The server logs to $TMPDIR/async-rust-lsp.log (never stdout/stderr, which are reserved for LSP stdio protocol).
RUST_LOG=debug
Architecture
┌─────────────┐ LSP/stdio ┌──────────────────┐
│ Editor │ <─────────────> │ async-rust-lsp │
│ (or Claude) │ │ │
└─────────────┘ │ tree-sitter-rust│
│ + custom rules │
└──────────────────┘
Built with:
tower-lsp— async LSP frameworktree-sitter-rust— incremental Rust parser
Origin
Born from a real deadlock in the nteract desktop daemon. See nteract/desktop#1614. The gap in static analysis for tokio async patterns is well-known but no one has filled it with an LSP yet.
License
MIT