feat: use LazyVim everywhere instead of require("lazyvim.util")

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

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.format
---@overload fun(opts?: {force?:boolean})
local M = setmetatable({}, {
@ -26,7 +24,7 @@ function M.register(formatter)
end
function M.formatexpr()
if Util.has("conform.nvim") then
if LazyVim.has("conform.nvim") then
return require("conform").formatexpr()
end
return vim.lsp.formatexpr({ timeout_ms = 3000 })
@ -76,7 +74,7 @@ function M.info(buf)
if not have then
lines[#lines + 1] = "\n***No formatters available for this buffer.***"
end
Util[enabled and "info" or "warn"](
LazyVim[enabled and "info" or "warn"](
table.concat(lines, "\n"),
{ title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" }
)
@ -120,14 +118,14 @@ function M.format(opts)
for _, formatter in ipairs(M.resolve(buf)) do
if formatter.active then
done = true
Util.try(function()
LazyVim.try(function()
return formatter.format(buf)
end, { msg = "Formatter `" .. formatter.name .. "` failed" })
end
end
if not done and opts and opts.force then
Util.warn("No formatter available", { title = "LazyVim" })
LazyVim.warn("No formatter available", { title = "LazyVim" })
end
end
@ -136,7 +134,7 @@ function M.health()
local has_plugin = Config.spec.plugins["none-ls.nvim"]
local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls")
if has_plugin and not has_extra then
Util.warn({
LazyVim.warn({
"`conform.nvim` and `nvim-lint` are now the default formatters and linters in LazyVim.",
"",
"You can use those plugins together with `none-ls.nvim`,",