gopher.nvim/lua/gopher/health.lua
Smirnov Oleksandr 6016ca57d4
refactor: use vim.system instead of pleanry (#85)
* refactor!: migrate to vim.system

* refactor(gotests): use vim.system

* refactor(iferr): use vim.system

* refactor(impl): use vim.system

* refactor(installer): use vim.system and add sync mode

* test: fix gotests' tests

* refactor(struct_tags): use vim.system

* chore(ci): install all deps explicitly

* refactor(installer)!: add sync as an option

* docs: update readme
2025-03-02 16:31:50 +02:00

63 lines
1.8 KiB
Lua

local health = {}
local cmd = require("gopher.config").commands
local u = require "gopher._utils.health_util"
local deps = {
plugin = {
{ lib = "nvim-treesitter", msg = "required for everything in gopher.nvim" },
},
bin = {
{
bin = cmd.go,
msg = "required for `:GoGet`, `:GoMod`, `:GoGenerate`, `:GoWork`, `:GoInstallDeps`",
optional = false,
},
{ bin = cmd.gomodifytags, msg = "required for `:GoTagAdd`, `:GoTagRm`", optional = true },
{ bin = cmd.impl, msg = "required for `:GoImpl`", optional = true },
{ bin = cmd.iferr, msg = "required for `:GoIfErr`", optional = true },
{
bin = cmd.gotests,
msg = "required for `:GoTestAdd`, `:GoTestsAll`, `:GoTestsExp`",
optional = true,
},
},
treesitter = {
{ parser = "go", msg = "required for `gopher.nvim`" },
},
}
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
u.error(plugin.lib .. " not found, " .. plugin.msg)
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