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:
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:
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
After vim/vim#15314 and vim/vim#15561 it is now possible for completion items to have a dedicated highlighting through
hl_group
andkind_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 fromPmenu
in terms of background lightness. Here is an example with 'evening' color scheme:One possible solution to this is to switch
fg
/bg
attributes forPmenu*Sel
groups and addreverse
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:Code used for testing: