Skip to content

Add rustc compiler development support for the Zed Editor #126931

Open
@KittyBorgX

Description

@KittyBorgX

Currently running x setup prompts an editor setup for VSCode for rustc compiler development in the following way :

x.py can automatically install the recommended `.vscode/settings.json` file for rustc development
Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]

Seeing the rising popularity of the Zed Editor, why not add support for it too? I spent some time configuring and tweaking .zed/settings.json and it's working for me on Zed 0.140.5. I've opened this issue with regard to the workflow of the x setup part, whether:

  • Asking the user to setup zed after the prompt of vscode, something like:
x.py can automatically install the recommended `.vscode/settings.json` file for rustc development
Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]

x.py can automatically install the recommended `.zed/settings.json` file for rustc development
Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]
  • Displaying it in a "menu" - which is seen in the "Welcome to the Rust project! What do you want to do with x.py?" section as follows (just sample text, not the final one):
x.py can automatically install the recommended settings for rustc development. 
Would you like to create/update settings.json for
a) vscode (.vscode/settings.json)
b) zed (.zed/settings.json)
c) none
  • Any other way which it can be displayed to make it user friendly

btw, here's the .zed/settings.json that works (taken almost 1:1 from https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_settings.json):

{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "check": {
          "invocationLocation": "root",
          "invocationStrategy": "once",
          "overrideCommand": ["python3", "x.py", "check", "--json-output"]
        },
        "linkedProjects": [
          "Cargo.toml",
          "src/tools/x/Cargo.toml",
          "src/bootstrap/Cargo.toml",
          "src/tools/rust-analyzer/Cargo.toml",
          "compiler/rustc_codegen_cranelift/Cargo.toml",
          "compiler/rustc_codegen_gcc/Cargo.toml"
        ],
        "rustfmt": {
          "overrideCommand": [
            "./build/host/rustfmt/bin/rustfmt",
            "--edition=2021"
          ]
        },
        "procMacro": {
          "enable": true,
          "server": "./build/host/stage0/libexec/rust-analyzer-proc-macro-srv"
        },
        "cargo": {
          "buildScripts": {
            "enable": true,
            "invocationLocation": "root",
            "invocationStrategy": "once",
            "overrideCommand": ["python3", "x.py", "check", "--json-output"]
          },
          "sysrootSrc": "./library",
          "extraEnv": {
            "RUSTC_BOOTSTRAP": "1"
          }
        }
      }
    }
  }
}

note : i've removed the ${workspaceFolder} and replaced it with ./ since afaik there's no way of using vars in settings.json in zed. variables like ZED_WORKTREE_ROOT can be used in tasks.json hovewer.

Metadata

Metadata

Assignees

Labels

A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions