Add support for mappings

This commit is contained in:
Pedro Alves 2021-01-05 16:11:56 +00:00
parent 7122ccd208
commit 0586bed5ad
7 changed files with 142 additions and 14 deletions

View file

@ -27,4 +27,28 @@ rec {
else if isNull args then
"nil"
else "";
# Generates maps for a lua config
genMaps = mode: maps: let
normalized = builtins.mapAttrs (key: action:
if builtins.isString action then
{
silent = false;
expr = false;
unique = false;
noremap = true;
script = false;
nowait = false;
action = action;
}
else action) maps;
in builtins.attrValues (builtins.mapAttrs (key: action:
{
action = action.action;
config = lib.filterAttrs (_: v: v) {
inherit (action) silent expr unique noremap script nowait;
};
key = key;
mode = mode;
}) normalized);
}

View file

@ -30,14 +30,12 @@ in {
sections = mkOption {
default = null;
type = with types; nullOr (submodule {
options = {
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
};
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
});
};