mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
helpers/keymaps: add mkMapOptionsSubmodule
This commit is contained in:
parent
798cbe99ce
commit
b3fb1c4c81
1 changed files with 25 additions and 15 deletions
|
@ -77,16 +77,21 @@ in rec {
|
||||||
(attrValues modes)
|
(attrValues modes)
|
||||||
);
|
);
|
||||||
|
|
||||||
# TODO: When `maps` will have to be deprecated (early December 2023), change this.
|
mapOptionSubmodule = mkMapOptionSubmodule {};
|
||||||
# mapOptionSubmodule = {...} (no need for options... except for 'optionalAction')
|
|
||||||
mapOptionSubmodule = with types;
|
mkMapOptionSubmodule = defaults: (with types;
|
||||||
submodule {
|
submodule {
|
||||||
options = {
|
options = {
|
||||||
key = mkOption {
|
key = mkOption ({
|
||||||
type = str;
|
type = str;
|
||||||
description = "The key to map.";
|
description = "The key to map.";
|
||||||
example = "<C-m>";
|
example = "<C-m>";
|
||||||
};
|
}
|
||||||
|
// (
|
||||||
|
optionalAttrs
|
||||||
|
(defaults ? key)
|
||||||
|
{default = defaults.key;}
|
||||||
|
));
|
||||||
|
|
||||||
mode = mkOption {
|
mode = mkOption {
|
||||||
type = either modeEnum (listOf modeEnum);
|
type = either modeEnum (listOf modeEnum);
|
||||||
|
@ -95,14 +100,19 @@ in rec {
|
||||||
Use the short-names (`"n"`, `"v"`, ...).
|
Use the short-names (`"n"`, `"v"`, ...).
|
||||||
See `:h map-modes` to learn more.
|
See `:h map-modes` to learn more.
|
||||||
'';
|
'';
|
||||||
default = "";
|
default = defaults.mode or "";
|
||||||
example = ["n" "v"];
|
example = ["n" "v"];
|
||||||
};
|
};
|
||||||
|
|
||||||
action = mkOption {
|
action = mkOption ({
|
||||||
type = str;
|
type = str;
|
||||||
description = "The action to execute.";
|
description = "The action to execute.";
|
||||||
};
|
}
|
||||||
|
// (
|
||||||
|
optionalAttrs
|
||||||
|
(defaults ? action)
|
||||||
|
{default = defaults.action;}
|
||||||
|
));
|
||||||
|
|
||||||
lua = mkOption {
|
lua = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
|
@ -110,12 +120,12 @@ in rec {
|
||||||
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 `""`.
|
||||||
'';
|
'';
|
||||||
default = false;
|
default = defaults.lua or false;
|
||||||
};
|
};
|
||||||
|
|
||||||
options = mapConfigOptions;
|
options = mapConfigOptions;
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
|
|
||||||
# Correctly merge two attrs (partially) representing a mapping.
|
# Correctly merge two attrs (partially) representing a mapping.
|
||||||
mergeKeymap = defaults: keymap: let
|
mergeKeymap = defaults: keymap: let
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue