From 4e010b50b5ced86782a7282a7587baf0a2d697c0 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Tue, 23 Jul 2024 11:39:07 +0200 Subject: [PATCH] chore: improve checkhealth --- lua/neotest-golang/health.lua | 38 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/lua/neotest-golang/health.lua b/lua/neotest-golang/health.lua index d49aad72..b5972af5 100644 --- a/lua/neotest-golang/health.lua +++ b/lua/neotest-golang/health.lua @@ -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() @@ -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