From 37e99450cf0ce146be7c4ab863f9827ffd4d4e75 Mon Sep 17 00:00:00 2001 From: Zhong Liu Date: Sun, 26 Jun 2022 15:03:07 +0800 Subject: [PATCH] new autocmd event `CatppuccinLoaded` --- README.md | 14 ++++++++++++++ lua/catppuccin/main.lua | 2 ++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index e063ed3..284d469 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,20 @@ catppuccin.before_loading = function () end ``` +#### Autocmd + +Instead of `after_loading` hook, you can use autocmd event like this: + +```lua +vim.api.nvim_create_autocmd("User", { + pattern = "CatppuccinLoaded", + callback = function() + local colors = require("catppuccin.api.colors").get_colors() + -- do something with colors + end +}) +``` + ## 💝 Thanks to - [Pocco81](https://github.com/Pocco81) diff --git a/lua/catppuccin/main.lua b/lua/catppuccin/main.lua index 16fc21c..0f96ba7 100644 --- a/lua/catppuccin/main.lua +++ b/lua/catppuccin/main.lua @@ -21,6 +21,8 @@ local function load() if catppuccin.after_loading ~= nil then catppuccin.after_loading() end + + vim.api.nvim_exec_autocmds("User", { pattern = "CatppuccinLoaded" }) end function M.main(option)