diff --git a/modules/input.nix b/modules/input.nix index ccd2d9b..79b35f4 100644 --- a/modules/input.nix +++ b/modules/input.nix @@ -7,6 +7,17 @@ let in { options.input = with lib; with types; { + leader = mkOption { + type = str; + default = ''\''; + apply = x: assert (builtins.stringLength x == 1 || abort " `${x}` is longer than one character is not allowed"); x; + }; + localLeader = mkOption { + type = 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") // { default = true; }; arrowKeys = { disableInMode = mkOption { @@ -22,13 +33,17 @@ in }; }; - config.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 [ "" "" "" "" ]) - # Disable PageUp / PageDown - ++ lib.optionals (cfg.pageButtons.disableInMode != [ ]) - (disableKeymaps cfg.pageButtons.disableInMode [ "" "" ]); + 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 [ "" "" "" "" ]) + # Disable PageUp / PageDown + ++ lib.optionals (cfg.pageButtons.disableInMode != [ ]) + (disableKeymaps cfg.pageButtons.disableInMode [ "" "" ]); + }; }