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