all repos

gopher.nvim @ f507a37

Minimalistic plugin for Go development
3 files changed, 55 insertions(+), 0 deletions(-)
feat: add health checker
Author: Smirnov Olexander ss2316544@gmail.com
Committed at: 2022-06-07 01:08:33 +0300
Parent: 8bb8c14
A autoload/health/gopher.vim

@@ -0,0 +1,3 @@

+function! health#gopher#check() + lua require"gopher.health".check() +endfunction
M lua/gopher/_utils/init.lua

@@ -19,4 +19,21 @@ end

return s:sub(1, n) end, + + ---@param lib string + ---@return boolean + lualib_is_found = function(lib) + local is_found, _ = pcall(require, lib) + return is_found + end, + + ---@param bin string + ---@return boolean + binary_is_found = function(bin) + if vim.fn.executable(bin) == 1 then + return true + end + + return false + end, }
A lua/gopher/health.lua

@@ -0,0 +1,35 @@

+local utils = require "gopher._utils" +local M = { + _required = { + plugins = { + { lib = "plenary" }, + { lib = "nvim-treesitter" }, + }, + binarys = { + { bin = "go", help = "required for GoMod command" }, + { bin = "gomodifytags", help = "required for modify struct tags" }, + }, + }, +} + +function M.check() + vim.health.report_start "Required plugins" + for _, plugin in ipairs(M._required.plugins) do + if utils.lualib_is_found(plugin.lib) then + vim.health.report_ok(plugin.lib .. " installed.") + else + vim.health.report_error(plugin.lib .. " not found. Gopher.nvim will not work without it!") + end + end + + vim.health.report_start "Required go tools" + for _, binary in ipairs(M._required.binarys) do + if utils.binary_is_found(binary.bin) then + vim.health.report_ok(binary.bin .. " installed") + else + vim.health.report_warn(binary.bin .. " is not installed but " .. binary.help) + end + end +end + +return M