From 1df80a1847e83c1839304063aef947cbb9928aea Mon Sep 17 00:00:00 2001 From: Pete Yandell Date: Sun, 5 Jan 2025 12:32:38 +1100 Subject: [PATCH] Try out grug-far for search and replace --- config/nvim/lazy-lock.json | 9 +++++---- config/nvim/lua/config/key-mappings.lua | 5 +++++ config/nvim/lua/config/options.lua | 1 + config/nvim/lua/plugins/grug-far.lua | 6 ++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 config/nvim/lua/plugins/grug-far.lua diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index c2ff46f8c6..b2672efd7e 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -1,8 +1,9 @@ { - "blink.cmp": { "branch": "main", "commit": "e3b7cb4a1094377c3093a021300de123d9fc60d3" }, + "blink.cmp": { "branch": "main", "commit": "51fb932f63af0d6722ad6e31c8e931a5a684bd25" }, "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "grug-far.nvim": { "branch": "main", "commit": "08f32182335754abf461dfb77b2c4e24bfe4d614" }, "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, "lsp-progress.nvim": { "branch": "main", "commit": "f3df1df8f5ea33d082db047b5d2d2b83cc01cd8a" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, @@ -10,18 +11,18 @@ "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "nightfox.nvim": { "branch": "main", "commit": "595ffb8f291fc4a9bef3201a28b7c0379a41cdee" }, "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, - "none-ls.nvim": { "branch": "main", "commit": "00421b9dc7a4d132ca74cfb4c7e8030d05d6fd0b" }, + "none-ls.nvim": { "branch": "main", "commit": "20f5650988cd849e18c7f3d2dce4b0e6a260e126" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, "nvim-lightbulb": { "branch": "master", "commit": "3ac0791be37ba9cc7939f1ad90ebc5e75abf4eea" }, "nvim-lspconfig": { "branch": "master", "commit": "f4ed656e876e45cf914d7beb972830561178e232" }, "nvim-notify": { "branch": "master", "commit": "bd9cd51f9ef2f6326fc2bc9931d0718c1794e247" }, "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, - "nvim-treesitter": { "branch": "master", "commit": "fae21737be2846a04ae06a41d70b7fc8ad4bf9eb" }, + "nvim-treesitter": { "branch": "master", "commit": "57713d079c3c2afcc31f3e0650bf8594a2a296ba" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, "nvim-web-devicons": { "branch": "master", "commit": "5740b7382429d20b6ed0bbdb0694185af9507d44" }, "oil-git-status.nvim": { "branch": "main", "commit": "a7ea816bac0cc3b8b4c3605e2f2b87960be60a05" }, - "oil.nvim": { "branch": "master", "commit": "c6a39a69b2df7c10466f150dde0bd23e49c1fba3" }, + "oil.nvim": { "branch": "master", "commit": "254bc6635cb3f77e6e9a89155652f368e5535160" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "snacks.nvim": { "branch": "main", "commit": "d312053f78b4fb55523def179ac502438dd93193" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, diff --git a/config/nvim/lua/config/key-mappings.lua b/config/nvim/lua/config/key-mappings.lua index 37ed7f8c1c..43930be905 100644 --- a/config/nvim/lua/config/key-mappings.lua +++ b/config/nvim/lua/config/key-mappings.lua @@ -56,6 +56,10 @@ local function previous_git_hunk() require("gitsigns").prev_hunk() end +local function search_and_replace() + require("grug-far").open() +end + -- Tip: Try to have few custom mappings, and use built-in mappings as much as -- possible. Stick to mostly "*" mappings, rather than going deeper. @@ -86,6 +90,7 @@ vim.keymap.set("n", "h", telescope_help_tags, { desc = "Help" }) vim.keymap.set("n", "j", toggle_join, { desc = "Join/split" }) vim.keymap.set("n", "n", open_notifications, { desc = "Notifications" }) vim.keymap.set("n", "q", vim.cmd.xall, { desc = "Quit" }) +vim.keymap.set("n", "r", search_and_replace, { desc = "Search and replace" }) vim.keymap.set("n", "w", vim.cmd.wall, { desc = "Write all" }) vim.keymap.set("n", "x", delete_buffer, { desc = "Delete buffer" }) vim.keymap.set("n", "/", telescope_live_grep, { desc = "Live grep" }) diff --git a/config/nvim/lua/config/options.lua b/config/nvim/lua/config/options.lua index 870afe1319..7b7c929f29 100644 --- a/config/nvim/lua/config/options.lua +++ b/config/nvim/lua/config/options.lua @@ -1,5 +1,6 @@ -- Use space as the leader key. vim.g.mapleader = " " +vim.g.localleader = "\\" -- Show relative line numbers, but display the actual line -- number on the current line, and highlight it. diff --git a/config/nvim/lua/plugins/grug-far.lua b/config/nvim/lua/plugins/grug-far.lua new file mode 100644 index 0000000000..69793689a8 --- /dev/null +++ b/config/nvim/lua/plugins/grug-far.lua @@ -0,0 +1,6 @@ +-- Search and replace using ripgrep. +return { + "MagicDuck/grug-far.nvim", + lazy = true, + opts = {}, +}