feat: use selection when in visual mode

This commit is contained in:
Folke Lemaitre 2024-07-18 17:01:45 +02:00
parent 68cf175176
commit 5adec47431
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -135,13 +135,16 @@ return {
{ {
"<leader>sr", "<leader>sr",
function() function()
require("grug-far").grug_far({ local is_visual = vim.fn.mode():lower():find("v")
prefills = { if is_visual then -- needed to make visual selection work
search = vim.fn.expand("<cword>"), vim.cmd([[normal! v]])
filesFilter = "*." .. vim.fn.expand("%:e"), end
}, local grug = require("grug-far");
(is_visual and grug.with_visual_selection or grug.grug_far)({
prefills = { filesFilter = "*." .. vim.fn.expand("%:e") },
}) })
end, end,
mode = { "n", "v" },
desc = "Search and Replace", desc = "Search and Replace",
}, },
}, },