diff --git a/lib/stdlib-extended.nix b/lib/stdlib-extended.nix index 92945a5..0455983 100644 --- a/lib/stdlib-extended.nix +++ b/lib/stdlib-extended.nix @@ -4,7 +4,7 @@ nixpkgsLib: let mkNvimLib = import ./.; in - nixpkgsLib.extend (self: super: { + nixpkgsLib.extend (self: super: rec { nvim = mkNvimLib {lib = self;}; mkLuaBinding = key: action: desc: @@ -40,6 +40,24 @@ in inherit default 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: + self.attrsets.mapAttrs (name: value: { + value = value; + description = mappingDefinitions."${name}".description; + }) + actualMappings; + + mkSetBinding = binding: action: + mkBinding binding.value action binding.description; + + mkSetLuaBinding = binding: action: + mkLuaBinding binding.value action binding.description; + # For forward compatibility. literalExpression = super.literalExpression or super.literalExample; literalDocBook = super.literalDocBook or super.literalExample;