feat: refactor all vim.loop -> vim.uv and add a shim when needed

This commit is contained in:
Folke Lemaitre 2024-03-22 08:58:36 +01:00
parent 83493db50a
commit 9e157df077
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
19 changed files with 53 additions and 51 deletions

View file

@ -41,7 +41,7 @@ M.signals = {
}
---@diagnostic disable-next-line: no-unknown
local uv = vim.loop
local uv = vim.uv
---@class ProcessOpts
---@field args string[]

View file

@ -16,7 +16,7 @@ function M.enable()
M.timer:stop()
end
if #Config.spec.modules > 0 then
M.timer = assert(vim.loop.new_timer())
M.timer = assert(vim.uv.new_timer())
M.check(true)
M.timer:start(2000, 2000, M.check)
end
@ -44,7 +44,7 @@ function M.check(start)
-- spec is a module
local function check(_, modpath)
checked[modpath] = true
local hash = vim.loop.fs_stat(modpath)
local hash = vim.uv.fs_stat(modpath)
if hash then
if M.files[modpath] then
if not M.eq(M.files[modpath], hash) then

View file

@ -92,7 +92,7 @@ function Runner:start()
end
end
local check = vim.loop.new_check()
local check = vim.uv.new_check()
check:start(function()
if self:resume() then
return

View file

@ -12,17 +12,17 @@ M.clean = {
local dir = self.plugin.dir:gsub("/+$", "")
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
local stat = vim.loop.fs_lstat(dir)
local stat = vim.uv.fs_lstat(dir)
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
Util.walk(dir, function(path, _, type)
if type == "directory" then
vim.loop.fs_rmdir(path)
vim.uv.fs_rmdir(path)
else
vim.loop.fs_unlink(path)
vim.uv.fs_unlink(path)
end
end)
vim.loop.fs_rmdir(dir)
vim.uv.fs_rmdir(dir)
self.plugin._.installed = false
end,

View file

@ -15,7 +15,7 @@ M.log = {
if opts.updated and not (plugin._.updated and plugin._.updated.from ~= plugin._.updated.to) then
return true
end
local stat = vim.loop.fs_stat(plugin.dir .. "/.git")
local stat = vim.uv.fs_stat(plugin.dir .. "/.git")
return not (stat and stat.type == "directory")
end,
---@param opts {args?: string[], updated?:boolean, check?:boolean}
@ -106,7 +106,7 @@ M.clone = {
self.plugin._.cloned = true
self.plugin._.installed = true
self.plugin._.dirty = true
vim.loop.fs_unlink(marker)
vim.uv.fs_unlink(marker)
end
end,
})

View file

@ -65,7 +65,7 @@ function Task:start()
self:start()
end)
end
self._started = vim.loop.hrtime()
self._started = vim.uv.hrtime()
---@type boolean, string|any
local ok, err = pcall(self._task, self, self._opts)
if not ok then
@ -81,7 +81,7 @@ function Task:_check()
return
end
end
self._ended = vim.loop.hrtime()
self._ended = vim.uv.hrtime()
if self._opts.on_done then
self._opts.on_done(self)
end
@ -97,7 +97,7 @@ function Task:time()
return 0
end
if not self:is_done() then
return (vim.loop.hrtime() - self._started) / 1e6
return (vim.uv.hrtime() - self._started) / 1e6
end
return (self._ended - self._started) / 1e6
end