mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/keymaps: fix false-positive lua
warning
This commit is contained in:
parent
db32a4ebda
commit
29922e13f7
2 changed files with 12 additions and 4 deletions
|
@ -80,6 +80,9 @@ rec {
|
||||||
|
|
||||||
mkMapOptionSubmodule =
|
mkMapOptionSubmodule =
|
||||||
defaults:
|
defaults:
|
||||||
|
# TODO remove assert once `lua` option is gone
|
||||||
|
# This is here to ensure no uses of `mkMapOptionSubmodule` set a `lua` default
|
||||||
|
assert !(defaults ? lua);
|
||||||
(
|
(
|
||||||
with types;
|
with types;
|
||||||
submodule {
|
submodule {
|
||||||
|
@ -104,7 +107,7 @@ rec {
|
||||||
);
|
);
|
||||||
|
|
||||||
lua = mkOption {
|
lua = mkOption {
|
||||||
type = bool;
|
type = nullOr bool;
|
||||||
description = ''
|
description = ''
|
||||||
If true, `action` is considered to be lua code.
|
If true, `action` is considered to be lua code.
|
||||||
Thus, it will not be wrapped in `""`.
|
Thus, it will not be wrapped in `""`.
|
||||||
|
@ -112,7 +115,7 @@ rec {
|
||||||
This option is deprecated and will be removed in 24.11.
|
This option is deprecated and will be removed in 24.11.
|
||||||
You should use a "raw" action instead, e.g. `action.__raw = ""`.
|
You should use a "raw" action instead, e.g. `action.__raw = ""`.
|
||||||
'';
|
'';
|
||||||
default = defaults.lua or false;
|
default = null;
|
||||||
visible = false;
|
visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,15 @@ with lib;
|
||||||
|
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
|
# TODO remove `normalizeMapping` once `lua` option is gone
|
||||||
normalizeMapping = keyMapping: {
|
normalizeMapping = keyMapping: {
|
||||||
inherit (keyMapping) mode key options;
|
inherit (keyMapping) mode key options;
|
||||||
|
|
||||||
action = if keyMapping.lua then helpers.mkRaw keyMapping.action else keyMapping.action;
|
action =
|
||||||
|
if keyMapping.lua != null && keyMapping.lua then
|
||||||
|
helpers.mkRaw keyMapping.action
|
||||||
|
else
|
||||||
|
keyMapping.action;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -59,7 +64,7 @@ with lib;
|
||||||
luaDefs = pipe options.keymaps.definitionsWithLocations [
|
luaDefs = pipe options.keymaps.definitionsWithLocations [
|
||||||
(map (def: {
|
(map (def: {
|
||||||
inherit (def) file;
|
inherit (def) file;
|
||||||
value = filter (hasAttr "lua") def.value;
|
value = filter (v: (v.lua or null) != null) def.value;
|
||||||
}))
|
}))
|
||||||
(filter (def: def.value != [ ]))
|
(filter (def: def.value != [ ]))
|
||||||
(map (
|
(map (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue