From fb2a69c7fff1fa9afe4d101454802ca026ed16dd Mon Sep 17 00:00:00 2001 From: anon Date: Sun, 3 Jul 2022 15:29:53 +0300 Subject: [PATCH 1/3] support overriding colors using vim.g.catppuccin_override_colors --- lua/catppuccin/core/palettes/init.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/catppuccin/core/palettes/init.lua b/lua/catppuccin/core/palettes/init.lua index fc01b70..5d88f0c 100644 --- a/lua/catppuccin/core/palettes/init.lua +++ b/lua/catppuccin/core/palettes/init.lua @@ -3,10 +3,20 @@ local M = {} 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 - return require("catppuccin.core.palettes.mocha") + + if type(vim.g.catppuccin_override_colors) == "table" then + for k, v in pairs(vim.g.catppuccin_override_colors) do + if palette[k] then + palette[k] = v + end + end + end + + return palette end return M From f47c6ea2260473cd3b8024e66cc509498dfb9deb Mon Sep 17 00:00:00 2001 From: anon Date: Mon, 4 Jul 2022 15:25:14 +0300 Subject: [PATCH 2/3] add warning for incorrect color keys and update documentation --- README.md | 12 ++++++++++++ lua/catppuccin/core/palettes/init.lua | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index e063ed3..8fcda06 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lua/catppuccin/core/palettes/init.lua b/lua/catppuccin/core/palettes/init.lua index 5d88f0c..1f85101 100644 --- a/lua/catppuccin/core/palettes/init.lua +++ b/lua/catppuccin/core/palettes/init.lua @@ -12,6 +12,12 @@ function M.get_palette() for k, v in pairs(vim.g.catppuccin_override_colors) 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 From 62856bd8d54220f70118798df26965d03d2b20c1 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Mon, 11 Jul 2022 21:13:13 -0500 Subject: [PATCH 3/3] feat: added color_overrides to settings the `g:catppuccin_override_colors` variable was removed in favour of a setting in the user's Catppuccin conf. This commit also added the ability to change individual colors per palette and also apply changes to all of them. --- lua/catppuccin/config.lua | 1 + lua/catppuccin/core/palettes/init.lua | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lua/catppuccin/config.lua b/lua/catppuccin/config.lua index 3ae05e9..6f401c8 100644 --- a/lua/catppuccin/config.lua +++ b/lua/catppuccin/config.lua @@ -71,6 +71,7 @@ config.options = { telekasten = true, symbols_outline = true, }, + color_overrides = {} } function config.set_options(opts) diff --git a/lua/catppuccin/core/palettes/init.lua b/lua/catppuccin/core/palettes/init.lua index 1f85101..ee4e36c 100644 --- a/lua/catppuccin/core/palettes/init.lua +++ b/lua/catppuccin/core/palettes/init.lua @@ -1,5 +1,7 @@ local M = {} +local cnf = require("catppuccin.config").options + function M.get_palette() local flvr = vim.g.catppuccin_flavour @@ -8,16 +10,20 @@ function M.get_palette() palette = require("catppuccin.core.palettes." .. flvr) end - if type(vim.g.catppuccin_override_colors) == "table" then - for k, v in pairs(vim.g.catppuccin_override_colors) do - if palette[k] then - palette[k] = v - else - vim.api.nvim_echo( - { { 'Warning: "' .. k .. '" is not a valid catppucin palette color.', "WarningMsg" } }, - true, - {} - ) + 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