mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
plugins/dap-go: migrate to mkNeovimPlugin
This commit is contained in:
parent
4d1bd375c7
commit
6ff7127291
6 changed files with 131 additions and 98 deletions
53
plugins/by-name/dap-go/default.nix
Normal file
53
plugins/by-name/dap-go/default.nix
Normal 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 ];
|
||||||
|
}
|
48
plugins/by-name/dap-go/deprecations.nix
Normal file
48
plugins/by-name/dap-go/deprecations.nix
Normal 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" ]))
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,69 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (lib) types;
|
|
||||||
inherit (lib.nixvim) defaultNullOpts;
|
|
||||||
|
|
||||||
cfg = config.plugins.dap.extensions.dap-go;
|
|
||||||
dapHelpers = import ./dapHelpers.nix { inherit lib; };
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.plugins.dap.extensions.dap-go = {
|
|
||||||
enable = lib.mkEnableOption "dap-go";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "dap-go" {
|
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
|
||||||
"nvim-dap-go"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
dapConfigurations = 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.";
|
|
||||||
|
|
||||||
initializeTimeoutSec = defaultNullOpts.mkInt 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.";
|
|
||||||
|
|
||||||
buildFlags = defaultNullOpts.mkStr "" "Build flags to pass to dlv.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
options = with cfg; {
|
|
||||||
dap_configurations = dapConfigurations;
|
|
||||||
|
|
||||||
delve = with delve; {
|
|
||||||
inherit path port args;
|
|
||||||
initialize_timeout_sec = initializeTimeoutSec;
|
|
||||||
build_flags = buildFlags;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
plugins.dap = {
|
|
||||||
enable = true;
|
|
||||||
extensionConfigLua = ''
|
|
||||||
require("dap-go").setup(${lib.nixvim.toLuaObject options})
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ let
|
||||||
in
|
in
|
||||||
lib.nixvim.plugins.mkNeovimPlugin {
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
imports = [
|
imports = [
|
||||||
./dap-go.nix
|
|
||||||
./dap-python.nix
|
./dap-python.nix
|
||||||
./dap-ui.nix
|
./dap-ui.nix
|
||||||
./dap-virtual-text.nix
|
./dap-virtual-text.nix
|
||||||
|
|
30
tests/test-sources/plugins/by-name/dap-go/default.nix
Normal file
30
tests/test-sources/plugins/by-name/dap-go/default.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.dap-go.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
default = {
|
||||||
|
plugins.dap-go = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
dap_configurations = [
|
||||||
|
{
|
||||||
|
# Must be "go" or it will be ignored by the plugin
|
||||||
|
type = "go";
|
||||||
|
name = "Attach remote";
|
||||||
|
mode = "remote";
|
||||||
|
request = "attach";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
delve = {
|
||||||
|
path = "dlv";
|
||||||
|
initialize_timeout_sec = 20;
|
||||||
|
port = "$\{port}";
|
||||||
|
args = [ ];
|
||||||
|
build_flags = "-tags=unit";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
empty = {
|
|
||||||
plugins.dap.extensions.dap-go.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
default = {
|
|
||||||
plugins.dap.extensions.dap-go = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
dapConfigurations = [
|
|
||||||
{
|
|
||||||
# Must be "go" or it will be ignored by the plugin
|
|
||||||
type = "go";
|
|
||||||
name = "Attach remote";
|
|
||||||
mode = "remote";
|
|
||||||
request = "attach";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
delve = {
|
|
||||||
path = "dlv";
|
|
||||||
initializeTimeoutSec = 20;
|
|
||||||
port = "$\{port}";
|
|
||||||
args = [ ];
|
|
||||||
buildFlags = "-tags=unit";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue