[mini.hues] What is the recommended method to add additional highlight groups? #784
-
What is the recommended method of adding additional highlight groups using the same palette on top of the existing ones provided by In most themes I've used before, usually there is a means to add your own highlights via a function that is called with the theme's palette of colors, so one can define/override groups using the same palette. Would the current recommended approach be:
One last question, the documentation has a note about how Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Yes, this is the recommended way at the moment, if you specifically want to use palette colors. Another, possibly more robust approach, would be to link to an existing group with similar semantics or visuals. Good examples will be 5
Usually there is no difference, but there might be. Creating separate color scheme has (at least) these major side effects:
|
Beta Was this translation helpful? Give feedback.
-
It would be nice if the palette could be exposed at some point.
Yes, good advice. Will be sure to try that approach first. During this process of trying to adopt mini, I've come across two cases so far where I need to define specific groups:
|
Beta Was this translation helpful? Give feedback.
-
A bit hacky: It's possible to obtain the reference using a closure in a decorated Hues.make_palette: local Hues = require("mini.hues") -- "capture" the palette on hues.setup
local orig_make_palette = Hues.make_palette
local p = nil
---@diagnostic disable-next-line: duplicate-set-field
Hues.make_palette = function(config)
p = orig_make_palette(config)
return p
end
vim.api.nvim_create_autocmd("Colorscheme", {
pattern = { "*hue" },
callback = function()
if p == nil then return end
local hi = function(name, data) vim.api.nvim_set_hl(0, name, data) end
-- Links to MiniJump2dSpot by default, changed fg(fg_edge2)
hi("MiniJump2dSpotUnique", { fg = p.orange, bg = p.bg_edge2, bold = true, nocombine = true })
-- Area for messages and cmdline, using Comment.fg
hi("MsgArea", { fg = p.fg_mid2 })
end,
}) I call this config before the |
Beta Was this translation helpful? Give feedback.
Yes, this is the recommended way at the mom…