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