mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 09:49:48 +01:00
feat: create utility functions to make adding bindings even easier
This commit is contained in:
parent
586a7f5b41
commit
1b1743dc5a
1 changed files with 19 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
nixpkgsLib: let
|
nixpkgsLib: let
|
||||||
mkNvimLib = import ./.;
|
mkNvimLib = import ./.;
|
||||||
in
|
in
|
||||||
nixpkgsLib.extend (self: super: {
|
nixpkgsLib.extend (self: super: rec {
|
||||||
nvim = mkNvimLib {lib = self;};
|
nvim = mkNvimLib {lib = self;};
|
||||||
|
|
||||||
mkLuaBinding = key: action: desc:
|
mkLuaBinding = key: action: desc:
|
||||||
|
@ -40,6 +40,24 @@ in
|
||||||
inherit default description;
|
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.
|
# For forward compatibility.
|
||||||
literalExpression = super.literalExpression or super.literalExample;
|
literalExpression = super.literalExpression or super.literalExample;
|
||||||
literalDocBook = super.literalDocBook or super.literalExample;
|
literalDocBook = super.literalDocBook or super.literalExample;
|
||||||
|
|
Loading…
Reference in a new issue