PythonNut / company-flx

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

Possible to make this work with intero (haskell)? #18

Open unhammer opened 7 years ago

unhammer commented 7 years ago

https://github.com/commercialhaskell/intero/issues/299 is a request for this kind of matching in intero. I was trying to look into it, but I can't actually find any examples of code that calls a function named capf or completion-at-point in the other company.el code …

Is it right to assume that intero just needs to define a function that can be added to completion-at-point-functions? And do you happen to have an example of how this was done for other company backends?

PythonNut commented 7 years ago

I was trying to look into it, but I can't actually find any examples of code that calls a function named capf or completion-at-point in the other company.el code …

Fuzzy completion is broken into two important components: matching and sorting. Sorting is trivial, and that's what's implemented here for all backends. Matching is less trivial, because it redefines what company means by the "prefix" (i.e. the prefix need not be a prefix at all...)

The modification for matching was implemented for the completion-at-point system. It actually has the potential to work for other completion systems as well, although I haven't got around to that, as there doesn't seem to be a credible competitor to company-mode.

Is it right to assume that intero just needs to define a function that can be added to completion-at-point-functions?

That is one way to do it. In that case, I'd need to change nothing. Alternatively, intero could support fuzzy matching using some API, which I could leverage.

And do you happen to have an example of how this was done for other company backends?

It was done for only one backend. The code is here. However, I don't expect it has much in common with the required modifications to any other backend, unfortunately.