57 lines
1.6 KiB
Nix
57 lines
1.6 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.input;
|
|
|
|
disableKeymaps = mode: lhss: lib.flip map lhss (lhs: { inherit mode lhs; rhs = "<nop>"; });
|
|
in
|
|
{
|
|
options.input = with lib; {
|
|
leader = mkOption {
|
|
type = types.str;
|
|
default = ''\'';
|
|
apply = x: assert (builtins.stringLength x == 1 || abort "<Leader> `${x}` is longer than one character is not allowed"); x;
|
|
};
|
|
localLeader = mkOption {
|
|
type = types.str;
|
|
default = ''\'';
|
|
apply = x: assert (builtins.stringLength x == 1 || abort "<LocalLeader> `${x}` is longer than one character is not allowed"); x;
|
|
};
|
|
|
|
exMode.enable = (mkEnableOption "Ex mode") // { default = true; };
|
|
arrowKeys = {
|
|
disable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
};
|
|
mode = mkOption {
|
|
type = types.mode;
|
|
default = [ "n" "v" ];
|
|
};
|
|
};
|
|
pageButtons = {
|
|
disable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
};
|
|
mode = mkOption {
|
|
type = types.mode;
|
|
default = "";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
vim.g.mapleader = cfg.leader;
|
|
|
|
vim.keymap.set =
|
|
# Disable the annoying and useless ex-mode
|
|
lib.optionals (!cfg.exMode.enable) (disableKeymaps "n" [ "Q" "gQ" ])
|
|
# Disable arrow keys
|
|
++ lib.optionals cfg.arrowKeys.disable
|
|
(disableKeymaps cfg.arrowKeys.mode [ "<Up>" "<Down>" "<Left>" "<Right>" ])
|
|
# Disable PageUp / PageDown
|
|
++ lib.optionals cfg.pageButtons.disable
|
|
(disableKeymaps cfg.pageButtons.mode [ "<PageUp>" "<PageDown>" ]);
|
|
};
|
|
}
|