mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-22 02:59:49 +01:00
feat: add dap support for clang
This commit is contained in:
parent
b3b6f56fbc
commit
3a8b614ea9
1 changed files with 52 additions and 0 deletions
|
@ -36,6 +36,35 @@ with builtins; let
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultDebugger = "lldb-vscode";
|
||||
debuggers = {
|
||||
lldb-vscode = {
|
||||
package = pkgs.lldb;
|
||||
dapConfig = ''
|
||||
dap.adapters.lldb = {
|
||||
type = 'executable',
|
||||
command = '${cfg.dap.package}/bin/lldb-vscode',
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.clang = {
|
||||
enable = mkEnableOption "C/C++ language support";
|
||||
|
@ -76,6 +105,24 @@ in {
|
|||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
description = "Enable clang Debug Adapter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
};
|
||||
debugger = mkOption {
|
||||
description = "clang debugger to use";
|
||||
type = with types; enum (attrNames debuggers);
|
||||
default = defaultDebugger;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "clang debugger package.";
|
||||
type = types.package;
|
||||
default = debuggers.${cfg.dap.debugger}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
|
@ -93,5 +140,10 @@ in {
|
|||
|
||||
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.dap.enable {
|
||||
vim.debugger.nvim-dap.enable = true;
|
||||
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue