mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +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,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; {
|
with lib;
|
||||||
options.plugins.nvim-lightbulb = {
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
enable = mkEnableOption "nvim-lightbulb, showing available code actions";
|
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) "[]" ''
|
# TODO introduced 2024-02-15. Remove on 2024-03-15
|
||||||
LSP client names to ignore
|
imports =
|
||||||
|
map
|
||||||
|
(
|
||||||
|
optionName:
|
||||||
|
mkRemovedOptionModule
|
||||||
|
["plugins" "nvim-lightbulb" optionName]
|
||||||
|
"Please use `plugins.nvim-lightbulb.settings` instead."
|
||||||
|
)
|
||||||
|
[
|
||||||
|
"ignore"
|
||||||
|
"sign"
|
||||||
|
"float"
|
||||||
|
"virtualText"
|
||||||
|
"statusText"
|
||||||
|
"autocmd"
|
||||||
|
];
|
||||||
|
|
||||||
|
settingsOptions = {
|
||||||
|
priority = helpers.defaultNullOpts.mkUnsignedInt 10 ''
|
||||||
|
Priority of the lightbulb for all handlers except float.
|
||||||
|
'';
|
||||||
|
|
||||||
|
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`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
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`
|
||||||
|
|
||||||
|
Only works if configured during `NvimLightbulb.setup`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
validate_config = helpers.defaultNullOpts.mkEnumFirstDefault ["auto" "always" "never"] ''
|
||||||
|
Perform full validation of configuration.
|
||||||
|
|
||||||
|
- "auto" only performs full validation in `NvimLightbulb.setup`.
|
||||||
|
- "always" performs full validation in `NvimLightbulb.update_lightbulb` as well.
|
||||||
|
- "never" disables config validation.
|
||||||
|
'';
|
||||||
|
|
||||||
|
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 = {
|
sign = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool true "";
|
enabled = helpers.defaultNullOpts.mkBool true "Sign column.";
|
||||||
priority = helpers.defaultNullOpts.mkInt 10 "";
|
|
||||||
|
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|.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
float = {
|
float = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
enabled = helpers.defaultNullOpts.mkBool false "Floating window.";
|
||||||
|
|
||||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float";
|
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the floating window.";
|
||||||
|
|
||||||
winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ''
|
hl = helpers.defaultNullOpts.mkStr "LightBulbFloatWin" ''
|
||||||
Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information)
|
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|.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualText = {
|
status_text = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
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 show at virtual text";
|
text = helpers.defaultNullOpts.mkStr "💡" "Text to set if a lightbulb is available.";
|
||||||
|
|
||||||
hlMode = helpers.defaultNullOpts.mkStr "replace" ''
|
text_unavailable = helpers.defaultNullOpts.mkStr "" ''
|
||||||
highlight mode to use for virtual text (replace, combine, blend), see
|
Text to set if a lightbulb is unavailable.
|
||||||
:help nvim_buf_set_extmark() for reference
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
statusText = {
|
number = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
enabled = helpers.defaultNullOpts.mkBool false "Number column.";
|
||||||
|
|
||||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available";
|
hl = helpers.defaultNullOpts.mkStr "LightBulbNumber" ''
|
||||||
|
Highlight group to highlight the number column if there is a lightbulb.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
textUnavailable = helpers.defaultNullOpts.mkStr "" ''
|
line = {
|
||||||
Text to provide when no actions are available
|
enabled = helpers.defaultNullOpts.mkBool false "Content line.";
|
||||||
|
|
||||||
|
hl = helpers.defaultNullOpts.mkStr "LightBulbLine" ''
|
||||||
|
Highlight group to highlight the line if there is a lightbulb.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
autocmd = {
|
autocmd = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool false "";
|
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`.
|
||||||
|
'';
|
||||||
|
|
||||||
pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' "";
|
updatetime = helpers.defaultNullOpts.mkInt 200 ''
|
||||||
|
See |updatetime|.
|
||||||
|
Set to a negative value to avoid setting the updatetime.
|
||||||
|
'';
|
||||||
|
|
||||||
events =
|
pattern = helpers.defaultNullOpts.mkListOf types.str ''["*"]'' ''
|
||||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
See |nvim_create_autocmd| and |autocmd-pattern|.
|
||||||
''["CursorHold" "CursorHoldI"]'' "";
|
'';
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = let
|
events = helpers.defaultNullOpts.mkListOf types.str ''["CursorHold" "CursorHoldI"]'' ''
|
||||||
cfg = config.plugins.nvim-lightbulb;
|
See |nvim_create_autocmd|.
|
||||||
setupOptions = {
|
|
||||||
inherit (cfg) ignore sign autocmd;
|
|
||||||
float = {
|
|
||||||
inherit (cfg.float) enabled text;
|
|
||||||
win_opts = cfg.float.winOpts;
|
|
||||||
};
|
|
||||||
virtual_text = {
|
|
||||||
inherit (cfg.virtualText) enabled text;
|
|
||||||
hl_mode = cfg.virtualText.hlMode;
|
|
||||||
};
|
|
||||||
status_text = {
|
|
||||||
inherit (cfg.statusText) enabled text;
|
|
||||||
text_unavailable = cfg.statusText.textUnavailable;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
mkIf cfg.enable {
|
|
||||||
extraPlugins = [cfg.package];
|
|
||||||
extraConfigLua = ''
|
|
||||||
require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions})
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
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