|
4 | 4 | ... |
5 | 5 | }: let |
6 | 6 | inherit (lib.modules) mkIf; |
| 7 | + inherit (lib.strings) optionalString; |
7 | 8 | inherit (lib.nvim.dag) entryAnywhere; |
8 | 9 | inherit (lib.nvim.lua) toLuaObject; |
9 | 10 |
|
|
12 | 13 | config = mkIf (cfg.enable && cfg.lightbulb.enable) { |
13 | 14 | vim = { |
14 | 15 | startPlugins = ["nvim-lightbulb"]; |
15 | | - |
16 | 16 | pluginRC.lightbulb = entryAnywhere '' |
17 | | - vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') |
18 | | -
|
19 | | - -- Enable trouble diagnostics viewer |
20 | | - require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts}) |
| 17 | + local nvim_lightbulb = require("nvim-lightbulb") |
| 18 | + nvim_lightbulb.setup(${toLuaObject cfg.lightbulb.setupOpts}) |
| 19 | + ${optionalString cfg.lightbulb.autocmd.enable '' |
| 20 | + vim.api.nvim_create_autocmd(${toLuaObject cfg.lightbulb.autocmd.events}, { |
| 21 | + pattern = ${toLuaObject cfg.lightbulb.autocmd.pattern} |
| 22 | + callback = function() |
| 23 | + nvim-lightbulb.update_lightbulb() |
| 24 | + end, |
| 25 | + }) |
| 26 | + ''} |
21 | 27 | ''; |
22 | 28 | }; |
| 29 | + |
| 30 | + warnings = [ |
| 31 | + # This could have been an assertion, but the chances of collision is very low and asserting here |
| 32 | + # might be too dramatic. Let's only warn the user, *in case* this occurs and is not intended. No |
| 33 | + # error will be thrown if 'lightbulb.setupOpts.autocmd.enable' has not been set by the user. |
| 34 | + (optionalString (cfg.lightbulb.autocmd.enable -> (cfg.lightbulb.setupOpts.autocmd.enable or false)) '' |
| 35 | + Both 'vim.lsp.lightbulb.autocmd.enable' and 'vim.lsp.lightbulb.setupOpts.autocmd.enable' are set |
| 36 | + simultaneously. This might have performance implications due to frequent updates. Please set only |
| 37 | + one option to handle nvim-lightbulb autocmd. |
| 38 | + '') |
| 39 | + ]; |
23 | 40 | }; |
24 | 41 | } |
0 commit comments