Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NormalFloat instead of Normal for cmp.config.window.bordered()'s winhighlight #2042

Open
2 tasks done
slugbyte opened this issue Sep 19, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@slugbyte
Copy link

slugbyte commented Sep 19, 2024

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

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'
call plug#end()
PlugInstall | quit

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

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

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

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

Description

The winhighlight does not follow the :help docs when using the bordered configuration. the help docs recommends pairing NormalFloat and FloatBorder when configuring floating windows, but nvim-cmp is using Normal with FloatBorder.

winhighlight is assigned Normal:Normal here

I was wondering if it could change the borders window winhighlight to
NormalFloat:NormalFloat,FloatBorder:FloatBorder,CursorLine:Visual,Search:None or
Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:Visual,Search:None
In order to make backgrounds and borders consistent with the nvim help docs, other floating windows.

This becomes an issue for colorscheme editors when trying to make nvim-cmps's borders the have the same background color as the main nvim-cmp floating window, it breaks the way borders look for all other floating windows, that follow the :help docs.

Steps to reproduce

use cmp.config.window_bordered()

cmp.setup({
    window = {
       completion = cmp.config.window.bordered(),
       documentation = cmp.config.window.bordered(),
     },
})

Expected behavior

the winhighlight should use NormalFloat for the background when using the bordered config``

Actual behavior

the winhighlight uses Normal for the background when using the the bordered config

Additional context

nvims help docs

  • :help hl-NormalFloat says "Normal text in floating windows"
  • :help hl-FloatBorder says "Border of floating windows"

related issues

This is an essentially asking for the same thing as issue #748 (merged in PR #1689) but for the main window's fg/bg instead of just the border.

I would be happy to create a PR if this is approved :)

@slugbyte
Copy link
Author

slugbyte commented Sep 19, 2024

this is what i used for testing my proposed change to winhighlight

cmp.setup({
	window = {
		completion = vim.tbl_extend("force", cmp.config.window.bordered(), {
			winhighlight = "NormalFloat:NormalFloat,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
		}),
		documentation = vim.tbl_extend("force", cmp.config.window.bordered(), {
			winhighlight = "NormalFloat:NormalFloat,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
		}),
	},
	-- rest of config
})

@mehalter
Copy link
Contributor

I would also recommend changing the default CursorLine to PmenuSel rather than Visual since that matches the semantics a bit more as well as to what it means to "select something in a pop up"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants