mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +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 =
|
||||
{
|
||||
# Allow overriding defaults for key, action, mode, etc
|
||||
defaults ? { },
|
||||
|
||||
# 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.
|
||||
key ? true,
|
||||
action ? true,
|
||||
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;
|
||||
submodule (
|
||||
{ config, options, ... }:
|
||||
{
|
||||
imports = extraModules;
|
||||
|
||||
options =
|
||||
(optionalAttrs (isAttrs key || key) {
|
||||
key = mkOption (
|
||||
|
@ -135,7 +144,8 @@ rec {
|
|||
// {
|
||||
mode = mkModeOption defaults.mode or "";
|
||||
options = mapConfigOptions;
|
||||
};
|
||||
}
|
||||
// extraOptions;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue