mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 17:58:38 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -3,56 +3,51 @@
|
|||
nixvimOptions,
|
||||
nixvimUtils,
|
||||
}:
|
||||
with lib; {
|
||||
mkVimPlugin = config: {
|
||||
name,
|
||||
url ?
|
||||
if defaultPackage != null
|
||||
then defaultPackage.meta.homepage
|
||||
else null,
|
||||
maintainers,
|
||||
imports ? [],
|
||||
description ? null,
|
||||
# deprecations
|
||||
deprecateExtraConfig ? false,
|
||||
optionsRenamedToSettings ? [],
|
||||
# colorscheme
|
||||
isColorscheme ? false,
|
||||
colorscheme ? name,
|
||||
# options
|
||||
originalName ? name,
|
||||
defaultPackage ? null,
|
||||
settingsOptions ? {},
|
||||
settingsExample ? null,
|
||||
globalPrefix ? "",
|
||||
extraOptions ? {},
|
||||
# config
|
||||
extraConfig ? cfg: {},
|
||||
extraPlugins ? [],
|
||||
extraPackages ? [],
|
||||
}: let
|
||||
namespace =
|
||||
if isColorscheme
|
||||
then "colorschemes"
|
||||
else "plugins";
|
||||
with lib;
|
||||
{
|
||||
mkVimPlugin =
|
||||
config:
|
||||
{
|
||||
name,
|
||||
url ? if defaultPackage != null then defaultPackage.meta.homepage else null,
|
||||
maintainers,
|
||||
imports ? [ ],
|
||||
description ? null,
|
||||
# deprecations
|
||||
deprecateExtraConfig ? false,
|
||||
optionsRenamedToSettings ? [ ],
|
||||
# colorscheme
|
||||
isColorscheme ? false,
|
||||
colorscheme ? name,
|
||||
# options
|
||||
originalName ? name,
|
||||
defaultPackage ? null,
|
||||
settingsOptions ? { },
|
||||
settingsExample ? null,
|
||||
globalPrefix ? "",
|
||||
extraOptions ? { },
|
||||
# config
|
||||
extraConfig ? cfg: { },
|
||||
extraPlugins ? [ ],
|
||||
extraPackages ? [ ],
|
||||
}:
|
||||
let
|
||||
namespace = if isColorscheme then "colorschemes" else "plugins";
|
||||
|
||||
cfg = config.${namespace}.${name};
|
||||
cfg = config.${namespace}.${name};
|
||||
|
||||
globals = cfg.settings or {};
|
||||
globals = cfg.settings or { };
|
||||
|
||||
# does this evaluate package?
|
||||
packageOption =
|
||||
if defaultPackage == null
|
||||
then {}
|
||||
else {
|
||||
package = nixvimOptions.mkPackageOption name defaultPackage;
|
||||
};
|
||||
# does this evaluate package?
|
||||
packageOption =
|
||||
if defaultPackage == null then
|
||||
{ }
|
||||
else
|
||||
{ package = nixvimOptions.mkPackageOption name defaultPackage; };
|
||||
|
||||
createSettingsOption = (isString globalPrefix) && (globalPrefix != "");
|
||||
createSettingsOption = (isString globalPrefix) && (globalPrefix != "");
|
||||
|
||||
settingsOption =
|
||||
optionalAttrs createSettingsOption
|
||||
{
|
||||
settingsOption = optionalAttrs createSettingsOption {
|
||||
settings = nixvimOptions.mkSettingsOption {
|
||||
options = settingsOptions;
|
||||
example = settingsExample;
|
||||
|
@ -68,73 +63,50 @@ with lib; {
|
|||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
meta = {
|
||||
inherit maintainers;
|
||||
nixvimInfo = {
|
||||
inherit
|
||||
description
|
||||
name
|
||||
url
|
||||
;
|
||||
kind = namespace;
|
||||
};
|
||||
};
|
||||
options.${namespace}.${name} =
|
||||
{
|
||||
enable = mkEnableOption originalName;
|
||||
}
|
||||
// settingsOption
|
||||
// packageOption
|
||||
// extraOptions;
|
||||
|
||||
imports = let
|
||||
basePluginPath = [namespace name];
|
||||
settingsPath = basePluginPath ++ ["settings"];
|
||||
in
|
||||
imports
|
||||
++ (
|
||||
optional
|
||||
(deprecateExtraConfig && createSettingsOption)
|
||||
(
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ ["extraConfig"])
|
||||
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;
|
||||
};
|
||||
};
|
||||
options.${namespace}.${name} = {
|
||||
enable = mkEnableOption originalName;
|
||||
} // settingsOption // packageOption // extraOptions;
|
||||
|
||||
imports =
|
||||
let
|
||||
basePluginPath = [
|
||||
namespace
|
||||
name
|
||||
];
|
||||
settingsPath = basePluginPath ++ [ "settings" ];
|
||||
in
|
||||
imports
|
||||
++ (optional (deprecateExtraConfig && createSettingsOption) (
|
||||
mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) 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);
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
(
|
||||
mkMerge [
|
||||
{
|
||||
inherit extraPackages;
|
||||
globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals;
|
||||
# does this evaluate package? it would not be desired to evaluate package if we use another package.
|
||||
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
|
||||
}
|
||||
(optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||
inherit colorscheme;
|
||||
})
|
||||
(extraConfig cfg)
|
||||
]
|
||||
);
|
||||
};
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
inherit extraPackages;
|
||||
globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals;
|
||||
# does this evaluate package? it would not be desired to evaluate package if we use another package.
|
||||
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
|
||||
}
|
||||
(optionalAttrs (isColorscheme && (colorscheme != null)) { inherit colorscheme; })
|
||||
(extraConfig cfg)
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue