feat: callbacks to easily override (or add) colors and highlights
This commit is contained in:
@@ -68,9 +68,6 @@ function M.autocmds(config)
|
||||
vim.cmd([[augroup TokyoNight]])
|
||||
vim.cmd([[ autocmd!]])
|
||||
vim.cmd([[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]])
|
||||
if config.dev then
|
||||
vim.cmd([[ autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight]])
|
||||
end
|
||||
for _, sidebar in ipairs(config.sidebars) do
|
||||
if sidebar == "terminal" then
|
||||
vim.cmd([[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]])
|
||||
@@ -164,13 +161,11 @@ function M.load(theme)
|
||||
|
||||
vim.o.termguicolors = true
|
||||
vim.g.colors_name = "tokyonight"
|
||||
-- vim.api.nvim__set_hl_ns(ns)
|
||||
-- load base theme
|
||||
M.syntax(theme.base)
|
||||
M.syntax(theme.plugins)
|
||||
|
||||
M.syntax(theme.highlights)
|
||||
|
||||
-- vim.api.nvim_set_hl_ns(M.ns)
|
||||
if theme.config.terminalColors then
|
||||
if theme.config.terminal_colors then
|
||||
M.terminal(theme.colors)
|
||||
end
|
||||
|
||||
@@ -181,35 +176,4 @@ function M.load(theme)
|
||||
end, 100)
|
||||
end
|
||||
|
||||
---@param config Config
|
||||
---@param colors ColorScheme
|
||||
function M.color_overrides(colors, config)
|
||||
if type(config.colors) == "table" then
|
||||
for key, value in pairs(config.colors) do
|
||||
if not colors[key] then
|
||||
error("Color " .. key .. " does not exist")
|
||||
end
|
||||
|
||||
-- Patch: https://github.com/ful1e5/onedark.nvim/issues/6
|
||||
if type(colors[key]) == "table" then
|
||||
M.color_overrides(colors[key], { colors = value })
|
||||
else
|
||||
if value:lower() == "none" then
|
||||
-- set to none
|
||||
colors[key] = "NONE"
|
||||
elseif string.sub(value, 1, 1) == "#" then
|
||||
-- hex override
|
||||
colors[key] = value
|
||||
else
|
||||
-- another group
|
||||
if not colors[value] then
|
||||
error("Color " .. value .. " does not exist")
|
||||
end
|
||||
colors[key] = colors[value]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user