mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
lib: add mkLznBinding
This commit is contained in:
parent
a0f4e6a942
commit
cdda400905
1 changed files with 36 additions and 4 deletions
|
@ -65,7 +65,39 @@
|
|||
mkSetLuaBinding = mode: binding: action:
|
||||
mkLuaBinding mode binding.value action binding.description;
|
||||
|
||||
# Utility function that takes two attrsets:
|
||||
# { someKey = "some_value" } and
|
||||
# { someKey = { description = "Some Description"; }; }
|
||||
# and merges them into
|
||||
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||
mapAttrs (name: value: let
|
||||
isNested = isAttrs value;
|
||||
returnedValue =
|
||||
if isNested
|
||||
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
||||
else {
|
||||
inherit value;
|
||||
inherit (mappingDefinitions."${name}") description;
|
||||
};
|
||||
in
|
||||
returnedValue)
|
||||
actualMappings;
|
||||
|
||||
mkSetBinding = binding: action:
|
||||
mkBinding binding.value action binding.description;
|
||||
|
||||
mkSetExprBinding = binding: action:
|
||||
mkExprBinding binding.value action binding.description;
|
||||
|
||||
mkSetLuaBinding = binding: action:
|
||||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||
in {
|
||||
inherit mkLuaBinding mkExprBinding mkBinding mkMappingOption addDescriptionsToMappings mkSetBinding mkSetExprBinding mkSetLuaBinding pushDownDefault;
|
||||
}
|
||||
|
||||
mkLznBinding = mode: lhs: rhs: desc: {
|
||||
inherit mode lhs rhs desc;
|
||||
};
|
||||
};
|
||||
in
|
||||
binds
|
||||
|
|
Loading…
Reference in a new issue