From fed9f348c20de1df2ae3a9c2460f62e9f0d5a935 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 17 Nov 2024 19:31:55 +0100 Subject: [PATCH] telescope: switch to simpler keybind helper --- modules/plugins/utility/telescope/config.nix | 59 +++++++++----------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/modules/plugins/utility/telescope/config.nix b/modules/plugins/utility/telescope/config.nix index c94fe901..76cfa8bd 100644 --- a/modules/plugins/utility/telescope/config.nix +++ b/modules/plugins/utility/telescope/config.nix @@ -5,15 +5,14 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.strings) optionalString; inherit (lib.lists) optionals; - inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding; + inherit (lib.nvim.binds) pushDownDefault mkKeymap; cfg = config.vim.telescope; - mappingDefinitions = options.vim.telescope.mappings; - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; + keys = cfg.mappings; + inherit (options.vim.telescope) mappings; in { config = mkIf cfg.enable { vim = { @@ -34,39 +33,35 @@ in { keys = [ - (mkSetLznBinding "n" mappings.findFiles "Telescope find_files") - (mkSetLznBinding "n" mappings.liveGrep "Telescope live_grep") - (mkSetLznBinding "n" mappings.buffers "Telescope buffers") - (mkSetLznBinding "n" mappings.helpTags "Telescope help_tags") - (mkSetLznBinding "n" mappings.open "Telescope") - (mkSetLznBinding "n" mappings.resume "Telescope resume") + (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;}) - (mkSetLznBinding "n" mappings.gitCommits "Telescope git_commits") - (mkSetLznBinding "n" mappings.gitBufferCommits "Telescope git_bcommits") - (mkSetLznBinding "n" mappings.gitBranches "Telescope git_branches") - (mkSetLznBinding "n" mappings.gitStatus "Telescope git_status") - (mkSetLznBinding "n" mappings.gitStash "Telescope git_stash") + (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 [ - (mkSetLznBinding "n" mappings.lspDocumentSymbols "Telescope lsp_document_symbols") - (mkSetLznBinding "n" mappings.lspWorkspaceSymbols "Telescope lsp_workspace_symbols") + (mkKeymap "n" keys.lspDocumentSymbols "Telescope lsp_document_symbols" {desc = mappings.lspDocumentSymbols.description;}) + (mkKeymap "n" keys.lspWorkspaceSymbols "Telescope lsp_workspace_symbols" {desc = mappings.lspWorkspaceSymbols.description;}) - (mkSetLznBinding "n" mappings.lspReferences "Telescope lsp_references") - (mkSetLznBinding "n" mappings.lspImplementations "Telescope lsp_implementations") - (mkSetLznBinding "n" mappings.lspDefinitions "Telescope lsp_definitions") - (mkSetLznBinding "n" mappings.lspTypeDefinitions "Telescope lsp_type_definitions") - (mkSetLznBinding "n" mappings.diagnostics "Telescope diagnostics") + (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 [ - (mkSetLznBinding "n" mappings.treesitter "Telescope treesitter") - ] - ) - ++ ( - optionals config.vim.projects.project-nvim.enable [ - (mkSetLznBinding "n" mappings.findProjects "Telescope projects") - ] - ); + ++ 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 {