2021-10-07 17:47:53 +02:00
|
|
|
local M = {}
|
|
|
|
|
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-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
|
|
|
|
|
2021-12-09 17:08:53 +01:00
|
|
|
function M.run_pre_reload()
|
|
|
|
Log:debug "Starting pre-reload hook"
|
|
|
|
if package.loaded["lspconfig"] then
|
|
|
|
vim.cmd [[ LspStop ]]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.run_on_packer_complete()
|
|
|
|
require("lvim.plugin-loader").recompile()
|
|
|
|
-- forcefully activate nvim-web-devicons
|
|
|
|
require("nvim-web-devicons").set_up_highlights()
|
2022-01-03 11:06:45 +01:00
|
|
|
if package.loaded["lspconfig"] then
|
|
|
|
vim.cmd [[ LspStart ]]
|
|
|
|
end
|
2021-12-09 17:08:53 +01:00
|
|
|
Log:info "Reloaded configuration"
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.run_post_reload()
|
|
|
|
Log:debug "Starting post-reload hook"
|
|
|
|
|
|
|
|
M.reset_cache()
|
|
|
|
require("lvim.plugin-loader").ensure_installed()
|
|
|
|
end
|
|
|
|
|
2021-10-07 17:47:53 +02:00
|
|
|
---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()
|
2021-12-09 17:08:53 +01:00
|
|
|
local impatient = _G.__luacache
|
|
|
|
if impatient then
|
|
|
|
impatient.clear_cache()
|
|
|
|
end
|
|
|
|
local lvim_modules = {}
|
|
|
|
for module, _ in pairs(package.loaded) do
|
|
|
|
if module:match "lvim.core" or module:match "lvim.lsp" then
|
|
|
|
package.loaded[module] = nil
|
|
|
|
table.insert(lvim_modules, module)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Log:trace(string.format("Cache invalidated for core modules: { %s }", table.concat(lvim_modules, ", ")))
|
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-12-09 17:08:53 +01:00
|
|
|
M.reset_cache()
|
2021-10-29 19:33:00 +02:00
|
|
|
|
|
|
|
Log:debug "Updating core plugins"
|
2021-12-09 17:08:53 +01:00
|
|
|
require("lvim.plugin-loader").ensure_installed()
|
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
|
2022-01-03 11:06:45 +01:00
|
|
|
vim.cmd [[ LspStart ]]
|
2021-12-06 17:04:46 +01:00
|
|
|
end
|
2021-10-07 17:47:53 +02:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|