From bd81037c5fb10493f73c4b9b0d6f12b40008c034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 4 Apr 2023 18:34:05 +0200 Subject: [PATCH] modules/keymaps: fix bug in keymaps generation (#300) --- lib/helpers.nix | 36 --------- modules/keymaps.nix | 189 ++++++++++++++++++++++++++++---------------- 2 files changed, 119 insertions(+), 106 deletions(-) diff --git a/lib/helpers.nix b/lib/helpers.nix index 7ef8b802..ecc709a3 100644 --- a/lib/helpers.nix +++ b/lib/helpers.nix @@ -49,42 +49,6 @@ with lib; rec { emptyTable = {"__empty" = null;}; - # Generates maps for a lua config - genMaps = mode: maps: let - normalized = - builtins.mapAttrs - (key: action: - if builtins.isString action - then { - silent = false; - expr = false; - unique = false; - noremap = true; - remap = false; - script = false; - nowait = false; - action = action; - } - else { - inherit (action) silent expr unique noremap script nowait remap; - action = - if action.lua - then mkRaw action.action - else action.action; - }) - maps; - in - builtins.attrValues (builtins.mapAttrs - (key: action: { - action = action.action; - config = lib.filterAttrs (_: v: v) { - inherit (action) silent expr unique noremap script nowait remap; - }; - key = key; - mode = mode; - }) - normalized); - # Given an attrs of key mappings (for a single mode), applies the defaults to each one of them. # # Example: diff --git a/modules/keymaps.nix b/modules/keymaps.nix index e9f584e4..2407da2d 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -6,70 +6,119 @@ with lib; let helpers = import ../lib/helpers.nix {inherit lib;}; + # These are the configuration options that change the behavior of each mapping. + mapConfigOptions = { + silent = + helpers.defaultNullOpts.mkBool false + "Whether this mapping should be silent. Equivalent to adding to a map."; + + nowait = + helpers.defaultNullOpts.mkBool false + "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; + + script = + helpers.defaultNullOpts.mkBool false + "Equivalent to adding