Skip to content

Commit 2fe8be4

Browse files
authored
languages/rust: fix rustaceanvim DAP adapter (#1283)
Align codelldb adapter setup with rustaceanvim’s built-in logic. Add languages.rust.dap.backend option to choose between codelldb and lldb-dap adapters.
2 parents 13b3916 + 1d362cd commit 2fe8be4

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

docs/manual/release-notes/rl-0.8.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,3 +621,9 @@
621621
[JudahZF](https://github.com/JudahZF):
622622

623623
- Added gitFiles mapping option to telescope
624+
625+
[Ring-A-Ding-Ding-Baby](https://github.com/Ring-A-Ding-Ding-Baby)
626+
627+
- Aligned `codelldb` adapter setup with [rustaceanvim]’s built-in logic.
628+
- Added `languages.rust.dap.backend` option to choose between `codelldb` and
629+
`lldb-dap` adapters.

modules/plugins/languages/rust.nix

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ in {
8787
type = package;
8888
default = pkgs.lldb;
8989
};
90+
91+
adapter = mkOption {
92+
type = enum ["lldb-dap" "codelldb"];
93+
default = "codelldb";
94+
description = ''
95+
Select which LLDB-based debug adapter to use:
96+
97+
- "codelldb": use the CodeLLDB adapter from the vadimcn.vscode-lldb extension.
98+
- "lldb-dap": use the LLDB DAP implementation shipped with LLVM (lldb-dap).
99+
100+
The default "codelldb" backend generally provides a better debugging experience for Rust.
101+
'';
102+
};
90103
};
91104

92105
extensions = {
@@ -191,11 +204,20 @@ in {
191204
192205
${optionalString cfg.dap.enable ''
193206
dap = {
194-
adapter = {
195-
type = "executable",
196-
command = "${cfg.dap.package}/bin/lldb-dap",
197-
name = "rustacean_lldb",
198-
},
207+
adapter = ${
208+
if cfg.dap.adapter == "lldb-dap"
209+
then ''
210+
{
211+
type = "executable",
212+
command = "${cfg.dap.package}/bin/lldb-dap",
213+
name = "rustacean_lldb",
214+
}''
215+
else let
216+
codelldb = pkgs.vscode-extensions.vadimcn.vscode-lldb.adapter;
217+
codelldbPath = "${codelldb}/bin/codelldb";
218+
liblldbPath = "${codelldb}/share/lldb/lib/liblldb.so";
219+
in ''require("rustaceanvim.config").get_codelldb_adapter("${codelldbPath}", "${liblldbPath}")''
220+
},
199221
},
200222
''}
201223
}

0 commit comments

Comments
 (0)