I want to change the color of the header in alpha.nvim dashboard. I can set it to predefined highlight groups(right now "Error") but I want to provide a custom hl_group. I use vim.cmd(hi custom guifg="hex" guibg="hex" gui="none")
before dashboard.section.header.opts.hl = 'custom'
but it sometimes works and sometimes doesn't. This is inside a alpha.lua where
return {
'goolord/alpha-nvim',
dependencies = { 'nvim-tree/nvim-web-devicons', 'BlakeJC94/alpha-nvim-fortune' },
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
local fortune = require("alpha.fortune")
math.randomseed(os.time())
local ascii_arts = {}
dashboard.section.header.val = ascii_arts['pacman']
-- vim.cmd('hi custom <my values>')
-- vim.cmd('hi custom')
dashboard.section.header.opts.hl = "Error" -- custom
dashboard.section.buttons.opts.hl = "Debug"
dashboard.section.footer.opts.hl = "Conceal"
dashboard.config.opts.noautocmd = true
vim.cmd [[autocmd user alphaready echo 'ready']]
alpha.setup(dashboard.opts)
also when I set dashboard.footer.opts.hl
to "Custom"
that also doesn't work. I tried to google it, ask on reddit but couldn't find any solutions. Most of trouble shooting I did was thanx to chatGPT.
When I vim.cmd('hi custom')
after I set custom then it shows the value that I want it to all the time. Highlighting works sometimes randomly. So when it doesn't I enter :hi custom
in terminal and the result it xxx cleared
so it's probably not working cuz nvim is not setting my custom highlight at the right time but I don't know how to fix it.
You can define bg & fg of the color groups "AlphaShortcut, AlphaHeader, AlphaHeaderLabel, AlphaButtons, AlphaFooter" in your colorscheme config.
Example using catppuccin colorscheme:
return {
"catppuccin/nvim",
config = function()
require("catppuccin").setup({
custom_highlights = function(colors)
return {
AlphaShortcut = { fg = colors.red, bg = colors.mauve },
AlphaHeader = { fg = colors.red, bg = colors.mauve },
}
end,
})
end
}