From 02568754603a4e1773141433f480c5ee318db0a1 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Sat, 26 Aug 2023 00:13:35 +0200 Subject: [PATCH] fix(nvim): Git repository detection --- .config/nvim/lua/telescope-config.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/telescope-config.lua b/.config/nvim/lua/telescope-config.lua index 6e34520..f97d9c2 100644 --- a/.config/nvim/lua/telescope-config.lua +++ b/.config/nvim/lua/telescope-config.lua @@ -1,12 +1,20 @@ local M = {} +local is_inside_work_tree = {} + M.project_files = function() 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}) else - require("telescope.builtin").find_files(opts) + require("telescope.builtin").find_files({hidden=true}) end end