2024-04-20 23:10:06 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2024-08-18 12:16:44 +00:00
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (builtins) mapAttrs;
|
|
|
|
|
|
|
|
processLegacyMap = modes: legacyMap: [(legacyMap // {mode = modes;})];
|
2024-04-20 23:10:06 +00:00
|
|
|
|
|
|
|
cfg = config.vim;
|
|
|
|
in {
|
|
|
|
config = {
|
2024-08-18 12:16:44 +00:00
|
|
|
vim.keymaps = mkMerge [
|
|
|
|
(mkIf cfg.disableArrows {
|
|
|
|
"<up>" = [
|
|
|
|
{
|
|
|
|
mode = ["n" "i"];
|
|
|
|
action = "<nop>";
|
|
|
|
noremap = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
"<down>" = [
|
|
|
|
{
|
|
|
|
mode = ["n" "i"];
|
|
|
|
action = "<nop>";
|
|
|
|
noremap = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
"<left>" = [
|
|
|
|
{
|
|
|
|
mode = ["n" "i"];
|
|
|
|
action = "<nop>";
|
|
|
|
noremap = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
"<right>" = [
|
|
|
|
{
|
|
|
|
mode = ["n" "i"];
|
|
|
|
action = "<nop>";
|
|
|
|
noremap = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
})
|
|
|
|
(mapAttrs (_key: processLegacyMap "n") cfg.maps.normal)
|
|
|
|
(mapAttrs (_key: processLegacyMap "i") cfg.maps.insert)
|
|
|
|
(mapAttrs (_key: processLegacyMap "s") cfg.maps.select)
|
|
|
|
(mapAttrs (_key: processLegacyMap "v") cfg.maps.visual)
|
|
|
|
(mapAttrs (_key: processLegacyMap "t") cfg.maps.terminal)
|
|
|
|
(mapAttrs (_key: processLegacyMap "nvo") cfg.maps.normalVisualOp)
|
|
|
|
(mapAttrs (_key: processLegacyMap "nx") cfg.maps.visualOnly)
|
|
|
|
(mapAttrs (_key: processLegacyMap "o") cfg.maps.operator)
|
|
|
|
(mapAttrs (_key: processLegacyMap "ic") cfg.maps.insertCommand)
|
|
|
|
(mapAttrs (_key: processLegacyMap "l") cfg.maps.lang)
|
|
|
|
(mapAttrs (_key: processLegacyMap "c") cfg.maps.command)
|
|
|
|
];
|
2024-04-20 23:10:06 +00:00
|
|
|
};
|
|
|
|
}
|