aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-12-22 14:08:38 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-12-22 14:44:02 +0100
commit9204642002ba91f9e0b7d0e5989f373657fe754a (patch)
tree7c9599930582a5f6b364dac84621d10384ac383b
parentrefactor: silence luals warnings (diff)
downloadnvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar.gz
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar.bz2
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar.lz
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar.xz
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.tar.zst
nvim-lspconfig-9204642002ba91f9e0b7d0e5989f373657fe754a.zip
refactor: deprecate util.path.iterate_parents
Work on https://github.com/neovim/nvim-lspconfig/issues/2079.
-rw-r--r--.github/ci/run_sanitizer.sh2
-rw-r--r--lua/lspconfig/util.lua23
2 files changed, 5 insertions, 20 deletions
diff --git a/.github/ci/run_sanitizer.sh b/.github/ci/run_sanitizer.sh
index af1ceeb8..edcf4b5a 100644
--- a/.github/ci/run_sanitizer.sh
+++ b/.github/ci/run_sanitizer.sh
@@ -15,7 +15,7 @@ if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANC
exit 1
fi
-SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.path\.join|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor|util\.find_git_ancestor)'
+SEARCH_PATTERN='(util\.path\.dirname|util\.path\.sanitize|util\.path\.exists|util\.path\.is_file|util\.path\.is_dir|util\.path\.join|util\.path\.iterate_parents|util\.find_mercurial_ancestor|util\.find_node_modules_ancestor|util\.find_package_json_ancestor|util\.find_git_ancestor)'
if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
echo
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 7a47d722..e3e23807 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -127,23 +127,6 @@ M.path = (function()
end
end
- -- Iterate the path until we find the rootdir.
- local function iterate_parents(path)
- local function it(_, v)
- if v and not is_fs_root(v) then
- v = vim.fs.dirname(v)
- else
- return
- end
- if v and vim.loop.fs_realpath(v) then
- return v, path
- else
- return
- end
- end
- return it, path, path
- end
-
local function is_descendant(root, path)
if not path then
return false
@@ -160,7 +143,6 @@ M.path = (function()
return {
traverse_parents = traverse_parents,
- iterate_parents = iterate_parents,
is_descendant = is_descendant,
}
end)()
@@ -173,7 +155,7 @@ function M.search_ancestors(startpath, func)
return startpath
end
local guard = 100
- for path in M.path.iterate_parents(startpath) do
+ for path in vim.fs.parents(startpath) do
-- Prevent infinite recursion if our algorithm breaks
guard = guard - 1
if guard == 0 then
@@ -363,6 +345,9 @@ end
--- @deprecated use `vim.fn.has('win32') == 1 and ';' or ':'` instead
M.path.path_separator = vim.fn.has('win32') == 1 and ';' or ':'
+--- @deprecated use `vim.fs.parents(path)` instead
+M.path.iterate_parents = vim.fs.parents
+
--- @deprecated use `vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])` instead
function M.find_mercurial_ancestor(startpath)
return vim.fs.dirname(vim.fs.find('.hg', { path = startpath, upward = true })[1])