2023-02-01 19:11:37 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-08 02:16:46 +00:00
|
|
|
}: let
|
2024-03-12 00:46:29 +00:00
|
|
|
inherit (lib.modules) mkIf;
|
2025-01-19 17:26:52 +00:00
|
|
|
inherit (lib.strings) optionalString;
|
2024-03-12 00:46:29 +00:00
|
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
2024-12-10 21:00:51 +00:00
|
|
|
inherit (lib.nvim.lua) toLuaObject;
|
2023-11-08 02:16:46 +00:00
|
|
|
|
2023-02-01 19:11:37 +00:00
|
|
|
cfg = config.vim.lsp;
|
|
|
|
in {
|
|
|
|
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
2024-03-12 00:46:29 +00:00
|
|
|
vim = {
|
|
|
|
startPlugins = ["nvim-lightbulb"];
|
2024-07-20 08:30:48 +00:00
|
|
|
pluginRC.lightbulb = entryAnywhere ''
|
2025-01-19 17:26:52 +00:00
|
|
|
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,
|
|
|
|
})
|
|
|
|
''}
|
2024-03-12 00:46:29 +00:00
|
|
|
'';
|
|
|
|
};
|
2025-01-19 17:26:52 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
'')
|
|
|
|
];
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
}
|