refactor(health): move requires inside of function

This commit is contained in:
Smirnov Oleksandr 2022-11-13 14:14:15 +02:00
parent 125cac7058
commit 12d0885c0d

View file

@ -1,13 +1,11 @@
local health = vim.health or require "health"
local utils = require "gopher._utils._health"
local c = require("gopher.config").config.commands
local requried = "Gopher.nvim will not work without it!"
local requried_for_work_msg = "Gopher.nvim will not work without it!"
local M = {
_required = {
plugins = {
{ lib = "plenary", help = requried },
{ lib = "nvim-treesitter", help = requried },
{ lib = "plenary", help = requried_for_work_msg },
{ lib = "nvim-treesitter", help = requried_for_work_msg },
{ lib = "dap", help = "Required for set upping debugger" },
},
binarys = {
@ -21,9 +19,12 @@ local M = {
}
function M.check()
local health = vim.health or require "health"
local u = require "gopher._utils._health"
health.report_start "Required plugins"
for _, plugin in ipairs(M._required.plugins) do
if utils.lualib_is_found(plugin.lib) then
if u.lualib_is_found(plugin.lib) then
health.report_ok(plugin.lib .. " installed.")
else
health.report_error(plugin.lib .. " not found. " .. plugin.help)
@ -32,7 +33,7 @@ function M.check()
health.report_start "Required go tools"
for _, binary in ipairs(M._required.binarys) do
if utils.binary_is_found(binary.bin) then
if u.binary_is_found(binary.bin) then
health.report_ok(binary.bin .. " installed")
else
health.report_warn(binary.bin .. " is not installed but " .. binary.help)