From 73bfbcc3a35b4cbe3d6a3bf43e0ba1c0ed5beba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Tue, 9 Apr 2024 22:43:02 +0200 Subject: [PATCH] nvim: add telescope git_grep --- nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/lupan/remap.lua | 4 +--- nvim/.config/nvim/lua/plugins/convenience.lua | 1 + nvim/.config/nvim/lua/plugins/telescope.lua | 7 +++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index b787664..6a0e4bc 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -30,6 +30,7 @@ "orgmode": { "branch": "master", "commit": "edbcbfb7f156e0e4468d20e092e88a8127d6c12c" }, "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope-git-grep.nvim": { "branch": "main", "commit": "814217cb30c076bc5edebe36e525b05a7c9eb4b2" }, "telescope-tabs": { "branch": "master", "commit": "0a678eefcb71ebe5cb0876aa71dd2e2583d27fd3" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, diff --git a/nvim/.config/nvim/lua/lupan/remap.lua b/nvim/.config/nvim/lua/lupan/remap.lua index 9c43893..3f7d047 100644 --- a/nvim/.config/nvim/lua/lupan/remap.lua +++ b/nvim/.config/nvim/lua/lupan/remap.lua @@ -17,9 +17,7 @@ key("n", "dt", "Lexplore 30", { desc = "[D]isplay directory [t] key("n", "ct", "ColorizerToggle", { desc = "[C]olorizer [t]oggle" }) key("n", "ut", "UndotreeToggle", { desc = "[U]undotree [t]oggle" }) --- telescope - -key('n', 'gg', ':Git grep ', { desc = '[G]it [g]rep' }) +-- tabs key('n', 'td', function() require('lupan.ui').tab_change_dir() diff --git a/nvim/.config/nvim/lua/plugins/convenience.lua b/nvim/.config/nvim/lua/plugins/convenience.lua index 3c4cf8f..e8c8f52 100644 --- a/nvim/.config/nvim/lua/plugins/convenience.lua +++ b/nvim/.config/nvim/lua/plugins/convenience.lua @@ -9,6 +9,7 @@ return { require('which-key').register { ['c'] = { name = '[C]ode/Color', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua index b5d8741..31a83ed 100644 --- a/nvim/.config/nvim/lua/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -28,6 +28,8 @@ return { -- Icons, requires Nerd font. { 'nvim-tree/nvim-web-devicons' }, + + 'davvid/telescope-git-grep.nvim', }, config = function() local telescope = require 'telescope' @@ -51,6 +53,7 @@ return { pcall(telescope.load_extension, 'fzf') pcall(telescope.load_extension, 'ui-select') pcall(telescope.load_extension, 'whaler') + pcall(telescope.load_extension, 'git_grep') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' @@ -70,6 +73,10 @@ return { { desc = '[S]earch with wha[L]er' }) vim.keymap.set('n', 'gf', builtin.git_files, { desc = '[G]it [F]iles' }) vim.keymap.set('n', 'gs', builtin.git_status, { desc = '[G]it [S]tatus' }) + vim.keymap.set('n', 'gg', function() telescope.extensions.git_grep.live_grep() end, + { desc = '[G]it [g]rep' }) + vim.keymap.set('n', 'gw', function() telescope.extensions.git_grep.grep() end, + { desc = '[G]it grep current [W]ord' }) vim.keymap.set('n', '/', function() builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {