From afb383c91316af25da226c25c4b58113da5ba356 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Thu, 4 Apr 2024 17:31:43 +0300 Subject: [PATCH] refactor(health): keep in mind new way of health check (#63) --- lua/gopher/_utils/health.lua | 26 -------------------------- lua/gopher/health.lua | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 lua/gopher/_utils/health.lua diff --git a/lua/gopher/_utils/health.lua b/lua/gopher/_utils/health.lua deleted file mode 100644 index b651fe4..0000000 --- a/lua/gopher/_utils/health.lua +++ /dev/null @@ -1,26 +0,0 @@ -local h = vim.health or require "health" -local health = {} - -health.start = h.start or h.report_start -health.ok = h.ok or h.report_ok -health.warn = h.warn or h.report_warn -health.error = h.error or h.report_error -health.info = h.info or h.report_info - ----@param module string ----@return boolean -function health.is_lualib_found(module) - local is_found, _ = pcall(require, module) - return is_found -end - ----@param bin string ----@return boolean -function health.is_binary_found(bin) - if vim.fn.executable(bin) == 1 then - return true - end - return false -end - -return health diff --git a/lua/gopher/health.lua b/lua/gopher/health.lua index a7a4d14..633a184 100644 --- a/lua/gopher/health.lua +++ b/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 @@ local deps = { }, { 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 @@ -55,6 +56,15 @@ function health.check() 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 return health