nixvim/plugins/common/functions.nix
Lander Van den Bulcke 5c5c106495
wip
Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
2025-10-18 20:14:59 +02:00

40 lines
958 B
Nix

{ lib, ... }:
{
myvim.mkKey = rec {
# set of functions that returns attrs for keymap list
mkKeymap = mode: key: action: desc: {
inherit mode key action;
options = {
inherit desc;
silent = true;
noremap = true;
remap = true;
};
};
# use when no description is to be passed
mkKeymap' =
mode: key: action:
mkKeymap mode key action null;
mkKeymapWithOpts =
mode: key: action: desc: opts:
(mkKeymap mode key action desc) // { options = opts; };
# for which-key icon generation
# accepts a list of strings and returns a list of objects
# [{ __unkeyed, icon, group, hidden <optional boolean> }]
wKeyObj =
with builtins;
list:
{
__unkeyed = elemAt list 0;
icon = elemAt list 1;
group = elemAt list 2;
}
// lib.optionalAttrs (length list > 3) {
hidden = elemAt list 3;
};
};
}