feat: use vim.uv everywhere instead of vim.loop

This commit is contained in:
Folke Lemaitre 2024-03-22 09:02:34 +01:00
parent 7f333f006f
commit 3a87c08cda
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
11 changed files with 23 additions and 23 deletions

View file

@ -50,7 +50,7 @@ setmetatable(M, {
})
function M.is_win()
return vim.loop.os_uname().sysname:find("Windows") ~= nil
return vim.uv.os_uname().sysname:find("Windows") ~= nil
end
---@param plugin string
@ -97,8 +97,8 @@ function M.lazy_notify()
local orig = vim.notify
vim.notify = temp
local timer = vim.loop.new_timer()
local check = assert(vim.loop.new_check())
local timer = vim.uv.new_timer()
local check = assert(vim.uv.new_check())
local replay = function()
timer:stop()

View file

@ -5,7 +5,7 @@ local Util = require("lazyvim.util")
local M = {}
function M.hash(file)
local stat = vim.loop.fs_stat(file)
local stat = vim.uv.fs_stat(file)
if not stat then
return
end

View file

@ -22,7 +22,7 @@ M.spec = { "lsp", { ".git", "lua" }, "cwd" }
M.detectors = {}
function M.detectors.cwd()
return { vim.loop.cwd() }
return { vim.uv.cwd() }
end
function M.detectors.lsp(buf)
@ -48,7 +48,7 @@ end
---@param patterns string[]|string
function M.detectors.pattern(buf, patterns)
patterns = type(patterns) == "string" and { patterns } or patterns
local path = M.bufpath(buf) or vim.loop.cwd()
local path = M.bufpath(buf) or vim.uv.cwd()
local pattern = vim.fs.find(patterns, { path = path, upward = true })[1]
return pattern and { vim.fs.dirname(pattern) } or {}
end
@ -58,14 +58,14 @@ function M.bufpath(buf)
end
function M.cwd()
return M.realpath(vim.loop.cwd()) or ""
return M.realpath(vim.uv.cwd()) or ""
end
function M.realpath(path)
if path == "" or path == nil then
return nil
end
path = vim.loop.fs_realpath(path) or path
path = vim.uv.fs_realpath(path) or path
return Util.norm(path)
end
@ -133,7 +133,7 @@ function M.info()
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
lines[#lines + 1] = "```"
require("lazyvim.util").info(lines, { title = "LazyVim Roots" })
return roots[1] and roots[1].paths[1] or vim.loop.cwd()
return roots[1] and roots[1].paths[1] or vim.uv.cwd()
end
---@type table<number, string>
@ -164,7 +164,7 @@ function M.get(opts)
local ret = M.cache[buf]
if not ret then
local roots = M.detect({ all = false })
ret = roots[1] and roots[1].paths[1] or vim.loop.cwd()
ret = roots[1] and roots[1].paths[1] or vim.uv.cwd()
M.cache[buf] = ret
end
if opts and opts.normalize then

View file

@ -25,9 +25,9 @@ function M.telescope(builtin, opts)
opts = vim.tbl_deep_extend("force", { cwd = Util.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]]
if builtin == "files" then
if
vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git")
and not vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.ignore")
and not vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.rgignore")
vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git")
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore")
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore")
then
if opts.show_untracked == nil then
opts.show_untracked = true
@ -37,7 +37,7 @@ function M.telescope(builtin, opts)
builtin = "find_files"
end
end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
if opts.cwd and opts.cwd ~= vim.uv.cwd() then
local function open_cwd_dir()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()

View file

@ -150,7 +150,7 @@ function M.fg(name)
end
M.skip_foldexpr = {} ---@type table<number,boolean>
local skip_check = assert(vim.loop.new_check())
local skip_check = assert(vim.uv.new_check())
function M.foldexpr()
local buf = vim.api.nvim_get_current_buf()