hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
8.01k stars 398 forks source link

Custom popup menu has incorrect colors when Pmenu has cterm=inverse set #437

Open tbodt opened 2 years ago

tbodt commented 2 years ago

Describe the bug

Minimal config based on this

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  },

  sources = {
    { name = "nvim_lsp" },
    { name = "buffer" },
  },
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

highlight clear Pmenu
highlight clear PmenuSel
highlight Pmenu cterm=inverse
highlight PmenuSel ctermfg=1

To Reproduce

Use the above vimrc. Open the popup menu and select an entry.

Custom popup ends up looking up like this: image

Expected behavior

Vim default popup menu, from pressing ctrl-p: image

The selected line is incorrectly inverted in the cmp popup. This bug seems to be triggered by the Pmenu highlight including cterm=inverse.

Additional context

Non-gui nvim

hrsh7th commented 2 years ago

Reproduced. But I can't figure out the reason at the moment.

Hm... if we fix it, we have to avoid using CursorLine highlights, I guess.

tbodt commented 2 years ago

I thought it might be a bug in neovim so I filed an issue: https://github.com/neovim/neovim/issues/16171