aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2024-11-28 22:44:19 +0100
committerGitHub <noreply@github.com>2024-11-28 13:44:19 -0800
commit86dcd4d4ec014c5cb47033c52a54508acd503b97 (patch)
tree94a024bade90965ce0fdc329fc8c63ddb628faed /lua/lspconfig/util.lua
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar.gz
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar.bz2
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar.lz
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar.xz
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.tar.zst
nvim-lspconfig-86dcd4d4ec014c5cb47033c52a54508acd503b97.zip
refactor: deprecate util.path.is_file #3474
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 16ffa729..241c7223 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -109,13 +109,6 @@ M.path = (function()
return stat and stat.type == 'directory' or false
end
- --- @param filename string
- --- @return boolean
- local function is_file(filename)
- local stat = uv.fs_stat(filename)
- return stat and stat.type == 'file' or false
- end
-
--- @param path string
--- @return boolean
local function is_fs_root(path)
@@ -196,7 +189,6 @@ M.path = (function()
return {
escape_wildcards = escape_wildcards,
is_dir = is_dir,
- is_file = is_file,
is_absolute = is_absolute,
join = path_join,
traverse_parents = traverse_parents,
@@ -256,7 +248,8 @@ end
function M.find_git_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
-- Support git directories and git files (worktrees)
- if M.path.is_dir(M.path.join(path, '.git')) or M.path.is_file(M.path.join(path, '.git')) then
+ local gitpath = M.path.join(path, '.git')
+ if M.path.is_dir(gitpath) or (uv.fs_stat(gitpath) or {}).type == 'file' then
return path
end
end)
@@ -281,7 +274,8 @@ end
function M.find_package_json_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
- if M.path.is_file(M.path.join(path, 'package.json')) then
+ local jsonpath = M.path.join(path, 'package.json')
+ if (uv.fs_stat(jsonpath) or {}).type == 'file' then
return path
end
end)
@@ -391,6 +385,13 @@ end
--- Deprecated functions
+--- @deprecated use `(vim.loop.fs_stat(path) or {}).type == 'file'` instead
+--- @param path string
+--- @return boolean
+function M.path.is_file(path)
+ return (vim.loop.fs_stat(path) or {}).type == 'file'
+end
+
--- @deprecated use `vim.fs.dirname` instead
M.path.dirname = vim.fs.dirname