From 19626a3a4484de12c3d8c0833bb49ecb3dcd5c76 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 28 Nov 2024 18:11:56 +0100 Subject: refactor: deprecate util.find_node_modules_ancestor Work on https://github.com/neovim/nvim-lspconfig/issues/2079. --- lua/lspconfig/util.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lua/lspconfig/util.lua') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 1b186e85..7b894ee3 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -246,14 +246,6 @@ function M.find_git_ancestor(startpath) end) end -function M.find_node_modules_ancestor(startpath) - return M.search_ancestors(startpath, function(path) - if vim.fn.isdirectory(M.path.join(path, 'node_modules')) == 1 then - return path - end - end) -end - function M.find_package_json_ancestor(startpath) return M.search_ancestors(startpath, function(path) local jsonpath = M.path.join(path, 'package.json') @@ -400,4 +392,9 @@ function M.find_mercurial_ancestor(startpath) return vim.fs.find('.hg', { path = startpath, upward = true })[1] end +--- @deprecated use `vim.fs.find('node_modules', { path = startpath, upward = true })[1]` instead +function M.find_node_modules_ancestor(startpath) + return vim.fs.find('node_modules', { path = startpath, upward = true })[1] +end + return M -- cgit v1.2.3-70-g09d2