From 12d0885c0d09910fd56f3e97a55580188ab9e974 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Sun, 13 Nov 2022 14:14:15 +0200 Subject: [PATCH] refactor(health): move requires inside of function --- lua/gopher/health.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/gopher/health.lua b/lua/gopher/health.lua index f1cc979..17d76ec 100644 --- a/lua/gopher/health.lua +++ b/lua/gopher/health.lua @@ -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)