From 62856bd8d54220f70118798df26965d03d2b20c1 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Mon, 11 Jul 2022 21:13:13 -0500 Subject: [PATCH] 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