hooks.lua 787 B

123456789101112131415161718192021222324252627282930313233
  1. local M = {}
  2. local Log = require "core.log"
  3. local in_headless = #vim.api.nvim_list_uis() == 0
  4. function M.run_pre_update()
  5. Log:debug "Starting pre-update hook"
  6. end
  7. ---Reset any startup cache files used by Packer and Impatient
  8. ---Tip: Useful for clearing any outdated settings
  9. function M.reset_cache()
  10. _G.__luacache.clear_cache()
  11. require("plugin-loader"):cache_reset()
  12. end
  13. function M.run_post_update()
  14. M.reset_cache()
  15. Log:debug "Starting post-update hook"
  16. package.loaded["lsp.templates"] = nil
  17. require("lsp.templates").generate_templates()
  18. if not in_headless then
  19. vim.schedule(function()
  20. require("packer").install()
  21. -- TODO: add a changelog
  22. vim.notify("Update complete", vim.log.levels.INFO)
  23. vim.cmd "LspStart"
  24. end)
  25. end
  26. end
  27. return M