mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-29 20:04:28 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -4,24 +4,25 @@
|
|||
toLuaObject,
|
||||
nixvimUtils,
|
||||
}:
|
||||
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;
|
||||
};
|
||||
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
|
||||
extraOptionsOptions = {
|
||||
extraOptions = mkOption {
|
||||
default = {};
|
||||
default = { };
|
||||
type = with types; attrsOf anything;
|
||||
description = ''
|
||||
These attributes will be added to the table parameter for the setup function.
|
||||
|
@ -30,82 +31,68 @@ with lib; rec {
|
|||
};
|
||||
};
|
||||
|
||||
mkNeovimPlugin = config: {
|
||||
name,
|
||||
maintainers,
|
||||
url ? defaultPackage.meta.homepage,
|
||||
imports ? [],
|
||||
description ? null,
|
||||
# deprecations
|
||||
deprecateExtraOptions ? false,
|
||||
optionsRenamedToSettings ? [],
|
||||
# colorscheme
|
||||
isColorscheme ? false,
|
||||
colorscheme ? name,
|
||||
# options
|
||||
originalName ? name,
|
||||
defaultPackage,
|
||||
settingsOptions ? {},
|
||||
settingsExample ? null,
|
||||
extraOptions ? {},
|
||||
# config
|
||||
luaName ? name,
|
||||
extraConfig ? cfg: {},
|
||||
extraPlugins ? [],
|
||||
extraPackages ? [],
|
||||
callSetup ? true,
|
||||
}: let
|
||||
namespace =
|
||||
if isColorscheme
|
||||
then "colorschemes"
|
||||
else "plugins";
|
||||
in {
|
||||
meta = {
|
||||
inherit maintainers;
|
||||
nixvimInfo = {
|
||||
inherit
|
||||
description
|
||||
name
|
||||
url
|
||||
;
|
||||
kind = namespace;
|
||||
};
|
||||
};
|
||||
|
||||
imports = let
|
||||
basePluginPath = [namespace name];
|
||||
settingsPath = basePluginPath ++ ["settings"];
|
||||
mkNeovimPlugin =
|
||||
config:
|
||||
{
|
||||
name,
|
||||
maintainers,
|
||||
url ? defaultPackage.meta.homepage,
|
||||
imports ? [ ],
|
||||
description ? null,
|
||||
# deprecations
|
||||
deprecateExtraOptions ? false,
|
||||
optionsRenamedToSettings ? [ ],
|
||||
# colorscheme
|
||||
isColorscheme ? false,
|
||||
colorscheme ? name,
|
||||
# options
|
||||
originalName ? name,
|
||||
defaultPackage,
|
||||
settingsOptions ? { },
|
||||
settingsExample ? null,
|
||||
extraOptions ? { },
|
||||
# config
|
||||
luaName ? name,
|
||||
extraConfig ? cfg: { },
|
||||
extraPlugins ? [ ],
|
||||
extraPackages ? [ ],
|
||||
callSetup ? true,
|
||||
}:
|
||||
let
|
||||
namespace = if isColorscheme then "colorschemes" else "plugins";
|
||||
in
|
||||
imports
|
||||
++ (
|
||||
optional
|
||||
deprecateExtraOptions
|
||||
(
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ ["extraOptions"])
|
||||
settingsPath
|
||||
)
|
||||
)
|
||||
++ (
|
||||
map
|
||||
(
|
||||
option: let
|
||||
optionPath =
|
||||
if isString option
|
||||
then [option]
|
||||
else option; # option is already a path (i.e. a list)
|
||||
{
|
||||
meta = {
|
||||
inherit maintainers;
|
||||
nixvimInfo = {
|
||||
inherit description name url;
|
||||
kind = namespace;
|
||||
};
|
||||
};
|
||||
|
||||
imports =
|
||||
let
|
||||
basePluginPath = [
|
||||
namespace
|
||||
name
|
||||
];
|
||||
settingsPath = basePluginPath ++ [ "settings" ];
|
||||
in
|
||||
imports
|
||||
++ (optional deprecateExtraOptions (
|
||||
mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
|
||||
))
|
||||
++ (map (
|
||||
option:
|
||||
let
|
||||
optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
|
||||
|
||||
optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath;
|
||||
in
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ optionPath)
|
||||
(settingsPath ++ optionPathSnakeCase)
|
||||
)
|
||||
optionsRenamedToSettings
|
||||
);
|
||||
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
|
||||
) optionsRenamedToSettings);
|
||||
|
||||
options.${namespace}.${name} =
|
||||
{
|
||||
options.${namespace}.${name} = {
|
||||
enable = mkEnableOption originalName;
|
||||
|
||||
package = nixvimOptions.mkPackageOption originalName defaultPackage;
|
||||
|
@ -115,31 +102,24 @@ with lib; rec {
|
|||
options = settingsOptions;
|
||||
example = settingsExample;
|
||||
};
|
||||
}
|
||||
// extraOptions;
|
||||
} // extraOptions;
|
||||
|
||||
config = let
|
||||
cfg = config.${namespace}.${name};
|
||||
extraConfigNamespace =
|
||||
if isColorscheme
|
||||
then "extraConfigLuaPre"
|
||||
else "extraConfigLua";
|
||||
in
|
||||
mkIf cfg.enable (
|
||||
mkMerge [
|
||||
config =
|
||||
let
|
||||
cfg = config.${namespace}.${name};
|
||||
extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua";
|
||||
in
|
||||
mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
extraPlugins = [cfg.package] ++ extraPlugins;
|
||||
extraPlugins = [ cfg.package ] ++ extraPlugins;
|
||||
inherit extraPackages;
|
||||
|
||||
${extraConfigNamespace} = optionalString callSetup ''
|
||||
require('${luaName}').setup(${toLuaObject cfg.settings})
|
||||
'';
|
||||
}
|
||||
(optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||
inherit colorscheme;
|
||||
})
|
||||
(optionalAttrs (isColorscheme && (colorscheme != null)) { inherit colorscheme; })
|
||||
(extraConfig cfg)
|
||||
]
|
||||
);
|
||||
};
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue