Skip to content

Commit

Permalink
Add support for the Zed IDE to ./x setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaiTRex committed Feb 15, 2025
1 parent 18d7ffa commit d9f125d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ enum EditorKind {
Helix,
Vim,
VsCode,
Zed,
}

impl EditorKind {
Expand All @@ -536,6 +537,7 @@ impl EditorKind {
2. Helix
3. Vim
4. VS Code
5. Zed
Select which editor you would like to set up [default: None]: ";

Expand All @@ -552,6 +554,7 @@ Select which editor you would like to set up [default: None]: ";
"2" | "helix" => return Ok(Some(EditorKind::Helix)),
"3" | "vim" => return Ok(Some(EditorKind::Vim)),
"4" | "vscode" => return Ok(Some(EditorKind::VsCode)),
"5" | "zed" => return Ok(Some(EditorKind::Zed)),
"" | "none" => return Ok(None),
_ => {
eprintln!("ERROR: unrecognized option '{}'", input.trim());
Expand Down Expand Up @@ -587,6 +590,9 @@ Select which editor you would like to set up [default: None]: ";
"4eecb58a2168b252077369da446c30ed0e658301efe69691979d1ef0443928f4",
"c394386e6133bbf29ffd32c8af0bb3d4aac354cba9ee051f29612aa9350f8f8d",
],
EditorKind::Zed => {
&["bbce727c269d1bd0c98afef4d612eb4ce27aea3c3a8968c5f10b31affbc40b6c"]
}
}
}

Expand All @@ -599,7 +605,7 @@ Select which editor you would like to set up [default: None]: ";
EditorKind::Emacs => ".dir-locals.el",
EditorKind::Helix => "languages.toml",
EditorKind::Vim => "coc-settings.json",
EditorKind::VsCode => "settings.json",
EditorKind::VsCode | EditorKind::Zed => "settings.json",
})
}

Expand All @@ -609,6 +615,7 @@ Select which editor you would like to set up [default: None]: ";
EditorKind::Helix => PathBuf::from(".helix"),
EditorKind::Vim => PathBuf::from(".vim"),
EditorKind::VsCode => PathBuf::from(".vscode"),
EditorKind::Zed => PathBuf::from(".zed"),
}
}

Expand All @@ -619,6 +626,7 @@ Select which editor you would like to set up [default: None]: ";
EditorKind::Vim | EditorKind::VsCode => {
include_str!("../../../../etc/rust_analyzer_settings.json")
}
EditorKind::Zed => include_str!("../../../../etc/rust_analyzer_zed.json"),
}
}

Expand Down
52 changes: 52 additions & 0 deletions src/etc/rust_analyzer_zed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"cargo": {
"buildScripts": {
"enable": true,
"invocationLocation": "root",
"invocationStrategy": "once",
"overrideCommand": ["python3", "x.py", "check", "--json-output"]
},
"extraEnv": {
"RUSTC_BOOTSTRAP": "1"
},
"sysrootSrc": "./library"
},
"check": {
"invocationLocation": "root",
"invocationStrategy": "once",
"overrideCommand": ["python3", "x.py", "check", "--json-output"]
},
"linkedProjects": [
"Cargo.toml",
"library/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"
],
"procMacro": {
"enable": true,
"server": "${workspaceFolder}/build/host/stage0/libexec/rust-analyzer-proc-macro-srv"
},
"rustc": {
"source": "./Cargo.toml"
},
"rustfmt": {
"overrideCommand": [
"${workspaceFolder}/build/host/rustfmt/bin/rustfmt",
"--edition=2021"
]
},
"server": {
"extraEnv": {
"RUSTUP_TOOLCHAIN": "nightly"
}
}
}
}
}
}

0 comments on commit d9f125d

Please sign in to comment.