fix: live_grep will now accept cwd (#390)

This commit is contained in:
Simon Hauser
2021-01-04 22:01:03 +01:00
committed by GitHub
parent 5d121ee58c
commit 313ce9d0b6
2 changed files with 8 additions and 2 deletions

View File

@@ -23,6 +23,10 @@ local escape_chars = function(string)
end end
files.live_grep = function(opts) files.live_grep = function(opts)
if opts.cwd then
opts.cwd = vim.fn.expand(opts.cwd)
end
local live_grepper = finders.new_job(function(prompt) local live_grepper = finders.new_job(function(prompt)
-- TODO: Probably could add some options for smart case and whatever else rg offers. -- TODO: Probably could add some options for smart case and whatever else rg offers.
@@ -35,7 +39,8 @@ files.live_grep = function(opts)
return flatten { conf.vimgrep_arguments, prompt } return flatten { conf.vimgrep_arguments, prompt }
end, end,
opts.entry_maker or make_entry.gen_from_vimgrep(opts), opts.entry_maker or make_entry.gen_from_vimgrep(opts),
opts.max_results opts.max_results,
opts.cwd
) )
pickers.new(opts, { pickers.new(opts, {

View File

@@ -274,7 +274,7 @@ finders._new = function(opts)
return JobFinder:new(opts) return JobFinder:new(opts)
end end
finders.new_job = function(command_generator, entry_maker, maximum_results) finders.new_job = function(command_generator, entry_maker, maximum_results, cwd)
return JobFinder:new { return JobFinder:new {
fn_command = function(_, prompt) fn_command = function(_, prompt)
local command_list = command_generator(prompt) local command_list = command_generator(prompt)
@@ -292,6 +292,7 @@ finders.new_job = function(command_generator, entry_maker, maximum_results)
entry_maker = entry_maker, entry_maker = entry_maker,
maximum_results = maximum_results, maximum_results = maximum_results,
cwd = cwd,
} }
end end