ncm2 icon indicating copy to clipboard operation
ncm2 copied to clipboard

[TODO] ncm2#complete_add

Open roxma opened this issue 6 years ago • 3 comments

With this, it's easier to provide much more completion results with decent response performance.

roxma avatar Aug 01 '18 09:08 roxma

Imagine that we have tens of thousands of candidates to filter in the background, the filtering process might take ~2 seconds before finish.

But when the process finishes, the user may have already typed more characters, and left current completion context. Which means the current completion results are useless, and the worse thing is, we're late for calculating the next completion task.

Using an incremental minibatch approach solves this issue.

roxma avatar Aug 01 '18 09:08 roxma

This is exactly what I did in my plugin for deoplete a while ago before "matcher_key" feature and lib_cpsm filter were added. I had an async source and a background thread with a cancellation flag. The thread would check that flag from time to time while filtering the results, and the source would set the flag when user input in the context has changed.

This, however, rendered completely unnecessary after addition of lib_cpsm, which is a fuzzy filter written in plain C with a Python module wrapper. Even without sophisticated tricks and algorithmic optimizations, just offloading the filtering to a more performant language can easily get you 10x performance gain. That's another approach to keep in mind.

balta2ar avatar Aug 01 '18 10:08 balta2ar

@balta2ar Thanks for the information

I have some more plans which also need this feature.

The jedi integration for example, If I want dn to complete datetime.now, the implementation will require two steps.

  1. get the completion results which include datetime
  2. simulate the typeing datetime., then finally get datetime.now

The second step loop over the result of the previous step. It may consumes a lot of CPU time. It needs minibatch incremental completion too.

roxma avatar Aug 01 '18 10:08 roxma