mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-27 11:08:53 +02:00
86 lines
1.9 KiB
Nix
86 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
|
||
|
builtins.map (
|
||
|
option:
|
||
|
let
|
||
|
optionPath = lib.toList option;
|
||
|
optionPathSnakeCase = map lib.nixvim.toSnakeCase optionPath;
|
||
|
in
|
||
|
lib.mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
|
||
|
) 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 = { config, ... }: extraConfig (getPluginAttr config);
|
||
|
in
|
||
|
{
|
||
|
imports = imports ++ [
|
||
|
module
|
||
|
extraConfigModule
|
||
|
renameModule
|
||
|
];
|
||
|
}
|