| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- local M = {
- "MagicDuck/grug-far.nvim",
- cmd = "GrugFar",
- keys = {
- { "<leader>S", "<cmd>GrugFar<CR>", desc = "GrugFar: Find and Replace" },
- },
- }
- M.config = function()
- require("grug-far").setup({
- -- Basic configuration
- minSearchLength = 2,
- debounceMs = 300,
- -- UI configuration
- ui = {
- border = "rounded",
- size = {
- width = 0.8,
- height = 0.8,
- },
- },
- -- Search configuration
- search = {
- engines = { "ripgrep", "astgrep", "astgrep-rules" },
- defaultEngine = "ripgrep",
- },
- -- History configuration - simplified to avoid the autoSave bug
- history = {
- enabled = true,
- maxEntries = 50,
- },
- -- Result configuration
- resultLocation = {
- showNumberLabel = true,
- },
- })
- -- Additional keybindings for enhanced functionality
- vim.api.nvim_create_autocmd("FileType", {
- group = vim.api.nvim_create_augroup("grug-far-custom-keybinds", { clear = true }),
- pattern = { "grug-far" },
- callback = function()
- -- Toggle --fixed-strings flag
- vim.keymap.set("n", "<localleader>w", function()
- local state = unpack(require("grug-far").get_instance(0):toggle_flags({ "--fixed-strings" }))
- vim.notify("grug-far: toggled --fixed-strings " .. (state and "ON" or "OFF"))
- end, { buffer = true, desc = "Toggle fixed strings" })
- -- Open result location and close grug-far
- vim.keymap.set("n", "<C-enter>", function()
- require("grug-far").get_instance(0):open_location()
- require("grug-far").get_instance(0):close()
- end, { buffer = true, desc = "Open location and close" })
- -- Jump back to first input
- vim.keymap.set("n", "<left>", function()
- require("grug-far").get_instance(0):goto_first_input()
- end, { buffer = true, desc = "Jump to first input" })
- -- Toggle multiline mode
- vim.keymap.set("n", "<localleader>m", function()
- local state = unpack(require("grug-far").get_instance(0):toggle_flags({ "--multiline" }))
- vim.notify("grug-far: toggled --multiline " .. (state and "ON" or "OFF"))
- end, { buffer = true, desc = "Toggle multiline mode" })
- end,
- })
- end
- return M
|