mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
lib/keymap: allow extra options/modules in mkMapOptionSubmodule
This is needed to allow plugins to add bespoke features to their keymap submodules without having to re-implement the whole thing.
This commit is contained in:
parent
7fb1f9dd9d
commit
7a11b66f11
1 changed files with 11 additions and 1 deletions
|
@ -82,17 +82,26 @@ rec {
|
||||||
|
|
||||||
mkMapOptionSubmodule =
|
mkMapOptionSubmodule =
|
||||||
{
|
{
|
||||||
|
# Allow overriding defaults for key, action, mode, etc
|
||||||
defaults ? { },
|
defaults ? { },
|
||||||
|
|
||||||
# key and action can be true/false to enable/disable adding the option,
|
# key and action can be true/false to enable/disable adding the option,
|
||||||
# or an attrset to enable the option and add/override mkOption args.
|
# or an attrset to enable the option and add/override mkOption args.
|
||||||
key ? true,
|
key ? true,
|
||||||
action ? true,
|
action ? true,
|
||||||
lua ? false, # WARNING: for historic use only - do not use in new options!
|
lua ? false, # WARNING: for historic use only - do not use in new options!
|
||||||
|
|
||||||
|
# Allow passing additional options or modules to the submodule
|
||||||
|
# Useful for plugin-specific features
|
||||||
|
extraOptions ? { },
|
||||||
|
extraModules ? [ ],
|
||||||
}:
|
}:
|
||||||
with types;
|
with types;
|
||||||
submodule (
|
submodule (
|
||||||
{ config, options, ... }:
|
{ config, options, ... }:
|
||||||
{
|
{
|
||||||
|
imports = extraModules;
|
||||||
|
|
||||||
options =
|
options =
|
||||||
(optionalAttrs (isAttrs key || key) {
|
(optionalAttrs (isAttrs key || key) {
|
||||||
key = mkOption (
|
key = mkOption (
|
||||||
|
@ -135,7 +144,8 @@ rec {
|
||||||
// {
|
// {
|
||||||
mode = mkModeOption defaults.mode or "";
|
mode = mkModeOption defaults.mode or "";
|
||||||
options = mapConfigOptions;
|
options = mapConfigOptions;
|
||||||
};
|
}
|
||||||
|
// extraOptions;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue