Skip to content

Commit 6453f7e

Browse files
committed
etc: Add rust-analyzer configs for eglot & helix
LSP configuration in editors like Emacs (eglot) and helix does not use the same JSON format as vscode and vim do. It is not obvious how to set up LSP for rustc in those editors and the dev guide currently does not cover them. Adding sample configuration files for those editors alongside the currently existing JSON one would be helpful.
1 parent 7042c26 commit 6453f7e

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/etc/rust_analyzer_eglot.el

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
((rustic-mode
2+
.((eglot-workspace-configuration
3+
. (:rust-analyzer
4+
( :check ( :invocationLocation "root"
5+
:invocationStrategy "once"
6+
:overrideCommand ["python3"
7+
"x.py"
8+
"check"
9+
"--json-output"])
10+
:linkedProjects ["Cargo.toml"
11+
"src/tools/x/Cargo.toml"
12+
"src/bootstrap/Cargo.toml"
13+
"src/tools/rust-analyzer/Cargo.toml"
14+
"compiler/rustc_codegen_cranelift/Cargo.toml"
15+
"compiler/rustc_codegen_gcc/Cargo.toml"]
16+
:rustfmt ( :overrideCommand ["build/host/rustfmt/bin/rustfmt"
17+
"--edition=2021"])
18+
:procMacro ( :server "build/host/stage0/libexec/rust-analyzer-proc-macro-srv"
19+
:enable t)
20+
:cargo ( :buildScripts ( :enable t
21+
:invocationLocation "root"
22+
:invocationStrategy "once"
23+
:overrideCommand ["python3"
24+
"x.py"
25+
"check"
26+
"--json-output"])
27+
:sysrootSrc "./library"
28+
:extraEnv (:RUSTC_BOOTSTRAP "1"))
29+
:rustc ( :source "./Cargo.toml" )))))))

src/etc/rust_analyzer_helix.toml

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

0 commit comments

Comments
 (0)