2023-02-06 18:57:35 +00:00
|
|
|
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/stdlib-extended.nix
|
|
|
|
# Just a convenience function that returns the given Nixpkgs standard
|
|
|
|
# library extended with the HM library.
|
|
|
|
nixpkgsLib: let
|
|
|
|
mkNvimLib = import ./.;
|
|
|
|
in
|
2023-04-22 13:48:10 +00:00
|
|
|
nixpkgsLib.extend (self: super: rec {
|
2023-02-06 18:57:35 +00:00
|
|
|
nvim = mkNvimLib {lib = self;};
|
|
|
|
|
2023-04-11 12:38:08 +00:00
|
|
|
mkLuaBinding = key: action: desc:
|
|
|
|
self.mkIf (key != null) {
|
|
|
|
"${key}" = {
|
|
|
|
inherit action desc;
|
|
|
|
lua = true;
|
|
|
|
silent = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-12 21:42:55 +00:00
|
|
|
mkExprBinding = key: action: desc:
|
|
|
|
self.mkIf (key != null) {
|
|
|
|
"${key}" = {
|
|
|
|
inherit action desc;
|
|
|
|
lua = true;
|
|
|
|
silent = true;
|
|
|
|
expr = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-11 12:38:08 +00:00
|
|
|
mkBinding = key: action: desc:
|
|
|
|
self.mkIf (key != null) {
|
|
|
|
"${key}" = {
|
|
|
|
inherit action desc;
|
|
|
|
silent = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-12 18:13:30 +00:00
|
|
|
mkMappingOption = description: default:
|
|
|
|
self.mkOption {
|
|
|
|
type = self.types.nullOr self.types.str;
|
|
|
|
inherit default description;
|
|
|
|
};
|
|
|
|
|
2023-04-22 13:48:10 +00:00
|
|
|
# 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:
|
2023-05-02 22:06:49 +00:00
|
|
|
self.attrsets.mapAttrs (name: value: let
|
|
|
|
isNested = self.isAttrs value;
|
|
|
|
returnedValue =
|
|
|
|
if isNested
|
|
|
|
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
|
|
|
else {
|
|
|
|
value = value;
|
|
|
|
description = mappingDefinitions."${name}".description;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
returnedValue)
|
2023-04-22 13:48:10 +00:00
|
|
|
actualMappings;
|
|
|
|
|
|
|
|
mkSetBinding = binding: action:
|
|
|
|
mkBinding binding.value action binding.description;
|
|
|
|
|
2023-04-22 16:47:07 +00:00
|
|
|
mkSetExprBinding = binding: action:
|
|
|
|
mkExprBinding binding.value action binding.description;
|
|
|
|
|
2023-04-22 13:48:10 +00:00
|
|
|
mkSetLuaBinding = binding: action:
|
|
|
|
mkLuaBinding binding.value action binding.description;
|
|
|
|
|
2024-02-26 03:52:21 +00:00
|
|
|
pushDownDefault = attr: self.mapAttrs (name: value: self.mkDefault value) attr;
|
2024-02-25 16:40:43 +00:00
|
|
|
|
2023-02-06 18:57:35 +00:00
|
|
|
# For forward compatibility.
|
|
|
|
literalExpression = super.literalExpression or super.literalExample;
|
|
|
|
})
|