lib/neovim-plugin: Add lua configuration scoped to the plugin

This commit adds a `plugins.<name>.luaConfig` section controlling the
plugin specific configuration.

The section contains the internal `init` option, containing the plugin's
initialization code.

It also contains the public `pre` and `post` options, that allow to add
code before & after the `init` section

Finally, it contains the `final` option, being the concatenation of the
three previous options.
This commit is contained in:
Quentin Boyer 2024-08-19 23:31:57 +02:00 committed by nix-infra-bot
parent 2bc6a94992
commit d2f9e011d9
21 changed files with 129 additions and 35 deletions

View file

@ -113,4 +113,38 @@ rec {
types.optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
}";
};
pluginLuaConfig = types.submodule (
{ config, ... }:
{
options = {
pre = lib.mkOption {
type = types.lines;
default = "";
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 = "";
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`.
'';
};
content = lib.mkOption {
type = types.lines;
default = "";
description = "Configuration of the plugin";
};
};
config.content = lib.mkMerge [
(lib.nixvim.utils.mkBeforeSection config.pre)
(lib.nixvim.utils.mkAfterSection config.post)
];
}
);
}