BREAKING CHANGE: Remove loading hooks

dev
nullchilly 2 years ago
parent 7f718802b6
commit 90b7bd6e33

@ -356,6 +356,11 @@ Plug 'catppuccin/nvim', {'as': 'catppuccin', 'do': 'CatppuccinCompile'}
Packer.nvim Packer.nvim
```lua ```lua
-- Enable packer auto reload
require("packer").init {
auto_reload_compiled = true,
}
-- Create an autocmd `User PackerCompileDone` to update it every time packer is compiled -- Create an autocmd `User PackerCompileDone` to update it every time packer is compiled
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "PackerCompileDone", pattern = "PackerCompileDone",
@ -425,32 +430,28 @@ color_overrides = {
Use them to execute code at certain events. These are the ones available: Use them to execute code at certain events. These are the ones available:
| Function | Description | | Autocmd | Description |
| ------------------ | ---------------------------- | | ------------------ | ---------------------------- |
| `before_loading()` | Before loading a colorscheme | | `ColorSchemePre` | Before loading a colorscheme |
| `after_loading()` | After loading a colorscheme | | `ColorScheme` | After loading a colorscheme |
They can be used like so: They can be used like so:
```lua ```lua
local catppuccin = require("catppuccin") vim.api.nvim_create_autocmd("ColorSchemePre", {
pattern = "*",
catppuccin.before_loading = function () callback = function()
print("I ran before loading Catppuccin!") print "I ran before loading Catppuccin!"
end end,
``` })
#### Autocmd
Instead of `after_loading` hook, you can use autocmd event like this:
```lua vim.api.nvim_create_autocmd("ColorScheme", {
vim.api.nvim_create_autocmd("User", { pattern = "*",
pattern = "CatppuccinLoaded",
callback = function() callback = function()
local colors = require("catppuccin.palettes").get_palette() local colors = require("catppuccin.palettes").get_palette()
-- do something with colors -- do something with colors
end print "ok"
end,
}) })
``` ```

@ -21,12 +21,6 @@ end, {
}) })
function M.load() function M.load()
local catppuccin = require("catppuccin")
if catppuccin.before_loading ~= nil then
catppuccin.before_loading()
end
local compiled = nil local compiled = nil
local config = require("catppuccin.config").options local config = require("catppuccin.config").options
@ -47,12 +41,6 @@ function M.load()
if not compiled then -- colorscheme gets evaluated from mapper.lua if not compiled then -- colorscheme gets evaluated from mapper.lua
require("catppuccin.lib.highlighter").load(require("catppuccin.lib.mapper").apply()) require("catppuccin.lib.highlighter").load(require("catppuccin.lib.mapper").apply())
end end
if catppuccin.after_loading ~= nil then
catppuccin.after_loading()
end
vim.api.nvim_exec_autocmds("User", { pattern = "CatppuccinLoaded" })
end end
function M.setup(custom_opts) function M.setup(custom_opts)

Loading…
Cancel
Save