From 7b03a0e779449f0e0b024e555c09a8ef3ff24c49 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 18 Jan 2024 16:22:20 -0500 Subject: [PATCH] fix(lazy): validate lazy is able to be loaded --- lua/config/lazy.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 450f355..aec5f07 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -1,12 +1,20 @@ -local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then +local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not (vim.env.LAZY or vim.loop.fs_stat(lazypath)) then vim.g.astronvim_first_install = true -- lets AstroNvim know that this is an initial installation -- stylua: ignore vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) end -vim.opt.rtp:prepend(vim.env.LAZY or lazypath) +vim.opt.rtp:prepend(lazypath) -require("lazy").setup { +local lazy_loaded, lazy = pcall(require, "lazy") -- validate that lazy is available +if not lazy_loaded then + -- stylua: ignore + vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) + vim.fn.getchar() + vim.cmd.quit() +end + +lazy.setup { spec = { -- TODO: change `branch="v4"` to `version="^4"` on release { "AstroNvim/AstroNvim", branch = "v4", import = "astronvim.plugins" },