plugins/dap-go: migrate to mkNeovimPlugin

This commit is contained in:
Austin Horstman 2025-01-26 13:14:13 -06:00
parent 4d1bd375c7
commit 6ff7127291
No known key found for this signature in database
6 changed files with 131 additions and 98 deletions

View file

@ -0,0 +1,53 @@
{
lib,
...
}:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
dapHelpers = import ../dap/dapHelpers.nix { inherit lib; };
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "dap-go";
package = "nvim-dap-go";
maintainers = [ lib.maintainers.khaneliman ];
settingsOptions = {
dap_configurations = lib.nixvim.mkNullOrOption (types.listOf dapHelpers.configurationOption) ''
Additional dap configurations.
See `:h dap-configuration` for more detail.
'';
delve = {
path = defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging.";
initialize_timeout_sec = defaultNullOpts.mkUnsignedInt 20 "Time to wait for delve to initialize the debug session.";
port = defaultNullOpts.mkStr "$${port}" ''
A string that defines the port to start delve debugger.
Defaults to string "$${port}" which instructs dap
to start the process in a random available port.
'';
args = lib.nixvim.mkNullOrOption (types.listOf types.str) "Additional args to pass to dlv.";
build_flags = defaultNullOpts.mkStr "" "Build flags to pass to dlv.";
};
};
# Manually supplied to nvim-dap config module
callSetup = false;
extraConfig = cfg: {
plugins.dap = {
enable = true;
extensionConfigLua = ''
require("dap-go").setup(${lib.nixvim.toLuaObject cfg.settings})
'';
};
};
# NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26)
imports = [ ./deprecations.nix ];
}

View file

@ -0,0 +1,48 @@
{ lib, ... }:
let
oldPluginBasePath = [
"plugins"
"dap"
"extensions"
"dap-go"
];
newPluginBasePath = [
"plugins"
"dap-go"
];
settingsPath = newPluginBasePath ++ [ "settings" ];
renamedOptions = [
"dapConfigurations"
[
"delve"
"path"
]
[
"delve"
"initializeTimeoutSec"
]
[
"delve"
"port"
]
[
"delve"
"args"
]
[
"delve"
"buildFlags"
]
];
renameWarnings =
lib.nixvim.mkSettingsRenamedOptionModules oldPluginBasePath settingsPath
renamedOptions;
in
{
imports = renameWarnings ++ [
(lib.mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
];
}