vim / colorschemes

colorschemes for Vim
279 stars 23 forks source link

`PmenuSel` might need adjustment to work with colored items #265

Open echasnovski opened 2 weeks ago

echasnovski commented 2 weeks ago

After vim/vim#15314 and vim/vim#15561 it is now possible for completion items to have a dedicated highlighting through hl_group and kind_hlgroup item fields. Those highlight groups are applied while combining with underlying highlighting. Which is a good thing as it allows to use highlight groups defining only necessary attributes (like foreground, for example, which I'd assume would be very common).

However, this can result in poorly readable text if color scheme has PmenuSel very different from Pmenu in terms of background lightness. Here is an example with 'evening' color scheme:

screenshot_2024-08-29_16:38:49

screenshot_2024-08-29_16:39:03

One possible solution to this is to switch fg/bg attributes for Pmenu*Sel groups and add reverse attribute. This way highlighting of "regular" items stays the same while "highlighted" items have colored backgrounds with readable text. Here is an example with adjusted groups:

screenshot_2024-08-29_16:39:24

screenshot_2024-08-29_16:39:35


Code used for testing:

func CompleteWithHl()
  let l:item_1 = { 'word': 'apple',   'kind': 'Fruit', 'hl_group': 'String', 'kind_hlgroup': 'Identifier' }
  let l:item_2 = { 'word': 'apricot', 'kind': 'Fruit', 'hl_group': 'String', 'kind_hlgroup': 'Identifier' }
  let l:item_3 = { 'word': 'avocado', 'kind': 'Fruit' }
  call complete(1, [item_1, item_2, item_3])
  return ''
endfunc

set termguicolors
set bg=dark
color evening

" Current:
" hi PmenuSel      guifg=#000000 guibg=#bebebe gui=NONE cterm=NONE
" hi PmenuMatchSel guifg=#8b008b guibg=#bebebe gui=NONE cterm=NONE

" " Adjusted
" hi PmenuSel      guifg=#bebebe guibg=#000000 gui=reverse cterm=reverse
" hi PmenuMatchSel guifg=#bebebe guibg=#8b008b gui=reverse cterm=reverse