From 8fe5adc81020e6a4f49ac871187e9c54ceccf81a Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Wed, 8 May 2024 01:09:18 +0300 Subject: [PATCH] modules/input: use lib.mod instead --- modules/input.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/input.nix b/modules/input.nix index 136caac..4e37f09 100644 --- a/modules/input.nix +++ b/modules/input.nix @@ -1,21 +1,23 @@ { config, lib, ... }: let + inherit (lib) mod; + cfg = config.input; - disableKeymaps = mode: lhss: lib.flip map lhss (lhs: { inherit mode lhs; rhs = ""; }); + disableKeymaps = mode: lhss: lib.flip map lhss (lhs: { inherit mode lhs; rhs = mod.nop; }); 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; + apply = x: assert (builtins.stringLength x == 1 || abort "${mod.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 " `${x}` is longer than one character is not allowed"); x; + apply = x: assert (builtins.stringLength x == 1 || abort "${mod.localLeader} `${x}` is longer than one character is not allowed"); x; }; exMode.enable = mkEnableOption "Ex mode"; @@ -50,9 +52,9 @@ in lib.optionals (!cfg.exMode.enable) (disableKeymaps "n" [ "Q" "gQ" ]) # Disable arrow keys ++ lib.optionals cfg.arrowKeys.disable - (disableKeymaps cfg.arrowKeys.mode [ "" "" "" "" ]) + (disableKeymaps cfg.arrowKeys.mode [ mod.up mod.down mod.left mod.right ]) # Disable PageUp / PageDown ++ lib.optionals cfg.pageButtons.disable - (disableKeymaps cfg.pageButtons.mode [ "" "" ]); + (disableKeymaps cfg.pageButtons.mode [ mod.pageUp mod.pageDown ]); }; }