mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-01-30 22:02:23 +00:00
languages/zig: add dap support (#581)
* languages/zig: Added dap support Implemented DAP support for zig. Included comment regarding redundant `dap.adapters.lldb` code when both clang and zig dap modules are enabled. * languages/zig: Added dap support cleanup Cleaned up code from the zig dap implementation for consistency.
This commit is contained in:
parent
8df64accab
commit
547cbd28b6
2 changed files with 64 additions and 2 deletions
|
@ -122,3 +122,8 @@
|
|||
[ruff]: (https://github.com/astral-sh/ruff)
|
||||
|
||||
- Add [ruff] as a formatter option in `vim.languages.python.format.type`.
|
||||
|
||||
[ARCIII](https://github.com/ArmandoCIII):
|
||||
|
||||
- Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter.
|
||||
Code Inspiration from `vim.languages.clang.dap` implementation.
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge mkDefault;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) either listOf package str enum;
|
||||
inherit (lib.types) bool either listOf package str enum;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.zig;
|
||||
|
||||
defaultServer = "zls";
|
||||
servers = {
|
||||
zls = {
|
||||
|
@ -31,7 +33,35 @@
|
|||
};
|
||||
};
|
||||
|
||||
cfg = config.vim.languages.zig;
|
||||
# TODO: dap.adapter.lldb is duplicated when enabling the
|
||||
# vim.languages.clang.dap module. This does not cause
|
||||
# breakage... but could be cleaner.
|
||||
defaultDebugger = "lldb-vscode";
|
||||
debuggers = {
|
||||
lldb-vscode = {
|
||||
package = pkgs.lldb;
|
||||
dapConfig = ''
|
||||
dap.adapters.lldb = {
|
||||
type = 'executable',
|
||||
command = '${cfg.dap.package}/bin/lldb-dap',
|
||||
name = 'lldb'
|
||||
}
|
||||
dap.configurations.zig = {
|
||||
{
|
||||
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 = {},
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.zig = {
|
||||
enable = mkEnableOption "Zig language support";
|
||||
|
@ -56,6 +86,26 @@ in {
|
|||
default = pkgs.zls;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
type = bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
description = "Enable Zig Debug Adapter";
|
||||
};
|
||||
|
||||
debugger = mkOption {
|
||||
type = enum (attrNames debuggers);
|
||||
default = defaultDebugger;
|
||||
description = "Zig debugger to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = debuggers.${cfg.dap.debugger}.package;
|
||||
description = "Zig debugger package.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
|
@ -77,5 +127,12 @@ in {
|
|||
globals.zig_fmt_autosave = mkDefault 0;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.dap.enable {
|
||||
vim = {
|
||||
debugger.nvim-dap.enable = true;
|
||||
debugger.nvim-dap.sources.zig-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue