utility/telescope: add custom extensions API; clean up setupOptions

This commit is contained in:
raf 2025-01-14 16:45:08 +03:00
commit 6594409a25
No known key found for this signature in database
GPG key ID: EED98D11B85A2819
2 changed files with 71 additions and 31 deletions

View file

@ -5,8 +5,8 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.lists) optionals;
inherit (lib.strings) optionalString concatMapStringsSep;
inherit (lib.lists) optionals concatLists;
inherit (lib.nvim.binds) pushDownDefault mkKeymap;
cfg = config.vim.telescope;
@ -16,7 +16,7 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["plenary-nvim"];
startPlugins = ["plenary-nvim"] ++ concatLists (map (x: x.packages) cfg.extensions);
lazy.plugins.telescope = {
package = "telescope";
@ -28,11 +28,14 @@ in {
vim.g.loaded_telescope = nil
'';
after = ''
after = let
enabledExtensions = map (x: x.name) cfg.extensions;
in ''
local telescope = require("telescope")
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"}
${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"}
${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"}
${concatMapStringsSep "\n" (x: "telescope.load_extension('${x}')") enabledExtensions}
'';
cmd = ["Telescope"];