Skip to content

rust_analyzer setup: add a Zed mode #4439

Open

Description

@armatys

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.path selects the rust-analyzer binary. Without this key, Zed uses its own download or the rust-analyzer on PATH.
  • initialization_options holds the rust-analyzer configuration. Its keys have no rust-analyzer. prefix.

I'm happy to send a PR for this.

Describe alternatives you've considered

  • Convert the setup -- print output by hand. Each user then has to learn Zed's key layout.
  • Document Zed in docs/src/rust_analyzer.md instead 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

  1. added theissue type on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThe ticket needs maintainer attention.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions