mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-01-31 06:12:26 +00:00
lsp/lightbulb: cleanup; modularize autocommand behaviour
This commit is contained in:
parent
db8a586b7e
commit
c97f9dab2c
3 changed files with 36 additions and 7 deletions
|
@ -31,6 +31,9 @@
|
||||||
your Editorconfig configuration, or use an autocommand to set indentation
|
your Editorconfig configuration, or use an autocommand to set indentation
|
||||||
values for buffers with the Nix filetype.
|
values for buffers with the Nix filetype.
|
||||||
|
|
||||||
|
- Add [](#opt-vim.lsp.lightbulb.autocmd.enable) for manually managing the
|
||||||
|
previously managed lightbulb autocommand.
|
||||||
|
|
||||||
[amadaluzia](https://github.com/amadaluzia):
|
[amadaluzia](https://github.com/amadaluzia):
|
||||||
|
|
||||||
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
|
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
|
||||||
|
@ -59,7 +62,8 @@
|
||||||
- Add `vim.snippets.luasnip.setupOpts`, which was previously missing.
|
- Add `vim.snippets.luasnip.setupOpts`, which was previously missing.
|
||||||
- Add `"prettierd"` as a formatter option in
|
- Add `"prettierd"` as a formatter option in
|
||||||
`vim.languages.markdown.format.type`.
|
`vim.languages.markdown.format.type`.
|
||||||
- Add the following plugins from [mini.nvim](https://github.com/echasnovski/mini.nvim)
|
- Add the following plugins from
|
||||||
|
[mini.nvim](https://github.com/echasnovski/mini.nvim)
|
||||||
- `mini.ai`
|
- `mini.ai`
|
||||||
- `mini.align`
|
- `mini.align`
|
||||||
- `mini.animate`
|
- `mini.animate`
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
|
@ -12,13 +13,28 @@ in {
|
||||||
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["nvim-lightbulb"];
|
startPlugins = ["nvim-lightbulb"];
|
||||||
|
|
||||||
pluginRC.lightbulb = entryAnywhere ''
|
pluginRC.lightbulb = entryAnywhere ''
|
||||||
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
|
local nvim-lightbulb = require('nvim-lightbulb')
|
||||||
|
nvim-lightbulb.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
||||||
-- Enable trouble diagnostics viewer
|
${optionalString cfg.lightbulb.autocmd.enable ''
|
||||||
require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
vim.api.nvim_create_autocmd(${toLuaObject cfg.lightbulb.autocmd.events}, {
|
||||||
|
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.
|
||||||
|
(optionalString (cfg.lightbulb.setupOpts.autocmd.enable && cfg.lightbulb.autocmd.enable) ''
|
||||||
|
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,20 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) listOf str;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.lsp = {
|
options.vim.lsp = {
|
||||||
lightbulb = {
|
lightbulb = {
|
||||||
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
||||||
setupOpts = mkPluginSetupOption "nvim-lightbulb" {};
|
setupOpts = mkPluginSetupOption "nvim-lightbulb" {};
|
||||||
|
autocmd = {
|
||||||
|
enable = mkEnableOption "updating lightbulb glyph automatically";
|
||||||
|
events = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = ["CursorHold" "CursorHoldI"];
|
||||||
|
description = "Events on which to update nvim-lightbulb glyphs";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue