Update to Latest
This commit is contained in:
parent
d1bbbcbb15
commit
71d6a8ab3b
157 changed files with 3467 additions and 5151 deletions
54
nvim/lua/config/telescope/multigrep.lua
Normal file
54
nvim/lua/config/telescope/multigrep.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
local pickers = require("telescope.pickers")
|
||||
local finders = require("telescope.finders")
|
||||
local make_entry = require("telescope.make_entry")
|
||||
local conf = require("telescope.config").values
|
||||
local M = {}
|
||||
|
||||
local live_multigrep = function(opts)
|
||||
opts = opts or {}
|
||||
opts.cwd = opts.cwd or vim.fn.getcwd()
|
||||
|
||||
local finder = finders.new_async_job({
|
||||
command_generator = function(prompt)
|
||||
if not prompt or prompt == "" then
|
||||
return nil
|
||||
end
|
||||
|
||||
local pieces = vim.split(prompt, " ")
|
||||
local args = { "rg" }
|
||||
|
||||
if pieces[1] then
|
||||
table.insert(args, "-e")
|
||||
table.insert(args, pieces[1])
|
||||
end
|
||||
|
||||
if pieces[2] then
|
||||
table.insert(args, "-g")
|
||||
table.insert(args, pieces[2])
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
return vim.tbl_flatten({
|
||||
args,
|
||||
{ "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" },
|
||||
})
|
||||
end,
|
||||
entry_maker = make_entry.gen_from_vimgrep(opts),
|
||||
cwd = opts.cwd,
|
||||
})
|
||||
pickers
|
||||
.new(opts, {
|
||||
debounce = 100,
|
||||
prompt_title = "Multi Grep",
|
||||
finder = finder,
|
||||
previewer = conf.grep_previewer(opts),
|
||||
sorter = require("telescope.sorters").empty(),
|
||||
})
|
||||
:find()
|
||||
end
|
||||
|
||||
M.setup = function()
|
||||
vim.keymap.set("n", "<leader>fg", live_multigrep, { desc = "Multi grep" })
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue