From abed04444ec3c4f04223b1c3d61443c7d8b2b5c8 Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Sun, 7 Nov 2021 23:39:41 -0800 Subject: [PATCH] feat(utils): clean up --- lua/cosmic/utils.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/cosmic/utils.lua b/lua/cosmic/utils.lua index b6efb0c..21e3e54 100644 --- a/lua/cosmic/utils.lua +++ b/lua/cosmic/utils.lua @@ -47,21 +47,25 @@ function M.get_active_lsp_client_names() return client_names end -local function reload(module_pattern) +local function unload(module_pattern, reload) + reload = reload or false for module, _ in pairs(package.loaded) do if module:match(module_pattern) then package.loaded[module] = nil - require(module) + if reload then + require(module) + end end end end function M.reload_user_config() - reload('cosmic.config') + unload('cosmic.config', true) end function M.reload_cosmic() - reload('cosmic') + unload('cosmic') + require('cosmic') end function M.get_install_dir()