build/neovim: add keymap validation to build process
This commit is contained in:
parent
e98bb24f6d
commit
4c73e0220e
2 changed files with 11 additions and 5 deletions
|
@ -42,7 +42,13 @@ in
|
|||
(lib.optional (config.vim.cmd != "") (call "vim.cmd" config.vim.cmd))
|
||||
# Keymaps
|
||||
(lib.flip map config.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
||||
let
|
||||
buf = lib.optionalString (vars.buffer != null) vars.buffer;
|
||||
m = if builtins.isList mode then lib.head mode else mode;
|
||||
in
|
||||
if config.vim.keymap._validate."${buf}"."${m}"."${lhs}" == rhs then
|
||||
call "vim.keymap.set" [ mode lhs rhs (removeAttrs vars [ "mode" "lhs" "rhs" ]) ]
|
||||
else abort "This case should never happen."
|
||||
))
|
||||
]));
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ let cfg = config.vim.keymap; in
|
|||
let
|
||||
sourceModes = if builtins.isList mode then mode else [ mode ];
|
||||
unwrappedModes = lib.flatten (lib.flip map sourceModes (m:
|
||||
if m == "" then [ "n" "x" "s" "o" ]
|
||||
else if m == "!" then [ "i" "c" ]
|
||||
else if m == "v" then [ "x" "s" ]
|
||||
else if m == "l" then [ "i" "c" "l" ]
|
||||
if m == "" then [ m "n" "x" "s" "o" ]
|
||||
else if m == "!" then [ m "i" "c" ]
|
||||
else if m == "v" then [ m "x" "s" ]
|
||||
else if m == "l" then [ m "i" "c" "l" ]
|
||||
else m
|
||||
));
|
||||
|
||||
|
|
Loading…
Reference in a new issue