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.
30 lines
612 B
Lua
30 lines
612 B
Lua
3 months ago
|
print("Loading up etc definitions")
|
||
|
local M = {}
|
||
|
|
||
|
local telescope = require("telescope.builtin")
|
||
|
|
||
|
-- cache directory checks for great speed
|
||
|
local is_inside_work_tree = {}
|
||
|
|
||
|
|
||
|
M.project_files = function()
|
||
|
local opts = {}
|
||
|
|
||
|
local cwd = vim.fn.getcwd()
|
||
|
|
||
|
if is_inside_work_tree[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
|
||
|
is_inside_work_tree[cwd] = vim.v.shell_error == 0
|
||
|
end
|
||
|
|
||
|
if is_inside_work_tree[cwd] then
|
||
|
telescope.git_files(opts)
|
||
|
else
|
||
|
telescope.find_files(opts)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return M
|