aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2024-11-28 23:39:12 +0100
committerGitHub <noreply@github.com>2024-11-28 14:39:12 -0800
commit6a5ed22255bbe10104ff9b72c55ec2e233a8e571 (patch)
tree6f34f9fbbdaf654a7e33b5ecc5ff5168607115b9 /lua/lspconfig/util.lua
parentrefactor: deprecate util.path.is_file #3474 (diff)
downloadnvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar.gz
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar.bz2
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar.lz
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar.xz
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.tar.zst
nvim-lspconfig-6a5ed22255bbe10104ff9b72c55ec2e233a8e571.zip
refactor: deprecate util.path.is_dir #3475
Work on https://github.com/neovim/nvim-lspconfig/issues/2079
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua21
1 files changed, 10 insertions, 11 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 241c7223..f8ffe57e 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -102,13 +102,6 @@ M.path = (function()
return path:gsub('([%[%]%?%*])', '\\%1')
end
- --- @param filename string
- --- @return boolean
- local function is_dir(filename)
- local stat = uv.fs_stat(filename)
- return stat and stat.type == 'directory' or false
- end
-
--- @param path string
--- @return boolean
local function is_fs_root(path)
@@ -188,7 +181,6 @@ M.path = (function()
return {
escape_wildcards = escape_wildcards,
- is_dir = is_dir,
is_absolute = is_absolute,
join = path_join,
traverse_parents = traverse_parents,
@@ -249,7 +241,7 @@ function M.find_git_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
-- Support git directories and git files (worktrees)
local gitpath = M.path.join(path, '.git')
- if M.path.is_dir(gitpath) or (uv.fs_stat(gitpath) or {}).type == 'file' then
+ if vim.fn.isdirectory(gitpath) == 1 or (uv.fs_stat(gitpath) or {}).type == 'file' then
return path
end
end)
@@ -258,7 +250,7 @@ end
function M.find_mercurial_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
-- Support Mercurial directories
- if M.path.is_dir(M.path.join(path, '.hg')) then
+ if vim.fn.isdirectory(M.path.join(path, '.hg')) == 1 then
return path
end
end)
@@ -266,7 +258,7 @@ end
function M.find_node_modules_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
- if M.path.is_dir(M.path.join(path, 'node_modules')) then
+ if vim.fn.isdirectory(M.path.join(path, 'node_modules')) == 1 then
return path
end
end)
@@ -385,6 +377,13 @@ end
--- Deprecated functions
+--- @deprecated use `vim.fn.isdirectory(path) == 1` instead
+--- @param filename string
+--- @return boolean
+function M.path.is_dir(filename)
+ return vim.fn.isdirectory(filename) == 1
+end
+
--- @deprecated use `(vim.loop.fs_stat(path) or {}).type == 'file'` instead
--- @param path string
--- @return boolean