Add a custom variant name
Is your feature request related to a problem? Please describe.
I often find myself always tinkering my catpuccin color palettes, but at the same time I don't want to replace all of the default colors variant. It depends on the situation e.g. I am working on my low light room, I usually switch from mocha to frappe because frappe is more satisfying to work with. The problem is now I have my new color palettes for frappe, but I sometimes going back to my config to toggle them in order to get my default ones (again because I like it).
Describe the solution you'd like
I want a custom variant name to work with when i am focusing on work, rather then going back and forth to toggle my custom palettes. For example by simple calling vim.cmd("colorscheme catppuccin-custom1"),
Describe alternatives you've considered
I was thinking maybe you guys can provide some config similar to the following:
custom_variants = {
custom1 = {
merge_from = "frappe",
values = {
maroon = "#ea999c",
peach = "#ff9b5e",
},
},
custom2 = {
merge_from = "mocha",
values = {
maroon = "#ea999c",
peach = "#ff9b5e",
},
},
},
Additional context
This is my custom config override for frappe variant, I like the color contrast sometimes, but I don't want to override the default palette because I like all of the default variants palette.
Anyway, thanks for a good work!. I've been using catppuccin since I started to switch to neovim couple months ago.
I would love to have #0000ff blue variants!
I have been trying to do this on my own as well. So far I have done the following and hit a snag
- In my config at
lua/catppuccin/palettes/, I added files akin to the ones on this repo, lua files that just return a table of color definitions. (For my case, this islua/catppuccin/palettes/gruvbox.lua - Added the file
colors/catppuccin-gruvbox.vimthat callslua require("catppuccin").load 'gruvbox'
Hit a snag here, because the list of palettes are built-in at lua/catppuccin/init.lua without any ability to have a drop in file to have additional themes added in.
If this could be specified in the opts to the config, it would be great. Current overriding mechanism requires one to sacrifice one of the flavor options if I want to be able to use a different colorscheme but with all the catppuccin integrations still available.
- In my config at lua/catppuccin/palettes/, I added files akin to the ones on this repo, lua files that just return a table of color definitions. (For my case, this is lua/catppuccin/palettes/gruvbox.lua
- Added the file colors/catppuccin-gruvbox.vim that calls lua require("catppuccin").load 'gruvbox'
FYI, it is also possible to make a palette module without a file ~~, since the value stored in package.loaded[modname] is returned by require(modname) if it is found~~. Since require() checks package.preload[module] first, adding a loader there lets you return and cache a module value without a file.
e.g.
local catppuccin = require("catppuccin")
local function generate_colorscheme(name)
local path = vim.fs.joinpath(vim.fn.stdpath("config"), "colors", ("catppuccin-%s.vim"):format(name))
if not vim.uv.fs_stat(path) then
local f = io.open(path, "w")
assert(f ~= nil)
f:write(([[lua require("catppuccin").load "%s"]]):format(name))
f:close()
end
end
local function generate_palettes(palettes)
for name, palette in pairs(palettes) do
catppuccin.flavours[name] = 42
package.preload["catppuccin.palettes." .. name] = function()
return palette
end
generate_colorscheme(name)
end
end
local config = {
flavour = "onedark",
palettes = {
onedark = {
rosewater = "#b6bdca",
flamingo = "#be5046",
pink = "#F5C2E7",
mauve = "#c678dd",
red = "#e06c75",
maroon = "#e06c75",
peach = "#d19a66",
yellow = "#e5c07b",
green = "#98c379",
teal = "#56b6c2",
sky = "#d19a66",
sapphire = "#74C7EC",
blue = "#61afef",
lavender = "#c8ccd4",
text = "#abb2bf",
subtext1 = "#BAC2DE",
subtext0 = "#A6ADC8",
overlay2 = "#9399B2",
overlay1 = "#7F849C",
overlay0 = "#6C7086",
surface0 = "#3e4451",
surface1 = "#545862",
surface2 = "#565c64",
base = "#282c34",
mantle = "#353b45",
crust = "#11111B",
},
},
}
generate_palettes(config.palettes)
catppuccin.setup(config)
EDIT: package.loaded breaks CatppuccinCompile
@here in case you're still interested I found a hackish, albeit working, way to add any number of extra, custom color schemes in catppuccin. The cool points are:
:CatppuccinCompilework, hence you can enjoy your cached, custom themes:colorscheme catppuccin<TAB>will show also your custom theme
Below you'll find the instructions to achieve this 🔥
1. Create your own palette
Assuming you'd like to create a matrix theme: create a file called ~/.config/nvim/lua/catppuccin/palettes/matrix.lua and return your own palettes, following the usual catppuccin's structure for its palettes.
However, during development, i found it useful to load a pre-existing theme, override few properties at a time, reload neovim, rinse and repeat until I've got decent values for all properties 👇
-- Note: remove once the theme has been finalised !
local base = require("catppuccin.palettes.mocha")
local M = {
text = "#bcbec4",
base = "#27282a",
mantle = "#222225",
crust = "#1c1c1f",
}
return vim.tbl_deep_extend("force", base, M)
2. Create the corresponding colorscheme alias
This is as easy as creating a file ~/.config/nvim/colors/catppuccin-matrix.lua with the following content
require("catppuccin").load("matrix")
3. Tell catppuccin to load the new flavour
Note: I'm using lazy.nvim, but instructions should be easily transferrable to other package managers:
return {
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
local catppuccin = require("catppuccin")
catppuccin.flavours = { latte = 1, frappe = 2, macchiato = 3, mocha = 4, matrix = 5 }
catppuccin.setup({}) -- add your setup here
vim.cmd.colorscheme("catppuccin-matrix")
end,
}
And you're set!
of course, if you have multiple palettes, you could go one step further and autodiscovery all palettes as follows
local path = vim.fn.expand("~/.config/nvim/lua/catppuccin/palettes/")
local files = vim.fn.globpath(path, "*", false, true)
local flavours = { latte = 1, frappe = 2, macchiato = 3, mocha = 4 }
for i, file in ipairs(files) do
local name = vim.fn.fnamemodify(file, ":t:r")
flavours[name] = 4 + i
end
local catppuccin = require("catppuccin")
catppuccin.flavours = flavours
catppuccin.setup({}) -- add your setup here
vim.cmd.colorscheme("catppuccin-matrix")
Hope you'll find it useful !