Skip to content

Commit 32aa73a

Browse files
committed
plugins/dap-virtual-text: migrate to mkNeovimPlugin
1 parent 9eae5db commit 32aa73a

File tree

6 files changed

+142
-137
lines changed

6 files changed

+142
-137
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
lib,
3+
...
4+
}:
5+
let
6+
inherit (lib.nixvim) defaultNullOpts;
7+
in
8+
lib.nixvim.plugins.mkNeovimPlugin {
9+
name = "dap-virtual-text";
10+
moduleName = "nvim-dap-virtual-text";
11+
packPathName = "nvim-dap-virtual-text";
12+
package = "nvim-dap-virtual-text";
13+
14+
maintainers = [ lib.maintainers.khaneliman ];
15+
16+
settingsOptions = {
17+
enabled_commands = defaultNullOpts.mkBool true ''
18+
Create commands `DapVirtualTextEnable`, `DapVirtualTextDisable`, `DapVirtualTextToggle`.
19+
20+
(`DapVirtualTextForceRefresh` for refreshing when debug adapter did not notify its termination).
21+
'';
22+
23+
highlight_changed_variables = defaultNullOpts.mkBool true ''
24+
Highlight changed values with `NvimDapVirtualTextChanged`, else always `NvimDapVirtualText`.
25+
'';
26+
27+
highlight_new_as_changed = defaultNullOpts.mkBool false ''
28+
Highlight new variables in the same way as changed variables (if highlight_changed_variables).
29+
'';
30+
31+
show_stop_reason = defaultNullOpts.mkBool true "Show stop reason when stopped for exceptions.";
32+
33+
commented = defaultNullOpts.mkBool false "Prefix virtual text with comment string.";
34+
35+
only_first_definition = defaultNullOpts.mkBool true "Only show virtual text at first definition (if there are multiple).";
36+
37+
all_references = defaultNullOpts.mkBool false "Show virtual text on all references of the variable (not only definitions).";
38+
39+
clear_on_continue = defaultNullOpts.mkBool false "Clear virtual text on `continue` (might cause flickering when stepping).";
40+
41+
display_callback = defaultNullOpts.mkLuaFn ''
42+
function(variable, buf, stackframe, node, options)
43+
if options.virt_text_pos == 'inline' then
44+
return ' = ' .. variable.value
45+
else
46+
return variable.name .. ' = ' .. variable.value
47+
end
48+
end,
49+
'' "A callback that determines how a variable is displayed or whether it should be omitted.";
50+
51+
virt_text_pos = defaultNullOpts.mkStr "vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol'" ''
52+
Position of virtual text, see `:h nvim_buf_set_extmark()`.
53+
Default tries to inline the virtual text. Use 'eol' to set to end of line.
54+
'';
55+
56+
all_frames = defaultNullOpts.mkBool false "Show virtual text for all stack frames not only current.";
57+
58+
virt_lines = defaultNullOpts.mkBool false "Show virtual lines instead of virtual text (will flicker!).";
59+
60+
virt_text_win_col = lib.nixvim.mkNullOrOption lib.types.int ''
61+
Position the virtual text at a fixed window column (starting from the first text column).
62+
See `:h nvim_buf_set_extmark()`.
63+
'';
64+
};
65+
66+
# NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26)
67+
imports = [ ./deprecations.nix ];
68+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{ lib, ... }:
2+
let
3+
oldPluginBasePath = [
4+
"plugins"
5+
"dap"
6+
"extensions"
7+
"dap-virtual-text"
8+
];
9+
newPluginBasePath = [
10+
"plugins"
11+
"dap-virtual-text"
12+
];
13+
14+
settingsPath = newPluginBasePath ++ [ "settings" ];
15+
16+
renamedOptions = [
17+
[ "enabledCommands" ]
18+
[ "highlightChangedVariables" ]
19+
[ "highlightNewAsChanged" ]
20+
[ "showStopReason" ]
21+
[ "commented" ]
22+
[ "onlyFirstDefinition" ]
23+
[ "allReferences" ]
24+
[ "clearOnContinue" ]
25+
[ "displayCallback" ]
26+
[ "virtTextPos" ]
27+
[ "allFrames" ]
28+
[ "virtLines" ]
29+
[ "virtTextWinCol" ]
30+
];
31+
32+
renameWarnings =
33+
lib.nixvim.mkSettingsRenamedOptionModules oldPluginBasePath settingsPath
34+
renamedOptions;
35+
in
36+
{
37+
imports = renameWarnings ++ [
38+
(lib.mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
39+
];
40+
}

plugins/by-name/dap/dap-virtual-text.nix

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

plugins/by-name/dap/default.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ let
1212
inherit (dapHelpers) mkSignOption;
1313
in
1414
lib.nixvim.plugins.mkNeovimPlugin {
15-
imports = [
16-
./dap-virtual-text.nix
17-
];
18-
1915
name = "dap";
2016
package = "nvim-dap";
2117
packPathName = "nvim-dap";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
empty = {
3+
plugins.dap-virtual-text.enable = true;
4+
};
5+
6+
default = {
7+
plugins.dap-virtual-text = {
8+
enable = true;
9+
10+
settings = {
11+
enabled_commands = true;
12+
highlight_changed_variables = true;
13+
highlight_new_as_changed = true;
14+
show_stop_reason = true;
15+
commented = false;
16+
only_first_definition = true;
17+
all_references = false;
18+
clear_on_continue = false;
19+
display_callback = ''
20+
function(variable, buf, stackframe, node, options)
21+
if options.virt_text_pos == 'inline' then
22+
return ' = ' .. variable.value
23+
else
24+
return variable.name .. ' = ' .. variable.value
25+
end
26+
end
27+
'';
28+
virt_text_pos = "eol";
29+
all_frames = false;
30+
virt_lines = false;
31+
};
32+
};
33+
};
34+
}

tests/test-sources/plugins/by-name/dap/dap-virtual-text.nix

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

0 commit comments

Comments
 (0)