Repository navigation
Description
Is your feature request related to a problem? Please describe.
The rust-analyzer setup tool supports VS Code, Neovim and Helix. It has no subcommand for Zed. Zed works with the binaries that bazel run @rules_rust//tools/rust_analyzer:setup -- print installs. Users still have to write the Zed settings by hand. The print snippet uses VS Code style keys, such as "rust-analyzer.workspace.discoverConfig". Zed expects these keys nested under lsp.rust-analyzer.
Describe the solution you'd like
Add a setup -- zed subcommand. Like helix, it would install the binaries and print a snippet for .zed/settings.json at the workspace root:
{
"lsp": {
"rust-analyzer": {
"binary": {
"path": "/abs/path/to/rust-analyzer"
},
"initialization_options": {
"workspace": {
"discoverConfig": {
"command": ["/abs/path/to/discover_bazel_rust_project.exe", "{arg}"],
"progressLabel": "rules_rust",
"filesToWatch": ["BUILD", "BUILD.bazel", "MODULE.bazel", "WORKSPACE", "WORKSPACE.bazel"]
}
},
"check": {
"overrideCommand": ["/abs/path/to/flycheck.exe", "--saved-file", "$saved_file"]
},
"procMacro": {
"server": "/abs/path/to/rust-analyzer-proc-macro-srv"
},
"rustfmt": {
"overrideCommand": ["/abs/path/to/rustfmt"]
}
}
}
}
}Two keys differ from the other editors:
binary.pathselects the rust-analyzer binary. Without this key, Zed uses its own download or therust-analyzeronPATH.initialization_optionsholds the rust-analyzer configuration. Its keys have norust-analyzer.prefix.
I'm happy to send a PR for this.
Describe alternatives you've considered
- Convert the
setup -- printoutput by hand. Each user then has to learn Zed's key layout. - Document Zed in
docs/src/rust_analyzer.mdinstead of adding a subcommand. The docs change needs less code. Users still fill in the paths by hand, though.
Additional context
I tested the snippet above in Zed on a large Bazel monorepo, with the paths from setup -- print. Discovery, check on save, proc macros and the bazel test runnables in the gutter work.
Drafted with an AI assistant. I reviewed the text and tested the configuration in Zed.
Activity