mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-31 15:19:26 +02:00
fix(config): more comprehensive cache reset (#3416)
This commit is contained in:
parent
1eb4188bfb
commit
153593ff51
2 changed files with 29 additions and 21 deletions
|
@ -69,17 +69,31 @@ local function pcall_packer_command(cmd, kwargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin_loader.cache_clear()
|
function plugin_loader.cache_clear()
|
||||||
|
if not utils.is_file(compile_path) then
|
||||||
|
return
|
||||||
|
end
|
||||||
if vim.fn.delete(compile_path) == 0 then
|
if vim.fn.delete(compile_path) == 0 then
|
||||||
Log:debug "deleted packer_compiled.lua"
|
Log:debug "deleted packer_compiled.lua"
|
||||||
end
|
end
|
||||||
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()
|
function plugin_loader.recompile()
|
||||||
plugin_loader.cache_clear()
|
plugin_loader.cache_clear()
|
||||||
pcall_packer_command "compile"
|
plugin_loader.compile()
|
||||||
if utils.is_file(compile_path) then
|
|
||||||
Log:debug "generated packer_compiled.lua"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin_loader.reload(configurations)
|
function plugin_loader.reload(configurations)
|
||||||
|
@ -140,17 +154,10 @@ function plugin_loader.load_snapshot(snapshot_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin_loader.sync_core_plugins()
|
function plugin_loader.sync_core_plugins()
|
||||||
-- problem: rollback() will get stuck if a plugin directory doesn't exist
|
plugin_loader.cache_clear()
|
||||||
-- solution: call sync() beforehand
|
local core_plugins = plugin_loader.get_core_plugins()
|
||||||
-- see https://github.com/wbthomason/packer.nvim/issues/862
|
Log:trace(string.format("Syncing core plugins: [%q]", table.concat(core_plugins, ", ")))
|
||||||
vim.api.nvim_create_autocmd("User", {
|
pcall_packer_command("sync", core_plugins)
|
||||||
pattern = "PackerComplete",
|
|
||||||
once = true,
|
|
||||||
callback = function()
|
|
||||||
require("lvim.plugin-loader").load_snapshot(default_snapshot)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
pcall_packer_command "sync"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin_loader.ensure_plugins()
|
function plugin_loader.ensure_plugins()
|
||||||
|
@ -158,8 +165,7 @@ function plugin_loader.ensure_plugins()
|
||||||
pattern = "PackerComplete",
|
pattern = "PackerComplete",
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
Log:debug "calling packer.clean()"
|
plugin_loader.compile()
|
||||||
pcall_packer_command "clean"
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
Log:debug "calling packer.install()"
|
Log:debug "calling packer.install()"
|
||||||
|
|
|
@ -2,6 +2,7 @@ local M = {}
|
||||||
|
|
||||||
local Log = require "lvim.core.log"
|
local Log = require "lvim.core.log"
|
||||||
local in_headless = #vim.api.nvim_list_uis() == 0
|
local in_headless = #vim.api.nvim_list_uis() == 0
|
||||||
|
local plugin_loader = require "lvim.plugin-loader"
|
||||||
|
|
||||||
function M.run_pre_update()
|
function M.run_pre_update()
|
||||||
Log:debug "Starting pre-update hook"
|
Log:debug "Starting pre-update hook"
|
||||||
|
@ -15,8 +16,9 @@ function M.run_on_packer_complete()
|
||||||
Log:debug "Packer operation complete"
|
Log:debug "Packer operation complete"
|
||||||
vim.api.nvim_exec_autocmds("User", { pattern = "PackerComplete" })
|
vim.api.nvim_exec_autocmds("User", { pattern = "PackerComplete" })
|
||||||
|
|
||||||
vim.g.colors_name = lvim.colorscheme
|
-- -- FIXME(kylo252): nvim-tree.lua/lua/nvim-tree/view.lua:442: Invalid window id
|
||||||
pcall(vim.cmd, "colorscheme " .. lvim.colorscheme)
|
-- vim.g.colors_name = lvim.colorscheme
|
||||||
|
-- pcall(vim.cmd.colorscheme, lvim.colorscheme)
|
||||||
|
|
||||||
if M._reload_triggered then
|
if M._reload_triggered then
|
||||||
Log:debug "Reloaded configuration"
|
Log:debug "Reloaded configuration"
|
||||||
|
@ -26,7 +28,6 @@ end
|
||||||
|
|
||||||
function M.run_post_reload()
|
function M.run_post_reload()
|
||||||
Log:debug "Starting post-reload hook"
|
Log:debug "Starting post-reload hook"
|
||||||
M.reset_cache()
|
|
||||||
M._reload_triggered = true
|
M._reload_triggered = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ end
|
||||||
---Tip: Useful for clearing any outdated settings
|
---Tip: Useful for clearing any outdated settings
|
||||||
function M.reset_cache()
|
function M.reset_cache()
|
||||||
vim.cmd [[LuaCacheClear]]
|
vim.cmd [[LuaCacheClear]]
|
||||||
|
plugin_loader.recompile()
|
||||||
local lvim_modules = {}
|
local lvim_modules = {}
|
||||||
for module, _ in pairs(package.loaded) do
|
for module, _ in pairs(package.loaded) do
|
||||||
if module:match "lvim.core" or module:match "lvim.lsp" then
|
if module:match "lvim.core" or module:match "lvim.lsp" then
|
||||||
|
@ -68,7 +70,7 @@ function M.run_post_update()
|
||||||
M.reset_cache()
|
M.reset_cache()
|
||||||
|
|
||||||
Log:debug "Syncing core plugins"
|
Log:debug "Syncing core plugins"
|
||||||
require("lvim.plugin-loader").sync_core_plugins()
|
plugin_loader.sync_core_plugins()
|
||||||
|
|
||||||
if not in_headless then
|
if not in_headless then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue