mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/dap: migrate to mkNeovimPlugin
This commit is contained in:
parent
216ae2bf40
commit
4d1bd375c7
1 changed files with 46 additions and 48 deletions
|
@ -1,23 +1,17 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkEnableOption
|
|
||||||
mkOption
|
mkOption
|
||||||
optionalString
|
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
cfg = config.plugins.dap;
|
|
||||||
|
|
||||||
dapHelpers = import ./dapHelpers.nix { inherit lib; };
|
dapHelpers = import ./dapHelpers.nix { inherit lib; };
|
||||||
inherit (dapHelpers) mkSignOption;
|
inherit (dapHelpers) mkSignOption;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
imports = [
|
imports = [
|
||||||
./dap-go.nix
|
./dap-go.nix
|
||||||
./dap-python.nix
|
./dap-python.nix
|
||||||
|
@ -25,16 +19,16 @@ in
|
||||||
./dap-virtual-text.nix
|
./dap-virtual-text.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.plugins.dap = lib.nixvim.plugins.neovim.extraOptionsOptions // {
|
name = "dap";
|
||||||
enable = mkEnableOption "dap";
|
package = "nvim-dap";
|
||||||
|
packPathName = "nvim-dap";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "dap" {
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
|
||||||
"nvim-dap"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
# Added 2025-01-26
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
adapters = lib.nixvim.mkCompositeOption "Dap adapters." {
|
adapters = lib.nixvim.mkCompositeOption "Dap adapters." {
|
||||||
executables = dapHelpers.mkAdapterOption "executable" dapHelpers.executableAdapterOption;
|
executables = dapHelpers.mkAdapterOption "executable" dapHelpers.executableAdapterOption;
|
||||||
servers = dapHelpers.mkAdapterOption "server" dapHelpers.serverAdapterOption;
|
servers = dapHelpers.mkAdapterOption "server" dapHelpers.serverAdapterOption;
|
||||||
|
@ -43,7 +37,7 @@ in
|
||||||
configurations =
|
configurations =
|
||||||
lib.nixvim.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption))
|
lib.nixvim.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption))
|
||||||
''
|
''
|
||||||
Debuggee configurations, see `:h dap-configuration` for more info.
|
Debugger configurations, see `:h dap-configuration` for more info.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
signs = lib.nixvim.mkCompositeOption "Signs for dap." {
|
signs = lib.nixvim.mkCompositeOption "Signs for dap." {
|
||||||
|
@ -68,47 +62,51 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
# Separate configuration and adapter configurations
|
||||||
|
callSetup = false;
|
||||||
|
extraConfig =
|
||||||
|
cfg:
|
||||||
let
|
let
|
||||||
options =
|
options = {
|
||||||
with cfg;
|
inherit (cfg) configurations;
|
||||||
{
|
|
||||||
inherit configurations;
|
|
||||||
|
|
||||||
adapters =
|
adapters =
|
||||||
(lib.optionalAttrs (adapters.executables != null) (
|
(lib.optionalAttrs (cfg.adapters.executables != null) (
|
||||||
dapHelpers.processAdapters "executable" adapters.executables
|
dapHelpers.processAdapters "executable" cfg.adapters.executables
|
||||||
))
|
))
|
||||||
// (lib.optionalAttrs (adapters.servers != null) (
|
// (lib.optionalAttrs (cfg.adapters.servers != null) (
|
||||||
dapHelpers.processAdapters "server" adapters.servers
|
dapHelpers.processAdapters "server" cfg.adapters.servers
|
||||||
));
|
));
|
||||||
|
|
||||||
signs = with signs; {
|
signs = with cfg.signs; {
|
||||||
DapBreakpoint = dapBreakpoint;
|
DapBreakpoint = dapBreakpoint;
|
||||||
DapBreakpointCondition = dapBreakpointCondition;
|
DapBreakpointCondition = dapBreakpointCondition;
|
||||||
DapLogPoint = dapLogPoint;
|
DapLogPoint = dapLogPoint;
|
||||||
DapStopped = dapStopped;
|
DapStopped = dapStopped;
|
||||||
DapBreakpointRejected = dapBreakpointRejected;
|
DapBreakpointRejected = dapBreakpointRejected;
|
||||||
};
|
};
|
||||||
}
|
} // cfg.settings;
|
||||||
// cfg.extraOptions;
|
|
||||||
in
|
in
|
||||||
lib.mkIf cfg.enable {
|
{
|
||||||
extraPlugins = [ cfg.package ];
|
plugins.dap.luaConfig.content = lib.mkMerge [
|
||||||
|
(lib.mkIf (cfg.adapters != null) ''
|
||||||
extraConfigLua =
|
|
||||||
(optionalString (cfg.adapters != null) ''
|
|
||||||
require("dap").adapters = ${lib.nixvim.toLuaObject options.adapters}
|
require("dap").adapters = ${lib.nixvim.toLuaObject options.adapters}
|
||||||
'')
|
'')
|
||||||
+ (optionalString (options.configurations != null) ''
|
(lib.mkIf (options.configurations != null) ''
|
||||||
require("dap").configurations = ${lib.nixvim.toLuaObject options.configurations}
|
require("dap").configurations = ${lib.nixvim.toLuaObject options.configurations}
|
||||||
'')
|
'')
|
||||||
+ (optionalString (cfg.signs != null) ''
|
(lib.mkIf (cfg.signs != null) ''
|
||||||
|
do
|
||||||
local __dap_signs = ${lib.nixvim.toLuaObject options.signs}
|
local __dap_signs = ${lib.nixvim.toLuaObject options.signs}
|
||||||
|
|
||||||
for sign_name, sign in pairs(__dap_signs) do
|
for sign_name, sign in pairs(__dap_signs) do
|
||||||
vim.fn.sign_define(sign_name, sign)
|
vim.fn.sign_define(sign_name, sign)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
'')
|
'')
|
||||||
+ cfg.extensionConfigLua;
|
''
|
||||||
|
${cfg.extensionConfigLua}
|
||||||
|
''
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue