all repos

gopher.nvim @ 65fa1486612ac4392f48e484ba0d6dbdac184256

Minimalistic plugin for Go development
2 files changed, 20 insertions(+), 3 deletions(-)
refactor(health): keep in mind new way of health check (#63)

Author: Smirnov Oleksandr ss2316544@gmail.com
Committed at: 2024-06-07 21:14:35 +0300
Parent: 10cec9c
M lua/gopher/_utils/health_util.lualua/gopher/_utils/health_util.lua

@@ -23,4 +23,11 @@ end

return false end +---@param ft string +---@return boolean +function health.is_treesitter_parser_available(ft) + local ok, parser = pcall(vim.treesitter.get_parser, 0, ft) + return ok and parser ~= nil +end + return health
M lua/gopher/health.lua

@@ -1,6 +1,6 @@

local health = {} local cmd = require("gopher.config").commands -local u = require "gopher._utils.health" +local u = require "gopher._utils.health_util" local deps = { plugin = {

@@ -24,11 +24,12 @@ 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.info "install go treesitter parser by `:TSInstall go` if you don't have it already" - u.start "required plugins" for _, plugin in ipairs(deps.plugin) do if u.is_lualib_found(plugin.lib) then

@@ -53,6 +54,15 @@ 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