modules/keymap: don't validate by buffer
This commit is contained in:
parent
688e8e2ece
commit
bc38ab74de
3 changed files with 5 additions and 10 deletions
|
@ -43,10 +43,9 @@ in
|
||||||
# Keymaps
|
# Keymaps
|
||||||
(lib.flip map config.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
(lib.flip map config.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
||||||
let
|
let
|
||||||
buf = lib.optionalString (vars.buffer != null) vars.buffer;
|
|
||||||
m = if builtins.isList mode then lib.head mode else mode;
|
m = if builtins.isList mode then lib.head mode else mode;
|
||||||
in
|
in
|
||||||
if config.vim.keymap._validate."${buf}"."${m}"."${lhs}" == rhs then vars.genConfig
|
if config.vim.keymap._validate."${m}"."${lhs}" == rhs then vars.genConfig
|
||||||
else abort "This case should never happen."
|
else abort "This case should never happen."
|
||||||
))
|
))
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
fnOpts = { name, config, ... }: {
|
fnOpts = { name, config, ... }: {
|
||||||
options = with lib; {
|
options = with lib; {
|
||||||
args = mkOption {
|
args = mkOption {
|
||||||
|
@ -43,10 +42,9 @@ let
|
||||||
|
|
||||||
(lib.flip map innerCfg.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
(lib.flip map innerCfg.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
||||||
let
|
let
|
||||||
buf = lib.optionalString (vars.buffer != null) vars.buffer.raw;
|
|
||||||
m = if builtins.isList mode then lib.head mode else mode;
|
m = if builtins.isList mode then lib.head mode else mode;
|
||||||
in
|
in
|
||||||
if innerCfg.vim.keymap._validate."${buf}"."${m}"."${lhs}" == rhs then vars.genConfig
|
if innerCfg.vim.keymap._validate."${m}"."${lhs}" == rhs then vars.genConfig
|
||||||
else abort "This case should never happen."
|
else abort "This case should never happen."
|
||||||
))
|
))
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -4,8 +4,8 @@ let cfg = config.vim.keymap; in
|
||||||
{
|
{
|
||||||
options.vim.keymap = with lib; {
|
options.vim.keymap = with lib; {
|
||||||
_validate = mkOption {
|
_validate = mkOption {
|
||||||
# buffer mode lhs rhs
|
# mode lhs rhs
|
||||||
type = with types; attrsOf (attrsOf (attrsOf (either str attrs)));
|
type = with types; attrsOf (attrsOf (either str attrs));
|
||||||
visible = false;
|
visible = false;
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
|
@ -29,12 +29,10 @@ let cfg = config.vim.keymap; in
|
||||||
else if m == "l" then [ m "i" "c" "l" ]
|
else if m == "l" then [ m "i" "c" "l" ]
|
||||||
else m
|
else m
|
||||||
)));
|
)));
|
||||||
|
|
||||||
buf = lib.optionalString (buffer != null) buffer.raw;
|
|
||||||
in
|
in
|
||||||
lib.foldl lib.recursiveUpdate { }
|
lib.foldl lib.recursiveUpdate { }
|
||||||
(lib.flip map unwrappedModes (m: {
|
(lib.flip map unwrappedModes (m: {
|
||||||
"${buf}"."${m}"."${lhs}" = rhs;
|
"${m}"."${lhs}" = rhs;
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
cfg.set);
|
cfg.set);
|
||||||
|
|
Loading…
Reference in a new issue