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

nvim-cmp's pupup window doesn't close if command-line window is opened from command-line mode #603

Closed
mawkler opened this issue Dec 3, 2021 · 3 comments · May be fixed by #1904
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mawkler
Copy link

mawkler commented Dec 3, 2021

Describe the bug

If <C-f> is pressed command-line mode it opens the command-line window. However, nvim-cmp's completion window doesn't close which means that it hides the command-line window.

Minimal 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 'hrsh7th/cmp-cmdline'
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" },
  },
}

cmp.setup.cmdline(':', {
  sources = cmp.config.sources({
    { name = 'path' },
    { name = 'cmdline' }
  })
})
EOF

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

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

To Reproduce

  1. Open Neovim
  2. Press : to enter command-line mode
  3. Press any character to bring up the completion menu, for instance c
  4. Press <C-f>

Expected behavior

nvim-cmp's completion window closes when command-line window opens

@hrsh7th hrsh7th added bug Something isn't working help wanted Extra attention is needed labels Dec 4, 2021
@mawkler
Copy link
Author

mawkler commented Dec 14, 2021

Works great, thanks! 🎉

@DmDurnov
Copy link

DmDurnov commented Oct 6, 2023

@hrsh7th
The error is being reproduced again
Possible fix:
lua/cmp/init.lua: 354 line
-autocmd.subscribe({ 'InsertLeave', 'CmdlineLeave' }, function()
+autocmd.subscribe({ 'InsertLeave', 'CmdlineLeave', 'CmdwinEnter' }, function()

@bobrippling
Copy link

@DmDurnov thanks for the tip - #1904 opened

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

Successfully merging a pull request may close this issue.

4 participants