mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +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 (
|
||||
{ config, ... }:
|
||||
let
|
||||
inherit (builtins) toString;
|
||||
inherit (lib.nixvim.utils) mkBeforeSection mkAfterSection;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
pre = lib.mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
type = with types; nullOr lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Lua code inserted at the start of the plugin's configuration.
|
||||
This is the same as using `lib.nixvim.utils.mkBeforeSection` when defining `content`.
|
||||
'';
|
||||
};
|
||||
post = lib.mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
type = with types; nullOr lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Lua code inserted at the end of the plugin's configuration.
|
||||
This is the same as using `lib.nixvim.utils.mkAfterSection` when defining `content`.
|
||||
|
@ -137,13 +141,19 @@ rec {
|
|||
content = lib.mkOption {
|
||||
type = types.lines;
|
||||
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 [
|
||||
(lib.nixvim.utils.mkBeforeSection config.pre)
|
||||
(lib.nixvim.utils.mkAfterSection config.post)
|
||||
(lib.mkIf (config.pre != null) (mkBeforeSection config.pre))
|
||||
(lib.mkIf (config.post != null) (mkAfterSection config.post))
|
||||
];
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue