aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-12-01 12:57:16 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-12-01 15:11:38 +0100
commit90c1c6cc822b1836209514c096069b9bbeab63d9 (patch)
treea553e1bb6bfe7a5cf81fcbef587b9095c0184c0f /lua/lspconfig/util.lua
parentbuild(editorconfig): set max_line_length to 120 only for lua files (diff)
downloadnvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar.gz
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar.bz2
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar.lz
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar.xz
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.tar.zst
nvim-lspconfig-90c1c6cc822b1836209514c096069b9bbeab63d9.zip
refactor: use simpler file existence check
The vimscript function `getftype` is an easier way to check for file existence compared to vim.uv.
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index c0a08052..7c02d76c 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -241,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 vim.fn.isdirectory(gitpath) == 1 or (uv.fs_stat(gitpath) or {}).type == 'file' then
+ if vim.fn.isdirectory(gitpath) == 1 or (vim.fn.getftype(gitpath) == 'file') then
return path
end
end)
@@ -258,7 +258,7 @@ end
function M.find_package_json_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
local jsonpath = M.path.join(path, 'package.json')
- if (uv.fs_stat(jsonpath) or {}).type == 'file' then
+ if vim.fn.getftype(jsonpath) == 'file' then
return path
end
end)
@@ -375,11 +375,11 @@ function M.path.is_dir(filename)
return vim.fn.isdirectory(filename) == 1
end
---- @deprecated use `(vim.loop.fs_stat(path) or {}).type == 'file'` instead
+--- @deprecated use `vim.fn.getftype(path) == 'file'` instead
--- @param path string
--- @return boolean
function M.path.is_file(path)
- return (vim.loop.fs_stat(path) or {}).type == 'file'
+ return vim.fn.getftype(path) == 'file'
end
--- @deprecated use `vim.fs.dirname` instead