roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

Popup shows unwanted completions when triggered manual #143

Closed robinknaapen closed 6 years ago

robinknaapen commented 6 years ago

I'm currently using

let g:cm_auto_popup = 0
imap <C-Space> <Plug>(cm_force_refresh)

When I use this I notice that I get results in some of my completions that make no sense to me.

2017-10-05-14-44-47

My expected result would be the same as with cm_auto_popup enabled

2017-10-05-14-58-10

I've found a workaround for this issue. When looking through your source code I found out that changing cm_force_refresh fixed my issue.

func! cm#_force_refresh()
    " force=1
    call s:notify_core_channel('cm_refresh',g:_cm_sources,cm#context(),0)
    return ''
endfunc

What I did was change the 1 into 0.

I'm using nvim-cm-tern in my examples

robinknaapen commented 6 years ago

Concluded that this is a terrible workaround... This only worked in JS for me. In Golang this will result in NCM not finding any completion; In my experience.

roxma commented 6 years ago

That's line completion. https://github.com/roxma/nvim-completion-manager/issues/24

Line completion is a non auto popup source, it's only triggered by <Plug>(cm_force_refresh)

It has lower priority so it's at the bottom of the menu.

You could disable it with g:cm_sources_override

roxma commented 6 years ago

I'm wondering:


Here is a brief explanation of current behavior:

<Plug>(cm_force_refresh) activates all sources according to current file type. And it ignores the sources's cm_refresh_length. For example, with buffer keyword completion,

It auto pops up when you has typed four characters foob|, by default, But with manually completion, it's triggered for only one character. f|

Activates all souces could be annoying. But it seems it's needed in some use cases, for example, when you don't know what more to type to trigger the menu.

roxma commented 6 years ago

My proposal:

  1. Add a mark into each completion item.

  2. We could setup another config variable cm_manual_refresh_length, like cm_refresh_length, but only used for manual completion.

  3. As for the line completion source, it should only be triggered by manually, and only when the cursor is at the beginning of a word, before typing a character. It should be hidden when suggestions with higher priority is available.

// cc @rafaeln

roxma commented 6 years ago

fixed in ncm2 <Plug>(ncm2_manual_trigger) has almost the same behavior of auto trigger