mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
lib/types/pluginLuaConfig: only merge pre
and post
when defined
- Have them default to `null` - Only merge them into `content` when non-null - Mention this in `content`'s description
This commit is contained in:
parent
d2f9e011d9
commit
76df09619d
1 changed files with 17 additions and 7 deletions
|
@ -116,19 +116,23 @@ rec {
|
||||||
|
|
||||||
pluginLuaConfig = types.submodule (
|
pluginLuaConfig = types.submodule (
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
inherit (builtins) toString;
|
||||||
|
inherit (lib.nixvim.utils) mkBeforeSection mkAfterSection;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
pre = lib.mkOption {
|
pre = lib.mkOption {
|
||||||
type = types.lines;
|
type = with types; nullOr lines;
|
||||||
default = "";
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Lua code inserted at the start of the plugin's configuration.
|
Lua code inserted at the start of the plugin's configuration.
|
||||||
This is the same as using `lib.nixvim.utils.mkBeforeSection` when defining `content`.
|
This is the same as using `lib.nixvim.utils.mkBeforeSection` when defining `content`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
post = lib.mkOption {
|
post = lib.mkOption {
|
||||||
type = types.lines;
|
type = with types; nullOr lines;
|
||||||
default = "";
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Lua code inserted at the end of the plugin's configuration.
|
Lua code inserted at the end of the plugin's configuration.
|
||||||
This is the same as using `lib.nixvim.utils.mkAfterSection` when defining `content`.
|
This is the same as using `lib.nixvim.utils.mkAfterSection` when defining `content`.
|
||||||
|
@ -137,13 +141,19 @@ rec {
|
||||||
content = lib.mkOption {
|
content = lib.mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
description = "Configuration of the plugin";
|
description = ''
|
||||||
|
Configuration of the plugin.
|
||||||
|
|
||||||
|
If `pre` and/or `post` are non-null, they will be merged using the order priorities
|
||||||
|
${toString (mkBeforeSection null).priority} and ${toString (mkBeforeSection null).priority}
|
||||||
|
respectively.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.content = lib.mkMerge [
|
config.content = lib.mkMerge [
|
||||||
(lib.nixvim.utils.mkBeforeSection config.pre)
|
(lib.mkIf (config.pre != null) (mkBeforeSection config.pre))
|
||||||
(lib.nixvim.utils.mkAfterSection config.post)
|
(lib.mkIf (config.post != null) (mkAfterSection config.post))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue