refactor(health): keep in mind new way of health check (#63)
This commit is contained in:
parent
10cec9c6b0
commit
65fa148661
2 changed files with 20 additions and 3 deletions
|
|
@ -23,4 +23,11 @@ function health.is_binary_found(bin)
|
||||||
return false
|
return false
|
||||||
end
|
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
|
return health
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local health = {}
|
local health = {}
|
||||||
local cmd = require("gopher.config").commands
|
local cmd = require("gopher.config").commands
|
||||||
local u = require "gopher._utils.health"
|
local u = require "gopher._utils.health_util"
|
||||||
|
|
||||||
local deps = {
|
local deps = {
|
||||||
plugin = {
|
plugin = {
|
||||||
|
|
@ -24,11 +24,12 @@ local deps = {
|
||||||
},
|
},
|
||||||
{ bin = cmd.dlv, msg = "required for debugging, (`nvim-dap`, `gopher.dap`)", optional = true },
|
{ 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()
|
function health.check()
|
||||||
u.info "install go treesitter parser by `:TSInstall go` if you don't have it already"
|
|
||||||
|
|
||||||
u.start "required plugins"
|
u.start "required plugins"
|
||||||
for _, plugin in ipairs(deps.plugin) do
|
for _, plugin in ipairs(deps.plugin) do
|
||||||
if u.is_lualib_found(plugin.lib) then
|
if u.is_lualib_found(plugin.lib) then
|
||||||
|
|
@ -55,6 +56,15 @@ function health.check()
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
return health
|
return health
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue