Add grug-far.nvim for search and replace

- Add MagicDuck/grug-far.nvim plugin with lazy loading
- Bind to <leader>sr in normal and visual mode
- Auto-filter by current file extension when opening

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-28 15:12:04 +08:00
parent 2c524fc30d
commit c5a31a26f6
2 changed files with 25 additions and 0 deletions

View File

@ -10,6 +10,7 @@ vim.pack.add({
"https://github.com/mason-org/mason.nvim", "https://github.com/mason-org/mason.nvim",
"https://github.com/stevearc/conform.nvim", "https://github.com/stevearc/conform.nvim",
"https://github.com/tpope/vim-fugitive", "https://github.com/tpope/vim-fugitive",
"https://github.com/MagicDuck/grug-far.nvim",
}, { load = false }) }, { load = false })
-- mini.starter 启动页 -- mini.starter 启动页
@ -208,3 +209,23 @@ end)
lazy.on_event("lsp", "VimEnter", "*", function() lazy.on_event("lsp", "VimEnter", "*", function()
require("lsp") require("lsp")
end) end)
-- grug-far - <leader>sr 触发
local function load_grug_far()
vim.cmd.packadd("grug-far.nvim")
require("grug-far").setup({ headerMaxWidth = 80 })
end
local function open_grug_far()
local grug = require("grug-far")
local ext = vim.bo.buftype == "" and vim.fn.expand("%:e")
grug.open({
transient = true,
prefills = {
filesFilter = ext and ext ~= "" and "*." .. ext or nil,
},
})
end
lazy.on_keys("grugfar", "<leader>sr", "n", load_grug_far, open_grug_far, { desc = "Search and Replace" })
lazy.on_keys("grugfar", "<leader>sr", "x", load_grug_far, open_grug_far, { desc = "Search and Replace" })

View File

@ -8,6 +8,10 @@
"rev": "6cd7280adead7f586db6fccbd15d2cac7e2188b9", "rev": "6cd7280adead7f586db6fccbd15d2cac7e2188b9",
"src": "https://github.com/rafamadriz/friendly-snippets" "src": "https://github.com/rafamadriz/friendly-snippets"
}, },
"grug-far.nvim": {
"rev": "5506c2f59dc9ab2ed6c233585412b24d31d51521",
"src": "https://github.com/MagicDuck/grug-far.nvim"
},
"mason.nvim": { "mason.nvim": {
"rev": "bb639d4bf385a4d89f478b83af4d770be05ab7eb", "rev": "bb639d4bf385a4d89f478b83af4d770be05ab7eb",
"src": "https://github.com/mason-org/mason.nvim" "src": "https://github.com/mason-org/mason.nvim"