From 5bfbfa6eae8a3641572605aa3397d7e7f6c082d8 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Tue, 21 Dec 2021 10:01:58 -0500 Subject: [PATCH] doc: hooks and overwriting hi groups --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index b1b6c1f..206f6ef 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,8 @@ colorscheme catppuccin vim.cmd[[colorscheme catppuccin]] ``` +### Extra + #### API The API allows you fetch data from Catppuccin. It can be required as a Lua module: @@ -300,6 +302,40 @@ cp_api.get_colors() > Returns a table where the key is the name of the color and the value is its hex value. +#### Overwriting highlight groups + +Both colors and highlight groups can be overwritten like so: + +```lua +catppuccin.remap({ = { }, }) +``` + +Here is an example: + +```lua +local colors = require'catppuccin.api.colors'.get_colors() -- fetch colors with API +catppuccin.remap({ Comment = { fg = colors.catppuccin2 }, }) +``` + +#### Hooks + +Use them to execute code at certain events. These are the ones available: + +| Function | Description | +| ------------------ | ---------------------------- | +| `before_loading()` | Before loading a colorscheme | +| `after_loading()` | After loading a colorscheme | + +They can be used like so: + +```lua +local catppuccin = require("catppuccin") + +catppuccino.before_loading = function () + print("I ran before loading Catppuccin!") +end +``` + ### Configuration Although settings already have self-explanatory names, here is where you can find info about each one of them and their classifications!