2024-04-26 02:08:23 +03:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
2024-05-08 01:09:18 +03:00
|
|
|
inherit (lib) mod;
|
|
|
|
|
2024-04-26 02:08:23 +03:00
|
|
|
cfg = config.input;
|
|
|
|
|
2024-05-08 01:30:47 +03:00
|
|
|
disableKeymaps = mode: lhss: lib.flip map lhss (lhs: { inherit mode lhs; rhs = mod.Nop; });
|
2024-04-26 02:08:23 +03:00
|
|
|
in
|
|
|
|
{
|
2024-04-28 00:39:50 +03:00
|
|
|
options.input = with lib; {
|
2024-04-27 02:44:52 +03:00
|
|
|
leader = mkOption {
|
2024-04-28 00:39:50 +03:00
|
|
|
type = types.str;
|
2024-04-27 02:44:52 +03:00
|
|
|
default = ''\'';
|
2024-05-08 01:30:47 +03:00
|
|
|
apply = x: assert (builtins.stringLength x == 1 || abort "${mod.Leader} `${x}` is longer than one character is not allowed"); x;
|
2024-04-27 02:44:52 +03:00
|
|
|
};
|
|
|
|
localLeader = mkOption {
|
2024-04-28 00:39:50 +03:00
|
|
|
type = types.str;
|
2024-04-27 02:44:52 +03:00
|
|
|
default = ''\'';
|
2024-05-08 01:30:47 +03:00
|
|
|
apply = x: assert (builtins.stringLength x == 1 || abort "${mod.LocalLeader} `${x}` is longer than one character is not allowed"); x;
|
2024-04-27 02:44:52 +03:00
|
|
|
};
|
|
|
|
|
2024-04-28 00:42:30 +03:00
|
|
|
exMode.enable = mkEnableOption "Ex mode";
|
2024-04-26 02:08:23 +03:00
|
|
|
arrowKeys = {
|
2024-04-28 00:39:50 +03:00
|
|
|
disable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
mode = mkOption {
|
|
|
|
type = types.mode;
|
2024-04-28 09:35:54 +03:00
|
|
|
default = [ "n" "v" "o" ];
|
2024-04-26 02:08:23 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
pageButtons = {
|
2024-04-28 00:39:50 +03:00
|
|
|
disable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
mode = mkOption {
|
|
|
|
type = types.mode;
|
2024-04-28 02:14:03 +03:00
|
|
|
default = [ "" "!" ];
|
2024-04-26 02:08:23 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-27 02:44:52 +03:00
|
|
|
config = {
|
|
|
|
vim.g.mapleader = cfg.leader;
|
2024-05-08 01:07:41 +03:00
|
|
|
vim.g.maplocalleader = cfg.localLeader;
|
2024-04-27 02:44:52 +03:00
|
|
|
|
|
|
|
vim.keymap.set =
|
|
|
|
# Disable the annoying and useless ex-mode
|
|
|
|
lib.optionals (!cfg.exMode.enable) (disableKeymaps "n" [ "Q" "gQ" ])
|
|
|
|
# Disable arrow keys
|
2024-04-28 00:39:50 +03:00
|
|
|
++ lib.optionals cfg.arrowKeys.disable
|
2024-05-08 01:30:47 +03:00
|
|
|
(disableKeymaps cfg.arrowKeys.mode [ mod.Up mod.Down mod.Left mod.Right ])
|
2024-04-27 02:44:52 +03:00
|
|
|
# Disable PageUp / PageDown
|
2024-04-28 00:39:50 +03:00
|
|
|
++ lib.optionals cfg.pageButtons.disable
|
2024-05-08 01:30:47 +03:00
|
|
|
(disableKeymaps cfg.pageButtons.mode [ mod.PageUp mod.PageDown ]);
|
2024-04-27 02:44:52 +03:00
|
|
|
};
|
2024-04-26 02:08:23 +03:00
|
|
|
}
|