summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2021-01-04 22:01:03 +0100
committerGitHub <noreply@github.com>2021-01-04 22:01:03 +0100
commit313ce9d0b6fb3bdb5ee07af60ee8840bdd4fbf73 (patch)
treeab893fcb4b877fac31dbfdd01e50a86eb1ca4108
parent5d121ee58cf45aa3fd591e6c51054f9fbe38e83a (diff)
fix: live_grep will now accept cwd (#390)
-rw-r--r--lua/telescope/builtin/files.lua7
-rw-r--r--lua/telescope/finders.lua3
2 files changed, 8 insertions, 2 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua
index d8175e2..9d26a4a 100644
--- a/lua/telescope/builtin/files.lua
+++ b/lua/telescope/builtin/files.lua
@@ -23,6 +23,10 @@ local escape_chars = function(string)
end
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)
-- 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 }
end,
opts.entry_maker or make_entry.gen_from_vimgrep(opts),
- opts.max_results
+ opts.max_results,
+ opts.cwd
)
pickers.new(opts, {
diff --git a/lua/telescope/finders.lua b/lua/telescope/finders.lua
index f968ad3..7bc4ec5 100644
--- a/lua/telescope/finders.lua
+++ b/lua/telescope/finders.lua
@@ -274,7 +274,7 @@ finders._new = function(opts)
return JobFinder:new(opts)
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 {
fn_command = function(_, 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,
maximum_results = maximum_results,
+ cwd = cwd,
}
end