modules/input: add options to configure leaders

This commit is contained in:
Dmitriy Pleshevskiy 2024-04-27 02:44:52 +03:00
parent c4cc7d5a80
commit 85f2524196
Signed by: pleshevskiy
GPG Key ID: 17041163DA10A9A2

View File

@ -7,6 +7,17 @@ let
in in
{ {
options.input = with lib; with types; { 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; }; exMode.enable = (mkEnableOption "Ex mode") // { default = true; };
arrowKeys = { arrowKeys = {
disableInMode = mkOption { disableInMode = mkOption {
@ -22,13 +33,17 @@ in
}; };
}; };
config.vim.keymap.set = config = {
# Disable the annoying and useless ex-mode vim.g.mapleader = cfg.leader;
lib.optionals (!cfg.exMode.enable) (disableKeymaps "n" [ "Q" "gQ" ])
# Disable arrow keys vim.keymap.set =
++ lib.optionals (cfg.arrowKeys.disableInMode != [ ]) # Disable the annoying and useless ex-mode
(disableKeymaps cfg.arrowKeys.disableInMode [ "<Up>" "<Down>" "<Left>" "<Right>" ]) lib.optionals (!cfg.exMode.enable) (disableKeymaps "n" [ "Q" "gQ" ])
# Disable PageUp / PageDown # Disable arrow keys
++ lib.optionals (cfg.pageButtons.disableInMode != [ ]) ++ lib.optionals (cfg.arrowKeys.disableInMode != [ ])
(disableKeymaps cfg.pageButtons.disableInMode [ "<PageUp>" "<PageDown>" ]); (disableKeymaps cfg.arrowKeys.disableInMode [ "<Up>" "<Down>" "<Left>" "<Right>" ])
# Disable PageUp / PageDown
++ lib.optionals (cfg.pageButtons.disableInMode != [ ])
(disableKeymaps cfg.pageButtons.disableInMode [ "<PageUp>" "<PageDown>" ]);
};
} }