deoplete.nvim icon indicating copy to clipboard operation
deoplete.nvim copied to clipboard

Is it possible to trigger popup on shortcut?

Open WhiteBlackGoose opened this issue 2 years ago • 0 comments

Hello. Thanks for this great plugin!

My question is if I can somehow trigger the popup on shortcut (say, <C-Space>) only. Here's what I did so far is disabled the automatic popup:

vim.cmd[[
call deoplete#custom#option({
\    'auto_complete_popup': 'manual'
\})
]]

I read the docs multiple times but still couldn't figure it out.

WhiteBlackGoose avatar Aug 09 '22 17:08 WhiteBlackGoose

Please use deoplete#manual_complete.

Shougo avatar Aug 11 '22 09:08 Shougo

Thanks, I was trying to figure out how to use it too. It doesn't seem to get triggered in normal mode (I binded <C-Space> to <ESC>:lua vim.g.trigger_deoplete()i, where vim.g.trigger_deoplete uses deoplete#manual_complete()). Any idea?

WhiteBlackGoose avatar Aug 11 '22 17:08 WhiteBlackGoose

It is really want to execute in normal mode??

Shougo avatar Aug 12 '22 09:08 Shougo

I have checked the source code and it cannot...

If you have set auto_complete_popup is manual, deoplete uses cached results. But the cache is cleared when you have leave insert mode.

Shougo avatar Aug 12 '22 10:08 Shougo

So call deoplete#complete() in insert mode is best.

You need to read the documentation.

I think you have not read the documentation.

					*deoplete-options-auto_complete_popup*
auto_complete_popup
		Change auto completion popup behavior.

		"auto": popup is displayed automatically.
		"manual": popup is displayed by |deoplete#complete()|.

		Default value: "auto"

Shougo avatar Aug 12 '22 10:08 Shougo

Hm.. This is undocumented way but it works for me.

set runtimepath+=~/src/deoplete.nvim/

let g:deoplete#enable_at_startup = 1

call deoplete#custom#option({
\    'auto_complete': v:false,
\})
nnoremap <Tab>  i<Cmd>call deoplete#mapping#_rpcrequest_wrapper([])<CR>
inoremap <Tab><expr>  deoplete#manual_complete()

or

set runtimepath+=~/src/deoplete.nvim/

let g:deoplete#enable_at_startup = 1

call deoplete#custom#option({
\    'auto_complete_popup': 'manual'
\})
inoremap <Tab><expr>  deoplete#complete()

Shougo avatar Aug 12 '22 10:08 Shougo

It is really want to execute in normal mode??

No but idk how to run a command in insert mode :flushed: .

You need to read the documentation.

I did read it. I just perhaps lack the knowledge of vim

Hm.. This is undocumented way but it works for me.

Thanks, I'll try it out

WhiteBlackGoose avatar Aug 12 '22 13:08 WhiteBlackGoose

No but idk how to run a command in insert mode flushed .

<Cmd>call foobar()<CR>

Shougo avatar Aug 14 '22 04:08 Shougo

Thank you so much, with slight modifications it works for me:

vim.cmd[[
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option({
\    'auto_complete': v:false,
\})
inoremap <C-Space>  <Cmd>call deoplete#mapping#_rpcrequest_wrapper([])<CR>
]]

WhiteBlackGoose avatar Aug 14 '22 08:08 WhiteBlackGoose

I think it is better. Because it is documented function.

inoremap <C-space><expr>  deoplete#manual_complete()

Shougo avatar Aug 14 '22 08:08 Shougo

I may be doing something wrong, but yours doesn't work for me. It freezes for half a second with 80>ü^D<20> in the right bottom corner and then gets into normal mode without any suggestions :((.

WhiteBlackGoose avatar Aug 14 '22 20:08 WhiteBlackGoose

OK. I have reproduced it. Please update to the latest version. I have fixed it.

Shougo avatar Aug 15 '22 00:08 Shougo

Still the same behavior... here's my repro:

watermelon<CR>water<C-Space>

Doesn't show the popup for me. I updated with :PlugUpdate deoplete.nvim. nvim 0.7.

Both

inoremap <C-space><expr>  deoplete#manual_complete()
inoremap <C-space>  <Cmd>call deoplete#manual_complete()<CR>

Don't work for me (the second one doesn't do anything at all). :shrug:

WhiteBlackGoose avatar Aug 15 '22 06:08 WhiteBlackGoose

inoremap <C-space> <Cmd>call deoplete#manual_complete()<CR>

It does not work. Because you must use deoplete#manual_complete() in map-<expr>.

Shougo avatar Aug 15 '22 09:08 Shougo

It works for me.

Please check your deoplete.nvim is the latest version. You should check sha1.

set runtimepath+=~/src/deoplete.nvim/

let g:deoplete#enable_at_startup = 1

call deoplete#custom#option({
      \    'auto_complete': v:false,
      \})
nnoremap <Tab>  i<Cmd>call deoplete#mapping#_rpcrequest_wrapper([])<CR>
inoremap <expr><Tab>  deoplete#manual_complete()

Shougo avatar Aug 15 '22 09:08 Shougo

And please test the minimal init.vim. I think you have tested non minimal init.vim.

Shougo avatar Aug 15 '22 09:08 Shougo

The latest commit is cc0f6116fa4abd4a6b4c1234f220d00ad4fe3c58 so it's supposed to be the correct version. Alright, if I find time I'll try to test minimal nvim. Thanks for your help anyway, for now it works

WhiteBlackGoose avatar Aug 15 '22 19:08 WhiteBlackGoose