utest.nvim/lua/utest/health.lua (view raw)
| 1 | ---@param parser string |
| 2 | local function check_treesitter(parser) |
| 3 | local ok, p = pcall(vim.treesitter.get_parser, 0, parser) |
| 4 | if ok and p ~= nil then |
| 5 | vim.health.ok("`" .. parser .. "` parser is installed") |
| 6 | else |
| 7 | vim.health.error("`" .. parser .. "` parser not found") |
| 8 | end |
| 9 | end |
| 10 | |
| 11 | ---@param bin string |
| 12 | local function check_binary(bin) |
| 13 | if vim.fn.executable(bin) == 1 then |
| 14 | vim.health.ok(bin .. " is found oh PATH: `" .. vim.fn.exepath(bin) .. "`") |
| 15 | else |
| 16 | vim.health.error(bin .. " not found on PATH") |
| 17 | end |
| 18 | end |
| 19 | |
| 20 | local health = {} |
| 21 | function health.check() |
| 22 | vim.health.start "Go adapter" |
| 23 | check_treesitter "go" |
| 24 | check_binary "go" |
| 25 | end |
| 26 | |
| 27 | return health |