mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
lib/neovim-plugin: allow overriding settings description
- The `setup` function name can be overridden with `setup` (default ".setup") - The entire `settings` option description can be overridden with `settingsDescription` - `luaName` and `setup` are used in the default description
This commit is contained in:
parent
c351c175ec
commit
7c35bdb3f7
2 changed files with 9 additions and 19 deletions
|
@ -5,20 +5,7 @@
|
||||||
nixvimUtils,
|
nixvimUtils,
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
rec {
|
|
||||||
mkSettingsOption =
|
|
||||||
{
|
{
|
||||||
pluginName ? null,
|
|
||||||
options ? { },
|
|
||||||
description ?
|
|
||||||
if pluginName != null then
|
|
||||||
"Options provided to the `require('${pluginName}').setup` function."
|
|
||||||
else
|
|
||||||
throw "mkSettingsOption: Please provide either a `pluginName` or `description`.",
|
|
||||||
example ? null,
|
|
||||||
}:
|
|
||||||
nixvimOptions.mkSettingsOption { inherit options description example; };
|
|
||||||
|
|
||||||
# TODO: DEPRECATED: use the `settings` option instead
|
# TODO: DEPRECATED: use the `settings` option instead
|
||||||
extraOptionsOptions = {
|
extraOptionsOptions = {
|
||||||
extraOptions = mkOption {
|
extraOptions = mkOption {
|
||||||
|
@ -50,10 +37,12 @@ rec {
|
||||||
defaultPackage,
|
defaultPackage,
|
||||||
settingsOptions ? { },
|
settingsOptions ? { },
|
||||||
settingsExample ? null,
|
settingsExample ? null,
|
||||||
|
settingsDescription ? "Options provided to the `require('${luaName}')${setup}` function.",
|
||||||
hasSettings ? true,
|
hasSettings ? true,
|
||||||
extraOptions ? { },
|
extraOptions ? { },
|
||||||
# config
|
# config
|
||||||
luaName ? name,
|
luaName ? name,
|
||||||
|
setup ? ".setup",
|
||||||
extraConfig ? cfg: { },
|
extraConfig ? cfg: { },
|
||||||
extraPlugins ? [ ],
|
extraPlugins ? [ ],
|
||||||
extraPackages ? [ ],
|
extraPackages ? [ ],
|
||||||
|
@ -99,11 +88,12 @@ rec {
|
||||||
options.${namespace}.${name} =
|
options.${namespace}.${name} =
|
||||||
{
|
{
|
||||||
enable = mkEnableOption originalName;
|
enable = mkEnableOption originalName;
|
||||||
|
|
||||||
package = nixvimOptions.mkPluginPackageOption originalName defaultPackage;
|
package = nixvimOptions.mkPluginPackageOption originalName defaultPackage;
|
||||||
}
|
}
|
||||||
// optionalAttrs hasSettings {
|
// optionalAttrs hasSettings {
|
||||||
settings = mkSettingsOption {
|
settings = nixvimOptions.mkSettingsOption {
|
||||||
pluginName = name;
|
description = settingsDescription;
|
||||||
options = settingsOptions;
|
options = settingsOptions;
|
||||||
example = settingsExample;
|
example = settingsExample;
|
||||||
};
|
};
|
||||||
|
@ -121,7 +111,7 @@ rec {
|
||||||
inherit extraPackages;
|
inherit extraPackages;
|
||||||
|
|
||||||
${extraConfigNamespace} = optionalString callSetup ''
|
${extraConfigNamespace} = optionalString callSetup ''
|
||||||
require('${luaName}').setup(${optionalString (cfg ? settings) (toLuaObject cfg.settings)})
|
require('${luaName}')${setup}(${optionalString (cfg ? settings) (toLuaObject cfg.settings)})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
|
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
|
||||||
|
|
|
@ -15,8 +15,8 @@ let
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.cmp-git.settings = helpers.neovim-plugin.mkSettingsOption {
|
options.plugins.cmp-git.settings = helpers.mkSettingsOption {
|
||||||
pluginName = "cmp_git";
|
description = "Options provided to the `require('cmp_git').setup` function.";
|
||||||
options = {
|
options = {
|
||||||
filetypes = helpers.defaultNullOpts.mkListOf types.str [
|
filetypes = helpers.defaultNullOpts.mkListOf types.str [
|
||||||
"gitcommit"
|
"gitcommit"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue