aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-12-13 14:02:48 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-12-13 14:31:20 +0100
commitf675f8c430ae3012f6d140899c2cec3b59e9cb43 (patch)
treeff617d1fe953f467dfdd7d3f20a511f220e877fc /lua/lspconfig/util.lua
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar.gz
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar.bz2
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar.lz
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar.xz
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.tar.zst
nvim-lspconfig-f675f8c430ae3012f6d140899c2cec3b59e9cb43.zip
refactor: deprecate util.find_package_json_ancestor
Work on https://github.com/neovim/nvim-lspconfig/issues/2079.
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua16
1 files changed, 6 insertions, 10 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 7b894ee3..a5cf67fd 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -246,18 +246,9 @@ function M.find_git_ancestor(startpath)
end)
end
-function M.find_package_json_ancestor(startpath)
- return M.search_ancestors(startpath, function(path)
- local jsonpath = M.path.join(path, 'package.json')
- if (vim.loop.fs_stat(jsonpath) or {}).type == 'file' then
- return path
- end
- end)
-end
-
function M.insert_package_json(config_files, field, fname)
local path = vim.fn.fnamemodify(fname, ':h')
- local root_with_package = M.find_package_json_ancestor(path)
+ local root_with_package = vim.fs.find('package.json', { path = path, upward = true })[1]
if root_with_package then
-- only add package.json if it contains field parameter
@@ -397,4 +388,9 @@ function M.find_node_modules_ancestor(startpath)
return vim.fs.find('node_modules', { path = startpath, upward = true })[1]
end
+--- @deprecated use `vim.fs.find('package.json', { path = startpath, upward = true })[1]` instead
+function M.find_package_json_ancestor(startpath)
+ return vim.fs.find('package.json', { path = startpath, upward = true })[1]
+end
+
return M