mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-26 18:58:43 +02:00
These util functions were previously defined in `modules`, but `plugins.utils` is a better home.
89 lines
1.9 KiB
Nix
89 lines
1.9 KiB
Nix
{
|
|
name,
|
|
package,
|
|
extensionName ? name,
|
|
settingsOptions ? { },
|
|
settingsExample ? null,
|
|
extraOptions ? { },
|
|
imports ? [ ],
|
|
optionsRenamedToSettings ? [ ],
|
|
extraConfig ? cfg: { },
|
|
}:
|
|
let
|
|
getPluginAttr = attrs: attrs.plugins.telescope.extensions.${name};
|
|
|
|
renameModule =
|
|
{ lib, ... }:
|
|
{
|
|
# TODO remove this once all deprecation warnings will have been removed.
|
|
imports =
|
|
let
|
|
basePluginPath = [
|
|
"plugins"
|
|
"telescope"
|
|
"extensions"
|
|
name
|
|
];
|
|
settingsPath = basePluginPath ++ [ "settings" ];
|
|
in
|
|
lib.nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings;
|
|
};
|
|
|
|
module =
|
|
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = getPluginAttr config;
|
|
in
|
|
{
|
|
options.plugins.telescope.extensions.${name} = {
|
|
enable = lib.mkEnableOption "the `${name}` telescope extension";
|
|
|
|
package = lib.mkPackageOption pkgs name {
|
|
default = [
|
|
"vimPlugins"
|
|
package
|
|
];
|
|
};
|
|
|
|
settings = lib.nixvim.mkSettingsOption {
|
|
description = "settings for the `${name}` telescope extension.";
|
|
options = settingsOptions;
|
|
example = settingsExample;
|
|
};
|
|
} // extraOptions;
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
plugins.telescope = {
|
|
enabledExtensions = [ extensionName ];
|
|
settings.extensions.${extensionName} = cfg.settings;
|
|
};
|
|
};
|
|
};
|
|
|
|
extraConfigModule =
|
|
{
|
|
lib,
|
|
config,
|
|
options,
|
|
...
|
|
}:
|
|
lib.nixvim.plugins.utils.applyExtraConfig {
|
|
inherit extraConfig;
|
|
cfg = getPluginAttr config;
|
|
opts = getPluginAttr options;
|
|
};
|
|
in
|
|
{
|
|
imports = imports ++ [
|
|
module
|
|
extraConfigModule
|
|
renameModule
|
|
];
|
|
}
|