More flexible overrides for Search and IncSearch
Closed this issue · 3 comments
I use hlsearch a lot and I'd like to customize both the IncSearch and Search style options including bg and fg. The problem is that those elements make use of common styles, so adjusting things for search elements will also affect other styling. Would you be open to a PR that defines new keywords for colors overrides?
hl.set('IncSearch', { bg = colors.other_keywords, fg = colors.bg }) -- 'incsearch' highlighting; also used for the text replaced with ':s///c'
hl.set('Search', { bg = colors.bg4, fg = colors.fg }) -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
I think what we need in this case is highlight overrides, that would be easier to implement and would provide more functionality. We could add highlight_overrides
option to config, it would expect a function that has colors table as a parameter, so that people could use the colors from the color set to define their highlight overrides. highlight_overrides
function would have to be executed after all the highlights are set. We would expect this function to simply contain vim.api.nvim_set_hl
instructions, i.e. it would not return any highlights table, it would set the highlights itself.
The way we add this to config should be similar to color_overrides:
require 'mellifluous'.setup({
<color_set_name> = { -- name any of the defined color sets
highlight_overrides = {
dark = function(colors)
end,
light = function(colors)
end,
}
}
})
Edit: On second thought, there should also be a global highlight_overrides
(not color set specific) option.
If you want to contribute, I can leave this for you to implement, otherwise I can do it myself.
I've been thinking for some time now, that the current IncSearch
highlight doesn't look good, so if you have any suggestions on how to change it, that would be great.
If you want to contribute, I can leave this for you to implement, otherwise I can do it myself.
I'll try to take a crack at it first thing 2024. If you don't see a PR within a few weeks then you might want to do it yourself :)
I've been thinking for some time now, that the current IncSearch highlight doesn't look good, so if you have any suggestions on how to change it, that would be great.
I agree, I'm not crazy about the current value either, but I couldn't find anything better. My original reason for wanting more customization is that the IncSearch vs Search where so different in styles and that Search was soooo subtle that I had a hard time recognizing highlighted items. That said, I REALLY like this theme because it doesn't have a huge color palette.... Maybe going with a subtle BG and a contrasting FG would work?
As you can probably see, I've created a PR. I ended up using my highlighter for highlight_overrides
, so instead of vim.api.nvim_set_hl
calls there will be highlighter.set
calls in highlight_overrides
function. I will add the documentation and merge the PR a bit later.