modules/keymap: dedup mode list before folding

This commit is contained in:
Dmitriy Pleshevskiy 2024-04-29 16:33:51 +03:00
parent 4c73e0220e
commit 5e12b830c8
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2

View file

@ -22,15 +22,15 @@ let cfg = config.vim.keymap; in
({ mode, lhs, rhs, buffer, ... }: ({ mode, lhs, rhs, buffer, ... }:
let let
sourceModes = if builtins.isList mode then mode else [ mode ]; sourceModes = if builtins.isList mode then mode else [ mode ];
unwrappedModes = lib.flatten (lib.flip map sourceModes (m: unwrappedModes = lib.unique (lib.flatten (lib.flip map sourceModes (m:
if m == "" then [ m "n" "x" "s" "o" ] if m == "" then [ m "n" "x" "s" "o" ]
else if m == "!" then [ m "i" "c" ] else if m == "!" then [ m "i" "c" ]
else if m == "v" then [ m "x" "s" ] else if m == "v" then [ m "x" "s" ]
else if m == "l" then [ m "i" "c" "l" ] else if m == "l" then [ m "i" "c" "l" ]
else m else m
)); )));
buf = if buffer == null then "" else buffer; buf = lib.optionalString (buffer != null) buffer;
in in
lib.foldl lib.recursiveUpdate { } lib.foldl lib.recursiveUpdate { }
(lib.flip map unwrappedModes (m: { (lib.flip map unwrappedModes (m: {