mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-01 21:14:38 +02:00
feat(telescope): use git_files or find_files for files
This commit is contained in:
parent
53c08e7aa1
commit
531f8baf5e
2 changed files with 19 additions and 4 deletions
|
@ -54,9 +54,24 @@ function M.get_root()
|
|||
return root
|
||||
end
|
||||
|
||||
-- this will return a function that calls telescope.
|
||||
-- cwd will defautlt to lazyvim.util.get_root
|
||||
-- for `files`, git_files or find_files will be chosen depending on .git
|
||||
function M.telescope(builtin, opts)
|
||||
local params = { builtin = builtin, opts = opts }
|
||||
return function()
|
||||
require("telescope.builtin")[builtin](vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}))
|
||||
builtin = params.builtin
|
||||
opts = params.opts
|
||||
opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})
|
||||
if builtin == "files" then
|
||||
if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then
|
||||
opts.show_untracked = true
|
||||
builtin = "git_files"
|
||||
else
|
||||
builtin = "find_files"
|
||||
end
|
||||
end
|
||||
require("telescope.builtin")[builtin](opts)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue