Skip to content

Commit 6ff7127

Browse files
committed
plugins/dap-go: migrate to mkNeovimPlugin
1 parent 4d1bd37 commit 6ff7127

File tree

6 files changed

+131
-98
lines changed

6 files changed

+131
-98
lines changed

plugins/by-name/dap-go/default.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
lib,
3+
...
4+
}:
5+
let
6+
inherit (lib) types;
7+
inherit (lib.nixvim) defaultNullOpts;
8+
9+
dapHelpers = import ../dap/dapHelpers.nix { inherit lib; };
10+
in
11+
lib.nixvim.plugins.mkNeovimPlugin {
12+
name = "dap-go";
13+
package = "nvim-dap-go";
14+
15+
maintainers = [ lib.maintainers.khaneliman ];
16+
17+
settingsOptions = {
18+
dap_configurations = lib.nixvim.mkNullOrOption (types.listOf dapHelpers.configurationOption) ''
19+
Additional dap configurations.
20+
See `:h dap-configuration` for more detail.
21+
'';
22+
23+
delve = {
24+
path = defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging.";
25+
26+
initialize_timeout_sec = defaultNullOpts.mkUnsignedInt 20 "Time to wait for delve to initialize the debug session.";
27+
28+
port = defaultNullOpts.mkStr "$${port}" ''
29+
A string that defines the port to start delve debugger.
30+
31+
Defaults to string "$${port}" which instructs dap
32+
to start the process in a random available port.
33+
'';
34+
35+
args = lib.nixvim.mkNullOrOption (types.listOf types.str) "Additional args to pass to dlv.";
36+
37+
build_flags = defaultNullOpts.mkStr "" "Build flags to pass to dlv.";
38+
};
39+
};
40+
41+
# Manually supplied to nvim-dap config module
42+
callSetup = false;
43+
extraConfig = cfg: {
44+
plugins.dap = {
45+
enable = true;
46+
extensionConfigLua = ''
47+
require("dap-go").setup(${lib.nixvim.toLuaObject cfg.settings})
48+
'';
49+
};
50+
};
51+
# NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26)
52+
imports = [ ./deprecations.nix ];
53+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{ lib, ... }:
2+
let
3+
oldPluginBasePath = [
4+
"plugins"
5+
"dap"
6+
"extensions"
7+
"dap-go"
8+
];
9+
newPluginBasePath = [
10+
"plugins"
11+
"dap-go"
12+
];
13+
14+
settingsPath = newPluginBasePath ++ [ "settings" ];
15+
16+
renamedOptions = [
17+
"dapConfigurations"
18+
[
19+
"delve"
20+
"path"
21+
]
22+
[
23+
"delve"
24+
"initializeTimeoutSec"
25+
]
26+
[
27+
"delve"
28+
"port"
29+
]
30+
[
31+
"delve"
32+
"args"
33+
]
34+
[
35+
"delve"
36+
"buildFlags"
37+
]
38+
];
39+
40+
renameWarnings =
41+
lib.nixvim.mkSettingsRenamedOptionModules oldPluginBasePath settingsPath
42+
renamedOptions;
43+
in
44+
{
45+
imports = renameWarnings ++ [
46+
(lib.mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
47+
];
48+
}

plugins/by-name/dap/dap-go.nix

Lines changed: 0 additions & 69 deletions
This file was deleted.

plugins/by-name/dap/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ let
1313
in
1414
lib.nixvim.plugins.mkNeovimPlugin {
1515
imports = [
16-
./dap-go.nix
1716
./dap-python.nix
1817
./dap-ui.nix
1918
./dap-virtual-text.nix
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
empty = {
3+
plugins.dap-go.enable = true;
4+
};
5+
6+
default = {
7+
plugins.dap-go = {
8+
enable = true;
9+
10+
settings = {
11+
dap_configurations = [
12+
{
13+
# Must be "go" or it will be ignored by the plugin
14+
type = "go";
15+
name = "Attach remote";
16+
mode = "remote";
17+
request = "attach";
18+
}
19+
];
20+
delve = {
21+
path = "dlv";
22+
initialize_timeout_sec = 20;
23+
port = "$\{port}";
24+
args = [ ];
25+
build_flags = "-tags=unit";
26+
};
27+
};
28+
};
29+
};
30+
}

tests/test-sources/plugins/by-name/dap/dap-go.nix

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)