From e5bcf01c759e7c833d8a5f1fcf665b6ea32a7c16 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 4 Oct 2022 19:23:52 +0200 Subject: refactor: more deliberate reload (#3133) --- lua/lvim/bootstrap.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lua/lvim/bootstrap.lua') diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua index e0b781d7..b803cfa6 100644 --- a/lua/lvim/bootstrap.lua +++ b/lua/lvim/bootstrap.lua @@ -19,15 +19,9 @@ function _G.join_paths(...) return result end ----Require a module in protected mode without relying on its cached value ----@param module string ----@return any -function _G.require_clean(module) - package.loaded[module] = nil - _G[module] = nil - local _, requested = pcall(require, module) - return requested -end +_G.require_clean = require("lvim.utils.modules").require_clean +_G.require_safe = require("lvim.utils.modules").require_safe +_G.reload = require("lvim.utils.modules").reload ---Get the full path to `$LUNARVIM_RUNTIME_DIR` ---@return string @@ -121,10 +115,10 @@ end ---Update LunarVim ---pulls the latest changes from github and, resets the startup cache function M:update() - require_clean("lvim.utils.hooks").run_pre_update() - local ret = require_clean("lvim.utils.git").update_base_lvim() + reload("lvim.utils.hooks").run_pre_update() + local ret = reload("lvim.utils.git").update_base_lvim() if ret then - require_clean("lvim.utils.hooks").run_post_update() + reload("lvim.utils.hooks").run_post_update() end end -- cgit v1.2.3