mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
lib/binds: improve code, adjust functions to new api
This commit is contained in:
parent
75cb9bced7
commit
6cb57e1d26
1 changed files with 60 additions and 61 deletions
|
@ -4,30 +4,29 @@
|
||||||
inherit (lib.types) nullOr str;
|
inherit (lib.types) nullOr str;
|
||||||
inherit (lib.attrsets) isAttrs mapAttrs;
|
inherit (lib.attrsets) isAttrs mapAttrs;
|
||||||
|
|
||||||
binds = rec {
|
mkLuaBinding = mode: key: action: desc:
|
||||||
mkLuaBinding = key: action: desc:
|
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkExprBinding = key: action: desc:
|
mkExprBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
expr = true;
|
expr = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkBinding = key: action: desc:
|
mkBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -48,25 +47,25 @@
|
||||||
isNested = isAttrs value;
|
isNested = isAttrs value;
|
||||||
returnedValue =
|
returnedValue =
|
||||||
if isNested
|
if isNested
|
||||||
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
then addDescriptionsToMappings actualMappings.${name} mappingDefinitions.${name}
|
||||||
else {
|
else {
|
||||||
inherit value;
|
inherit value;
|
||||||
inherit (mappingDefinitions."${name}") description;
|
inherit (mappingDefinitions.${name}) description;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
returnedValue)
|
returnedValue)
|
||||||
actualMappings;
|
actualMappings;
|
||||||
|
|
||||||
mkSetBinding = binding: action:
|
mkSetBinding = mode: binding: action:
|
||||||
mkBinding binding.value action binding.description;
|
mkBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
mkSetExprBinding = binding: action:
|
mkSetExprBinding = mode: binding: action:
|
||||||
mkExprBinding binding.value action binding.description;
|
mkExprBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
mkSetLuaBinding = binding: action:
|
mkSetLuaBinding = mode: binding: action:
|
||||||
mkLuaBinding binding.value action binding.description;
|
mkLuaBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||||
};
|
in {
|
||||||
in
|
inherit mkLuaBinding mkExprBinding mkBinding mkMappingOption addDescriptionsToMappings mkSetBinding mkSetExprBinding mkSetLuaBinding pushDownDefault;
|
||||||
binds
|
}
|
||||||
|
|
Loading…
Reference in a new issue