2024-04-08 00:28:49 +00:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (lib.options) mkOption;
|
|
|
|
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
2024-07-08 21:57:58 +00:00
|
|
|
inherit (lib.strings) hasPrefix removePrefix;
|
2024-04-08 00:28:49 +00:00
|
|
|
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
|
|
|
|
|
|
|
|
# Get the names of all flake inputs that start with the given prefix.
|
2024-04-09 06:55:45 +00:00
|
|
|
fromInputs = {
|
|
|
|
inputs,
|
|
|
|
prefix,
|
|
|
|
}:
|
2024-04-08 00:28:49 +00:00
|
|
|
mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs);
|
|
|
|
|
|
|
|
# Get the names of all flake inputs that start with the given prefix.
|
2024-04-09 06:55:45 +00:00
|
|
|
pluginInputNames = attrNames (fromInputs {
|
|
|
|
inherit inputs;
|
|
|
|
prefix = "plugin-";
|
|
|
|
});
|
2024-04-08 00:28:49 +00:00
|
|
|
|
2023-02-06 18:57:35 +00:00
|
|
|
# You can either use the name of the plugin or a package.
|
2024-04-08 00:28:49 +00:00
|
|
|
pluginType = nullOr (
|
|
|
|
either
|
|
|
|
package
|
2024-04-09 06:55:45 +00:00
|
|
|
(enum (pluginInputNames ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"]))
|
2024-04-08 00:28:49 +00:00
|
|
|
);
|
2023-07-18 19:21:36 +00:00
|
|
|
|
2024-04-08 00:28:49 +00:00
|
|
|
pluginsType = listOf pluginType;
|
2023-07-21 13:30:03 +00:00
|
|
|
|
2024-04-08 00:28:49 +00:00
|
|
|
extraPluginType = submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = pluginType;
|
|
|
|
description = "Plugin Package.";
|
|
|
|
};
|
2024-02-17 00:19:38 +00:00
|
|
|
|
2024-04-08 00:28:49 +00:00
|
|
|
after = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [];
|
|
|
|
description = "Setup this plugin after the following ones.";
|
|
|
|
};
|
2024-02-17 00:19:38 +00:00
|
|
|
|
2024-04-08 00:28:49 +00:00
|
|
|
setup = mkOption {
|
|
|
|
type = lines;
|
|
|
|
default = "";
|
|
|
|
description = "Lua code to run during setup.";
|
|
|
|
example = "require('aerial').setup {}";
|
2023-07-18 19:21:36 +00:00
|
|
|
};
|
|
|
|
};
|
2024-04-08 00:28:49 +00:00
|
|
|
};
|
2024-07-16 11:56:48 +00:00
|
|
|
|
|
|
|
borderPresets = ["none" "single" "double" "rounded" "solid" "shadow"];
|
2023-02-06 18:57:35 +00:00
|
|
|
in {
|
2024-07-10 19:58:37 +00:00
|
|
|
inherit extraPluginType fromInputs pluginType;
|
2023-07-18 19:21:36 +00:00
|
|
|
|
2024-07-17 10:48:56 +00:00
|
|
|
borderType = either (enum borderPresets) (listOf (either str (listOf str)));
|
2024-07-16 11:56:48 +00:00
|
|
|
|
2023-02-06 18:57:35 +00:00
|
|
|
pluginsOpt = {
|
|
|
|
description,
|
2024-04-20 15:08:07 +00:00
|
|
|
example,
|
2023-02-06 18:57:35 +00:00
|
|
|
default ? [],
|
|
|
|
}:
|
|
|
|
mkOption {
|
2024-04-20 15:08:07 +00:00
|
|
|
inherit example description default;
|
2023-02-06 18:57:35 +00:00
|
|
|
type = pluginsType;
|
|
|
|
};
|
2024-01-02 23:54:49 +00:00
|
|
|
|
2024-03-16 09:29:07 +00:00
|
|
|
luaInline = lib.mkOptionType {
|
|
|
|
name = "luaInline";
|
2024-04-27 00:12:35 +00:00
|
|
|
check = x: lib.nvim.lua.isLuaInline x;
|
2024-03-03 11:47:58 +00:00
|
|
|
};
|
|
|
|
|
2024-04-08 00:28:49 +00:00
|
|
|
/*
|
|
|
|
opts is a attrset of options, example:
|
|
|
|
```
|
|
|
|
mkPluginSetupOption "telescope" {
|
|
|
|
file_ignore_patterns = mkOption {
|
|
|
|
description = "...";
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
layout_config.horizontal = mkOption {...};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
*/
|
2024-01-02 23:54:49 +00:00
|
|
|
mkPluginSetupOption = pluginName: opts:
|
|
|
|
mkOption {
|
2024-04-20 12:24:00 +00:00
|
|
|
description = ''
|
2024-04-20 13:48:15 +00:00
|
|
|
Option table to pass into the setup function of ${pluginName}
|
2024-04-20 12:24:00 +00:00
|
|
|
|
|
|
|
You can pass in any additional options even if they're
|
2024-04-20 13:48:15 +00:00
|
|
|
not listed in the docs
|
2024-04-20 12:24:00 +00:00
|
|
|
'';
|
|
|
|
|
2024-01-02 23:54:49 +00:00
|
|
|
default = {};
|
2024-04-08 00:28:49 +00:00
|
|
|
type = submodule {
|
|
|
|
freeformType = attrsOf anything;
|
2024-01-02 23:54:49 +00:00
|
|
|
options = opts;
|
|
|
|
};
|
|
|
|
};
|
2023-02-06 18:57:35 +00:00
|
|
|
}
|