mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat: use vim.uv
everywhere instead of vim.loop
This commit is contained in:
parent
7f333f006f
commit
3a87c08cda
11 changed files with 23 additions and 23 deletions
|
@ -109,7 +109,7 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
if event.match:match("^%w%w+://") then
|
if event.match:match("^%w%w+://") then
|
||||||
return
|
return
|
||||||
end
|
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")
|
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,7 +18,7 @@ return {
|
||||||
{
|
{
|
||||||
"<leader>fE",
|
"<leader>fE",
|
||||||
function()
|
function()
|
||||||
require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() })
|
require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() })
|
||||||
end,
|
end,
|
||||||
desc = "Explorer NeoTree (cwd)",
|
desc = "Explorer NeoTree (cwd)",
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@ return {
|
||||||
end,
|
end,
|
||||||
init = function()
|
init = function()
|
||||||
if vim.fn.argc(-1) == 1 then
|
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
|
if stat and stat.type == "directory" then
|
||||||
require("neo-tree")
|
require("neo-tree")
|
||||||
end
|
end
|
||||||
|
@ -151,7 +151,7 @@ return {
|
||||||
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
|
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
|
||||||
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
|
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
|
||||||
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
|
{ "<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
|
-- git
|
||||||
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
|
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
|
||||||
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
|
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
|
||||||
|
|
|
@ -23,7 +23,7 @@ return {
|
||||||
{
|
{
|
||||||
"<leader>fM",
|
"<leader>fM",
|
||||||
function()
|
function()
|
||||||
require("mini.files").open(vim.loop.cwd(), true)
|
require("mini.files").open(vim.uv.cwd(), true)
|
||||||
end,
|
end,
|
||||||
desc = "Open mini.files (cwd)",
|
desc = "Open mini.files (cwd)",
|
||||||
},
|
},
|
||||||
|
|
|
@ -109,7 +109,7 @@ return {
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
|
{ "<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>tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
|
||||||
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
|
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
|
||||||
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
|
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
|
||||||
|
|
|
@ -3,7 +3,7 @@ local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config"
|
||||||
|
|
||||||
---@param path string
|
---@param path string
|
||||||
local function have(path)
|
local function have(path)
|
||||||
return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil
|
return vim.uv.fs_stat(xdg_config .. "/" .. path) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -42,7 +42,7 @@ return {
|
||||||
lint.linters_by_ft = opts.linters_by_ft
|
lint.linters_by_ft = opts.linters_by_ft
|
||||||
|
|
||||||
function M.debounce(ms, fn)
|
function M.debounce(ms, fn)
|
||||||
local timer = vim.loop.new_timer()
|
local timer = vim.uv.new_timer()
|
||||||
return function(...)
|
return function(...)
|
||||||
local argv = { ... }
|
local argv = { ... }
|
||||||
timer:start(ms, 0, function()
|
timer:start(ms, 0, function()
|
||||||
|
|
|
@ -50,7 +50,7 @@ setmetatable(M, {
|
||||||
})
|
})
|
||||||
|
|
||||||
function M.is_win()
|
function M.is_win()
|
||||||
return vim.loop.os_uname().sysname:find("Windows") ~= nil
|
return vim.uv.os_uname().sysname:find("Windows") ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param plugin string
|
---@param plugin string
|
||||||
|
@ -97,8 +97,8 @@ function M.lazy_notify()
|
||||||
local orig = vim.notify
|
local orig = vim.notify
|
||||||
vim.notify = temp
|
vim.notify = temp
|
||||||
|
|
||||||
local timer = vim.loop.new_timer()
|
local timer = vim.uv.new_timer()
|
||||||
local check = assert(vim.loop.new_check())
|
local check = assert(vim.uv.new_check())
|
||||||
|
|
||||||
local replay = function()
|
local replay = function()
|
||||||
timer:stop()
|
timer:stop()
|
||||||
|
|
|
@ -5,7 +5,7 @@ local Util = require("lazyvim.util")
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.hash(file)
|
function M.hash(file)
|
||||||
local stat = vim.loop.fs_stat(file)
|
local stat = vim.uv.fs_stat(file)
|
||||||
if not stat then
|
if not stat then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ M.spec = { "lsp", { ".git", "lua" }, "cwd" }
|
||||||
M.detectors = {}
|
M.detectors = {}
|
||||||
|
|
||||||
function M.detectors.cwd()
|
function M.detectors.cwd()
|
||||||
return { vim.loop.cwd() }
|
return { vim.uv.cwd() }
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.detectors.lsp(buf)
|
function M.detectors.lsp(buf)
|
||||||
|
@ -48,7 +48,7 @@ end
|
||||||
---@param patterns string[]|string
|
---@param patterns string[]|string
|
||||||
function M.detectors.pattern(buf, patterns)
|
function M.detectors.pattern(buf, patterns)
|
||||||
patterns = type(patterns) == "string" and { patterns } or 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]
|
local pattern = vim.fs.find(patterns, { path = path, upward = true })[1]
|
||||||
return pattern and { vim.fs.dirname(pattern) } or {}
|
return pattern and { vim.fs.dirname(pattern) } or {}
|
||||||
end
|
end
|
||||||
|
@ -58,14 +58,14 @@ function M.bufpath(buf)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.cwd()
|
function M.cwd()
|
||||||
return M.realpath(vim.loop.cwd()) or ""
|
return M.realpath(vim.uv.cwd()) or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.realpath(path)
|
function M.realpath(path)
|
||||||
if path == "" or path == nil then
|
if path == "" or path == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
path = vim.loop.fs_realpath(path) or path
|
path = vim.uv.fs_realpath(path) or path
|
||||||
return Util.norm(path)
|
return Util.norm(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ function M.info()
|
||||||
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
|
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
|
||||||
lines[#lines + 1] = "```"
|
lines[#lines + 1] = "```"
|
||||||
require("lazyvim.util").info(lines, { title = "LazyVim Roots" })
|
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
|
end
|
||||||
|
|
||||||
---@type table<number, string>
|
---@type table<number, string>
|
||||||
|
@ -164,7 +164,7 @@ function M.get(opts)
|
||||||
local ret = M.cache[buf]
|
local ret = M.cache[buf]
|
||||||
if not ret then
|
if not ret then
|
||||||
local roots = M.detect({ all = false })
|
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
|
M.cache[buf] = ret
|
||||||
end
|
end
|
||||||
if opts and opts.normalize then
|
if opts and opts.normalize then
|
||||||
|
|
|
@ -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]]
|
opts = vim.tbl_deep_extend("force", { cwd = Util.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]]
|
||||||
if builtin == "files" then
|
if builtin == "files" then
|
||||||
if
|
if
|
||||||
vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git")
|
vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git")
|
||||||
and not vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.ignore")
|
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore")
|
||||||
and not vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.rgignore")
|
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore")
|
||||||
then
|
then
|
||||||
if opts.show_untracked == nil then
|
if opts.show_untracked == nil then
|
||||||
opts.show_untracked = true
|
opts.show_untracked = true
|
||||||
|
@ -37,7 +37,7 @@ function M.telescope(builtin, opts)
|
||||||
builtin = "find_files"
|
builtin = "find_files"
|
||||||
end
|
end
|
||||||
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 function open_cwd_dir()
|
||||||
local action_state = require("telescope.actions.state")
|
local action_state = require("telescope.actions.state")
|
||||||
local line = action_state.get_current_line()
|
local line = action_state.get_current_line()
|
||||||
|
|
|
@ -150,7 +150,7 @@ function M.fg(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.skip_foldexpr = {} ---@type table<number,boolean>
|
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()
|
function M.foldexpr()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue