From eb8c841b4a014c3b0f3d4bfd3854db9c529a2cb0 Mon Sep 17 00:00:00 2001 From: n3oney Date: Sat, 22 Apr 2023 15:48:21 +0200 Subject: [PATCH] feat:32;2uadd telescope keybindings --- modules/utility/telescope/config.nix | 62 ++++++++++++------------- modules/utility/telescope/telescope.nix | 30 ++++++++++-- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index 01a96a3..e7e00dc 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -7,47 +7,45 @@ with lib; with builtins; let cfg = config.vim.telescope; + self = import ./telescope.nix {inherit lib;}; + mappingDefinitions = self.options.vim.telescope.mappings; + + mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf (cfg.enable) { vim.startPlugins = [ "telescope" ]; - vim.maps.normal = - { - "ff" = {action = " Telescope find_files";}; - "fg" = {action = " Telescope live_grep";}; - "fb" = {action = " Telescope buffers";}; - "fh" = {action = " Telescope help_tags";}; - "ft" = {action = " Telescope";}; + vim.maps.normal = mkMerge [ + (mkSetBinding mappings.findFiles " Telescope find_files") + (mkSetBinding mappings.liveGrep " Telescope live_grep") + (mkSetBinding mappings.buffers " Telescope buffers") + (mkSetBinding mappings.helpTags " Telescope help_tags") + (mkSetBinding mappings.open " Telescope") - "fvcw" = {action = " Telescope git_commits";}; - "fvcb" = {action = " Telescope git_bcommits";}; - "fvb" = {action = " Telescope git_branches";}; - "fvs" = {action = " Telescope git_status";}; - "fvx" = {action = " Telescope git_stash";}; - } - // ( - if config.vim.lsp.enable - then { - "flsb" = {action = " Telescope lsp_document_symbols";}; - "flsw" = {action = " Telescope lsp_workspace_symbols";}; + (mkSetBinding mappings.gitCommits " Telescope git_commits") + (mkSetBinding mappings.gitBufferCommits " Telescope git_bcommits") + (mkSetBinding mappings.gitBranches " Telescope git_branches") + (mkSetBinding mappings.gitStatus " Telescope git_status") + (mkSetBinding mappings.gitStash " Telescope git_stash") - "flr" = {action = " Telescope lsp_references";}; - "fli" = {action = " Telescope lsp_implementations";}; - "flD" = {action = " Telescope lsp_definitions";}; - "flt" = {action = " Telescope lsp_type_definitions";}; - "fld" = {action = " Telescope diagnostics";}; - } - else {} + (mkIf config.vim.lsp.enable (mkMerge [ + (mkSetBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") + (mkSetBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") + + (mkSetBinding mappings.lspReferences " Telescope lsp_references") + (mkSetBinding mappings.lspImplementations " Telescope lsp_implementations") + (mkSetBinding mappings.lspDefinitions " Telescope lsp_definitions") + (mkSetBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") + (mkSetBinding mappings.diagnostics " Telescope diagnostics") + ])) + + ( + mkIf config.vim.treesitter.enable + (mkSetBinding mappings.treesitter " Telescope treesitter") ) - // ( - if config.vim.treesitter.enable - then { - "fs" = {action = " Telescope treesitter";}; - } - else {} - ); + ]; vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' local telescope = require('telescope') diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix index 1ba45b8..fa77fdc 100644 --- a/modules/utility/telescope/telescope.nix +++ b/modules/utility/telescope/telescope.nix @@ -1,11 +1,31 @@ -{ - config, - lib, - ... -}: +{lib, ...}: with lib; with builtins; { options.vim.telescope = { + mappings = { + findFiles = mkMappingOption "Find files [Telescope]" "ff"; + liveGrep = mkMappingOption "Live grep [Telescope]" "fg"; + buffers = mkMappingOption "Buffers [Telescope]" "fb"; + helpTags = mkMappingOption "Help tags [Telescope]" "fh"; + open = mkMappingOption "Open [Telescope]" "ft"; + + gitCommits = mkMappingOption "Git commits [Telescope]" "fvcw"; + gitBufferCommits = mkMappingOption "Git buffer commits [Telescope]" "fvcb"; + gitBranches = mkMappingOption "Git branches [Telescope]" "fvb"; + gitStatus = mkMappingOption "Git status [Telescope]" "fvs"; + gitStash = mkMappingOption "Git stash [Telescope]" "fvx"; + + lspDocumentSymbols = mkMappingOption "LSP Document Symbols [Telescope]" "flsb"; + lspWorkspaceSymbols = mkMappingOption "LSP Workspace Symbols [Telescope]" "flsw"; + lspReferences = mkMappingOption "LSP References [Telescope]" "flr"; + lspImplementations = mkMappingOption "LSP Implementations [Telescope]" "fli"; + lspDefinitions = mkMappingOption "LSP Definitions [Telescope]" "flD"; + lspTypeDefinitions = mkMappingOption "LSP Type Definitions [Telescope]" "flt"; + diagnostics = mkMappingOption "Diagnostics [Telescope]" "fld"; + + treesitter = mkMappingOption "Treesitter [Telescope]" "fs"; + }; + enable = mkEnableOption "Enable multi-purpose telescope utility"; }; }