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

refactor(health): keep in mind new way of health check (#63)

Changed files
+20 -3
lua
gopher
+7
lua/gopher/_utils/health.lua lua/gopher/_utils/health_util.lua
··· 23 23 return false 24 24 end 25 25 26 + ---@param ft string 27 + ---@return boolean 28 + function health.is_treesitter_parser_available(ft) 29 + local ok, parser = pcall(vim.treesitter.get_parser, 0, ft) 30 + return ok and parser ~= nil 31 + end 32 + 26 33 return health
+13 -3
lua/gopher/health.lua
··· 1 1 local health = {} 2 2 local cmd = require("gopher.config").commands 3 - local u = require "gopher._utils.health" 3 + local u = require "gopher._utils.health_util" 4 4 5 5 local deps = { 6 6 plugin = { ··· 24 24 }, 25 25 { bin = cmd.dlv, msg = "required for debugging, (`nvim-dap`, `gopher.dap`)", optional = true }, 26 26 }, 27 + treesitter = { 28 + { parser = "go", msg = "required for `gopher.nvim`", optional = false }, 29 + }, 27 30 } 28 31 29 32 function health.check() 30 - u.info "install go treesitter parser by `:TSInstall go` if you don't have it already" 31 - 32 33 u.start "required plugins" 33 34 for _, plugin in ipairs(deps.plugin) do 34 35 if u.is_lualib_found(plugin.lib) then ··· 53 54 else 54 55 u.error(bin.bin .. " not found, " .. bin.msg) 55 56 end 57 + end 58 + end 59 + 60 + u.start "required treesitter parsers" 61 + for _, parser in ipairs(deps.treesitter) do 62 + if u.is_treesitter_parser_available(parser.parser) then 63 + u.ok(parser.parser .. " parser installed") 64 + else 65 + u.error(parser.parser .. " parser not found, " .. parser.msg) 56 66 end 57 67 end 58 68 end