4

I've been configuring my Neovim for quite a while now. This command menu seems a little ugly with the transparent background. I'd be great if I could add a border for this menu. How can I do that ?

enter image description here

I'll accept both lua and vim-lang answers.

3
  • You cannot add a border but you can make it opaque: :set pumblend =0. In Vim, it shouldn't be transparent as there is no option to make it transparent, so you should remove the mention of vim from your question title.
    – 3N4N
    Commented Oct 22, 2022 at 12:45
  • I previously tried something like vim.cmd[[:highlight Pmenu guibg=NONE cterm=NONE term=NONE]] to make my cmp completion menus transparent. Can I have different highlights for the cmp completion menu and this completion menu ?
    – Diwas10
    Commented Oct 22, 2022 at 12:52
  • No. Both those menus use the same highlight group.
    – 3N4N
    Commented Oct 22, 2022 at 12:57

2 Answers 2

4

I would propose you to use the wilder plugin

With the following settings:

call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
      \ 'highlights': {
      \   'border': 'Normal',
      \ },
      \ 'border': 'single',
      \ })))

3

Here's the Lua implementation of what @Vivian De Smedt mentioned.

local status_ok, wilder = pcall(require, "wilder")
if not status_ok then
  print("wilder plugin not found")
  return
end

wilder.set_option('renderer', wilder.popupmenu_renderer(
  wilder.popupmenu_border_theme({
    highlights = { border = 'Normal' },
    border = 'single',
  })
))

wilder.setup({modes = {':', '/', '?'}}) 

Another way:

If you use nvim-cmp for auto-completion like me, you can apply cmp popup menu borders to the command-line using cmp-cmdline plugin. This plugin will also let you fuzzy find the options.

local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
  return
end

cmp.setup({

  -- .... (other setups)

  -- Add borders around the popup window
  window = {
    completion = cmp.config.window.bordered(),  
  },

})

-- Enable command-line completion 
cmp.setup.cmdline(':', {
  sources = {
    { name = 'cmdline' },
  },
  formatting = {
    fields = { "abbr" },
  }
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.