Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support overriding colors using vim.g.catppuccin_override_colors #165

Merged
merged 4 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@ local colors = require'catppuccin.api.colors'.get_colors() -- fetch colors with
catppuccin.remap({ Comment = { fg = colors.flamingo }, })
```

#### Overwriting colors

Colors can be overwritten using `vim.g.catppucin_override_colors`:

```lua
vim.g.catppuccin_override_colors = {
base = "#ff0000",
mantle = "#242424",
crust = "#474747",
}
```

#### Hooks

Use them to execute code at certain events. These are the ones available:
Expand Down
1 change: 1 addition & 0 deletions lua/catppuccin/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ config.options = {
telekasten = true,
symbols_outline = true,
},
color_overrides = {}
custom_highlights = {},
}

Expand Down
26 changes: 24 additions & 2 deletions lua/catppuccin/core/palettes/init.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
local M = {}

local cnf = require("catppuccin.config").options

function M.get_palette()
local flvr = vim.g.catppuccin_flavour

local palette = require("catppuccin.core.palettes.mocha")
if flvr == "mocha" or flvr == "latte" or flvr == "macchiato" or flvr == "frappe" then
return require("catppuccin.core.palettes." .. flvr)
palette = require("catppuccin.core.palettes." .. flvr)
end

if type(cnf.color_overrides) == "table" then
for _, pal in pairs({"all", flvr}) do
if cnf.color_overrides[pal] ~= nil then
for k, v in pairs(cnf.color_overrides[pal]) do
if palette[k] then
palette[k] = v
else
vim.api.nvim_echo(
{ { 'Warning: "' .. k .. '" is not a valid catppucin palette color.', "WarningMsg" } },
true,
{}
)
end
end
end
end
end
return require("catppuccin.core.palettes.mocha")

return palette
end

return M