lib: add lz.n KeySpec

This commit is contained in:
Ching Pei Yang 2024-08-01 22:33:51 +02:00 committed by Pei Yang Ching
parent 054e60edf0
commit 91e2df6a93

View file

@ -6,7 +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 oneOf;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool;
# Get the names of all flake inputs that start with the given prefix.
fromInputs = {
inputs,
@ -56,6 +56,64 @@
check = x: lib.nvim.lua.isLuaInline x;
};
lznKeysSpec = submodule {
apply = x:
x
// {
"@1" = x.lhs;
"@2" = x.rhs;
};
options = {
desc = mkOption {
description = "Description of the key map";
type = nullOr str;
default = null;
};
noremap = mkOption {
description = "TBD";
type = bool;
default = false;
};
expr = mkOption {
description = "TBD";
type = bool;
default = false;
};
nowait = mkOption {
description = "TBD";
type = bool;
default = false;
};
ft = mkOption {
description = "TBD";
type = nullOr (listOf str);
default = null;
};
lhs = mkOption {
type = str;
description = "Key to bind to";
};
rhs = mkOption {
type = nullOr str;
default = null;
description = "Action to trigger";
};
mode = mkOption {
description = "Modes to bind in";
type = listOf str;
default = ["n"];
};
};
};
lznPluginTableType = attrsOf lznPluginType;
lznPluginType = submodule {
options = {
@ -135,7 +193,7 @@
keys = mkOption {
description = "Lazy-load on key mapping";
default = null;
type = nullOr (either str (listOf str)); # TODO: support lz.n.KeysSpec
type = nullOr (oneOf [str (listOf str) lznKeysSpec]); # TODO: support lz.n.KeysSpec
};
# TODO: enabled, beforeAll, colorscheme, priority, load