{ config, lib, ... }: let cfg = config.input; disableKeymaps = mode: lhss: lib.flip map lhss (lhs: { inherit mode lhs; rhs = ""; }); in { options.input = with lib; { leader = mkOption { type = types.str; default = ''\''; apply = x: assert (builtins.stringLength x == 1 || abort " `${x}` is longer than one character is not allowed"); x; }; localLeader = mkOption { type = types.str; default = ''\''; apply = x: assert (builtins.stringLength x == 1 || abort " `${x}` is longer than one character is not allowed"); x; }; exMode.enable = mkEnableOption "Ex mode"; arrowKeys = { disable = mkOption { type = types.bool; default = true; }; mode = mkOption { type = types.mode; default = [ "n" "v" "o" ]; }; }; 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 [ "" "" "" "" ]) # Disable PageUp / PageDown ++ lib.optionals cfg.pageButtons.disable (disableKeymaps cfg.pageButtons.mode [ "" "" ]); }; }