mirror of https://github.com/folke/lazy.nvim.git
feat: refactor all vim.loop -> vim.uv and add a shim when needed
This commit is contained in:
parent
83493db50a
commit
9e157df077
|
@ -1,4 +1,4 @@
|
||||||
local uv = vim.loop
|
local uv = vim.uv
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ end
|
||||||
---@private
|
---@private
|
||||||
function Loader.normalize(path)
|
function Loader.normalize(path)
|
||||||
if path:sub(1, 1) == "~" then
|
if path:sub(1, 1) == "~" then
|
||||||
local home = vim.loop.os_homedir() or "~"
|
local home = vim.uv.os_homedir() or "~"
|
||||||
if home:sub(-1) == "\\" or home:sub(-1) == "/" then
|
if home:sub(-1) == "\\" or home:sub(-1) == "/" then
|
||||||
home = home:sub(1, -2)
|
home = home:sub(1, -2)
|
||||||
end
|
end
|
||||||
|
@ -222,7 +222,7 @@ end
|
||||||
--- Loads the given module path using the cache
|
--- Loads the given module path using the cache
|
||||||
---@param modpath string
|
---@param modpath string
|
||||||
---@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table} (table|nil) Options for loading the module:
|
---@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table} (table|nil) Options for loading the module:
|
||||||
--- - hash: (table) the hash of the file to load if it is already known. (defaults to `vim.loop.fs_stat({modpath})`)
|
--- - hash: (table) the hash of the file to load if it is already known. (defaults to `vim.uv.fs_stat({modpath})`)
|
||||||
--- - mode: (string) the mode to load the module with. "b"|"t"|"bt" (defaults to `nil`)
|
--- - mode: (string) the mode to load the module with. "b"|"t"|"bt" (defaults to `nil`)
|
||||||
--- - env: (table) the environment to load the module in. (defaults to `nil`)
|
--- - env: (table) the environment to load the module in. (defaults to `nil`)
|
||||||
---@see |luaL_loadfile()|
|
---@see |luaL_loadfile()|
|
||||||
|
@ -442,9 +442,9 @@ function Loader.lsmod(path)
|
||||||
if not Loader._indexed[path] then
|
if not Loader._indexed[path] then
|
||||||
local start = uv.hrtime()
|
local start = uv.hrtime()
|
||||||
Loader._indexed[path] = {}
|
Loader._indexed[path] = {}
|
||||||
local handle = vim.loop.fs_scandir(path .. "/lua")
|
local handle = vim.uv.fs_scandir(path .. "/lua")
|
||||||
while handle do
|
while handle do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, t = vim.uv.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -480,7 +480,7 @@ function M._profile_loaders()
|
||||||
for l, loader in pairs(package.loaders) do
|
for l, loader in pairs(package.loaders) do
|
||||||
local loc = debug.getinfo(loader, "Sn").source:sub(2)
|
local loc = debug.getinfo(loader, "Sn").source:sub(2)
|
||||||
package.loaders[l] = function(modname)
|
package.loaders[l] = function(modname)
|
||||||
local start = vim.loop.hrtime()
|
local start = vim.uv.hrtime()
|
||||||
local ret = loader(modname)
|
local ret = loader(modname)
|
||||||
Loader.track("loader " .. l .. ": " .. loc, start)
|
Loader.track("loader " .. l .. ": " .. loc, start)
|
||||||
Loader.track("loader_all", start)
|
Loader.track("loader_all", start)
|
||||||
|
|
|
@ -17,7 +17,7 @@ M.defaults = {
|
||||||
-- leave nil when passing the spec as the first argument to setup()
|
-- leave nil when passing the spec as the first argument to setup()
|
||||||
spec = nil, ---@type LazySpec
|
spec = nil, ---@type LazySpec
|
||||||
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
||||||
concurrency = jit.os:find("Windows") and (vim.loop.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
|
concurrency = jit.os:find("Windows") and (vim.uv.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
|
||||||
git = {
|
git = {
|
||||||
-- defaults for the `Lazy log` command
|
-- defaults for the `Lazy log` command
|
||||||
-- log = { "--since=3 days ago" }, -- show commits from the last 3 days
|
-- log = { "--since=3 days ago" }, -- show commits from the last 3 days
|
||||||
|
|
|
@ -472,7 +472,7 @@ function M.add_to_rtp(plugin)
|
||||||
table.insert(rtp, idx_dir or (#rtp + 1), plugin.dir)
|
table.insert(rtp, idx_dir or (#rtp + 1), plugin.dir)
|
||||||
|
|
||||||
local after = plugin.dir .. "/after"
|
local after = plugin.dir .. "/after"
|
||||||
if vim.loop.fs_stat(after) then
|
if vim.uv.fs_stat(after) then
|
||||||
table.insert(rtp, idx_after or (#rtp + 1), after)
|
table.insert(rtp, idx_after or (#rtp + 1), after)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ function M.colorscheme(name)
|
||||||
if not plugin._.loaded then
|
if not plugin._.loaded then
|
||||||
for _, ext in ipairs({ "lua", "vim" }) do
|
for _, ext in ipairs({ "lua", "vim" }) do
|
||||||
local path = plugin.dir .. "/colors/" .. name .. "." .. ext
|
local path = plugin.dir .. "/colors/" .. name .. "." .. ext
|
||||||
if vim.loop.fs_stat(path) then
|
if vim.uv.fs_stat(path) then
|
||||||
return M.load(plugin, { colorscheme = name })
|
return M.load(plugin, { colorscheme = name })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ function M.track(data, time)
|
||||||
if data then
|
if data then
|
||||||
local entry = {
|
local entry = {
|
||||||
data = data,
|
data = data,
|
||||||
time = time or vim.loop.hrtime(),
|
time = time or vim.uv.hrtime(),
|
||||||
}
|
}
|
||||||
table.insert(M._profiles[#M._profiles], entry)
|
table.insert(M._profiles[#M._profiles], entry)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ function M.track(data, time)
|
||||||
else
|
else
|
||||||
---@type LazyProfile
|
---@type LazyProfile
|
||||||
local entry = table.remove(M._profiles)
|
local entry = table.remove(M._profiles)
|
||||||
entry.time = vim.loop.hrtime() - entry.time
|
entry.time = vim.uv.hrtime() - entry.time
|
||||||
return entry
|
return entry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ end
|
||||||
---@return string
|
---@return string
|
||||||
function M.norm(path)
|
function M.norm(path)
|
||||||
if path:sub(1, 1) == "~" then
|
if path:sub(1, 1) == "~" then
|
||||||
local home = vim.loop.os_homedir()
|
local home = vim.uv.os_homedir()
|
||||||
if home:sub(-1) == "\\" or home:sub(-1) == "/" then
|
if home:sub(-1) == "\\" or home:sub(-1) == "/" then
|
||||||
home = home:sub(1, -2)
|
home = home:sub(1, -2)
|
||||||
end
|
end
|
||||||
|
@ -175,9 +175,9 @@ end
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param fn fun(path: string, name:string, type:FileType):boolean?
|
---@param fn fun(path: string, name:string, type:FileType):boolean?
|
||||||
function M.ls(path, fn)
|
function M.ls(path, fn)
|
||||||
local handle = vim.loop.fs_scandir(path)
|
local handle = vim.uv.fs_scandir(path)
|
||||||
while handle do
|
while handle do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, t = vim.uv.fs_scandir_next(handle)
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -187,7 +187,7 @@ function M.ls(path, fn)
|
||||||
-- HACK: type is not always returned due to a bug in luv,
|
-- HACK: type is not always returned due to a bug in luv,
|
||||||
-- so fecth it with fs_stat instead when needed.
|
-- so fecth it with fs_stat instead when needed.
|
||||||
-- see https://github.com/folke/lazy.nvim/issues/306
|
-- see https://github.com/folke/lazy.nvim/issues/306
|
||||||
if fn(fname, name, t or vim.loop.fs_stat(fname).type) == false then
|
if fn(fname, name, t or vim.uv.fs_stat(fname).type) == false then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -263,7 +263,7 @@ function M.lsmod(modname, fn)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.loop.fs_stat(root .. ".lua") then
|
if vim.uv.fs_stat(root .. ".lua") then
|
||||||
fn(modname, root .. ".lua")
|
fn(modname, root .. ".lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ function M.lsmod(modname, fn)
|
||||||
fn(modname, path)
|
fn(modname, path)
|
||||||
elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then
|
elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then
|
||||||
fn(modname .. "." .. name:sub(1, -5), path)
|
fn(modname .. "." .. name:sub(1, -5), path)
|
||||||
elseif type == "directory" and vim.loop.fs_stat(path .. "/init.lua") then
|
elseif type == "directory" and vim.uv.fs_stat(path .. "/init.lua") then
|
||||||
fn(modname .. "." .. name, path .. "/init.lua")
|
fn(modname .. "." .. name, path .. "/init.lua")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -26,7 +26,7 @@ function M.check()
|
||||||
local existing = false
|
local existing = false
|
||||||
for _, site in pairs(sites) do
|
for _, site in pairs(sites) do
|
||||||
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
|
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
|
||||||
if not packs:find("[/\\]dist$") and vim.loop.fs_stat(packs) then
|
if not packs:find("[/\\]dist$") and vim.uv.fs_stat(packs) then
|
||||||
existing = true
|
existing = true
|
||||||
warn("found existing packages at `" .. packs .. "`")
|
warn("found existing packages at `" .. packs .. "`")
|
||||||
end
|
end
|
||||||
|
@ -46,7 +46,7 @@ function M.check()
|
||||||
end
|
end
|
||||||
|
|
||||||
local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
|
local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
|
||||||
if vim.loop.fs_stat(packer_compiled) then
|
if vim.uv.fs_stat(packer_compiled) then
|
||||||
error("please remove the file `" .. packer_compiled .. "`")
|
error("please remove the file `" .. packer_compiled .. "`")
|
||||||
else
|
else
|
||||||
ok("packer_compiled.lua not found")
|
ok("packer_compiled.lua not found")
|
||||||
|
|
|
@ -4,7 +4,7 @@ local Util = require("lazy.util")
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.index(plugin)
|
function M.index(plugin)
|
||||||
if Config.options.readme.skip_if_doc_exists and vim.loop.fs_stat(plugin.dir .. "/doc") then
|
if Config.options.readme.skip_if_doc_exists and vim.uv.fs_stat(plugin.dir .. "/doc") then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function M.index(plugin)
|
||||||
local tags = {}
|
local tags = {}
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
file = Util.norm(file)
|
file = Util.norm(file)
|
||||||
if vim.loop.fs_stat(file) then
|
if vim.uv.fs_stat(file) then
|
||||||
local rel_file = file:sub(#plugin.dir + 1)
|
local rel_file = file:sub(#plugin.dir + 1)
|
||||||
local tag_filename = plugin.name .. vim.fn.fnamemodify(rel_file, ":h"):gsub("%W+", "-"):gsub("^%-$", "")
|
local tag_filename = plugin.name .. vim.fn.fnamemodify(rel_file, ":h"):gsub("%W+", "-"):gsub("^%-$", "")
|
||||||
local lines = vim.split(Util.read_file(file), "\n")
|
local lines = vim.split(Util.read_file(file), "\n")
|
||||||
|
@ -50,7 +50,7 @@ function M.update()
|
||||||
|
|
||||||
Util.ls(docs, function(path, name, type)
|
Util.ls(docs, function(path, name, type)
|
||||||
if type == "file" and name:sub(-2) == "md" then
|
if type == "file" and name:sub(-2) == "md" then
|
||||||
vim.loop.fs_unlink(path)
|
vim.uv.fs_unlink(path)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
---@type {file:string, tag:string, line:string}[]
|
---@type {file:string, tag:string, line:string}[]
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
M._start = 0
|
M._start = 0
|
||||||
|
|
||||||
|
vim.uv = vim.uv or vim.uv
|
||||||
|
|
||||||
local function profile_require()
|
local function profile_require()
|
||||||
local done = {} ---@type table<string, true>
|
local done = {} ---@type table<string, true>
|
||||||
local r = require
|
local r = require
|
||||||
|
@ -35,7 +37,7 @@ function M.setup(spec, opts)
|
||||||
opts.spec = spec
|
opts.spec = spec
|
||||||
end
|
end
|
||||||
|
|
||||||
M._start = M._start == 0 and vim.loop.hrtime() or M._start
|
M._start = M._start == 0 and vim.uv.hrtime() or M._start
|
||||||
if vim.g.lazy_did_setup then
|
if vim.g.lazy_did_setup then
|
||||||
return vim.notify(
|
return vim.notify(
|
||||||
"Re-sourcing your config is not supported with lazy.nvim",
|
"Re-sourcing your config is not supported with lazy.nvim",
|
||||||
|
@ -53,7 +55,7 @@ function M.setup(spec, opts)
|
||||||
if not (pcall(require, "ffi") and jit and jit.version) then
|
if not (pcall(require, "ffi") and jit and jit.version) then
|
||||||
return vim.notify("lazy.nvim requires Neovim built with LuaJIT", vim.log.levels.ERROR, { title = "lazy.nvim" })
|
return vim.notify("lazy.nvim requires Neovim built with LuaJIT", vim.log.levels.ERROR, { title = "lazy.nvim" })
|
||||||
end
|
end
|
||||||
local start = vim.loop.hrtime()
|
local start = vim.uv.hrtime()
|
||||||
|
|
||||||
-- use the Neovim cache if available
|
-- use the Neovim cache if available
|
||||||
if vim.loader and vim.fn.has("nvim-0.9.1") == 1 then
|
if vim.loader and vim.fn.has("nvim-0.9.1") == 1 then
|
||||||
|
@ -89,7 +91,7 @@ function M.setup(spec, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
||||||
Util.track("module", vim.loop.hrtime() - start)
|
Util.track("module", vim.uv.hrtime() - start)
|
||||||
|
|
||||||
-- load config
|
-- load config
|
||||||
Util.track("config")
|
Util.track("config")
|
||||||
|
@ -100,7 +102,7 @@ function M.setup(spec, opts)
|
||||||
Loader.setup()
|
Loader.setup()
|
||||||
|
|
||||||
-- correct time delta and loaded
|
-- correct time delta and loaded
|
||||||
local delta = vim.loop.hrtime() - start
|
local delta = vim.uv.hrtime() - start
|
||||||
Util.track().time = delta -- end setup
|
Util.track().time = delta -- end setup
|
||||||
if Config.plugins["lazy.nvim"] then
|
if Config.plugins["lazy.nvim"] then
|
||||||
Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" }
|
Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" }
|
||||||
|
@ -120,7 +122,7 @@ end
|
||||||
|
|
||||||
function M.bootstrap()
|
function M.bootstrap()
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
|
|
|
@ -41,7 +41,7 @@ M.signals = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@diagnostic disable-next-line: no-unknown
|
---@diagnostic disable-next-line: no-unknown
|
||||||
local uv = vim.loop
|
local uv = vim.uv
|
||||||
|
|
||||||
---@class ProcessOpts
|
---@class ProcessOpts
|
||||||
---@field args string[]
|
---@field args string[]
|
||||||
|
|
|
@ -16,7 +16,7 @@ function M.enable()
|
||||||
M.timer:stop()
|
M.timer:stop()
|
||||||
end
|
end
|
||||||
if #Config.spec.modules > 0 then
|
if #Config.spec.modules > 0 then
|
||||||
M.timer = assert(vim.loop.new_timer())
|
M.timer = assert(vim.uv.new_timer())
|
||||||
M.check(true)
|
M.check(true)
|
||||||
M.timer:start(2000, 2000, M.check)
|
M.timer:start(2000, 2000, M.check)
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ function M.check(start)
|
||||||
-- spec is a module
|
-- spec is a module
|
||||||
local function check(_, modpath)
|
local function check(_, modpath)
|
||||||
checked[modpath] = true
|
checked[modpath] = true
|
||||||
local hash = vim.loop.fs_stat(modpath)
|
local hash = vim.uv.fs_stat(modpath)
|
||||||
if hash then
|
if hash then
|
||||||
if M.files[modpath] then
|
if M.files[modpath] then
|
||||||
if not M.eq(M.files[modpath], hash) then
|
if not M.eq(M.files[modpath], hash) then
|
||||||
|
|
|
@ -92,7 +92,7 @@ function Runner:start()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local check = vim.loop.new_check()
|
local check = vim.uv.new_check()
|
||||||
check:start(function()
|
check:start(function()
|
||||||
if self:resume() then
|
if self:resume() then
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,17 +12,17 @@ M.clean = {
|
||||||
local dir = self.plugin.dir:gsub("/+$", "")
|
local dir = self.plugin.dir:gsub("/+$", "")
|
||||||
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
|
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!")
|
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
|
||||||
|
|
||||||
Util.walk(dir, function(path, _, type)
|
Util.walk(dir, function(path, _, type)
|
||||||
if type == "directory" then
|
if type == "directory" then
|
||||||
vim.loop.fs_rmdir(path)
|
vim.uv.fs_rmdir(path)
|
||||||
else
|
else
|
||||||
vim.loop.fs_unlink(path)
|
vim.uv.fs_unlink(path)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
vim.loop.fs_rmdir(dir)
|
vim.uv.fs_rmdir(dir)
|
||||||
|
|
||||||
self.plugin._.installed = false
|
self.plugin._.installed = false
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -15,7 +15,7 @@ M.log = {
|
||||||
if opts.updated and not (plugin._.updated and plugin._.updated.from ~= plugin._.updated.to) then
|
if opts.updated and not (plugin._.updated and plugin._.updated.from ~= plugin._.updated.to) then
|
||||||
return true
|
return true
|
||||||
end
|
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")
|
return not (stat and stat.type == "directory")
|
||||||
end,
|
end,
|
||||||
---@param opts {args?: string[], updated?:boolean, check?:boolean}
|
---@param opts {args?: string[], updated?:boolean, check?:boolean}
|
||||||
|
@ -106,7 +106,7 @@ M.clone = {
|
||||||
self.plugin._.cloned = true
|
self.plugin._.cloned = true
|
||||||
self.plugin._.installed = true
|
self.plugin._.installed = true
|
||||||
self.plugin._.dirty = true
|
self.plugin._.dirty = true
|
||||||
vim.loop.fs_unlink(marker)
|
vim.uv.fs_unlink(marker)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ function Task:start()
|
||||||
self:start()
|
self:start()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
self._started = vim.loop.hrtime()
|
self._started = vim.uv.hrtime()
|
||||||
---@type boolean, string|any
|
---@type boolean, string|any
|
||||||
local ok, err = pcall(self._task, self, self._opts)
|
local ok, err = pcall(self._task, self, self._opts)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
@ -81,7 +81,7 @@ function Task:_check()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self._ended = vim.loop.hrtime()
|
self._ended = vim.uv.hrtime()
|
||||||
if self._opts.on_done then
|
if self._opts.on_done then
|
||||||
self._opts.on_done(self)
|
self._opts.on_done(self)
|
||||||
end
|
end
|
||||||
|
@ -97,7 +97,7 @@ function Task:time()
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if not self:is_done() then
|
if not self:is_done() then
|
||||||
return (vim.loop.hrtime() - self._started) / 1e6
|
return (vim.uv.hrtime() - self._started) / 1e6
|
||||||
end
|
end
|
||||||
return (self._ended - self._started) / 1e6
|
return (self._ended - self._started) / 1e6
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ function M.cputime()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fallback()
|
local function fallback()
|
||||||
return (vim.loop.hrtime() - require("lazy")._start) / 1e6
|
return (vim.uv.hrtime() - require("lazy")._start) / 1e6
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, ret = pcall(real)
|
local ok, ret = pcall(real)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
local M = setmetatable({}, { __index = require("lazy.core.util") })
|
local M = setmetatable({}, { __index = require("lazy.core.util") })
|
||||||
|
|
||||||
function M.file_exists(file)
|
function M.file_exists(file)
|
||||||
return vim.loop.fs_stat(file) ~= nil
|
return vim.uv.fs_stat(file) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts? LazyFloatOptions
|
---@param opts? LazyFloatOptions
|
||||||
|
@ -71,7 +71,7 @@ end
|
||||||
---@param fn F
|
---@param fn F
|
||||||
---@return F
|
---@return F
|
||||||
function M.throttle(ms, fn)
|
function M.throttle(ms, fn)
|
||||||
local timer = vim.loop.new_timer()
|
local timer = vim.uv.new_timer()
|
||||||
local running = false
|
local running = false
|
||||||
local first = true
|
local first = true
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ describe("lazy", function()
|
||||||
"folke/paint.nvim",
|
"folke/paint.nvim",
|
||||||
}, { install_missing = true, defaults = { lazy = true } })
|
}, { install_missing = true, defaults = { lazy = true } })
|
||||||
assert(3 == vim.tbl_count(Config.plugins))
|
assert(3 == vim.tbl_count(Config.plugins))
|
||||||
assert(vim.loop.fs_stat(root .. "/paint.nvim/README.md"))
|
assert(vim.uv.fs_stat(root .. "/paint.nvim/README.md"))
|
||||||
assert(vim.loop.fs_stat(root .. "/neodev.nvim/README.md"))
|
assert(vim.uv.fs_stat(root .. "/neodev.nvim/README.md"))
|
||||||
assert(not neodev)
|
assert(not neodev)
|
||||||
assert(Config.plugins["neodev.nvim"]._.installed)
|
assert(Config.plugins["neodev.nvim"]._.installed)
|
||||||
assert(not Config.plugins["neodev.nvim"]._.is_local)
|
assert(not Config.plugins["neodev.nvim"]._.is_local)
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe("util", function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Helpers.fs_rm("")
|
Helpers.fs_rm("")
|
||||||
assert(not vim.loop.fs_stat(Helpers.path("")), "fs root should be deleted")
|
assert(not vim.uv.fs_stat(Helpers.path("")), "fs root should be deleted")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("lsmod lists all mods in dir", function()
|
it("lsmod lists all mods in dir", function()
|
||||||
|
@ -85,7 +85,7 @@ describe("util", function()
|
||||||
assert.same(Helpers.path("old/lua/foobar"), root)
|
assert.same(Helpers.path("old/lua/foobar"), root)
|
||||||
|
|
||||||
Helpers.fs_rm("old")
|
Helpers.fs_rm("old")
|
||||||
assert(not vim.loop.fs_stat(Helpers.path("old/lua/foobar")), "old/lua/foobar should not exist")
|
assert(not vim.uv.fs_stat(Helpers.path("old/lua/foobar")), "old/lua/foobar should not exist")
|
||||||
|
|
||||||
-- vim.opt.rtp = rtp
|
-- vim.opt.rtp = rtp
|
||||||
vim.opt.rtp:append(Helpers.path("new"))
|
vim.opt.rtp:append(Helpers.path("new"))
|
||||||
|
|
|
@ -26,12 +26,12 @@ function M.fs_rm(dir)
|
||||||
dir = Util.norm(M.fs_root .. "/" .. dir)
|
dir = Util.norm(M.fs_root .. "/" .. dir)
|
||||||
Util.walk(dir, function(path, _, type)
|
Util.walk(dir, function(path, _, type)
|
||||||
if type == "directory" then
|
if type == "directory" then
|
||||||
vim.loop.fs_rmdir(path)
|
vim.uv.fs_rmdir(path)
|
||||||
else
|
else
|
||||||
vim.loop.fs_unlink(path)
|
vim.uv.fs_unlink(path)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
vim.loop.fs_rmdir(dir)
|
vim.uv.fs_rmdir(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -9,7 +9,7 @@ end
|
||||||
function M.load(plugin)
|
function M.load(plugin)
|
||||||
local name = plugin:match(".*/(.*)")
|
local name = plugin:match(".*/(.*)")
|
||||||
local package_root = M.root(".tests/site/pack/deps/start/")
|
local package_root = M.root(".tests/site/pack/deps/start/")
|
||||||
if not vim.loop.fs_stat(package_root .. name) then
|
if not vim.uv.fs_stat(package_root .. name) then
|
||||||
print("Installing " .. plugin)
|
print("Installing " .. plugin)
|
||||||
vim.fn.mkdir(package_root, "p")
|
vim.fn.mkdir(package_root, "p")
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
|
|
Loading…
Reference in New Issue