Skip to content

Commit ab73916

Browse files
Handle deprecated healthcheck api (#25)
1 parent 2986599 commit ab73916

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lua/neotest-busted/health.lua

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,36 @@ local config = require("neotest-busted.config")
55

66
local min_neovim_version = "0.9.0"
77

8+
local report_start = vim.health.report_start
9+
local report_ok = vim.health.report_ok
10+
local report_error = vim.health.report_error
11+
local report_warn = vim.health.report_warn
12+
13+
if vim.fn.has("nvim-0.10") == 1 then
14+
report_start = vim.health.start
15+
report_ok = vim.health.ok
16+
report_error = vim.health.error
17+
report_warn = vim.health.warn
18+
end
19+
820
---@param module_name string
921
local function check_module_installed(module_name)
1022
local installed, _ = pcall(require, module_name)
1123

1224
if installed then
13-
vim.health.report_ok(("`%s` is installed"):format(module_name))
25+
report_ok(("`%s` is installed"):format(module_name))
1426
else
15-
vim.health.report_error(("`%s` is not installed"):format(module_name))
27+
report_error(("`%s` is not installed"):format(module_name))
1628
end
1729
end
1830

1931
function health.check()
20-
vim.health.report_start("neotest-busted")
32+
report_start("neotest-busted")
2133

2234
if vim.fn.has("nvim-" .. min_neovim_version) == 1 then
23-
vim.health.report_ok(("has neovim %s+"):format(min_neovim_version))
35+
report_ok(("has neovim %s+"):format(min_neovim_version))
2436
else
25-
vim.health.report_error("neotest-busted requires at least neovim " .. min_neovim_version)
37+
report_error("neotest-busted requires at least neovim " .. min_neovim_version)
2638
end
2739

2840
-- NOTE: We cannot check the neotest version because it isn't advertised as
@@ -33,24 +45,24 @@ function health.check()
3345
local ok, error = config.validate(config)
3446

3547
if ok then
36-
vim.health.report_ok("found no errors in config")
48+
report_ok("found no errors in config")
3749
else
38-
vim.health.report_error("config has errors: " .. error)
50+
report_error("config has errors: " .. error)
3951
end
4052

4153
-- We skip looking for a local luarocks installation as the healthcheck
4254
-- could have been invoked from anywhere
4355
local busted = adapter.find_busted_command(true)
4456

4557
if busted then
46-
vim.health.report_ok(
58+
report_ok(
4759
("found `busted` (type: %s) at\n%s"):format(
4860
busted.type,
4961
vim.loop.fs_realpath(busted.command)
5062
)
5163
)
5264
else
53-
vim.health.report_warn(
65+
report_warn(
5466
"could not find busted executable globally or in user home folder",
5567
"if not already installed locally, please install busted using luarocks (https://luarocks.org/)"
5668
)

0 commit comments

Comments
 (0)