Open mrbiggfoot opened 6 years ago
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.
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>
.
Thanks @Shougo! But the issue described in the 1st comment should be possible to resolve, right?
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.
@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 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.
@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.
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.
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
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. https://github.com/prabirshrestha/asyncomplete.vim/commit/6a9a0e64c4362f9621eac263f310c7296404bee0 and https://github.com/prabirshrestha/asyncomplete.vim/commit/720be509c8b36de6e036a6b126f335203342c906
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.
@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 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.
@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.
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.
@Shougo fuzzy search does work for tags in NCM, at least to some extent. For example "PrintCMS" string matches "PrintCacheMaxSizes" candidate.
https://github.com/roxma/nvim-completion-manager/blob/master/pythonx/cm_sources/cm_tags.py#L36
ncm uses ctx['base']
for filtering.
I wonder why you guys use Python for performance-critical code like fuzzy matching?.. Speed has never been a strong side of Python.
Because, Python performance is not so bad. And it is very faster than Vim script.
I'm pretty sure it's hard to achieve the same level of performance as fzf in pure Python.
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!