mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
helpers/neovim-plugin: add mkNeovimPlugin
This commit is contained in:
parent
e797c36266
commit
44949348cb
2 changed files with 63 additions and 4 deletions
|
@ -1,16 +1,21 @@
|
|||
{lib, ...}: let
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
nixvimTypes = import ./types.nix {inherit lib nixvimOptions;};
|
||||
nixvimUtils = import ./utils.nix {inherit lib;};
|
||||
nixvimOptions = import ./options.nix {inherit lib nixvimTypes nixvimUtils;};
|
||||
inherit (import ./to-lua.nix {inherit lib;}) toLuaObject;
|
||||
in
|
||||
{
|
||||
maintainers = import ./maintainers.nix;
|
||||
keymaps = import ./keymap-helpers.nix {inherit lib nixvimOptions nixvimTypes;};
|
||||
autocmd = import ./autocmd-helpers.nix {inherit lib nixvimOptions nixvimTypes;};
|
||||
neovim-plugin = import ./neovim-plugin.nix {inherit lib nixvimOptions;};
|
||||
neovim-plugin = import ./neovim-plugin.nix {inherit lib nixvimOptions toLuaObject;};
|
||||
vim-plugin = import ./vim-plugin.nix {inherit lib nixvimOptions;};
|
||||
inherit (import ./to-lua.nix {inherit lib;}) toLuaObject;
|
||||
inherit nixvimTypes;
|
||||
inherit toLuaObject;
|
||||
}
|
||||
// nixvimUtils
|
||||
// nixvimOptions
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
nixvimOptions,
|
||||
toLuaObject,
|
||||
}:
|
||||
with lib; {
|
||||
with lib; rec {
|
||||
mkSettingsOption = {
|
||||
pluginName ? null,
|
||||
options ? {},
|
||||
|
@ -27,4 +28,57 @@ with lib; {
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
mkNeovimPlugin = config: {
|
||||
name,
|
||||
namespace ? "plugins",
|
||||
maintainers,
|
||||
imports ? [],
|
||||
# options
|
||||
originalName ? name,
|
||||
defaultPackage,
|
||||
settingsOptions ? {},
|
||||
settingsExample ? null,
|
||||
extraOptions ? {},
|
||||
# config
|
||||
luaName ? name,
|
||||
extraConfig ? cfg: {},
|
||||
extraPlugins ? [],
|
||||
extraPackages ? [],
|
||||
}: {
|
||||
meta.maintainers = maintainers;
|
||||
|
||||
inherit imports;
|
||||
|
||||
options.${namespace}.${name} =
|
||||
{
|
||||
enable = mkEnableOption originalName;
|
||||
|
||||
package = nixvimOptions.mkPackageOption originalName defaultPackage;
|
||||
|
||||
settings = mkSettingsOption {
|
||||
pluginName = name;
|
||||
options = settingsOptions;
|
||||
example = settingsExample;
|
||||
};
|
||||
}
|
||||
// extraOptions;
|
||||
|
||||
config = let
|
||||
cfg = config.${namespace}.${name};
|
||||
in
|
||||
mkIf cfg.enable (
|
||||
mkMerge [
|
||||
{
|
||||
extraPlugins = [cfg.package] ++ extraPlugins;
|
||||
inherit extraPackages;
|
||||
|
||||
extraConfigLua = ''
|
||||
require('${luaName}').setup(${toLuaObject cfg.settings})
|
||||
'';
|
||||
}
|
||||
(extraConfig cfg)
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue