vim-settings/neovim/lua/plugins/grepper.lua
ViViDboarder 0e446b86d1 Now using v0.7+ API functions in many places
This preserves backwards compatibility still, but that will be removed at
some point when dropping .6. At that point, another refactor can
simplify many of the functions used.
2023-06-09 12:30:30 -07:00

48 lines
1.5 KiB
Lua

-- Grepper settings and shortcuts
vim.g.grepper = {
quickfix = 1,
open = 1,
switch = 0,
jump = 0,
tools = { "git", "rg", "ag", "ack", "pt", "grep" },
dir = "repo,cwd",
}
require("utils").keymap_set({ "n", "x" }, "gs", "<plug>(GrepperOperator)", {
silent = true,
noremap = false,
desc = "Grepper",
})
-- Override Todo command to use Grepper
-- TODO: Remove check when dropping 0.6
if vim.fn.has("nvim-0.7.0") == 1 then
vim.api.nvim_create_user_command("Todo", ":Grepper -noprompt -query TODO", { desc = "Search for TODO tags" })
else
vim.cmd("command! Todo :Grepper -noprompt -query TODO")
end
-- Make some shortands for various grep programs
-- TODO: Remove check when dropping 0.6
if vim.fn.has("nvim-0.7.0") == 1 then
if vim.fn.executable("rg") == 1 then
vim.api.nvim_create_user_command("Rg", ":GrepperRg <args>", { nargs = "+", desc = "Ripgrep" })
end
if vim.fn.executable("ag") == 1 then
vim.api.nvim_create_user_command("Ag", ":GrepperAg <args>", { nargs = "+", desc = "Silversearcher" })
end
if vim.fn.executable("ack") == 1 then
vim.api.nvim_create_user_command("Ack", ":GrepperAck <args>", { nargs = "+", desc = "Ack search" })
end
else
if vim.fn.executable("rg") == 1 then
vim.cmd("command -nargs=+ Rg :GrepperRg <args>")
end
if vim.fn.executable("ag") == 1 then
vim.cmd("command -nargs=+ Ag :GrepperAg <args>")
end
if vim.fn.executable("ack") == 1 then
vim.cmd("command -nargs=+ Ack :GrepperAck <args>")
end
end