feat(utils): clean up

This commit is contained in:
Matt Leong 2021-11-07 23:39:41 -08:00
parent e552342902
commit abed04444e

View file

@ -47,21 +47,25 @@ function M.get_active_lsp_client_names()
return client_names return client_names
end end
local function reload(module_pattern) local function unload(module_pattern, reload)
reload = reload or false
for module, _ in pairs(package.loaded) do for module, _ in pairs(package.loaded) do
if module:match(module_pattern) then if module:match(module_pattern) then
package.loaded[module] = nil package.loaded[module] = nil
if reload then
require(module) require(module)
end end
end end
end
end end
function M.reload_user_config() function M.reload_user_config()
reload('cosmic.config') unload('cosmic.config', true)
end end
function M.reload_cosmic() function M.reload_cosmic()
reload('cosmic') unload('cosmic')
require('cosmic')
end end
function M.get_install_dir() function M.get_install_dir()