From 325bf72f935aa2caf25cb644f79dc7a3ea2c1168 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 1 Nov 2022 15:22:20 +0100 Subject: refactor(hooks): use colorscheme event after reload (#3375) --- lua/lvim/plugin-loader.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lua/lvim/plugin-loader.lua') diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index 1f574bba..b786bfa7 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -69,6 +69,9 @@ local function pcall_packer_command(cmd, kwargs) end function plugin_loader.cache_clear() + if not utils.is_file(compile_path) then + return + end if vim.fn.delete(compile_path) == 0 then Log:debug "deleted packer_compiled.lua" end @@ -76,10 +79,17 @@ end function plugin_loader.recompile() plugin_loader.cache_clear() + vim.cmd [[LuaCacheClear]] pcall_packer_command "compile" - if utils.is_file(compile_path) then - Log:debug "generated packer_compiled.lua" - end + vim.api.nvim_create_autocmd("User", { + pattern = "PackerCompileDone", + once = true, + callback = function() + if utils.is_file(compile_path) then + Log:debug "generated packer_compiled.lua" + end + end, + }) end function plugin_loader.reload(configurations) @@ -150,7 +160,11 @@ function plugin_loader.sync_core_plugins() require("lvim.plugin-loader").load_snapshot(default_snapshot) end, }) - pcall_packer_command "sync" + + plugin_loader.cache_clear() + local core_plugins = plugin_loader.get_core_plugins() + Log:trace(string.format("Syncing core plugins: [%q]", table.concat(core_plugins, ", "))) + pcall_packer_command("sync", core_plugins) end function plugin_loader.ensure_plugins() -- cgit v1.2.3