rad is an abbreviation for rust-analyzer daemon.
It decouples the rust-analyzer lifecycle from editor like neovim, so backend
instances can outlive editor sessions.
It also allows multiple editors opening the same workspace to reuse a single
rust-analyzer instance.
+----------------------+ stdio +------------+ +-------------+ stdio +-----------------------+
| Neovim1 | <-------> | rad client | -------------------> | | <-------------> | rust-analyzer A |
| ~/source/greptimedb | +------------+ | | | ~/source/greptimedb |
+----------------------+ | | +-----------------------+
| |
+----------------------+ stdio +------------+ | rad server |
| Neovim2 | <-------> | rad client | -------------------> | (mux/router)| stdio +-----------------------+
| ~/source/greptimedb | +------------+ | | <-------------> | rust-analyzer B |
+----------------------+ | | | ~/source/rad |
| | +-----------------------+
+----------------------+ stdio +------------+ | |
| VSCode | <-------> | rad client | -------------------> | |
| ~/source/rad | +------------+ +-------------+
+----------------------+
- Reuse existing rust-analyzer instance for the same workspace.
- Keep rust-analyzer alive when clients disconnect; idle reaper shuts it down after a configurable timeout.
- Start rust-analyzer in the workspace directory to respect each project's Rust toolchain.
The default config path is ~/.config/rad/rad.toml. Use -c / --config-file
to override it.
An example config file is provided at rad.toml in the repository
root.
Direct Run
rad serversystemd
For Linux setup, see deploy/systemd/README.md.
launchd (macOS)
For macOS setup, see deploy/launchd/README.md.
Neovim(rustaceanvim)
An example configuration of rustaceanvim is shown below.
vim.g.rustaceanvim = {
server = {
cmd = function()
return {
vim.fn.exepath("rad"),
"client",
}
end
},
-- other configurations
}VSCode
VSCode's Rust Analyzer extension calls --version (-V) on the configured
server binary during startup. Since rad client is a proxy command, use a
wrapper script to forward version queries to the real rust-analyzer.
- Create a wrapper script, for example
~/.local/bin/rad-ra:
#!/bin/bash
if [[ "$1" == "--version" || "$1" == "-V" ]]; then
exec rust-analyzer --version
fi
exec rad client "$@"- Make it executable:
chmod +x ~/.local/bin/rad-ra- Configure VSCode (
settings.json):
{
"rust-analyzer.server.path": "{path}/rad-ra"
}Show all running LSP instances:
rad statusExample output:
workspace: file:///home/user/greptimedb
pid: 12345
clients: 2
idle: 1m 15s
healthy: yes
workspace: file:///home/user/rad
pid: 67890
clients: 0
idle: 5m 30s
healthy: yes
Remove idle instances (no attached clients):
rad cleanRemove all instances, regardless of client count:
rad clean -fExample output:
file:///home/user/rad (pid: 67890)