ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.17k stars 142 forks source link

Default highlights for light background colorschemes #1092

Closed tomtomjhj closed 5 months ago

tomtomjhj commented 6 months ago

Info

problem 1

In (Neo)Vim, the default highlight link defined by :highlight default link is restored when :highlight clear is run (which is run by colorscheme scripts). However, non-link :highlight default is not restored, and just cleared.

But some fzf-lua highlight groups are defined with non-link hi-default: https://github.com/ibhagwan/fzf-lua/blob/5104ac1744b92f888ef9f1d4bb6ff14e700c7a37/lua/fzf-lua/init.lua#L62-L73. So their hightlights are lost when the user loads another colorscheme.

A solution I'm aware of is to setup a Colorscheme autocmd that defines the highlights.

problem 2

The foreground color of default non-link highlights are quite bright, so they are not legible in light background colorschemes. It would be great if fzf-lua sets non-link default highlights based on the current 'background', or use default links for all groups.

ibhagwan commented 6 months ago

problem 1 In (Neo)Vim, the default highlight link defined by :highlight default link is restored when :highlight clear is run (which is run by colorscheme scripts). However, non-link :highlight default is not restored, and just cleared.

I’m aware of that, I wanted to avoid yer another autocmd managed by fzf-lua, similar to the way some status line plugins require running a specific function to reset the highlight fzf-lua requires running :FzfLua setup_highlights.

problem 2 The foreground color of default non-link highlights are quite bright, so they are not legible in light background colorschemes. It would be great if fzf-lua sets non-link default highlights based on the current 'background', or use default links for all groups.

Perhaps we can come with different colors for a light scheme or link these to actual highlights (not from the color map), any recommendations would be welcome.

ibhagwan commented 5 months ago

@tomtomjhj, https://github.com/ibhagwan/fzf-lua/commit/74906d0906293992d7b11744e40e5cec9131d9af takes care of both problems (1) and (2), the code will now auto-detect both background and colorschme changes and setup the highlights accordingly (similarly to the way nvim-web-devicons was also updated on bg change).

This commit also sets up better default colors for bg="light" backgrounds, note that if your colorscheme doesn't support bg="light" or doesn't adjust accordingly (i.e. the background is still a dark color), fzf-lua will still use the light color set as it has no awareness of the actual color, only vim.o.bg.

tomtomjhj commented 5 months ago

Thanks, it looks great!