Skip to content

Commit c8cad54

Browse files
authored
fix(checkhealth): use non-deprecated versions if possible (#729)
1 parent 86c1a76 commit c8cad54

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

lua/lazy/health.lua

+19-13
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ local Config = require("lazy.core.config")
22

33
local M = {}
44

5+
-- "report_" prefix has been deprecated, use the recommended replacements if they exist.
6+
local start = vim.health.start or vim.health.report_start
7+
local ok = vim.health.ok or vim.health.report_ok
8+
local warn = vim.health.warn or vim.health.report_warn
9+
local error = vim.health.error or vim.health.report_error
10+
511
function M.check()
6-
vim.health.report_start("lazy.nvim")
12+
start("lazy.nvim")
713

814
if vim.fn.executable("git") == 1 then
9-
vim.health.report_ok("Git installed")
15+
ok("Git installed")
1016
else
11-
vim.health.report_error("Git not installd?")
17+
error("Git not installd?")
1218
end
1319

1420
local sites = vim.opt.packpath:get()
@@ -22,28 +28,28 @@ function M.check()
2228
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
2329
if not packs:find("[/\\]dist$") and vim.loop.fs_stat(packs) then
2430
existing = true
25-
vim.health.report_warn("found existing packages at `" .. packs .. "`")
31+
warn("found existing packages at `" .. packs .. "`")
2632
end
2733
end
2834
end
2935
if not existing then
30-
vim.health.report_ok("no existing packages found by other package managers")
36+
ok("no existing packages found by other package managers")
3137
end
3238

3339
for _, name in ipairs({ "packer", "plugged", "paq" }) do
3440
for _, path in ipairs(vim.opt.rtp:get()) do
3541
if path:find(name, 1, true) then
36-
vim.health.report_error("Found paths on the rtp from another plugin manager `" .. name .. "`")
42+
error("Found paths on the rtp from another plugin manager `" .. name .. "`")
3743
break
3844
end
3945
end
4046
end
4147

4248
local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
4349
if vim.loop.fs_stat(packer_compiled) then
44-
vim.health.report_error("please remove the file `" .. packer_compiled .. "`")
50+
error("please remove the file `" .. packer_compiled .. "`")
4551
else
46-
vim.health.report_ok("packer_compiled.lua not found")
52+
ok("packer_compiled.lua not found")
4753
end
4854

4955
local spec = Config.spec
@@ -52,14 +58,14 @@ function M.check()
5258
M.check_override(plugin)
5359
end
5460
if #spec.notifs > 0 then
55-
vim.health.report_error("Issues were reported when loading your specs:")
61+
error("Issues were reported when loading your specs:")
5662
for _, notif in ipairs(spec.notifs) do
5763
local lines = vim.split(notif.msg, "\n")
5864
for _, line in ipairs(lines) do
5965
if notif.level == vim.log.levels.ERROR then
60-
vim.health.report_error(line)
66+
error(line)
6167
else
62-
vim.health.report_warn(line)
68+
warn(line)
6369
end
6470
end
6571
end
@@ -71,7 +77,7 @@ function M.check_valid(plugin)
7177
for key in pairs(plugin) do
7278
if not vim.tbl_contains(M.valid, key) then
7379
if key ~= "module" or type(plugin.module) ~= "boolean" then
74-
vim.health.report_warn("{" .. plugin.name .. "}: unknown key <" .. key .. ">")
80+
warn("{" .. plugin.name .. "}: unknown key <" .. key .. ">")
7581
end
7682
end
7783
end
@@ -89,7 +95,7 @@ function M.check_override(plugin)
8995

9096
for key, value in pairs(plugin._.super) do
9197
if not vim.tbl_contains(skip, key) and plugin[key] and plugin[key] ~= value then
92-
vim.health.report_warn("{" .. plugin.name .. "}: overriding <" .. key .. ">")
98+
warn("{" .. plugin.name .. "}: overriding <" .. key .. ">")
9399
end
94100
end
95101
end

0 commit comments

Comments
 (0)