From e366fcede23e265b682f38977aaec3dd2b40d42d Mon Sep 17 00:00:00 2001 From: Dominik Schwabe Date: Thu, 30 Jun 2022 14:45:30 +0200 Subject: [PATCH] fix: Ignore invalid file paths --- lua/project_nvim/project.lua | 2 +- lua/project_nvim/utils/path.lua | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/project_nvim/project.lua b/lua/project_nvim/project.lua index 28fa4b7..6b3a1ab 100644 --- a/lua/project_nvim/project.lua +++ b/lua/project_nvim/project.lua @@ -232,7 +232,7 @@ function M.on_buf_enter() end local current_dir = vim.fn.expand("%:p:h", true) - if path.is_excluded(current_dir) then + if not path.exists(current_dir) or path.is_excluded(current_dir) then return end diff --git a/lua/project_nvim/utils/path.lua b/lua/project_nvim/utils/path.lua index fd06a68..69ac7ad 100644 --- a/lua/project_nvim/utils/path.lua +++ b/lua/project_nvim/utils/path.lua @@ -30,4 +30,8 @@ function M.is_excluded(dir) return false end +function M.exists(path) + return vim.fn.empty(vim.fn.glob(path)) == 0 +end + return M