2021-10-07 17:47:53 +02:00
|
|
|
local M = {}
|
|
|
|
|
2021-10-29 19:33:00 +02:00
|
|
|
local plugin_loader = require "lvim.plugin-loader"
|
2021-10-10 21:07:41 +02:00
|
|
|
local Log = require "lvim.core.log"
|
2021-10-07 17:47:53 +02:00
|
|
|
local in_headless = #vim.api.nvim_list_uis() == 0
|
|
|
|
|
|
|
|
function M.run_pre_update()
|
|
|
|
Log:debug "Starting pre-update hook"
|
2021-10-10 21:07:41 +02:00
|
|
|
_G.__luacache.clear_cache()
|
2021-12-06 17:04:46 +01:00
|
|
|
if package.loaded["lspconfig"] then
|
|
|
|
vim.cmd [[ LspStop ]]
|
|
|
|
end
|
2021-10-07 17:47:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
---Reset any startup cache files used by Packer and Impatient
|
2021-10-10 21:07:41 +02:00
|
|
|
---It also forces regenerating any template ftplugin files
|
2021-10-07 17:47:53 +02:00
|
|
|
---Tip: Useful for clearing any outdated settings
|
|
|
|
function M.reset_cache()
|
|
|
|
_G.__luacache.clear_cache()
|
2021-11-02 16:58:55 +01:00
|
|
|
require("lvim.plugin-loader").recompile()
|
2021-10-10 21:07:41 +02:00
|
|
|
package.loaded["lvim.lsp.templates"] = nil
|
2021-10-29 19:33:00 +02:00
|
|
|
|
|
|
|
Log:debug "Re-generatring ftplugin template files"
|
2021-10-10 21:07:41 +02:00
|
|
|
require("lvim.lsp.templates").generate_templates()
|
2021-10-07 17:47:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.run_post_update()
|
|
|
|
Log:debug "Starting post-update hook"
|
2021-10-29 19:33:00 +02:00
|
|
|
|
|
|
|
Log:debug "Re-generatring ftplugin template files"
|
|
|
|
package.loaded["lvim.lsp.templates"] = nil
|
|
|
|
require("lvim.lsp.templates").generate_templates()
|
|
|
|
|
|
|
|
Log:debug "Updating core plugins"
|
|
|
|
plugin_loader:sync_core_plugins()
|
2021-10-07 17:47:53 +02:00
|
|
|
|
|
|
|
if not in_headless then
|
|
|
|
vim.schedule(function()
|
2021-12-06 17:04:46 +01:00
|
|
|
if package.loaded["nvim-treesitter"] then
|
|
|
|
vim.cmd [[ TSUpdateSync ]]
|
|
|
|
end
|
2021-10-07 17:47:53 +02:00
|
|
|
-- TODO: add a changelog
|
|
|
|
vim.notify("Update complete", vim.log.levels.INFO)
|
2021-12-06 17:04:46 +01:00
|
|
|
if package.loaded["lspconfig"] then
|
|
|
|
vim.cmd [[ LspRestart ]]
|
|
|
|
end
|
2021-10-07 17:47:53 +02:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|