language/clang: use new dap config format

This commit is contained in:
Ching Pei Yang 2026-06-13 00:07:24 +02:00
commit 987867905e
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
5 changed files with 65 additions and 34 deletions

View file

@ -396,5 +396,12 @@ in {
Linters can still be customized via `vim.diagnostics.nvim-lint.<name>.args`
'')
]
# 2026-06-13
[
(mkRemovedOptionModule ["vim" "languages" "clang" "dap" "package"] ''
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
'')
]
];
}

View file

@ -1,5 +1,6 @@
{
imports = [
./presets
./config.nix
./nvim-dap.nix
];

View file

@ -0,0 +1,5 @@
{
imports = [
./lldb.nix
];
}

View file

@ -0,0 +1,22 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.vim.debugger.nvim-dap.presets.lldb;
in {
options.vim.debugger.nvim-dap.presets.lldb = {
enable = mkEnableOption "LLDB debugger using lldb-dap";
};
config.vim.debugger.nvim-dap.adapters = mkIf cfg.enable {
lldb = {
type = "executable";
command = "${pkgs.lldb}/bin/lldb-dap";
};
};
}

View file

@ -6,7 +6,7 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) bool enum package listOf;
inherit (lib.types) bool enum listOf;
inherit (lib) genAttrs;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkIf mkMerge;
@ -14,38 +14,32 @@
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) deprecatedSingleOrListOf enumWithRename;
cfg = config.vim.languages.clang;
defaultServers = ["clangd"];
servers = ["ccls" "clangd"];
defaultDebugger = "lldb-vscode";
defaultDebugger = ["lldb"];
debuggers = {
lldb-vscode = {
package = pkgs.lldb;
dapConfig = ''
dap.adapters.lldb = {
type = 'executable',
command = '${cfg.dap.package}/bin/lldb-dap',
name = 'lldb'
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "''${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
dap.configurations.c = dap.configurations.cpp
'';
lldb = let
configuration = {
name = "Launch";
type = "lldb";
request = "launch";
program = mkLuaInline ''
function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end
'';
cwd = "\${workspaceFolder}";
stopOnEntry = false;
args = {};
};
in {
c = [configuration];
cpp = [configuration];
};
};
@ -147,14 +141,13 @@ in {
};
debugger = mkOption {
description = "clang debugger to use";
type = enum (attrNames debuggers);
type =
deprecatedSingleOrListOf "vim.langauges.clang.dap.debugger"
(enumWithRename "vim.langauges.clang.dap.debugger" (attrNames debuggers) {
lldb-vscode = "lldb";
});
default = defaultDebugger;
};
package = mkOption {
description = "clang debugger package.";
type = package;
default = debuggers.${cfg.dap.debugger}.package;
};
};
format = {
@ -208,8 +201,11 @@ in {
})
(mkIf cfg.dap.enable {
vim.debugger.nvim-dap.enable = true;
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
vim.debugger.nvim-dap = {
enable = true;
presets.lldb.enable = true;
configurations = mkMerge (map (name: debuggers.${name}) cfg.dap.debugger);
};
})
(mkIf cfg.format.enable {