fix: supports getting of user-defined color palettes#1371
Merged
ayamir merged 1 commit intoayamir:mainfrom Nov 29, 2024
Merged
Conversation
Owner
Owner
|
This impl is enough for addressing the current bug: ---Initialize the palette
---@return table
local function init_palette()
-- Reinitialize the palette on event `ColorScheme`
if not _has_autocmd then
_has_autocmd = true
vim.api.nvim_create_autocmd("ColorScheme", {
group = vim.api.nvim_create_augroup("__builtin_palette", { clear = true }),
pattern = "*",
callback = function()
palette = nil
init_palette()
-- Also refresh hard-coded hl groups
M.gen_alpha_hl()
M.gen_lspkind_hl()
pcall(vim.cmd.AlphaRedraw)
end,
})
end
local fallback_palette = {
rosewater = "#DC8A78",
flamingo = "#DD7878",
mauve = "#CBA6F7",
pink = "#F5C2E7",
red = "#E95678",
maroon = "#B33076",
peach = "#FF8700",
yellow = "#F7BB3B",
green = "#AFD700",
sapphire = "#36D0E0",
blue = "#61AFEF",
sky = "#04A5E5",
teal = "#B5E8E0",
lavender = "#7287FD",
text = "#F2F2BF",
subtext1 = "#BAC2DE",
subtext0 = "#A6ADC8",
overlay2 = "#C3BAC6",
overlay1 = "#988BA2",
overlay0 = "#6E6B6B",
surface2 = "#6E6C7E",
surface1 = "#575268",
surface0 = "#302D41",
base = "#1D1536",
mantle = "#1C1C19",
crust = "#161320",
}
if not palette then
if vim.g.colors_name == nil or (vim.g.colors_name ~= nil and not vim.g.colors_name:find("catppuccin")) then
palette = fallback_palette
else
palette = require("catppuccin.palettes").get_palette()
end
palette = vim.tbl_extend("force", { none = "NONE" }, palette, require("core.settings").palette_overwrite)
end
return palette
end |
1f0bda5 to
42f513a
Compare
Collaborator
Author
|
Oh, I overlooked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Due to the change in a631be2, an error will now occur if a color scheme other than catppuccin is used.
Previously, when using another color scheme, it seemed to fall back to the defined palette.
This change supports retrieval of user-defined color palettes, allowing you to use a wider range of color schemes.