From 357dc3791184a8f7edeafaddc4cf4e8b801dd9be Mon Sep 17 00:00:00 2001 From: Zhong Liu Date: Sun, 26 Jun 2022 16:06:30 +0800 Subject: [PATCH] use autocmd event instead of `after_loading` hook --- .../core/integrations/lightspeed.lua | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lua/catppuccin/core/integrations/lightspeed.lua b/lua/catppuccin/core/integrations/lightspeed.lua index 5baf2ed..4b90a9e 100644 --- a/lua/catppuccin/core/integrations/lightspeed.lua +++ b/lua/catppuccin/core/integrations/lightspeed.lua @@ -13,19 +13,14 @@ end function M.get(cp) if not get_prepared() then - local catppuccin = require("catppuccin") - if catppuccin.after_loading ~= nil then - local callback = catppuccin.after_loading - catppuccin.after_loading = function () - callback() - require'lightspeed'.init_highlight() + set_prepared(vim.api.nvim_create_autocmd("User", { + pattern = "CatppuccinLoaded", + callback = function () + if pcall(require, "lightspeed") then + require("lightspeed").init_highlight() + end end - else - catppuccin.after_loading = function () - require'lightspeed'.init_highlight() - end - end - set_prepared(true) + })) end return {