|
@@ -69,17 +69,31 @@ 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
|
|
|
end
|
|
|
|
|
|
+function plugin_loader.compile()
|
|
|
+ Log:debug "calling packer.compile()"
|
|
|
+ vim.api.nvim_create_autocmd("User", {
|
|
|
+ pattern = "PackerCompileDone",
|
|
|
+ once = true,
|
|
|
+ callback = function()
|
|
|
+ if utils.is_file(compile_path) then
|
|
|
+ Log:debug "finished compiling packer_compiled.lua"
|
|
|
+ end
|
|
|
+ end,
|
|
|
+ })
|
|
|
+ pcall_packer_command "compile"
|
|
|
+end
|
|
|
+
|
|
|
function plugin_loader.recompile()
|
|
|
plugin_loader.cache_clear()
|
|
|
- pcall_packer_command "compile"
|
|
|
- if utils.is_file(compile_path) then
|
|
|
- Log:debug "generated packer_compiled.lua"
|
|
|
- end
|
|
|
+ plugin_loader.compile()
|
|
|
end
|
|
|
|
|
|
function plugin_loader.reload(configurations)
|
|
@@ -140,17 +154,10 @@ function plugin_loader.load_snapshot(snapshot_file)
|
|
|
end
|
|
|
|
|
|
function plugin_loader.sync_core_plugins()
|
|
|
- -- problem: rollback() will get stuck if a plugin directory doesn't exist
|
|
|
- -- solution: call sync() beforehand
|
|
|
- -- see https://github.com/wbthomason/packer.nvim/issues/862
|
|
|
- vim.api.nvim_create_autocmd("User", {
|
|
|
- pattern = "PackerComplete",
|
|
|
- once = true,
|
|
|
- callback = function()
|
|
|
- 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()
|
|
@@ -158,8 +165,7 @@ function plugin_loader.ensure_plugins()
|
|
|
pattern = "PackerComplete",
|
|
|
once = true,
|
|
|
callback = function()
|
|
|
- Log:debug "calling packer.clean()"
|
|
|
- pcall_packer_command "clean"
|
|
|
+ plugin_loader.compile()
|
|
|
end,
|
|
|
})
|
|
|
Log:debug "calling packer.install()"
|