mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat: refactor all vim.loop -> vim.uv and add a shim when needed
This commit is contained in:
parent
83493db50a
commit
9e157df077
19 changed files with 53 additions and 51 deletions
|
@ -1,4 +1,4 @@
|
|||
local uv = vim.loop
|
||||
local uv = vim.uv
|
||||
|
||||
local M = {}
|
||||
|
||||
|
@ -51,7 +51,7 @@ end
|
|||
---@private
|
||||
function Loader.normalize(path)
|
||||
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
|
||||
home = home:sub(1, -2)
|
||||
end
|
||||
|
@ -222,7 +222,7 @@ end
|
|||
--- Loads the given module path using the cache
|
||||
---@param modpath string
|
||||
---@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`)
|
||||
--- - env: (table) the environment to load the module in. (defaults to `nil`)
|
||||
---@see |luaL_loadfile()|
|
||||
|
@ -442,9 +442,9 @@ function Loader.lsmod(path)
|
|||
if not Loader._indexed[path] then
|
||||
local start = uv.hrtime()
|
||||
Loader._indexed[path] = {}
|
||||
local handle = vim.loop.fs_scandir(path .. "/lua")
|
||||
local handle = vim.uv.fs_scandir(path .. "/lua")
|
||||
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
|
||||
break
|
||||
end
|
||||
|
@ -480,7 +480,7 @@ function M._profile_loaders()
|
|||
for l, loader in pairs(package.loaders) do
|
||||
local loc = debug.getinfo(loader, "Sn").source:sub(2)
|
||||
package.loaders[l] = function(modname)
|
||||
local start = vim.loop.hrtime()
|
||||
local start = vim.uv.hrtime()
|
||||
local ret = loader(modname)
|
||||
Loader.track("loader " .. l .. ": " .. loc, start)
|
||||
Loader.track("loader_all", start)
|
||||
|
|
|
@ -17,7 +17,7 @@ M.defaults = {
|
|||
-- leave nil when passing the spec as the first argument to setup()
|
||||
spec = nil, ---@type LazySpec
|
||||
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 = {
|
||||
-- defaults for the `Lazy log` command
|
||||
-- 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)
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -495,7 +495,7 @@ function M.colorscheme(name)
|
|||
if not plugin._.loaded then
|
||||
for _, ext in ipairs({ "lua", "vim" }) do
|
||||
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 })
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ function M.track(data, time)
|
|||
if data then
|
||||
local entry = {
|
||||
data = data,
|
||||
time = time or vim.loop.hrtime(),
|
||||
time = time or vim.uv.hrtime(),
|
||||
}
|
||||
table.insert(M._profiles[#M._profiles], entry)
|
||||
|
||||
|
@ -23,7 +23,7 @@ function M.track(data, time)
|
|||
else
|
||||
---@type LazyProfile
|
||||
local entry = table.remove(M._profiles)
|
||||
entry.time = vim.loop.hrtime() - entry.time
|
||||
entry.time = vim.uv.hrtime() - entry.time
|
||||
return entry
|
||||
end
|
||||
end
|
||||
|
@ -54,7 +54,7 @@ end
|
|||
---@return string
|
||||
function M.norm(path)
|
||||
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
|
||||
home = home:sub(1, -2)
|
||||
end
|
||||
|
@ -175,9 +175,9 @@ end
|
|||
---@param path string
|
||||
---@param fn fun(path: string, name:string, type:FileType):boolean?
|
||||
function M.ls(path, fn)
|
||||
local handle = vim.loop.fs_scandir(path)
|
||||
local handle = vim.uv.fs_scandir(path)
|
||||
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
|
||||
break
|
||||
end
|
||||
|
@ -187,7 +187,7 @@ function M.ls(path, fn)
|
|||
-- HACK: type is not always returned due to a bug in luv,
|
||||
-- so fecth it with fs_stat instead when needed.
|
||||
-- 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
|
||||
end
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ function M.lsmod(modname, fn)
|
|||
return
|
||||
end
|
||||
|
||||
if vim.loop.fs_stat(root .. ".lua") then
|
||||
if vim.uv.fs_stat(root .. ".lua") then
|
||||
fn(modname, root .. ".lua")
|
||||
end
|
||||
|
||||
|
@ -272,7 +272,7 @@ function M.lsmod(modname, fn)
|
|||
fn(modname, path)
|
||||
elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then
|
||||
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")
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue