helpers/keymaps: factor out mkModeOption

This commit is contained in:
Gaetan Lepage 2024-02-14 22:18:27 +01:00 committed by Gaétan Lepage
parent 7edffe3896
commit 28d4d2a842

View file

@ -81,6 +81,21 @@ with lib; rec {
mapOptionSubmodule = mkMapOptionSubmodule {}; mapOptionSubmodule = mkMapOptionSubmodule {};
mkModeOption = default:
mkOption {
type = with types;
either
modeEnum
(listOf modeEnum);
description = ''
One or several modes.
Use the short-names (`"n"`, `"v"`, ...).
See `:h map-modes` to learn more.
'';
inherit default;
example = ["n" "v"];
};
mkMapOptionSubmodule = defaults: (with types; mkMapOptionSubmodule = defaults: (with types;
submodule { submodule {
options = { options = {
@ -95,16 +110,7 @@ with lib; rec {
{default = defaults.key;} {default = defaults.key;}
)); ));
mode = mkOption { mode = mkModeOption defaults.mode or "";
type = either modeEnum (listOf modeEnum);
description = ''
One or several modes.
Use the short-names (`"n"`, `"v"`, ...).
See `:h map-modes` to learn more.
'';
default = defaults.mode or "";
example = ["n" "v"];
};
action = mkOption ({ action = mkOption ({
type = nixvimTypes.maybeRaw str; type = nixvimTypes.maybeRaw str;