{ options, config, lib, ... }: let inherit (lib.modules) mkIf; inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.strings) optionalString; inherit (lib.lists) optionals; inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding; cfg = config.vim.telescope; mappingDefinitions = options.vim.telescope.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { vim = { startPlugins = ["plenary-nvim"]; lazy.plugins.telescope = { package = "telescope"; setupModule = "telescope"; inherit (cfg) setupOpts; # FIXME: how do I deal with extensions? set all as deps? after = '' 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')"} ''; cmd = ["Telescope"]; keys = [ (mkSetLznBinding mappings.findFiles " Telescope find_files") (mkSetLznBinding mappings.liveGrep " Telescope live_grep") (mkSetLznBinding mappings.buffers " Telescope buffers") (mkSetLznBinding mappings.helpTags " Telescope help_tags") (mkSetLznBinding mappings.open " Telescope") (mkSetLznBinding mappings.gitCommits " Telescope git_commits") (mkSetLznBinding mappings.gitBufferCommits " Telescope git_bcommits") (mkSetLznBinding mappings.gitBranches " Telescope git_branches") (mkSetLznBinding mappings.gitStatus " Telescope git_status") (mkSetLznBinding mappings.gitStash " Telescope git_stash") ] ++ (optionals config.vim.lsp.enable [ (mkSetLznBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") (mkSetLznBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") (mkSetLznBinding mappings.lspReferences " Telescope lsp_references") (mkSetLznBinding mappings.lspImplementations " Telescope lsp_implementations") (mkSetLznBinding mappings.lspDefinitions " Telescope lsp_definitions") (mkSetLznBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") (mkSetLznBinding mappings.diagnostics " Telescope diagnostics") ]) ++ ( optionals config.vim.treesitter.enable [ (mkSetLznBinding mappings.treesitter " Telescope treesitter") ] ) ++ ( optionals config.vim.projects.project-nvim.enable [ (mkSetLznBinding mappings.findProjects "") ] ); }; binds.whichKey.register = pushDownDefault { "f" = "+Telescope"; "fl" = "Telescope LSP"; "fm" = "Cellular Automaton"; "fv" = "Telescope Git"; "fvc" = "Commits"; }; }; }; }