gopher.nvim/lua/gopher/health.lua(view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
local health = {}
local cmd = require("gopher.config").commands
local u = require "gopher._utils.health_util"
local deps = {
plugin = {
{ lib = "dap", msg = "required for `gopher.dap`", optional = true },
{ lib = "plenary", msg = "required for everyting in gopher.nvim", optional = false },
{ lib = "nvim-treesitter", msg = "required for everyting in gopher.nvim", optional = false },
},
bin = {
{
bin = cmd.go,
msg = "required for `:GoGet`, `:GoMod`, `:GoGenerate`, `:GoWork`, `:GoInstallDeps`",
optional = false,
},
{ bin = cmd.gomodifytags, msg = "required for `:GoTagAdd`, `:GoTagRm`", optional = false },
{ bin = cmd.impl, msg = "required for `:GoImpl`", optional = false },
{ bin = cmd.iferr, msg = "required for `:GoIfErr`", optional = false },
{
bin = cmd.gotests,
msg = "required for `:GoTestAdd`, `:GoTestsAll`, `:GoTestsExp`",
optional = false,
},
{ bin = cmd.dlv, msg = "required for debugging, (`nvim-dap`, `gopher.dap`)", optional = true },
},
treesitter = {
{ parser = "go", msg = "required for `gopher.nvim`", optional = false },
},
}
function health.check()
u.start "required plugins"
for _, plugin in ipairs(deps.plugin) do
if u.is_lualib_found(plugin.lib) then
u.ok(plugin.lib .. " installed")
else
if plugin.optional then
u.warn(plugin.lib .. " not found, " .. plugin.msg)
else
u.error(plugin.lib .. " not found, " .. plugin.msg)
end
end
end
u.start "required binaries"
u.info "all those binaries can be installed by `:GoInstallDeps`"
for _, bin in ipairs(deps.bin) do
if u.is_binary_found(bin.bin) then
u.ok(bin.bin .. " installed")
else
if bin.optional then
u.warn(bin.bin .. " not found, " .. bin.msg)
else
u.error(bin.bin .. " not found, " .. bin.msg)
end
end
end
u.start "required treesitter parsers"
for _, parser in ipairs(deps.treesitter) do
if u.is_treesitter_parser_available(parser.parser) then
u.ok(parser.parser .. " parser installed")
else
u.error(parser.parser .. " parser not found, " .. parser.msg)
end
end
end
return health
|