mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
lsp/lightbulb: cleanup; modularize autocommand behaviour
Some checks failed
Check for typos in the source tree / check-typos (push) Has been cancelled
Some checks failed
Check for typos in the source tree / check-typos (push) Has been cancelled
This commit is contained in:
parent
547cbd28b6
commit
9a93409606
3 changed files with 54 additions and 11 deletions
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
|
@ -12,13 +13,29 @@ in {
|
|||
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lightbulb"];
|
||||
|
||||
pluginRC.lightbulb = entryAnywhere ''
|
||||
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
|
||||
|
||||
-- Enable trouble diagnostics viewer
|
||||
require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
||||
local nvim_lightbulb = require("nvim-lightbulb")
|
||||
nvim_lightbulb.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
||||
${optionalString cfg.lightbulb.autocmd.enable ''
|
||||
vim.api.nvim_create_autocmd(${toLuaObject cfg.lightbulb.autocmd.events}, {
|
||||
pattern = ${toLuaObject cfg.lightbulb.autocmd.pattern},
|
||||
callback = function()
|
||||
nvim_lightbulb.update_lightbulb()
|
||||
end,
|
||||
})
|
||||
''}
|
||||
'';
|
||||
};
|
||||
|
||||
warnings = [
|
||||
# This could have been an assertion, but the chances of collision is very low and asserting here
|
||||
# might be too dramatic. Let's only warn the user, *in case* this occurs and is not intended. No
|
||||
# error will be thrown if 'lightbulb.setupOpts.autocmd.enable' has not been set by the user.
|
||||
(mkIf (cfg.lightbulb.autocmd.enable -> (cfg.lightbulb.setupOpts.autocmd.enabled or false)) ''
|
||||
Both 'vim.lsp.lightbulb.autocmd.enable' and 'vim.lsp.lightbulb.setupOpts.autocmd.enable' are set
|
||||
simultaneously. This might have performance implications due to frequent updates. Please set only
|
||||
one option to handle nvim-lightbulb autocmd.
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) listOf str either;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lightbulb = {
|
||||
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
||||
setupOpts = mkPluginSetupOption "nvim-lightbulb" {};
|
||||
autocmd = {
|
||||
enable = mkEnableOption "updating lightbulb glyph automatically" // {default = true;};
|
||||
events = mkOption {
|
||||
type = listOf str;
|
||||
default = ["CursorHold" "CursorHoldI"];
|
||||
description = "Events on which to update nvim-lightbulb glyphs";
|
||||
};
|
||||
|
||||
pattern = mkOption {
|
||||
type = either str luaInline;
|
||||
default = "*";
|
||||
description = ''
|
||||
File patterns or buffer names to match, determining which files or buffers trigger
|
||||
glyph updates.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue