mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
plugins/dap: init + extensions + tests (#455)
This commit is contained in:
parent
993cf528b7
commit
d025d14f4e
12 changed files with 967 additions and 0 deletions
91
plugins/dap/default.nix
Normal file
91
plugins/dap/default.nix
Normal file
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.dap;
|
||||
helpers = import ../helpers.nix {inherit lib;};
|
||||
dapHelpers = import ./dapHelpers.nix {inherit lib;};
|
||||
in
|
||||
with dapHelpers; {
|
||||
imports = [
|
||||
./dap-go.nix
|
||||
./dap-python.nix
|
||||
./dap-ui.nix
|
||||
./dap-virtual-text.nix
|
||||
];
|
||||
|
||||
options.plugins.dap =
|
||||
helpers.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "dap";
|
||||
|
||||
package = helpers.mkPackageOption "dap" pkgs.vimPlugins.nvim-dap;
|
||||
|
||||
adapters = helpers.mkCompositeOption "Dap adapters." {
|
||||
executables = mkAdapterOption "executable" executableAdapterOption;
|
||||
servers = mkAdapterOption "server" serverAdapterOption;
|
||||
};
|
||||
|
||||
configurations = helpers.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption)) ''
|
||||
Debugee configurations, see `:h dap-configuration` for more info.
|
||||
'';
|
||||
|
||||
signs = helpers.mkCompositeOption "Signs for dap." {
|
||||
dapBreakpoint = mkSignOption "B" "Sign for breakpoints.";
|
||||
|
||||
dapBreakpointCondition = mkSignOption "C" "Sign for conditional breakpoints.";
|
||||
|
||||
dapLogPoint = mkSignOption "L" "Sign for log points.";
|
||||
|
||||
dapStopped = mkSignOption "→" "Sign to indicate where the debugee is stopped.";
|
||||
|
||||
dapBreakpointRejected = mkSignOption "R" "Sign to indicate breakpoints rejected by the debug adapter.";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
options = with cfg;
|
||||
{
|
||||
inherit configurations;
|
||||
|
||||
adapters =
|
||||
(
|
||||
lib.optionalAttrs (adapters.executables != null)
|
||||
(processAdapters "executable" adapters.executables)
|
||||
)
|
||||
// (
|
||||
lib.optionalAttrs (adapters.servers != null)
|
||||
(processAdapters "server" adapters.servers)
|
||||
);
|
||||
|
||||
signs = with signs; {
|
||||
DapBreakpoint = dapBreakpoint;
|
||||
DapBreakpointCondition = dapBreakpointCondition;
|
||||
DapLogPoint = dapLogPoint;
|
||||
DapStopped = dapStopped;
|
||||
DapBreakpointRejected = dapBreakpointRejected;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
extraConfigLua =
|
||||
(optionalString (cfg.adapters != null) ''
|
||||
require("dap").adapters = ${helpers.toLuaObject options.adapters}
|
||||
'')
|
||||
+ (optionalString (options.configurations != null) ''
|
||||
require("dap").configurations = ${helpers.toLuaObject options.configurations}
|
||||
'')
|
||||
+ (optionalString (cfg.signs != null) ''
|
||||
local __dap_signs = ${helpers.toLuaObject options.signs}
|
||||
for sign_name, sign in pairs(__dap_signs) do
|
||||
vim.fn.sign_define(sign_name, sign)
|
||||
end
|
||||
'');
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue