2022-01-15 11:14:56 +00:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
local util = require("go.utils")
|
|
|
|
local log = util.log
|
|
|
|
local health = require("health")
|
|
|
|
local tools = require("go.install").tools
|
|
|
|
|
|
|
|
local start = health.report_start
|
|
|
|
local ok = health.report_ok
|
|
|
|
local error = health.report_error
|
|
|
|
local warn = health.report_warn
|
|
|
|
local info = health.report_info
|
2022-06-01 11:29:13 +00:00
|
|
|
local vfn = vim.fn
|
2022-01-15 11:14:56 +00:00
|
|
|
|
|
|
|
local function binary_check()
|
|
|
|
health.report_start("Binaries")
|
|
|
|
local no_err = true
|
|
|
|
local go_bin = _GO_NVIM_CFG.go or "go"
|
2022-06-01 11:29:13 +00:00
|
|
|
if vfn.executable(go_bin) == 1 then
|
2022-01-15 11:14:56 +00:00
|
|
|
info(go_bin .. " installed.")
|
|
|
|
else
|
|
|
|
error(go_bin .. " is not installed.")
|
|
|
|
no_err = false
|
|
|
|
end
|
|
|
|
for _, val in ipairs(tools) do
|
|
|
|
log(val)
|
2022-06-01 11:29:13 +00:00
|
|
|
if vfn.executable(val) == 1 then
|
2022-01-15 11:14:56 +00:00
|
|
|
info("Tool installed: " .. val)
|
|
|
|
else
|
|
|
|
warn("Missing tool: " .. val)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if no_err then
|
|
|
|
ok("All binaries installed")
|
|
|
|
end
|
2022-05-10 01:03:15 +00:00
|
|
|
|
2022-06-01 11:29:13 +00:00
|
|
|
if vfn.executable('sed') == 1 then
|
2022-05-10 01:03:15 +00:00
|
|
|
info("sed installed.")
|
|
|
|
else
|
|
|
|
warn("sed is not installed.")
|
|
|
|
end
|
2022-05-25 06:06:36 +00:00
|
|
|
|
2022-06-01 11:29:13 +00:00
|
|
|
if vfn.executable('sed') == 1 then
|
2022-05-25 06:06:36 +00:00
|
|
|
info("sed installed.")
|
|
|
|
else
|
|
|
|
warn("sed is not installed.")
|
|
|
|
end
|
|
|
|
|
2022-06-01 11:29:13 +00:00
|
|
|
if vfn.executable('curl') == 1 then
|
2022-05-25 06:06:36 +00:00
|
|
|
info("curl installed.")
|
|
|
|
else
|
|
|
|
warn("curl is not installed.")
|
|
|
|
end
|
2022-01-15 11:14:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function plugin_check()
|
|
|
|
start("Go Plugin Check")
|
|
|
|
|
|
|
|
local plugins = {
|
|
|
|
"lspconfig",
|
|
|
|
"nvim-treesitter",
|
|
|
|
"guihua",
|
|
|
|
"nvim-dap-virtual-text",
|
|
|
|
"telescope",
|
|
|
|
}
|
|
|
|
local any_warn = false
|
2022-02-16 11:11:36 +00:00
|
|
|
local ts_installed = false
|
2022-01-15 11:14:56 +00:00
|
|
|
for _, plugin in ipairs(plugins) do
|
|
|
|
local pi = util.load_plugin(plugin)
|
|
|
|
if pi ~= nil then
|
|
|
|
ok(string.format("%s: plugin is installed", plugin))
|
2022-02-16 11:11:36 +00:00
|
|
|
if plugin == "nvim-treesitter" then
|
|
|
|
ts_installed = true
|
|
|
|
end
|
2022-01-15 11:14:56 +00:00
|
|
|
else
|
|
|
|
any_warn = true
|
|
|
|
warn(string.format("%s: not installed/loaded", plugin))
|
|
|
|
end
|
|
|
|
end
|
2022-02-16 11:11:36 +00:00
|
|
|
if ts_installed then
|
2022-06-01 11:29:13 +00:00
|
|
|
local _info = require("nvim-treesitter.info").installed_parsers()
|
|
|
|
if vim.tbl_contains(_info, "go") then
|
2022-02-16 11:11:36 +00:00
|
|
|
ok("nvim-treesitter-go is installed")
|
|
|
|
else
|
|
|
|
warn("nvim-treesitter-go is not installed, Please run TSInstall go to install")
|
|
|
|
any_warn = true
|
|
|
|
end
|
|
|
|
end
|
2022-01-15 11:14:56 +00:00
|
|
|
plugins = {
|
|
|
|
["nvim-dap"] = "dap",
|
|
|
|
["nvim-dap-ui"] = "dapui",
|
|
|
|
}
|
|
|
|
for name, req in pairs(plugins) do
|
|
|
|
local pi = util.load_plugin(name, req)
|
|
|
|
if pi ~= nil then
|
|
|
|
ok(string.format("%s: plugin is installed", name))
|
|
|
|
else
|
|
|
|
any_warn = true
|
|
|
|
warn(string.format("%s: not installed/loaded", name))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if any_warn then
|
|
|
|
warn("Not all plugin installed")
|
|
|
|
else
|
|
|
|
ok("All plugin installed")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.check()
|
|
|
|
binary_check()
|
|
|
|
plugin_check()
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|