Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve checkhealth #153

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading