mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/dap-virtual-text: migrate to mkNeovimPlugin
This commit is contained in:
parent
9eae5db29a
commit
32aa73af47
6 changed files with 142 additions and 137 deletions
68
plugins/by-name/dap-virtual-text/default.nix
Normal file
68
plugins/by-name/dap-virtual-text/default.nix
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
|
in
|
||||||
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
name = "dap-virtual-text";
|
||||||
|
moduleName = "nvim-dap-virtual-text";
|
||||||
|
packPathName = "nvim-dap-virtual-text";
|
||||||
|
package = "nvim-dap-virtual-text";
|
||||||
|
|
||||||
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
|
|
||||||
|
settingsOptions = {
|
||||||
|
enabled_commands = defaultNullOpts.mkBool true ''
|
||||||
|
Create commands `DapVirtualTextEnable`, `DapVirtualTextDisable`, `DapVirtualTextToggle`.
|
||||||
|
|
||||||
|
(`DapVirtualTextForceRefresh` for refreshing when debug adapter did not notify its termination).
|
||||||
|
'';
|
||||||
|
|
||||||
|
highlight_changed_variables = defaultNullOpts.mkBool true ''
|
||||||
|
Highlight changed values with `NvimDapVirtualTextChanged`, else always `NvimDapVirtualText`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
highlight_new_as_changed = defaultNullOpts.mkBool false ''
|
||||||
|
Highlight new variables in the same way as changed variables (if highlight_changed_variables).
|
||||||
|
'';
|
||||||
|
|
||||||
|
show_stop_reason = defaultNullOpts.mkBool true "Show stop reason when stopped for exceptions.";
|
||||||
|
|
||||||
|
commented = defaultNullOpts.mkBool false "Prefix virtual text with comment string.";
|
||||||
|
|
||||||
|
only_first_definition = defaultNullOpts.mkBool true "Only show virtual text at first definition (if there are multiple).";
|
||||||
|
|
||||||
|
all_references = defaultNullOpts.mkBool false "Show virtual text on all references of the variable (not only definitions).";
|
||||||
|
|
||||||
|
clear_on_continue = defaultNullOpts.mkBool false "Clear virtual text on `continue` (might cause flickering when stepping).";
|
||||||
|
|
||||||
|
display_callback = defaultNullOpts.mkLuaFn ''
|
||||||
|
function(variable, buf, stackframe, node, options)
|
||||||
|
if options.virt_text_pos == 'inline' then
|
||||||
|
return ' = ' .. variable.value
|
||||||
|
else
|
||||||
|
return variable.name .. ' = ' .. variable.value
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
'' "A callback that determines how a variable is displayed or whether it should be omitted.";
|
||||||
|
|
||||||
|
virt_text_pos = defaultNullOpts.mkStr "vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol'" ''
|
||||||
|
Position of virtual text, see `:h nvim_buf_set_extmark()`.
|
||||||
|
Default tries to inline the virtual text. Use 'eol' to set to end of line.
|
||||||
|
'';
|
||||||
|
|
||||||
|
all_frames = defaultNullOpts.mkBool false "Show virtual text for all stack frames not only current.";
|
||||||
|
|
||||||
|
virt_lines = defaultNullOpts.mkBool false "Show virtual lines instead of virtual text (will flicker!).";
|
||||||
|
|
||||||
|
virt_text_win_col = lib.nixvim.mkNullOrOption lib.types.int ''
|
||||||
|
Position the virtual text at a fixed window column (starting from the first text column).
|
||||||
|
See `:h nvim_buf_set_extmark()`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26)
|
||||||
|
imports = [ ./deprecations.nix ];
|
||||||
|
}
|
40
plugins/by-name/dap-virtual-text/deprecations.nix
Normal file
40
plugins/by-name/dap-virtual-text/deprecations.nix
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
oldPluginBasePath = [
|
||||||
|
"plugins"
|
||||||
|
"dap"
|
||||||
|
"extensions"
|
||||||
|
"dap-virtual-text"
|
||||||
|
];
|
||||||
|
newPluginBasePath = [
|
||||||
|
"plugins"
|
||||||
|
"dap-virtual-text"
|
||||||
|
];
|
||||||
|
|
||||||
|
settingsPath = newPluginBasePath ++ [ "settings" ];
|
||||||
|
|
||||||
|
renamedOptions = [
|
||||||
|
[ "enabledCommands" ]
|
||||||
|
[ "highlightChangedVariables" ]
|
||||||
|
[ "highlightNewAsChanged" ]
|
||||||
|
[ "showStopReason" ]
|
||||||
|
[ "commented" ]
|
||||||
|
[ "onlyFirstDefinition" ]
|
||||||
|
[ "allReferences" ]
|
||||||
|
[ "clearOnContinue" ]
|
||||||
|
[ "displayCallback" ]
|
||||||
|
[ "virtTextPos" ]
|
||||||
|
[ "allFrames" ]
|
||||||
|
[ "virtLines" ]
|
||||||
|
[ "virtTextWinCol" ]
|
||||||
|
];
|
||||||
|
|
||||||
|
renameWarnings =
|
||||||
|
lib.nixvim.mkSettingsRenamedOptionModules oldPluginBasePath settingsPath
|
||||||
|
renamedOptions;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = renameWarnings ++ [
|
||||||
|
(lib.mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,101 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (lib.nixvim) defaultNullOpts;
|
|
||||||
|
|
||||||
cfg = config.plugins.dap.extensions.dap-virtual-text;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.plugins.dap.extensions.dap-virtual-text = {
|
|
||||||
enable = lib.mkEnableOption "dap-virtual-text";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "dap-virtual-text" {
|
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
|
||||||
"nvim-dap-virtual-text"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
enabledCommands = defaultNullOpts.mkBool true ''
|
|
||||||
Create commands `DapVirtualTextEnable`, `DapVirtualTextDisable`, `DapVirtualTextToggle`.
|
|
||||||
(`DapVirtualTextForceRefresh` for refreshing when debug adapter did not notify its termination).
|
|
||||||
'';
|
|
||||||
|
|
||||||
highlightChangedVariables = defaultNullOpts.mkBool true ''
|
|
||||||
Highlight changed values with `NvimDapVirtualTextChanged`, else always `NvimDapVirtualText`.
|
|
||||||
'';
|
|
||||||
|
|
||||||
highlightNewAsChanged = defaultNullOpts.mkBool false ''
|
|
||||||
Highlight new variables in the same way as changed variables (if highlightChangedVariables).
|
|
||||||
'';
|
|
||||||
|
|
||||||
showStopReason = defaultNullOpts.mkBool true "Show stop reason when stopped for exceptions.";
|
|
||||||
|
|
||||||
commented = defaultNullOpts.mkBool false "Prefix virtual text with comment string.";
|
|
||||||
|
|
||||||
onlyFirstDefinition = defaultNullOpts.mkBool true "Only show virtual text at first definition (if there are multiple).";
|
|
||||||
|
|
||||||
allReferences = defaultNullOpts.mkBool false "Show virtual text on all all references of the variable (not only definitions).";
|
|
||||||
|
|
||||||
clearOnContinue = defaultNullOpts.mkBool false "Clear virtual text on `continue` (might cause flickering when stepping).";
|
|
||||||
|
|
||||||
displayCallback = defaultNullOpts.mkLuaFn ''
|
|
||||||
function(variable, buf, stackframe, node, options)
|
|
||||||
if options.virt_text_pos == 'inline' then
|
|
||||||
return ' = ' .. variable.value
|
|
||||||
else
|
|
||||||
return variable.name .. ' = ' .. variable.value
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
'' "A callback that determines how a variable is displayed or whether it should be omitted.";
|
|
||||||
|
|
||||||
virtTextPos = defaultNullOpts.mkStr "vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol'" ''
|
|
||||||
Position of virtual text, see `:h nvim_buf_set_extmark()`.
|
|
||||||
Default tries to inline the virtual text. Use 'eol' to set to end of line.
|
|
||||||
'';
|
|
||||||
|
|
||||||
allFrames = defaultNullOpts.mkBool false "Show virtual text for all stack frames not only current.";
|
|
||||||
|
|
||||||
virtLines = defaultNullOpts.mkBool false "Show virtual lines instead of virtual text (will flicker!).";
|
|
||||||
|
|
||||||
virtTextWinCol = lib.nixvim.mkNullOrOption lib.types.int ''
|
|
||||||
Position the virtual text at a fixed window column (starting from the first text column).
|
|
||||||
See `:h nvim_buf_set_extmark()`.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
options = with cfg; {
|
|
||||||
inherit commented;
|
|
||||||
|
|
||||||
enabled_commands = enabledCommands;
|
|
||||||
highlight_changed_variables = highlightChangedVariables;
|
|
||||||
highlight_new_as_changed = highlightNewAsChanged;
|
|
||||||
show_stop_reason = showStopReason;
|
|
||||||
only_first_definition = onlyFirstDefinition;
|
|
||||||
all_references = allReferences;
|
|
||||||
clear_on_continue = clearOnContinue;
|
|
||||||
display_callback = displayCallback;
|
|
||||||
virt_text_pos = virtTextPos;
|
|
||||||
all_frames = allFrames;
|
|
||||||
virt_lines = virtLines;
|
|
||||||
virt_text_win_col = virtTextWinCol;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
plugins.dap = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
extensionConfigLua = ''
|
|
||||||
require("nvim-dap-virtual-text").setup(${lib.nixvim.toLuaObject options});
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -12,10 +12,6 @@ let
|
||||||
inherit (dapHelpers) mkSignOption;
|
inherit (dapHelpers) mkSignOption;
|
||||||
in
|
in
|
||||||
lib.nixvim.plugins.mkNeovimPlugin {
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
imports = [
|
|
||||||
./dap-virtual-text.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
name = "dap";
|
name = "dap";
|
||||||
package = "nvim-dap";
|
package = "nvim-dap";
|
||||||
packPathName = "nvim-dap";
|
packPathName = "nvim-dap";
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.dap-virtual-text.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
default = {
|
||||||
|
plugins.dap-virtual-text = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
enabled_commands = true;
|
||||||
|
highlight_changed_variables = true;
|
||||||
|
highlight_new_as_changed = true;
|
||||||
|
show_stop_reason = true;
|
||||||
|
commented = false;
|
||||||
|
only_first_definition = true;
|
||||||
|
all_references = false;
|
||||||
|
clear_on_continue = false;
|
||||||
|
display_callback = ''
|
||||||
|
function(variable, buf, stackframe, node, options)
|
||||||
|
if options.virt_text_pos == 'inline' then
|
||||||
|
return ' = ' .. variable.value
|
||||||
|
else
|
||||||
|
return variable.name .. ' = ' .. variable.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
virt_text_pos = "eol";
|
||||||
|
all_frames = false;
|
||||||
|
virt_lines = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
{
|
|
||||||
empty = {
|
|
||||||
plugins.dap.extensions.dap-virtual-text.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
default = {
|
|
||||||
plugins.dap.extensions.dap-virtual-text = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
enabledCommands = true;
|
|
||||||
highlightChangedVariables = true;
|
|
||||||
highlightNewAsChanged = true;
|
|
||||||
showStopReason = true;
|
|
||||||
commented = false;
|
|
||||||
onlyFirstDefinition = true;
|
|
||||||
allReferences = false;
|
|
||||||
clearOnContinue = false;
|
|
||||||
displayCallback = ''
|
|
||||||
function(variable, buf, stackframe, node, options)
|
|
||||||
if options.virt_text_pos == 'inline' then
|
|
||||||
return ' = ' .. variable.value
|
|
||||||
else
|
|
||||||
return variable.name .. ' = ' .. variable.value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
virtTextPos = "eol";
|
|
||||||
allFrames = false;
|
|
||||||
virtLines = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue