Skip to content

Commit bff58a6

Browse files
committed
fix(health): Deprecations in nvim-0.10 (fixes #361)
1 parent 9d3c633 commit bff58a6

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

lua/diffview/health.lua

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
local health = vim.health or require("health")
22
local fmt = string.format
33

4+
-- Polyfill deprecated health api
5+
if vim.fn.has("nvim-0.10") ~= 1 then
6+
health = {
7+
start = health.report_start,
8+
ok = health.report_ok,
9+
info = health.report_info,
10+
warn = health.report_warn,
11+
error = health.report_error,
12+
}
13+
end
14+
415
local M = {}
516

617
M.plugin_deps = {
@@ -25,40 +36,40 @@ end
2536

2637
function M.check()
2738
if vim.fn.has("nvim-0.7") == 0 then
28-
health.report_error("Diffview.nvim requires Neovim 0.7.0+")
39+
health.error("Diffview.nvim requires Neovim 0.7.0+")
2940
end
3041

3142
-- LuaJIT
3243
if not _G.jit then
33-
health.report_error("Not running on LuaJIT! Non-JIT Lua runtimes are not officially supported by the plugin. Mileage may vary.")
44+
health.error("Not running on LuaJIT! Non-JIT Lua runtimes are not officially supported by the plugin. Mileage may vary.")
3445
end
3546

36-
health.report_start("Checking plugin dependencies")
47+
health.start("Checking plugin dependencies")
3748

3849
local missing_essential = false
3950

4051
for _, plugin in ipairs(M.plugin_deps) do
4152
if lualib_available(plugin.name) then
42-
health.report_ok(plugin.name .. " installed.")
53+
health.ok(plugin.name .. " installed.")
4354
else
4455
if plugin.optional then
45-
health.report_warn(fmt("Optional dependency '%s' not found.", plugin.name))
56+
health.warn(fmt("Optional dependency '%s' not found.", plugin.name))
4657
else
4758
missing_essential = true
48-
health.report_error(fmt("Dependency '%s' not found!", plugin.name))
59+
health.error(fmt("Dependency '%s' not found!", plugin.name))
4960
end
5061
end
5162
end
5263

53-
health.report_start("Checking VCS tools")
64+
health.start("Checking VCS tools")
5465

5566
;(function()
5667
if missing_essential then
57-
health.report_warn("Cannot perform checks on external dependencies without all essential plugin dependencies installed!")
68+
health.warn("Cannot perform checks on external dependencies without all essential plugin dependencies installed!")
5869
return
5970
end
6071

61-
health.report_info("The plugin requires at least one of the supported VCS tools to be valid.")
72+
health.info("The plugin requires at least one of the supported VCS tools to be valid.")
6273

6374
local has_valid_adapter = false
6475
local adapter_kinds = {
@@ -71,19 +82,19 @@ function M.check()
7182
if not bs.done then kind.class.run_bootstrap() end
7283

7384
if bs.version_string then
74-
health.report_ok(fmt("%s found.", kind.name))
85+
health.ok(fmt("%s found.", kind.name))
7586
end
7687

7788
if bs.ok then
78-
health.report_ok(fmt("%s is up-to-date. (%s)", kind.name, bs.version_string))
89+
health.ok(fmt("%s is up-to-date. (%s)", kind.name, bs.version_string))
7990
has_valid_adapter = true
8091
else
81-
health.report_warn(bs.err or (kind.name .. ": Unknown error"))
92+
health.warn(bs.err or (kind.name .. ": Unknown error"))
8293
end
8394
end
8495

8596
if not has_valid_adapter then
86-
health.report_error("No valid VCS tool was found!")
97+
health.error("No valid VCS tool was found!")
8798
end
8899
end)()
89100
end

0 commit comments

Comments
 (0)