hrsh7th / nvim-cmp

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

cmp.config.window.bordered() changes active item highlight bg. #1029

Open Lalit64 opened 2 years ago

Lalit64 commented 2 years ago

FAQ

Announcement

Minimal reproducible full config


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'
Plug 'olimorris/onedarkpro.nvim'
call plug#end()
PlugInstall | quit

colorscheme onedarkpro

" 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,
  },
  window = {
    completion = cmp.config.window.bordered(),
    documentation = cmp.config.window.bordered()
  }
  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

Description

When I use cmp.config.window.bordered() it changes active item highlight bg for the completion menu.

Steps to reproduce

  1. Use minimal config above.
  2. Open any filetype
  3. Make sure language server is installed for that filetype
  4. Start typing anything.
  5. Select first item.
  6. See that it way too bright
  7. remove window section from cmp config.
  8. Repeat steps 2 - 5
  9. See color difference

Expected behavior

Expected color is around #2d323b (not exact)

Actual behavior

Actual color is around #52565e (not exact) (too bright)

Additional context

My complete config is at https://github.com/Lalit64/HydroVim

hrsh7th commented 2 years ago

You can change CursorLine highlight see https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/config/window.lua#L7

Lalit64 commented 2 years ago

@hrsh7th It doesn't work. It still remains the same color while changing the background of the active editor line but not the active cmp item.

Edit: Thanks for reopening

hrsh7th commented 2 years ago

Hm...

  1. The nvim docs says following

    CursorLine Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set.

  2. The result of :hi CursorLine with your init.vim

    CursorLine xxx cterm=underline guibg=#282c34

So the CursorLine is low-priority (I think). In fact, the CursorLine does not shown even if cursorline option is true and cursor is contains the normal window...

Lalit64 commented 2 years ago

@hrsh7th could you try My full config. I am getting this issue with my full config.

Arian8j2 commented 1 year ago

Same issue, with bordered: image without bordered: image

my output of CursorLine:

:hi CursorLine
CursorLine     xxx guibg=#525156

Edit: Seems like a color scheme problem, on aura it's broken, but on tokyonight it's ok. Edit: CmpItemAbbr highlight was linked to something same as Pmenu and Normal and deleting CmpItemAbbr highlight or removing it's background highlight fixed the problem, idk why without bordered it was fine.