nix-community.nixvim/plugins/by-name/hydra/default.nix
Quentin Boyer d2f9e011d9 lib/neovim-plugin: Add lua configuration scoped to the plugin
This commit adds a `plugins.<name>.luaConfig` section controlling the
plugin specific configuration.

The section contains the internal `init` option, containing the plugin's
initialization code.

It also contains the public `pre` and `post` options, that allow to add
code before & after the `init` section

Finally, it contains the `final` option, being the concatenation of the
three previous options.
2024-09-22 16:15:27 +00:00

50 lines
1,008 B
Nix

{
lib,
helpers,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin {
name = "hydra";
originalName = "hydra.nvim";
package = "hydra-nvim";
maintainers = [ maintainers.GaetanLepage ];
extraOptions = {
# A list of `Hydra` definitions
hydras = import ./hydras-option.nix { inherit lib helpers; };
};
settingsOptions = import ./settings-options.nix { inherit lib helpers; };
settingsExample = {
exit = false;
foreign_keys = "run";
color = "red";
buffer = true;
invoke_on_body = false;
desc = null;
on_enter = ''
function()
print('hello')
end
'';
timeout = 5000;
hint = false;
};
callSetup = false;
extraConfig = cfg: {
plugins.hydra.luaConfig.content = ''
hydra = require('hydra')
hydra.setup(${helpers.toLuaObject cfg.settings})
__hydra_defs = ${helpers.toLuaObject cfg.hydras}
for _, hydra_config in ipairs(__hydra_defs) do
hydra(hydra_config)
end
'';
};
}