diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index af049fb..a44283b 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -53,6 +53,10 @@ return require('packer').startup(function() vim.api.nvim_set_keymap("n", "", ":call ToggleLocationList()", {silent=true, noremap=true}) end, } + use { + "mhinz/vim-grepper", + config = function() require("plugins.grepper") end, + } -- UI use { diff --git a/neovim/lua/plugins/grepper.lua b/neovim/lua/plugins/grepper.lua new file mode 100644 index 0000000..9298721 --- /dev/null +++ b/neovim/lua/plugins/grepper.lua @@ -0,0 +1,29 @@ +-- 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', +} + +local map = vim.api.nvim_set_keymap +local opt_silent = {silent = true} +map("n", "gs", "(GrepperOperator)", opt_silent) +map("x", "gs", "(GrepperOperator)", opt_silent) +map("n", "*", ":Grepper -cword -noprompt", opt_silent) + +-- Override Todo command to use Grepper +vim.cmd "command! Todo :Grepper -noprompt -query TODO" + +-- Make some shortands for various grep programs +if vim.fn.executable('rg') == 1 then + vim.cmd "command -nargs=+ Rg :GrepperRg " +end +if vim.fn.executable('ag') == 1 then + vim.cmd "command -nargs=+ Ag :GrepperAg " +end +if vim.fn.executable('ack') == 1 then + vim.cmd "command -nargs=+ Ack :GrepperAck " +end diff --git a/neovim/lua/plugins/telescope.lua b/neovim/lua/plugins/telescope.lua index 224ba33..c192531 100644 --- a/neovim/lua/plugins/telescope.lua +++ b/neovim/lua/plugins/telescope.lua @@ -30,9 +30,6 @@ local function config_telescope() vim.api.nvim_set_keymap("n", "t", "Telescope current_buffer_tags", opts) vim.api.nvim_set_keymap("n", "ft", "Telescope tags", opts) vim.api.nvim_set_keymap("n", "fg", "Telescope live_grep", opts) - - vim.cmd "command Rg Telescope live_grep" - vim.cmd "command Grep Telescope live_grep" end config_telescope()