Open mike-lloyd03 opened 2 years ago
This is possible without an update to the plugin (though it should probably support this use case anyway). You can take advantage of the ColorSchemePre
autocmd event to update your plugin config before it's used to apply the theme.
config = function()
local onedark = require("onedark")
local default_style = "dark"
local function get_theme_overrides(style)
local palette = require("onedark.palette")[style]
if type(palette) == "nil" then
vim.notify(string.format("couldn't get palette for style %q", style), vim.log.levels.ERROR)
return
end
return {
highlights = {
-- ....
},
}
end
local augroup_id = vim.api.nvim_create_augroup("OnedarkStyle", {})
vim.api.nvim_clear_autocmds({ group = augroup_id })
vim.api.nvim_create_autocmd("ColorSchemePre", {
group = augroup_id,
desc = "Apply theme overrides before colorscheme change",
callback = function()
if vim.g.onedark_config and vim.g.onedark_config.loaded then
local overrides = get_theme_overrides(vim.g.onedark_config.style)
onedark.set_options("highlights", overrides.highlights)
-- onedark.set_options("colors", overrides.colors)
-- etc
end
end,
})
onedark.setup({
toggle_style_list = { "dark", "light" },
highlights = get_theme_overrides(default_style).highlights,
})
onedark.load()
end
Also like this. It would be easier to set up if onedark has builtin support for per-theme overrides.
Thanks for this plug. It works really well. Is there a way to override colors on a per-theme basis?
Example: I'd like to override
bg1
but only on the dark theme and leave the light theme as default.This obviously doesn't work because setup configs are only evaluated upon initialization. But some way to do this would be nice.
Thanks!