Skip to content

Commit 9eae5db

Browse files
committed
plugins/dap-ui: migrate to mkNeovimPlugin
1 parent a70168e commit 9eae5db

File tree

5 files changed

+254
-173
lines changed

5 files changed

+254
-173
lines changed

plugins/by-name/dap/dap-ui.nix renamed to plugins/by-name/dap-ui/default.nix

Lines changed: 29 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
22
lib,
3-
config,
4-
pkgs,
53
...
64
}:
75
let
86
inherit (lib) mkOption types;
97
inherit (lib.nixvim) defaultNullOpts;
108

11-
cfg = config.plugins.dap.extensions.dap-ui;
12-
139
mkSizeOption = lib.nixvim.mkNullOrOption (with types; either int (numbers.between 0.0 1.0));
1410

1511
mkKeymapOptions =
@@ -54,17 +50,15 @@ let
5450
};
5551
};
5652
in
57-
{
58-
options.plugins.dap.extensions.dap-ui = lib.nixvim.plugins.neovim.extraOptionsOptions // {
59-
enable = lib.mkEnableOption "dap-ui";
60-
61-
package = lib.mkPackageOption pkgs "dap-ui" {
62-
default = [
63-
"vimPlugins"
64-
"nvim-dap-ui"
65-
];
66-
};
53+
lib.nixvim.plugins.mkNeovimPlugin {
54+
name = "dap-ui";
55+
moduleName = "dapui";
56+
packPathName = "nvim-dap-ui";
57+
package = "nvim-dap-ui";
6758

59+
maintainers = [ lib.maintainers.khaneliman ];
60+
61+
settingsOptions = {
6862
controls = {
6963
enabled = defaultNullOpts.mkBool true "Enable controls";
7064

@@ -77,20 +71,20 @@ in
7771
"console"
7872
] "Element to show the controls on.";
7973

80-
icons = {
81-
disconnect = defaultNullOpts.mkStr "" "";
82-
pause = defaultNullOpts.mkStr "" "";
83-
play = defaultNullOpts.mkStr "" "";
84-
run_last = defaultNullOpts.mkStr "" "";
85-
step_into = defaultNullOpts.mkStr "" "";
86-
step_over = defaultNullOpts.mkStr "" "";
87-
step_out = defaultNullOpts.mkStr "" "";
88-
step_back = defaultNullOpts.mkStr "" "";
89-
terminate = defaultNullOpts.mkStr "" "";
74+
icons = lib.mapAttrs (name: icon: defaultNullOpts.mkStr icon "The icon for ${name}.") {
75+
disconnect = "";
76+
pause = "";
77+
play = "";
78+
run_last = "";
79+
step_into = "";
80+
step_over = "";
81+
step_out = "";
82+
step_back = "";
83+
terminate = "";
9084
};
9185
};
9286

93-
elementMappings = lib.nixvim.mkNullOrOption (types.attrsOf (
87+
element_mappings = lib.nixvim.mkNullOrOption (types.attrsOf (
9488
types.submodule {
9589
options = mkKeymapOptions "element mapping overrides" {
9690
edit = "e";
@@ -106,12 +100,12 @@ in
106100
}
107101
)) "Per-element overrides of global mappings.";
108102

109-
expandLines = defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size.";
103+
expand_lines = defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size.";
110104

111105
floating = {
112-
maxHeight = mkSizeOption "Maximum height of the floating window.";
106+
max_height = mkSizeOption "Maximum height of the floating window.";
113107

114-
maxWidth = mkSizeOption "Maximum width of the floating window.";
108+
max_width = mkSizeOption "Maximum width of the floating window.";
115109

116110
border = defaultNullOpts.mkBorder "single" "dap-ui floating window" "";
117111

@@ -125,7 +119,7 @@ in
125119
}) "Keys to trigger actions in elements.";
126120
};
127121

128-
forceBuffers = defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows.";
122+
force_buffers = defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows.";
129123

130124
icons = {
131125
collapsed = defaultNullOpts.mkStr "" "";
@@ -189,57 +183,17 @@ in
189183
render = {
190184
indent = defaultNullOpts.mkInt 1 "Default indentation size.";
191185

192-
maxTypeLength = lib.nixvim.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming.";
186+
max_type_length = lib.nixvim.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming.";
193187

194-
maxValueLines = defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming.";
188+
max_value_lines = defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming.";
195189
};
196190

197-
selectWindow = defaultNullOpts.mkLuaFn null ''
191+
select_window = defaultNullOpts.mkLuaFn null ''
198192
A function which returns a window to be used for opening buffers such as a stack frame location.
199193
'';
200194
};
201195

202-
config =
203-
let
204-
options =
205-
with cfg;
206-
{
207-
inherit
208-
controls
209-
icons
210-
layouts
211-
mappings
212-
;
213-
214-
element_mappings = elementMappings;
215-
216-
floating = with floating; {
217-
inherit border mappings;
218-
max_height = maxHeight;
219-
max_width = maxWidth;
220-
};
221-
222-
force_buffers = forceBuffers;
223-
224-
render = with render; {
225-
inherit indent;
226-
max_type_length = maxTypeLength;
227-
max_value_lines = maxValueLines;
228-
};
229-
230-
select_window = selectWindow;
231-
}
232-
// cfg.extraOptions;
233-
in
234-
lib.mkIf cfg.enable {
235-
extraPlugins = [ cfg.package ];
236-
237-
plugins.dap = {
238-
enable = true;
239-
240-
extensionConfigLua = ''
241-
require("dapui").setup(${lib.nixvim.toLuaObject options});
242-
'';
243-
};
244-
};
196+
# NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26)
197+
deprecateExtraOptions = true;
198+
imports = [ ./deprecations.nix ];
245199
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{ lib, ... }:
2+
let
3+
oldPluginBasePath = [
4+
"plugins"
5+
"dap"
6+
"extensions"
7+
"dap-ui"
8+
];
9+
newPluginBasePath = [
10+
"plugins"
11+
"dap-ui"
12+
];
13+
14+
settingsPath = newPluginBasePath ++ [ "settings" ];
15+
16+
renamedOptions = [
17+
[
18+
"controls"
19+
"enabled"
20+
]
21+
[
22+
"controls"
23+
"element"
24+
]
25+
[
26+
"controls"
27+
"icons"
28+
"disconnect"
29+
]
30+
[
31+
"controls"
32+
"icons"
33+
"pause"
34+
]
35+
[
36+
"controls"
37+
"icons"
38+
"play"
39+
]
40+
[
41+
"controls"
42+
"icons"
43+
"run_last"
44+
]
45+
[
46+
"controls"
47+
"icons"
48+
"step_into"
49+
]
50+
[
51+
"controls"
52+
"icons"
53+
"step_over"
54+
]
55+
[
56+
"controls"
57+
"icons"
58+
"step_out"
59+
]
60+
[
61+
"controls"
62+
"icons"
63+
"step_back"
64+
]
65+
[
66+
"controls"
67+
"icons"
68+
"terminate"
69+
]
70+
[ "elementMappings" ]
71+
[ "expandLines" ]
72+
[
73+
"floating"
74+
"maxHeight"
75+
]
76+
[
77+
"floating"
78+
"maxWidth"
79+
]
80+
[
81+
"floating"
82+
"border"
83+
]
84+
[
85+
"floating"
86+
"mappings"
87+
]
88+
[ "forceBuffers" ]
89+
[
90+
"icons"
91+
"collapsed"
92+
]
93+
[
94+
"icons"
95+
"current_frame"
96+
]
97+
[
98+
"icons"
99+
"expanded"
100+
]
101+
[ "layouts" ]
102+
[ "mappings" ]
103+
[
104+
"render"
105+
"indent"
106+
]
107+
[
108+
"render"
109+
"maxTypeLength"
110+
]
111+
[
112+
"render"
113+
"maxValueLines"
114+
]
115+
[ "selectWindow" ]
116+
];
117+
118+
renameWarnings =
119+
lib.nixvim.mkSettingsRenamedOptionModules oldPluginBasePath settingsPath
120+
renamedOptions;
121+
in
122+
{
123+
imports = renameWarnings ++ [
124+
(lib.mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
125+
];
126+
}

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-ui.nix
1716
./dap-virtual-text.nix
1817
];
1918

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
empty = {
3+
plugins.dap-ui.enable = true;
4+
};
5+
6+
default = {
7+
plugins.dap-ui = {
8+
enable = true;
9+
10+
settings = {
11+
controls = {
12+
element = "repl";
13+
enabled = true;
14+
icons = {
15+
disconnect = "";
16+
pause = "";
17+
play = "";
18+
run_last = "";
19+
step_back = "";
20+
step_into = "";
21+
step_out = "";
22+
step_over = "";
23+
terminate = "";
24+
};
25+
};
26+
element_mappings = { };
27+
expand_lines = true;
28+
floating = {
29+
border = "single";
30+
mappings = {
31+
close = [
32+
"q"
33+
"<Esc>"
34+
];
35+
};
36+
};
37+
force_buffers = true;
38+
icons = {
39+
collapsed = "";
40+
current_frame = "";
41+
expanded = "";
42+
};
43+
layouts = [
44+
{
45+
elements = [
46+
{
47+
id = "scopes";
48+
size = 0.25;
49+
}
50+
{
51+
id = "breakpoints";
52+
size = 0.25;
53+
}
54+
{
55+
id = "stacks";
56+
size = 0.25;
57+
}
58+
{
59+
id = "watches";
60+
size = 0.25;
61+
}
62+
];
63+
position = "left";
64+
size = 40;
65+
}
66+
{
67+
elements = [
68+
{
69+
id = "repl";
70+
size = 0.5;
71+
}
72+
{
73+
id = "console";
74+
size = 0.5;
75+
}
76+
];
77+
position = "bottom";
78+
size = 10;
79+
}
80+
];
81+
mappings = {
82+
edit = "e";
83+
expand = [
84+
"<CR>"
85+
"<2-LeftMouse>"
86+
];
87+
open = "o";
88+
remove = "d";
89+
repl = "r";
90+
toggle = "t";
91+
};
92+
render = {
93+
indent = 1;
94+
max_value_lines = 100;
95+
};
96+
};
97+
};
98+
};
99+
}

0 commit comments

Comments
 (0)