From 592f3b03bb3cd01df42ee5db4cd6ba43937f067e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 18:38:29 +0200 Subject: [PATCH] fix(root): only use workspace folders that contain the buffer --- lua/lazyvim/util/root.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 707ba5f8..54f44169 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -26,7 +26,8 @@ function M.detectors.cwd() end function M.detectors.lsp(buf) - if not M.bufpath(buf) then + local bufpath = M.bufpath(buf) + if not bufpath then return {} end local roots = {} ---@type string[] @@ -39,7 +40,10 @@ function M.detectors.lsp(buf) roots[#roots + 1] = client.config.root_dir end end - return roots + return vim.tbl_filter(function(path) + path = Util.norm(path) + return path and bufpath:find(path, 1, true) == 1 + end, roots) end ---@param patterns string[]|string