[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang

feat: add health checker

Changed files
+55
autoload
health
lua
gopher
+3
autoload/health/gopher.vim
··· 1 + function! health#gopher#check() 2 + lua require"gopher.health".check() 3 + endfunction
+17
lua/gopher/_utils/init.lua
··· 19 19 20 20 return s:sub(1, n) 21 21 end, 22 + 23 + ---@param lib string 24 + ---@return boolean 25 + lualib_is_found = function(lib) 26 + local is_found, _ = pcall(require, lib) 27 + return is_found 28 + end, 29 + 30 + ---@param bin string 31 + ---@return boolean 32 + binary_is_found = function(bin) 33 + if vim.fn.executable(bin) == 1 then 34 + return true 35 + end 36 + 37 + return false 38 + end, 22 39 }
+35
lua/gopher/health.lua
··· 1 + local utils = require "gopher._utils" 2 + local M = { 3 + _required = { 4 + plugins = { 5 + { lib = "plenary" }, 6 + { lib = "nvim-treesitter" }, 7 + }, 8 + binarys = { 9 + { bin = "go", help = "required for GoMod command" }, 10 + { bin = "gomodifytags", help = "required for modify struct tags" }, 11 + }, 12 + }, 13 + } 14 + 15 + function M.check() 16 + vim.health.report_start "Required plugins" 17 + for _, plugin in ipairs(M._required.plugins) do 18 + if utils.lualib_is_found(plugin.lib) then 19 + vim.health.report_ok(plugin.lib .. " installed.") 20 + else 21 + vim.health.report_error(plugin.lib .. " not found. Gopher.nvim will not work without it!") 22 + end 23 + end 24 + 25 + vim.health.report_start "Required go tools" 26 + for _, binary in ipairs(M._required.binarys) do 27 + if utils.binary_is_found(binary.bin) then 28 + vim.health.report_ok(binary.bin .. " installed") 29 + else 30 + vim.health.report_warn(binary.bin .. " is not installed but " .. binary.help) 31 + end 32 + end 33 + end 34 + 35 + return M