Skip to content

Commit d9f125d

Browse files
committed
Add support for the Zed IDE to ./x setup
1 parent 18d7ffa commit d9f125d

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

src/bootstrap/src/core/build_steps/setup.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ enum EditorKind {
527527
Helix,
528528
Vim,
529529
VsCode,
530+
Zed,
530531
}
531532

532533
impl EditorKind {
@@ -536,6 +537,7 @@ impl EditorKind {
536537
2. Helix
537538
3. Vim
538539
4. VS Code
540+
5. Zed
539541
540542
Select which editor you would like to set up [default: None]: ";
541543

@@ -552,6 +554,7 @@ Select which editor you would like to set up [default: None]: ";
552554
"2" | "helix" => return Ok(Some(EditorKind::Helix)),
553555
"3" | "vim" => return Ok(Some(EditorKind::Vim)),
554556
"4" | "vscode" => return Ok(Some(EditorKind::VsCode)),
557+
"5" | "zed" => return Ok(Some(EditorKind::Zed)),
555558
"" | "none" => return Ok(None),
556559
_ => {
557560
eprintln!("ERROR: unrecognized option '{}'", input.trim());
@@ -587,6 +590,9 @@ Select which editor you would like to set up [default: None]: ";
587590
"4eecb58a2168b252077369da446c30ed0e658301efe69691979d1ef0443928f4",
588591
"c394386e6133bbf29ffd32c8af0bb3d4aac354cba9ee051f29612aa9350f8f8d",
589592
],
593+
EditorKind::Zed => {
594+
&["bbce727c269d1bd0c98afef4d612eb4ce27aea3c3a8968c5f10b31affbc40b6c"]
595+
}
590596
}
591597
}
592598

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

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

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

src/etc/rust_analyzer_zed.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"lsp": {
3+
"rust-analyzer": {
4+
"initialization_options": {
5+
"cargo": {
6+
"buildScripts": {
7+
"enable": true,
8+
"invocationLocation": "root",
9+
"invocationStrategy": "once",
10+
"overrideCommand": ["python3", "x.py", "check", "--json-output"]
11+
},
12+
"extraEnv": {
13+
"RUSTC_BOOTSTRAP": "1"
14+
},
15+
"sysrootSrc": "./library"
16+
},
17+
"check": {
18+
"invocationLocation": "root",
19+
"invocationStrategy": "once",
20+
"overrideCommand": ["python3", "x.py", "check", "--json-output"]
21+
},
22+
"linkedProjects": [
23+
"Cargo.toml",
24+
"library/Cargo.toml",
25+
"src/tools/x/Cargo.toml",
26+
"src/bootstrap/Cargo.toml",
27+
"src/tools/rust-analyzer/Cargo.toml",
28+
"compiler/rustc_codegen_cranelift/Cargo.toml",
29+
"compiler/rustc_codegen_gcc/Cargo.toml"
30+
],
31+
"procMacro": {
32+
"enable": true,
33+
"server": "${workspaceFolder}/build/host/stage0/libexec/rust-analyzer-proc-macro-srv"
34+
},
35+
"rustc": {
36+
"source": "./Cargo.toml"
37+
},
38+
"rustfmt": {
39+
"overrideCommand": [
40+
"${workspaceFolder}/build/host/rustfmt/bin/rustfmt",
41+
"--edition=2021"
42+
]
43+
},
44+
"server": {
45+
"extraEnv": {
46+
"RUSTUP_TOOLCHAIN": "nightly"
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)