hooks.lua 896 B

1234567891011121314151617181920212223242526272829303132333435
  1. local M = {}
  2. local Log = require "lvim.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. _G.__luacache.clear_cache()
  7. end
  8. ---Reset any startup cache files used by Packer and Impatient
  9. ---It also forces regenerating any template ftplugin files
  10. ---Tip: Useful for clearing any outdated settings
  11. function M.reset_cache()
  12. _G.__luacache.clear_cache()
  13. require("lvim.plugin-loader"):cache_reset()
  14. package.loaded["lvim.lsp.templates"] = nil
  15. require("lvim.lsp.templates").generate_templates()
  16. end
  17. function M.run_post_update()
  18. Log:debug "Starting post-update hook"
  19. M.reset_cache()
  20. if not in_headless then
  21. vim.schedule(function()
  22. require("packer").install()
  23. -- TODO: add a changelog
  24. vim.notify("Update complete", vim.log.levels.INFO)
  25. vim.cmd "LspStart"
  26. end)
  27. end
  28. end
  29. return M