feat: add ripgrep backend

`rg` will now be used over `ag` if it is available. This is because `rg`
is a faster alternative reduces lag when searching larger codebases.
`ag` is also now conditionally loaded if the command is available.
This commit is contained in:
Ade Attwood 2023-05-23 08:01:38 +01:00
parent 92aa2c3433
commit 027819e15f
2 changed files with 18 additions and 0 deletions

12
lua/ivy/backends/rg.lua Normal file
View file

@ -0,0 +1,12 @@
local utils = require "ivy.utils"
local rg = {
name = "RG",
command = "IvyRg",
description = "Run ripgrep to search for content in files",
keymap = "<leader>/",
items = utils.command_finder "rg --vimgrep --",
callback = utils.vimgrep_action(),
}
return rg

View file

@ -31,4 +31,10 @@ register_backend(require "ivy.backends.files")
register_backend(require "ivy.backends.lines") register_backend(require "ivy.backends.lines")
register_backend(require "ivy.backends.lsp-workspace-symbols") register_backend(require "ivy.backends.lsp-workspace-symbols")
if vim.fn.executable "rg" then
register_backend(require "ivy.backends.rg")
elseif vim.fn.executable "ag" then
register_backend(require "ivy.backends.ag")
end
vim.cmd "highlight IvyMatch cterm=bold gui=bold" vim.cmd "highlight IvyMatch cterm=bold gui=bold"