Skip to content

Commit 4ea9083

Browse files
authored
refactor: replace vim.loop with vim.uv #3703
The former is deprecated in neovim 0.10. Remove the check added in 9b89ba5. See: https://github.com/neovim/neovim/blob/v0.10.0/runtime/doc/deprecated.txt#L55
1 parent 94dda50 commit 4ea9083

26 files changed

+37
-46
lines changed

.github/ci/run_sanitizer.sh

-9
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,3 @@ if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANC
2222
echo 'Do not use deprecated util functions: '"${SEARCH_PATTERN}"
2323
exit 1
2424
fi
25-
26-
SEARCH_PATTERN='(vim\.uv)'
27-
28-
if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
29-
echo
30-
echo 'Do not use modules that are too new: '"${SEARCH_PATTERN}"
31-
echo 'Consult README to check the minimum supported neovim version.'
32-
exit 1
33-
fi

doc/configs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6279,7 +6279,7 @@ require'lspconfig'.lua_ls.setup {
62796279
on_init = function(client)
62806280
if client.workspace_folders then
62816281
local path = client.workspace_folders[1].name
6282-
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
6282+
if path ~= vim.fn.stdpath('config') and (vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc')) then
62836283
return
62846284
end
62856285
end

doc/configs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5757,7 +5757,7 @@ require'lspconfig'.lua_ls.setup {
57575757
on_init = function(client)
57585758
if client.workspace_folders then
57595759
local path = client.workspace_folders[1].name
5760-
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
5760+
if path ~= vim.fn.stdpath('config') and (vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc')) then
57615761
return
57625762
end
57635763
end

lua/lspconfig/configs.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function configs.__newindex(t, config_name, config_def)
9898
return
9999
end
100100

101-
local pwd = vim.loop.cwd()
101+
local pwd = vim.uv.cwd()
102102

103103
async.run(function()
104104
local root_dir

lua/lspconfig/configs/angularls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local function get_angular_core_version(root_dir)
1717
end
1818

1919
local package_json = project_root .. '/package.json'
20-
if not vim.loop.fs_stat(package_json) then
20+
if not vim.uv.fs_stat(package_json) then
2121
return ''
2222
end
2323

lua/lspconfig/configs/eslint.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ return {
125125
-- Support Yarn2 (PnP) projects
126126
local pnp_cjs = new_root_dir .. '/.pnp.cjs'
127127
local pnp_js = new_root_dir .. '/.pnp.js'
128-
if vim.loop.fs_stat(pnp_cjs) or vim.loop.fs_stat(pnp_js) then
128+
if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then
129129
config.cmd = vim.list_extend({ 'yarn', 'exec' }, config.cmd)
130130
end
131131
end,

lua/lspconfig/configs/fennel_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ return {
77
root_dir = function(dir)
88
local has_fls_project_cfg = function(path)
99
local fnlpath = vim.fs.joinpath(path, 'flsproject.fnl')
10-
return (vim.loop.fs_stat(fnlpath) or {}).type == 'file'
10+
return (vim.uv.fs_stat(fnlpath) or {}).type == 'file'
1111
end
1212
return util.search_ancestors(dir, has_fls_project_cfg) or vim.fs.root(0, '.git')
1313
end,

lua/lspconfig/configs/foam_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ return {
66
filetypes = { 'foam', 'OpenFOAM' },
77
root_dir = function(fname)
88
return util.search_ancestors(fname, function(path)
9-
if vim.loop.fs_stat(path .. '/system/controlDict') then
9+
if vim.uv.fs_stat(path .. '/system/controlDict') then
1010
return path
1111
end
1212
end)

lua/lspconfig/configs/gitlab_ci_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local util = require 'lspconfig.util'
22

3-
local cache_dir = vim.loop.os_homedir() .. '/.cache/gitlab-ci-ls/'
3+
local cache_dir = vim.uv.os_homedir() .. '/.cache/gitlab-ci-ls/'
44
return {
55
default_config = {
66
cmd = { 'gitlab-ci-ls' },

lua/lspconfig/configs/intelephense.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ return {
55
cmd = { 'intelephense', '--stdio' },
66
filetypes = { 'php' },
77
root_dir = function(pattern)
8-
local cwd = vim.loop.cwd()
8+
local cwd = vim.uv.cwd()
99
local root = util.root_pattern('composer.json', '.git')(pattern)
1010

1111
-- prefer cwd if root is a descendant

lua/lspconfig/configs/jdtls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local util = require 'lspconfig.util'
22
local handlers = require 'vim.lsp.handlers'
33

44
local env = {
5-
HOME = vim.loop.os_homedir(),
5+
HOME = vim.uv.os_homedir(),
66
XDG_CACHE_HOME = os.getenv 'XDG_CACHE_HOME',
77
JDTLS_JVM_ARGS = os.getenv 'JDTLS_JVM_ARGS',
88
}

lua/lspconfig/configs/julials.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ local function activate_env(path)
2222
path = vim.fs.normalize(vim.fn.fnamemodify(vim.fn.expand(path), ':p'))
2323
local found_env = false
2424
for _, project_file in ipairs(root_files) do
25-
local file = vim.loop.fs_stat(vim.fs.joinpath(path, project_file))
25+
local file = vim.uv.fs_stat(vim.fs.joinpath(path, project_file))
2626
if file and file.type then
2727
found_env = true
2828
break

lua/lspconfig/configs/lua_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require'lspconfig'.lua_ls.setup {
3838
on_init = function(client)
3939
if client.workspace_folders then
4040
local path = client.workspace_folders[1].name
41-
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
41+
if path ~= vim.fn.stdpath('config') and (vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc')) then
4242
return
4343
end
4444
end

lua/lspconfig/configs/phan.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ return {
1919
filetypes = { 'php' },
2020
single_file_support = true,
2121
root_dir = function(pattern)
22-
local cwd = vim.loop.cwd()
22+
local cwd = vim.uv.cwd()
2323
local root = util.root_pattern('composer.json', '.git')(pattern)
2424

2525
-- prefer cwd if root is a descendant

lua/lspconfig/configs/phpactor.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ return {
55
cmd = { 'phpactor', 'language-server' },
66
filetypes = { 'php' },
77
root_dir = function(pattern)
8-
local cwd = vim.loop.cwd()
8+
local cwd = vim.uv.cwd()
99
local root = util.root_pattern('composer.json', '.git', '.phpactor.json', '.phpactor.yml')(pattern)
1010

1111
-- prefer cwd if root is a descendant

lua/lspconfig/configs/r_language_server.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ return {
33
cmd = { 'R', '--no-echo', '-e', 'languageserver::run()' },
44
filetypes = { 'r', 'rmd', 'quarto' },
55
root_dir = function(fname)
6-
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) or vim.loop.os_homedir()
6+
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) or vim.uv.os_homedir()
77
end,
88
log_level = vim.lsp.protocol.MessageType.Warning,
99
},

lua/lspconfig/configs/relay_lsp.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ return {
3636
if config.path_to_config then
3737
config.path_to_config = vim.fs.normalize(config.path_to_config)
3838
local path_to_config = table.concat({ root_dir, config.path_to_config }, '/')
39-
if vim.loop.fs_stat(path_to_config) then
39+
if vim.uv.fs_stat(path_to_config) then
4040
vim.list_extend(config.cmd, { config.path_to_config })
4141
vim.list_extend(compiler_cmd, { config.path_to_config })
4242
else

lua/lspconfig/configs/rnix.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ return {
33
cmd = { 'rnix-lsp' },
44
filetypes = { 'nix' },
55
root_dir = function(fname)
6-
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) or vim.loop.os_homedir()
6+
return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) or vim.uv.os_homedir()
77
end,
88
settings = {},
99
init_options = {},

lua/lspconfig/configs/smarty_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ return {
55
cmd = { 'smarty-language-server', '--stdio' },
66
filetypes = { 'smarty' },
77
root_dir = function(pattern)
8-
local cwd = vim.loop.cwd()
8+
local cwd = vim.uv.cwd()
99
local root = util.root_pattern('composer.json', '.git')(pattern)
1010

1111
-- prefer cwd if root is a descendant

lua/lspconfig/configs/turtle_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if bin_path == nil then
1515
end
1616
for _, p in ipairs(paths) do
1717
local candidate = table.concat({ p, bin_name }, '/')
18-
if (vim.loop.fs_stat(candidate) or {}).type == 'file' then
18+
if (vim.uv.fs_stat(candidate) or {}).type == 'file' then
1919
full_path = candidate
2020
break
2121
end

lua/lspconfig/configs/vdmj.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local util = require 'lspconfig.util'
22

33
local function get_default_mavenrepo()
44
local repo = vim.env.HOME .. '/.m2/repository/dk/au/ece/vdmj'
5-
if vim.loop.fs_stat(repo) then
5+
if vim.uv.fs_stat(repo) then
66
return repo
77
else
88
return vim.env.HOME .. '/.m2/repository/com/fujitsu'
@@ -22,7 +22,7 @@ local function get_latest_installed_version(repo)
2222
local sort = vim.fn.sort
2323

2424
local subdirs = function(file)
25-
local stat = vim.loop.fs_stat(table.concat({ path, file }, '/'))
25+
local stat = vim.uv.fs_stat(table.concat({ path, file }, '/'))
2626
return stat.type == 'directory' and 1 or 0
2727
end
2828

lua/lspconfig/health.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ local function make_client_info(client, fname)
190190
local client_info, info_lines = make_info(client)
191191

192192
local workspace_folders = client.workspace_folders
193-
fname = vim.fs.normalize(vim.loop.fs_realpath(fname) or fn.fnamemodify(fn.resolve(fname), ':p'))
193+
fname = vim.fs.normalize(vim.uv.fs_realpath(fname) or fn.fnamemodify(fn.resolve(fname), ':p'))
194194

195195
if workspace_folders then
196196
for _, schema in ipairs(workspace_folders) do
197197
local matched = true
198-
local root_dir = vim.loop.fs_realpath(schema.name)
198+
local root_dir = vim.uv.fs_realpath(schema.name)
199199
if root_dir == nil or fname:sub(1, root_dir:len()) ~= root_dir then
200200
matched = false
201201
end

lua/lspconfig/manager.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function M:_start_client(bufnr, new_config, root_dir, single_file, silent)
115115

116116
-- Launch the server in the root directory used internally by lspconfig, if otherwise unset
117117
-- also check that the path exist
118-
if not new_config.cmd_cwd and vim.loop.fs_realpath(root_dir) then
118+
if not new_config.cmd_cwd and vim.uv.fs_realpath(root_dir) then
119119
new_config.cmd_cwd = root_dir
120120
end
121121

@@ -202,7 +202,7 @@ function M:try_add(bufnr, project_root, silent)
202202

203203
local get_root_dir = self.config.root_dir
204204

205-
local pwd = assert(vim.loop.cwd())
205+
local pwd = assert(vim.uv.cwd())
206206

207207
async.run(function()
208208
local root_dir

lua/lspconfig/util.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local api = vim.api
33
local lsp = vim.lsp
44
local nvim_eleven = vim.fn.has 'nvim-0.11' == 1
55

6-
local iswin = vim.loop.os_uname().version:match 'Windows'
6+
local iswin = vim.uv.os_uname().version:match 'Windows'
77

88
local M = { path = {} }
99

@@ -103,7 +103,7 @@ function M.root_pattern(...)
103103
for _, pattern in ipairs(patterns) do
104104
local match = M.search_ancestors(startpath, function(path)
105105
for _, p in ipairs(vim.fn.glob(table.concat({ escape_wildcards(path), pattern }, '/'), true, true)) do
106-
if vim.loop.fs_stat(p) then
106+
if vim.uv.fs_stat(p) then
107107
return path
108108
end
109109
end
@@ -194,7 +194,7 @@ end
194194

195195
-- Traverse the path calling cb along the way.
196196
local function traverse_parents(path, cb)
197-
path = vim.loop.fs_realpath(path)
197+
path = vim.uv.fs_realpath(path)
198198
local dir = path
199199
-- Just in case our algo is buggy, don't infinite loop.
200200
for _ = 1, 100 do
@@ -245,11 +245,11 @@ function M.path.is_dir(filename)
245245
return vim.fn.isdirectory(filename) == 1
246246
end
247247

248-
--- @deprecated use `(vim.loop.fs_stat(path) or {}).type == 'file'` instead
248+
--- @deprecated use `(vim.uv.fs_stat(path) or {}).type == 'file'` instead
249249
--- @param path string
250250
--- @return boolean
251251
function M.path.is_file(path)
252-
return (vim.loop.fs_stat(path) or {}).type == 'file'
252+
return (vim.uv.fs_stat(path) or {}).type == 'file'
253253
end
254254

255255
--- @deprecated use `vim.fs.dirname` instead
@@ -258,11 +258,11 @@ M.path.dirname = vim.fs.dirname
258258
--- @deprecated use `vim.fs.normalize` instead
259259
M.path.sanitize = vim.fs.normalize
260260

261-
--- @deprecated use `vim.loop.fs_stat` instead
261+
--- @deprecated use `vim.uv.fs_stat` instead
262262
--- @param filename string
263263
--- @return string|false
264264
function M.path.exists(filename)
265-
local stat = vim.loop.fs_stat(filename)
265+
local stat = vim.uv.fs_stat(filename)
266266
return stat and stat.type or false
267267
end
268268

plugin/lspconfig.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ api.nvim_create_user_command('LspRestart', function(info)
9797
detach_clients[client.name] = { client, lsp.get_buffers_by_client_id(client.id) }
9898
end
9999
end
100-
local timer = assert(vim.loop.new_timer())
100+
local timer = assert(vim.uv.new_timer())
101101
timer:start(
102102
500,
103103
100,

scripts/docgen.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ local function make_section(indentlvl, sep, parts)
5757
end
5858

5959
local function readfile(path)
60-
assert((vim.loop.fs_stat(path) or {}).type == 'file')
60+
assert((vim.uv.fs_stat(path) or {}).type == 'file')
6161
return io.open(path):read '*a'
6262
end
6363

@@ -182,7 +182,7 @@ local function make_lsp_sections(is_markdown)
182182
})
183183

184184
if docs then
185-
local tempdir = os.getenv 'DOCGEN_TEMPDIR' or vim.loop.fs_mkdtemp '/tmp/nvim-lspconfig.XXXXXX'
185+
local tempdir = os.getenv 'DOCGEN_TEMPDIR' or vim.uv.fs_mkdtemp '/tmp/nvim-lspconfig.XXXXXX'
186186
local preamble_parts = make_parts {
187187
function()
188188
if docs.description and #docs.description > 0 then
@@ -192,10 +192,10 @@ local function make_lsp_sections(is_markdown)
192192
function()
193193
local package_json_name = table.concat({ tempdir, config_name .. '.package.json' }, '/')
194194
if docs.package_json then
195-
if not ((vim.loop.fs_stat(package_json_name) or {}).type == 'file') then
195+
if not ((vim.uv.fs_stat(package_json_name) or {}).type == 'file') then
196196
os.execute(string.format('curl -v -L -o %q %q', package_json_name, docs.package_json))
197197
end
198-
if not ((vim.loop.fs_stat(package_json_name) or {}).type == 'file') then
198+
if not ((vim.uv.fs_stat(package_json_name) or {}).type == 'file') then
199199
print(string.format('Failed to download package.json for %q at %q', config_name, docs.package_json))
200200
os.exit(1)
201201
return

0 commit comments

Comments
 (0)