company-flx icon indicating copy to clipboard operation
company-flx copied to clipboard

Does company-flx work with anaconda-mode?

Open avli opened this issue 8 years ago • 10 comments

Hi,

First of all, I found this plugin recently and now really enjoying it. It works perfectly in most cases, but, unfortunately, doesn't work with anaconda-mode, which I use for Python development.

Am I correct and it's not a bug and have something to do with how anaconda handles a list of possible completions? Thanks in advance!

avli avatar Jun 19 '16 06:06 avli

You are correct company-flx does not currently work with any company backend that is not company-capf.

I would need to manually advise each backend I want to support to include fuzzy matching, and in the case of large packages like anaconda-mode and irony-mode this presents a significant challenge. In addition, these modifications are very fragile as they will almost always rely on undocumented behavior.

Perhaps if I can find a large swath of time to work on adding more backends, I'll give it a shot. My real hope is that packages like anaconda-mode will migrate to using completion-at-point-functions, which would automatically add support for fuzzy matching. (And are generally considered the way forward for company backends.)

PythonNut avatar Jun 25 '16 16:06 PythonNut

Thank you very much for the explanation!

avli avatar Jun 26 '16 08:06 avli

@proofit404, do you think this could be done easily by advising company-anaconda primitives?

PythonNut avatar Jun 27 '16 01:06 PythonNut

Hello.

@PythonNut I can't move company backend for anaconda-mode to complete-at-point-function implementation. Reason for this is really simple. anaconda-mode is written in asynchronous style to provide better user experience. Since complete-at-point-function require synchronous interface i.e. call function and obtain completion result immediately.

anaconda-mode works differently. When we call completion function it returns immediately. Then anaconda-mode perform background network interaction with its server written in python. When result is available we trigger its handler. Show company popup for example.

I can add company-flx support to company-anaconda if you explain me how :)

proofit404 avatar Jun 27 '16 07:06 proofit404

Hi @proofit404, thanks for getting back to me!

I was actually wondering if there was a way to add support without modifying company-anaconda (but of course, if you're wiling to make changes if they're required that'd be great too).

I really only need to be able to control two things:

  1. The requirements for a candidate to be matched

    e.g. we need to allow tialfthis_is_alongfunction.

  2. The sorting of the candidates according to their fuzzy score

    e.g. for tialf, we need to show this_is_alongfunction before this_sailfish

If you can point me towards some functions that I could override in anaconda-mode using advice in company-flx, that would be the easiest for you. If you'd like something cleaner then maybe we can arrange a *-function variable to use.

PythonNut avatar Jun 28 '16 23:06 PythonNut

If you need function to change the order of candidates then I can add this as a variable holding function with candidates list as an argument.

proofit404 avatar Jun 29 '16 06:06 proofit404

@proofit404 fuzzy matching is probably going to be the more challenging of the two. In fact, I already have a company transformer that will sort the candidates already, so matching is really the only thing anaconda-mode will have to worry about.

PythonNut avatar Jun 30 '16 03:06 PythonNut

Just tell me what I need to do on my side :D

proofit404 avatar Jun 30 '16 09:06 proofit404

@proofit404 ideally, you would implement a way for me to supply (by setting a variable or overriding a function) my own matching predicate, which would take the user's "prefix" and a candidate and return whether the candidate should be displayed.

PythonNut avatar Jul 01 '16 05:07 PythonNut

So, what is the status? This seems to be partially done in Dec 2019.

digikar99 avatar Apr 17 '20 07:04 digikar99