Skip to content

Commit 922b622

Browse files
committed
utility/telescope: concat extension setup sets
1 parent 6594409 commit 922b622

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

modules/plugins/utility/telescope/telescope.nix

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
2+
config,
23
pkgs,
34
lib,
45
...
56
}: let
6-
inherit (lib.options) mkEnableOption mkOption;
7+
inherit (lib.options) mkOption mkEnableOption literalExpression;
78
inherit (lib.types) int str listOf float bool either enum submodule attrsOf anything package;
89
inherit (lib.nvim.binds) mkMappingOption;
910
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
11+
12+
cfg = config.telescope;
1013
setupOptions = {
1114
defaults = {
1215
vimgrep_arguments = mkOption {
@@ -33,7 +36,7 @@
3336
type = either (listOf str) luaInline;
3437
default = ["${pkgs.fd}/bin/fd"];
3538
description = ''
36-
Command to use for finding files. If using an executable from `PATH` then you must
39+
Command to use for finding files. If using an executable from {env}`PATH` then you must
3740
make sure that the package is available in [](#opt-vim.extraPackages).
3841
'';
3942
};
@@ -90,34 +93,40 @@
9093
type = str;
9194
default = "top";
9295
};
96+
9397
preview_width = mkOption {
9498
description = "";
9599
type = float;
96100
default = 0.55;
97101
};
102+
98103
results_width = mkOption {
99104
description = "";
100105
type = float;
101106
default = 0.8;
102107
};
103108
};
109+
104110
vertical = {
105111
mirror = mkOption {
106112
description = "";
107113
type = bool;
108114
default = false;
109115
};
110116
};
117+
111118
width = mkOption {
112119
description = "";
113120
type = float;
114121
default = 0.8;
115122
};
123+
116124
height = mkOption {
117125
description = "";
118126
type = float;
119127
default = 0.8;
120128
};
129+
121130
preview_cutoff = mkOption {
122131
description = "";
123132
type = int;
@@ -162,6 +171,12 @@
162171
default = 0;
163172
description = "pseudo-transparency of keymap hints floating window";
164173
};
174+
175+
extensions = mkOption {
176+
type = attrsOf anything;
177+
default = builtins.foldl' (acc: x: acc // (x.setup or {})) {} cfg.extensions;
178+
description = "Attribute set containing per-extension settings for Telescope";
179+
};
165180
};
166181
};
167182

@@ -177,6 +192,13 @@
177192
default = [];
178193
description = "Package or packages providing the Telescope extension to be loaded.";
179194
};
195+
196+
setup = mkOption {
197+
type = attrsOf anything;
198+
default = {};
199+
example = {fzf = {fuzzy = true;};};
200+
description = "Named attribute set to be inserted into Telescope's extensions table.";
201+
};
180202
};
181203
};
182204
in {
@@ -210,10 +232,24 @@ in {
210232
enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";
211233

212234
setupOpts = mkPluginSetupOption "Telescope" setupOptions;
235+
213236
extensions = mkOption {
214237
type = listOf (attrsOf (submodule extensionOpts));
215238
default = [];
216-
description = "TODO";
239+
example = literalExpression ''
240+
[
241+
{
242+
name = "fzf";
243+
packages = [pkgs.vimPlugins.telescope-fzf-native-nvim];
244+
setup = {fzf = {fuzzy = true;};};
245+
}
246+
]
247+
'';
248+
description = ''
249+
Individual extension configurations containing **name**, **packages** and **setup**
250+
fields to resolve dependencies, handle `load_extension` calls and add the `setup`
251+
table into the `extensions` portion of Telescope's setup table.
252+
'';
217253
};
218254
};
219255
}

0 commit comments

Comments
 (0)