mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 14:55:59 +01:00
lib: add basic lz.n plugin spec type
This commit is contained in:
parent
baf216bb0f
commit
efd20adfd9
1 changed files with 73 additions and 8 deletions
|
@ -6,8 +6,7 @@
|
|||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||
inherit (lib.strings) hasPrefix removePrefix;
|
||||
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
|
||||
|
||||
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf;
|
||||
# Get the names of all flake inputs that start with the given prefix.
|
||||
fromInputs = {
|
||||
inputs,
|
||||
|
@ -51,8 +50,79 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
luaInline = lib.mkOptionType {
|
||||
name = "luaInline";
|
||||
check = x: lib.nvim.lua.isLuaInline x;
|
||||
};
|
||||
|
||||
lznPluginType = submodule {
|
||||
options = {
|
||||
## Should probably infer from the actual plugin somehow
|
||||
## In general this is the name passed to packadd, so the dir name of the plugin
|
||||
# name = mkOption {
|
||||
# type= str;
|
||||
# }
|
||||
|
||||
package = pluginType;
|
||||
|
||||
before = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run before plugin is loaded";
|
||||
default = null;
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run after plugin is loaded";
|
||||
default = null;
|
||||
};
|
||||
|
||||
event = mkOption {
|
||||
description = "Lazy-load on event";
|
||||
default = "null";
|
||||
type = let
|
||||
event = submodule {
|
||||
options = {
|
||||
event = mkOption {
|
||||
type = nullOr (either str (listOf str));
|
||||
description = "Exact event name";
|
||||
example = "BufEnter";
|
||||
};
|
||||
pattern = mkOption {
|
||||
type = nullOr (either str (listOf str));
|
||||
description = "Event pattern";
|
||||
example = "BufEnter *.lua";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
oneOf [str (listOf str) event];
|
||||
};
|
||||
|
||||
cmd = mkOption {
|
||||
description = "Lazy-load on command";
|
||||
default = null;
|
||||
type = nullOr (either str (listOf str));
|
||||
};
|
||||
|
||||
ft = mkOption {
|
||||
description = "Lazy-load on filetype";
|
||||
default = null;
|
||||
type = nullOr (either str (listOf str));
|
||||
};
|
||||
|
||||
keys = mkOption {
|
||||
description = "Lazy-load on key mapping";
|
||||
default = null;
|
||||
type = nullOr (either str (listOf str)); # TODO: support lz.n.KeysSpec
|
||||
};
|
||||
|
||||
# TODO: enabled, beforeAll, colorscheme, priority, load
|
||||
};
|
||||
};
|
||||
in {
|
||||
inherit extraPluginType fromInputs pluginType;
|
||||
inherit extraPluginType fromInputs pluginType luaInline lznPluginType;
|
||||
|
||||
pluginsOpt = {
|
||||
description,
|
||||
|
@ -64,11 +134,6 @@ in {
|
|||
type = pluginsType;
|
||||
};
|
||||
|
||||
luaInline = lib.mkOptionType {
|
||||
name = "luaInline";
|
||||
check = x: lib.nvim.lua.isLuaInline x;
|
||||
};
|
||||
|
||||
/*
|
||||
opts is a attrset of options, example:
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue