Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Don't show autocompletion popup after navigation keystrokes #208

Open
mrbiggfoot opened this issue Mar 22, 2018 · 20 comments
Open

Don't show autocompletion popup after navigation keystrokes #208

mrbiggfoot opened this issue Mar 22, 2018 · 20 comments

Comments

@mrbiggfoot
Copy link

mrbiggfoot commented Mar 22, 2018

If I'm in insert mode and just move the cursor around using <left>, <right>, <up>, <down>, <home>, <end>, and so on - autocompletion menu still pops up and interferes with my cursor movement (if there's something to complete under cursor). Is it possible to make the completion popup window only show up after I type letters, dot or colon? Thanks!

@mrbiggfoot
Copy link
Author

mrbiggfoot commented Mar 22, 2018

Also, it would be nice for NCM to behave like this: if nothing is selected in the autocompletion popup and I press <CR>, it should close the popup and insert newline. Currently it just closes the popup without adding a newline.

@Shougo
Copy link

Shougo commented Mar 22, 2018

Also, it would be nice for NCM to behave like this: if nothing is selected in the autocompletion popup and I press <CR>, it should close the popup and insert newline. Currently it just closes the popup without adding a newline.

It is not nvim-completion-manager issue.
You should map <CR>.

inoremap <silent> <expr><CR> pumvisible() ? "\<C-e>\<CR>" : "\<CR>"

Note: You cannot specify if nothing is selected. It is Vim/neovim limitation.
You should not select candidate by \<CR>.

@mrbiggfoot
Copy link
Author

Thanks @Shougo! But the issue described in the 1st comment should be possible to resolve, right?

@Shougo
Copy link

Shougo commented Mar 23, 2018

Is it possible to make the completion popup window only show up after I type letters, dot or colon? Thanks!

I have read the implementation and it is already implemented.
nvim-completion-manager only works if you have changed buffer.
Note: You may need to disable InsertEnter completion though.
It is same behavior with deoplete.

So what is the problem?

if there's something to complete under cursor

If you want to move the cursor when the popup menu visible, here.

inoremap <silent> <expr><Up> pumvisible() ? "\<C-e>\<Up>" : "\<Up>"

It is not nvim-completion-manager problem.
And I don't recommend to move the cursor in insert mode.

@mrbiggfoot
Copy link
Author

@Shougo the problem is this: I want autocompletion popup only when I'm typing something, not when I'm moving cursor around. Also, when the popup is visible, I want arrows to select a candidate.

It is same behavior with deoplete.

Alas, I had to move away from deoplete and now in a search of a completion plugin that works for me. Right now I'm using mucomplete which does not have the issue described in this bug. But there's no fuzzy search in mucomplete, and will never be.

@Shougo
Copy link

Shougo commented Mar 23, 2018

@Shougo the problem is this: I want autocompletion popup only when I'm typing something, not when I'm moving cursor around. Also, when the popup is visible, I want arrows to select a candidate.

I have researched nvim-completion-manager code.
It uses InsertEnter and TextChangedI only. It is same with deoplete.
So the problem is exists both deoplete and nvim-completion-manager?
I want to reproduce the problem. Please create the example. I will test it.

@mrbiggfoot
Copy link
Author

@Shougo edit this file with NCM enabled:

abcdefg
abcdefg

Now enter insert mode with cursor at (1, 1) and press <right> 3-4 times. Autocompletion popup will appear in the middle of abcdefg. Why?! I'm not typing anything.

@Shougo
Copy link

Shougo commented Mar 23, 2018

I don't get the popup using nvim-completion-manager.
Why? I'm not typing anything.

OK. Reproduced. I will check nvim-completion-manager implementation.
I don't reproduce the problem with deoplete.

If you can reproduce the problem with deoplete, please tell me.

@Shougo
Copy link

Shougo commented Mar 23, 2018

I have got the reason.

nvim-completion-manager checks the cursor position using timer feature.
It does not check b:changedtick. It checks getcurpos() only.
So,

Now enter insert mode with cursor at (1, 1) and press <right> 3-4 times. Autocompletion popup will appear in the middle of abcdefg. Why?! I'm not typing anything.

The behavior is feature.

It is the patch to fix the behavior.

diff --git a/autoload/cm.vim b/autoload/cm.vim
index 115b96f..01bf842 100644
--- a/autoload/cm.vim
+++ b/autoload/cm.vim
@@ -443,7 +443,7 @@ func! s:on_insert_enter()
     endif
     let s:lasttick = s:changetick()
     " check changes every 30ms, which is 0.03s, it should be fast enough
-    let s:change_timer = timer_start(30,function('s:check_changes'),{'repeat':-1})
+    " let s:change_timer = timer_start(30,function('s:check_changes'),{'repeat':-1})

     call s:on_changed()
 endfunc

Note: There may be side effects

@prabirshrestha
Copy link
Contributor

I can verify that using left right arrows in asyncomplete.vim shows popup if it is closed with timer but not with TextChangedP. Given that asyncomplete.vim is a fork of ncm migth be ncm could also support TextChangedP? In asyncomplete.vim using timers to poll is now legacy and TextChangedP is the future. I will be only supporting new features in TextChangedP.

These are the two commits that are needed to be ported. prabirshrestha/asyncomplete.vim@6a9a0e6 and prabirshrestha/asyncomplete.vim@720be50

@Shougo
Copy link

Shougo commented Mar 23, 2018

Given that asyncomplete.vim is a fork of ncm migth be ncm could also support TextChangedP?

I think Yes. deoplete already supports TextChangedP.

Note: neovim does not support TextChangedP yet.

@mrbiggfoot
Copy link
Author

@Shougo I don't have this specific problem with deoplete, but I do have several others. Apart from performance and stability issues that I've been having recently, I was never able to set it up to work with tags reliably. Looking at the speed at which mucomplete and NCM can offer candidates for tags completion, I simply can't live with deoplete.

@Shougo
Copy link

Shougo commented Mar 23, 2018

@Shougo I don't have this specific problem with deoplete, but I do have several others. Apart from performance and stability issues that I've been having recently, I was never able to set it up to work with tags reliably. Looking at the speed at which mucomplete and NCM can offer candidates for tags completion, I simply can't live with deoplete.

If deoplete does not work with tags, please create the issue in deoplete. I will check it.
mucomplete just use Vim built-in tags completion.

@mrbiggfoot
Copy link
Author

@Shougo it works... but the wait time for tags candidates to appear in the popup is many seconds. In NCM and mucomplete it's instantly. If you know how NCM does it, then deoplete should behave this way too.

@Shougo
Copy link

Shougo commented Mar 23, 2018

OK. I get it.
I will improve tag source performance in deoplete.

In nvim-completion-manager, it uses binary search. It is faster, but fuzzy match does not work.

@mrbiggfoot
Copy link
Author

@Shougo fuzzy search does work for tags in NCM, at least to some extent. For example "PrintCMS" string matches "PrintCacheMaxSizes" candidate.

@Shougo
Copy link

Shougo commented Mar 23, 2018

@mrbiggfoot
Copy link
Author

I wonder why you guys use Python for performance-critical code like fuzzy matching?.. Speed has never been a strong side of Python.

@Shougo
Copy link

Shougo commented Mar 23, 2018

Because, Python performance is not so bad.
And it is very faster than Vim script.

@mrbiggfoot
Copy link
Author

I'm pretty sure it's hard to achieve the same level of performance as fzf in pure Python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants