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
11 changed files with 23 additions and 23 deletions

View File

@ -109,7 +109,7 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
if event.match:match("^%w%w+://") then
return
end
local file = vim.loop.fs_realpath(event.match) or event.match
local file = vim.uv.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})

View File

@ -18,7 +18,7 @@ return {
{
"<leader>fE",
function()
require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() })
require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() })
end,
desc = "Explorer NeoTree (cwd)",
},
@ -44,7 +44,7 @@ return {
end,
init = function()
if vim.fn.argc(-1) == 1 then
local stat = vim.loop.fs_stat(vim.fn.argv(0))
local stat = vim.uv.fs_stat(vim.fn.argv(0))
if stat and stat.type == "directory" then
require("neo-tree")
end
@ -151,7 +151,7 @@ return {
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>fR", Util.telescope("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" },
{ "<leader>fR", Util.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" },
-- git
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },

View File

@ -23,7 +23,7 @@ return {
{
"<leader>fM",
function()
require("mini.files").open(vim.loop.cwd(), true)
require("mini.files").open(vim.uv.cwd(), true)
end,
desc = "Open mini.files (cwd)",
},

View File

@ -109,7 +109,7 @@ return {
-- stylua: ignore
keys = {
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
{ "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
{ "<leader>tT", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "Run All Test Files" },
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },

View File

@ -3,7 +3,7 @@ local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config"
---@param path string
local function have(path)
return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil
return vim.uv.fs_stat(xdg_config .. "/" .. path) ~= nil
end
return {

View File

@ -42,7 +42,7 @@ return {
lint.linters_by_ft = opts.linters_by_ft
function M.debounce(ms, fn)
local timer = vim.loop.new_timer()
local timer = vim.uv.new_timer()
return function(...)
local argv = { ... }
timer:start(ms, 0, function()

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()