mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugin/nvim-lightbulb: update and switch to mkNeovimPlugin
This commit is contained in:
parent
6d7e429537
commit
2594863af7
2 changed files with 295 additions and 62 deletions
|
@ -5,85 +5,221 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options.plugins.nvim-lightbulb = {
|
||||
enable = mkEnableOption "nvim-lightbulb, showing available code actions";
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "nvim-lightbulb";
|
||||
defaultPackage = pkgs.vimPlugins.nvim-lightbulb;
|
||||
|
||||
package = helpers.mkPackageOption "nvim-lightbulb" pkgs.vimPlugins.nvim-lightbulb;
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
|
||||
ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
LSP client names to ignore
|
||||
'';
|
||||
# TODO introduced 2024-02-15. Remove on 2024-03-15
|
||||
imports =
|
||||
map
|
||||
(
|
||||
optionName:
|
||||
mkRemovedOptionModule
|
||||
["plugins" "nvim-lightbulb" optionName]
|
||||
"Please use `plugins.nvim-lightbulb.settings` instead."
|
||||
)
|
||||
[
|
||||
"ignore"
|
||||
"sign"
|
||||
"float"
|
||||
"virtualText"
|
||||
"statusText"
|
||||
"autocmd"
|
||||
];
|
||||
|
||||
sign = {
|
||||
enabled = helpers.defaultNullOpts.mkBool true "";
|
||||
priority = helpers.defaultNullOpts.mkInt 10 "";
|
||||
};
|
||||
|
||||
float = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float";
|
||||
|
||||
winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ''
|
||||
Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information)
|
||||
settingsOptions = {
|
||||
priority = helpers.defaultNullOpts.mkUnsignedInt 10 ''
|
||||
Priority of the lightbulb for all handlers except float.
|
||||
'';
|
||||
};
|
||||
|
||||
virtualText = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show at virtual text";
|
||||
|
||||
hlMode = helpers.defaultNullOpts.mkStr "replace" ''
|
||||
highlight mode to use for virtual text (replace, combine, blend), see
|
||||
:help nvim_buf_set_extmark() for reference
|
||||
hide_in_unfocused_buffer = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to hide the lightbulb when the buffer is not focused.
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
};
|
||||
|
||||
statusText = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
||||
link_highlights = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to link the highlight groups automatically.
|
||||
Default highlight group links:
|
||||
- `LightBulbSign` -> `DiagnosticSignInfo`
|
||||
- `LightBulbFloatWin` -> `DiagnosticFloatingInfo`
|
||||
- `LightBulbVirtualText` -> `DiagnosticVirtualTextInfo`
|
||||
- `LightBulbNumber` -> `DiagnosticSignInfo`
|
||||
- `LightBulbLine` -> `CursorLine`
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available";
|
||||
|
||||
textUnavailable = helpers.defaultNullOpts.mkStr "" ''
|
||||
Text to provide when no actions are available
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
};
|
||||
|
||||
autocmd = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
||||
validate_config = helpers.defaultNullOpts.mkEnumFirstDefault ["auto" "always" "never"] ''
|
||||
Perform full validation of configuration.
|
||||
|
||||
pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' "";
|
||||
- "auto" only performs full validation in `NvimLightbulb.setup`.
|
||||
- "always" performs full validation in `NvimLightbulb.update_lightbulb` as well.
|
||||
- "never" disables config validation.
|
||||
'';
|
||||
|
||||
events =
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
''["CursorHold" "CursorHoldI"]'' "";
|
||||
};
|
||||
};
|
||||
action_kinds = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
Code action kinds to observe.
|
||||
To match all code actions, set to `null`.
|
||||
Otherwise, set to a list of kinds.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
[
|
||||
"quickfix"
|
||||
"refactor.rewrite"
|
||||
]
|
||||
```
|
||||
See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
|
||||
'';
|
||||
|
||||
sign = {
|
||||
enabled = helpers.defaultNullOpts.mkBool true "Sign column.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" ''
|
||||
Text to show in the sign column.
|
||||
Must be between 1-2 characters.
|
||||
'';
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbSign" ''
|
||||
Highlight group to highlight the sign column text.
|
||||
'';
|
||||
};
|
||||
|
||||
virtual_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Virtual text.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the virt_text.";
|
||||
|
||||
pos = helpers.defaultNullOpts.mkStr "eol" ''
|
||||
Position of virtual text given to |nvim_buf_set_extmark|.
|
||||
Can be a number representing a fixed column (see `virt_text_pos`).
|
||||
Can be a string representing a position (see `virt_text_win_col`).
|
||||
'';
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbVirtualText" ''
|
||||
Highlight group to highlight the virtual text.
|
||||
'';
|
||||
|
||||
hl_mode = helpers.defaultNullOpts.mkStr "combine" ''
|
||||
How to combine other highlights with text highlight.
|
||||
See `hl_mode` of |nvim_buf_set_extmark|.
|
||||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.nvim-lightbulb;
|
||||
setupOptions = {
|
||||
inherit (cfg) ignore sign autocmd;
|
||||
float = {
|
||||
inherit (cfg.float) enabled text;
|
||||
win_opts = cfg.float.winOpts;
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Floating window.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the floating window.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbFloatWin" ''
|
||||
Highlight group to highlight the floating window.
|
||||
'';
|
||||
|
||||
win_opts = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
|
||||
Window options.
|
||||
See |vim.lsp.util.open_floating_preview| and |nvim_open_win|.
|
||||
Note that some options may be overridden by |open_floating_preview|.
|
||||
'';
|
||||
};
|
||||
|
||||
status_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Status text.
|
||||
When enabled, will allow using |NvimLightbulb.get_status_text| to retrieve the configured text.
|
||||
'';
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to set if a lightbulb is available.";
|
||||
|
||||
text_unavailable = helpers.defaultNullOpts.mkStr "" ''
|
||||
Text to set if a lightbulb is unavailable.
|
||||
'';
|
||||
};
|
||||
|
||||
number = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Number column.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbNumber" ''
|
||||
Highlight group to highlight the number column if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
line = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Content line.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbLine" ''
|
||||
Highlight group to highlight the line if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
autocmd = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Autocmd configuration.
|
||||
If enabled, automatically defines an autocmd to show the lightbulb.
|
||||
If disabled, you will have to manually call |NvimLightbulb.update_lightbulb|.
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
|
||||
updatetime = helpers.defaultNullOpts.mkInt 200 ''
|
||||
See |updatetime|.
|
||||
Set to a negative value to avoid setting the updatetime.
|
||||
'';
|
||||
|
||||
pattern = helpers.defaultNullOpts.mkListOf types.str ''["*"]'' ''
|
||||
See |nvim_create_autocmd| and |autocmd-pattern|.
|
||||
'';
|
||||
|
||||
events = helpers.defaultNullOpts.mkListOf types.str ''["CursorHold" "CursorHoldI"]'' ''
|
||||
See |nvim_create_autocmd|.
|
||||
'';
|
||||
};
|
||||
|
||||
ignore = {
|
||||
clients = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
LSP client names to ignore.
|
||||
Example: {"null-ls", "lua_ls"}
|
||||
'';
|
||||
|
||||
ft = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
Filetypes to ignore.
|
||||
Example: {"neo-tree", "lua"}
|
||||
'';
|
||||
|
||||
actions_without_kind = helpers.defaultNullOpts.mkBool false ''
|
||||
Ignore code actions without a `kind` like `refactor.rewrite`, quickfix.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
sign = {
|
||||
enabled = false;
|
||||
text = "";
|
||||
};
|
||||
virtual_text = {
|
||||
inherit (cfg.virtualText) enabled text;
|
||||
hl_mode = cfg.virtualText.hlMode;
|
||||
enabled = true;
|
||||
text = "";
|
||||
};
|
||||
float = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
win_opts.border = "rounded";
|
||||
};
|
||||
status_text = {
|
||||
inherit (cfg.statusText) enabled text;
|
||||
text_unavailable = cfg.statusText.textUnavailable;
|
||||
enabled = false;
|
||||
text = " ";
|
||||
};
|
||||
number = {
|
||||
enabled = false;
|
||||
};
|
||||
line = {
|
||||
enabled = false;
|
||||
};
|
||||
autocmd = {
|
||||
enabled = true;
|
||||
updatetime = 200;
|
||||
};
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraConfigLua = ''
|
||||
require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
97
tests/test-sources/plugins/lsp/nvim-lightbulb.nix
Normal file
97
tests/test-sources/plugins/lsp/nvim-lightbulb.nix
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.nvim-lightbulb.enable = true;
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.nvim-lightbulb = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
priority = 10;
|
||||
hide_in_unfocused_buffer = true;
|
||||
link_highlights = true;
|
||||
validate_config = "auto";
|
||||
action_kinds = null;
|
||||
sign = {
|
||||
enabled = true;
|
||||
text = "💡";
|
||||
hl = "LightBulbSign";
|
||||
};
|
||||
virtual_text = {
|
||||
enabled = false;
|
||||
text = "💡";
|
||||
pos = "eol";
|
||||
hl = "LightBulbVirtualText";
|
||||
hl_mode = "combine";
|
||||
};
|
||||
float = {
|
||||
enabled = false;
|
||||
text = "💡";
|
||||
hl = "LightBulbFloatWin";
|
||||
win_opts = {};
|
||||
};
|
||||
status_text = {
|
||||
enabled = false;
|
||||
text = "💡";
|
||||
text_unavailable = "";
|
||||
};
|
||||
number = {
|
||||
enabled = false;
|
||||
hl = "LightBulbNumber";
|
||||
};
|
||||
line = {
|
||||
enabled = false;
|
||||
hl = "LightBulbLine";
|
||||
};
|
||||
autocmd = {
|
||||
enabled = false;
|
||||
updatetime = 200;
|
||||
pattern = ["*"];
|
||||
events = ["CursorHold" "CursorHoldI"];
|
||||
};
|
||||
ignore = {
|
||||
clients = [];
|
||||
ft = [];
|
||||
actions_without_kind = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.nvim-lightbulb = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
sign = {
|
||||
enabled = false;
|
||||
text = "";
|
||||
};
|
||||
virtual_text = {
|
||||
enabled = true;
|
||||
text = "";
|
||||
};
|
||||
float = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
win_opts.border = "rounded";
|
||||
};
|
||||
status_text = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
};
|
||||
number = {
|
||||
enabled = false;
|
||||
};
|
||||
line = {
|
||||
enabled = false;
|
||||
};
|
||||
autocmd = {
|
||||
enabled = true;
|
||||
updatetime = 200;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue