fix(nvim): Git repository detection

This commit is contained in:
Tanguy Herbron 2023-08-26 00:13:35 +02:00
parent 8b68afaeeb
commit 0256875460

View File

@ -1,12 +1,20 @@
local M = {} local M = {}
local is_inside_work_tree = {}
M.project_files = function() M.project_files = function()
local opts = {} local opts = {}
vim.fn.system('git rev-parse is-inside-work-tree')
if vim.v.shell_error == 0 then local cwd = vim.fn.getcwd()
if is_inside_work_tree[cwd] == nil then
vim.fn.system("git rev-parse --is-inside-work-tree")
is_inside_work_tree[cwd] = vim.v.shell_error == 0
end
if is_inside_work_tree[cwd] then
require("telescope.builtin").git_files({show_untracked=true}) require("telescope.builtin").git_files({show_untracked=true})
else else
require("telescope.builtin").find_files(opts) require("telescope.builtin").find_files({hidden=true})
end end
end end