hrsh7th/nvim-compe

close function completion on open parenthesis

gjeusel opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

I would like to automagically close the completion menu when opening a parenthesis, so I can then have completion for variable in signature.

Describe the solution you'd like

Current behaviour:
image

Expected behaviour (obtained by quitting insert mode, and re-entering it after open parenthesis):
image

Describe alternatives you've considered

I tried remaping the "(" in insert mode like follow:

-- Fix behaviour of completion not closing on (
_G.control_open_parenthesis_close_complete = function()
  if vim.fn.pumvisible() == 1 then
    vim.api.nvim_exec([[call compe#close()]], false)
    return t("(")
  else
    return t("(")
  end
end
vim.api.nvim_set_keymap("i", "(", "v:lua.control_open_parenthesis_close_complete()", mapopts)

Additional context

Not related to nvim-autopairs (I managed to reproduce when disabling it)

Question

I have not found any info on it, is it doable ?

Without any success.

Duplicate to which issue? I cannot find one. @gjeusel why was this closed?

UPDATE: #436

@gjeusel compe#close() is a function for imap expression -- it evaluates to a string \<C-e>\<C-r>=luaeval('require\"compe\"._close()')\<CR>.

Please refer to #436 (comment) for another possible workaround similar to yours.