From 0c7b41872ed20f12b45c41cadbccbf74554ac68e Mon Sep 17 00:00:00 2001 From: Ulibos <49131389+Ulibos@users.noreply.github.com> Date: Thu, 27 Apr 2023 19:21:02 +0300 Subject: [PATCH] fix(health): show error if setup didn't run * Fix back bootstrapping and healthcheck for fresh install with no packages to fetch. * Revert changes to bootstrapping, make checkhealth produce more meaningful message. --- lua/lazy/health.lua | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua index 38fa0ed..f0ccb22 100644 --- a/lua/lazy/health.lua +++ b/lua/lazy/health.lua @@ -53,19 +53,23 @@ function M.check() end local spec = Config.spec - for _, plugin in pairs(spec.plugins) do - M.check_valid(plugin) - M.check_override(plugin) - end - if #spec.notifs > 0 then - error("Issues were reported when loading your specs:") - for _, notif in ipairs(spec.notifs) do - local lines = vim.split(notif.msg, "\n") - for _, line in ipairs(lines) do - if notif.level == vim.log.levels.ERROR then - error(line) - else - warn(line) + if spec == nil then + error("No plugins loaded. Did you forget to run `require(\"lazy\").setup()`?") + else + for _, plugin in pairs(spec.plugins) do + M.check_valid(plugin) + M.check_override(plugin) + end + if #spec.notifs > 0 then + error("Issues were reported when loading your specs:") + for _, notif in ipairs(spec.notifs) do + local lines = vim.split(notif.msg, "\n") + for _, line in ipairs(lines) do + if notif.level == vim.log.levels.ERROR then + error(line) + else + warn(line) + end end end end