PythonNut / company-flx

:city_sunset: Flx fuzzy matching for company
GNU General Public License v3.0
85 stars 6 forks source link

Does company-flx work with anaconda-mode? #17

Open avli opened 8 years ago

avli commented 8 years ago

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!

PythonNut commented 8 years ago

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.)

avli commented 8 years ago

Thank you very much for the explanation!

PythonNut commented 8 years ago

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

proofit404 commented 8 years ago

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 :)

PythonNut commented 8 years ago

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 tialfthisisalongfunction.

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

    e.g. for tialf, we need to show thisisalongfunction 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.

proofit404 commented 8 years ago

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.

PythonNut commented 8 years ago

@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.

proofit404 commented 8 years ago

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

PythonNut commented 8 years ago

@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.

digikar99 commented 4 years ago

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