summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua
index 74b277c..5261243 100644
--- a/lua/telescope/builtin.lua
+++ b/lua/telescope/builtin.lua
@@ -46,10 +46,15 @@ local builtin = {}
builtin.git_files = function(opts)
opts = opts or {}
- opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
if opts.cwd then
opts.cwd = vim.fn.expand(opts.cwd)
+ else
+ --- Find root of git directory and remove trailing newline characters
+ opts.cwd = string.gsub(vim.fn.system("git rev-parse --show-toplevel"), '[\n\r]+', '')
end
+ -- By creating the entry maker after the cwd options,
+ -- we ensure the maker uses the cwd options when being created.
+ opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
pickers.new(opts, {
prompt_title = 'Git File',