You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
658 B
Lua

local M = {}
local telescope = require("telescope.builtin")
-- cache directory checks for great speed
local work_tree_lookup_cache = {}
M.cwd_is_in_git_repo = function()
local cwd = vim.fn.getcwd()
if work_tree_lookup_cache[cwd] == nil then
-- The directory has not been checked
vim.fn.system("git rev-parse --is-inside-work-tree")
-- Add the result to our cache
work_tree_lookup_cache[cwd] = vim.v.shell_error == 0
end
return work_tree_lookup_cache[cwd]
end
M.project_files = function()
local opts = {}
if M.cwd_is_in_git_repo() then
telescope.git_files(opts)
else
telescope.find_files(opts)
end
end
return M