Skip to content

Commit

Permalink
chore: improve checkhealth
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jul 23, 2024
1 parent 4e85955 commit 4e010b5
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions lua/neotest-golang/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,36 @@ local lib = require("neotest-golang.lib")
local M = {}

function M.check()
M.go_binary_on_path()
start("Requirements")
M.binary_found_on_path("go")
M.go_mod_found()

M.treesitter_parser_installed("go")
M.is_plugin_available("neotest")
M.is_plugin_available("nvim-treesitter")
M.is_plugin_available("nio")
M.is_plugin_available("dap-go")
M.is_plugin_available("plenary")

start("DAP (optional)")
M.binary_found_on_path("dlv")
M.is_plugin_available("dap")
M.is_plugin_available("dapui")
M.is_plugin_available("dap-go")
end

function M.go_binary_on_path()
local go = vim.fn.executable("go")
if go == 1 then
ok("Go binary found on PATH: " .. vim.fn.exepath("go"))
function M.binary_found_on_path(executable)
local found = vim.fn.executable(executable)
if found == 1 then
ok(
"Binary '"
.. executable
.. "' found on PATH: "
.. vim.fn.exepath(executable)
)
return true
else
warn("Go binary not found on PATH")
warn("Binary '" .. executable .. "' not found on PATH")
end
return false
end

function M.go_mod_found()
Expand Down Expand Up @@ -54,4 +67,13 @@ function M.is_plugin_available(plugin)
end
end

function M.treesitter_parser_installed(lang)
local is_installed = require("nvim-treesitter.parsers").has_parser(lang)
if is_installed then
ok("Treesitter parser for " .. lang .. " is installed")
else
warn("Treesitter parser for " .. lang .. " is not installed")
end
end

return M

0 comments on commit 4e010b5

Please sign in to comment.