49 lines
1.5 KiB
Nix
49 lines
1.5 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; with types; {
|
|
leader = mkOption {
|
|
type = str;
|
|
default = ''\'';
|
|
apply = x: assert (builtins.stringLength x == 1 || abort "<Leader> `${x}` is longer than one character is not allowed"); x;
|
|
};
|
|
localLeader = mkOption {
|
|
type = 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 = {
|
|
disableInMode = mkOption {
|
|
type = oneOf [ str (uniq (listOf str)) ];
|
|
default = [ "n" "v" ];
|
|
};
|
|
};
|
|
pageButtons = {
|
|
disableInMode = mkOption {
|
|
type = oneOf [ str (uniq (listOf str)) ];
|
|
default = [ "n" "v" "i" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
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.disableInMode != [ ])
|
|
(disableKeymaps cfg.arrowKeys.disableInMode [ "<Up>" "<Down>" "<Left>" "<Right>" ])
|
|
# Disable PageUp / PageDown
|
|
++ lib.optionals (cfg.pageButtons.disableInMode != [ ])
|
|
(disableKeymaps cfg.pageButtons.disableInMode [ "<PageUp>" "<PageDown>" ]);
|
|
};
|
|
}
|