completion-nvim icon indicating copy to clipboard operation
completion-nvim copied to clipboard

Default confirmation mapping is broken

Open AlxHnr opened this issue 5 years ago • 3 comments

  • Please read through this section before posting a bug report.

My testing minimal init.vim Post your init.vim to help me reproduce this issue

call plug#begin()

Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'

set completeopt=noinsert,menuone,noselect
autocmd BufEnter * lua require'completion'.on_attach()

call plug#end()

lua require'nvim_lsp'.clangd.setup{}

How to reproduce Detailed step to reproduce this issue.

Example Code:

class Bar {
public:
  void setValue(int value);

private:
  int value{};
};

void Bar::setValue(int value) {
  this->
}

Completion prompt:

before

Pressing <cr> does not behave like <c-n>:

after

Expected behavior A clear and concise description of what you expected to happen.

Don't map the completion key by default at all. This belongs (just like the <Tab> mappings) into the Recommended Settings section of the README. The behavior is inconsistent with almost every other autocomplete plugin out there and breaks the following mapping:

inoremap <expr><cr> pumvisible() ? '<c-n>' : '<cr>'

It took me quite a while to find the solution, which is let g:completion_confirm_key = "".

AlxHnr avatar Sep 15 '20 09:09 AlxHnr

I've mapped <CR> because we have to confirm the completion and expand snippets items, and I want to make sure snippets wasn't expand because of some other keys but only on the confirm key. Also it does help providing a more out of the box behavior. However, right now I do think that this should be a recommended setting instead of mapping by default. I have to think how should it be implemented though because this will break backward compatibility.

haorenW1025 avatar Sep 16 '20 02:09 haorenW1025

I have to think how should it be implemented though because this will break backward compatibility.

The few people out there who are running Neovim 0.5 nightly are likely to update plugins regularly. The whole native LSP thing is still messy, so better break stuff before its stable. You could remove this mapping and show a removal warning when loaded on attach. Maybe even print the command or setting to restore the previous behavior.

AlxHnr avatar Sep 16 '20 10:09 AlxHnr

I have to think how should it be implemented though because this will break backward compatibility.

The few people out there who are running Neovim 0.5 nightly are likely to update plugins regularly. The whole native LSP thing is still messy, so better break stuff before its stable. You could remove this mapping and show a removal warning when loaded on attach. Maybe even print the command or setting to restore the previous behavior.

On the image you uploaded, you don't seem select any of the items on the completion thus the completion is not getting triggered. Try selecting (by pressing <c-n>), press enter and that will do the trick. If you want the completion to auto-select the first entry make sure you don't have noinsert on your completeopt setting on vim.

zakybilfagih avatar Sep 16 '20 14:09 zakybilfagih