clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.56k stars 645 forks source link

[completion] Fix custom completion style and make it default for fuzzy matching #3746

Closed alexander-yakushev closed 1 month ago

alexander-yakushev commented 1 month ago

Back to completion woes.

Some time ago we moved the official way to enable fuzzy Compliment-driven completion from a custom completion style to flex. This worked correctly until https://github.com/company-mode/company-mode/issues/1493 – cider completion now no longer suggests candidates for class shortnames like e.g. Persistent. Nothing has been broken in Company, vice versa, Company has became more like corfu and complete-at-point, so it was already broken in those clients.

I tried to fix it for flex but did not succeed. It looks like owning a custom completion style is still the proper way to go, so I'm resurrecting it with this PR and undeprecating the previous way to enable "fuzzy" completion. The current partial compatibility with flex remains, so if folks prefer to use that, they still can.

I've also fixed our custom completion style so that it is compatible with Emacs machinery – something that users complained about before.

bbatsov commented 1 month ago

Seems we constantly manage to both fix something and break something on the completion side of things. Let me think about this for a bit.

alexander-yakushev commented 1 month ago

Sure. But what I understood from @dgutov words is that a custom completion style is an OK solution for many packages, not something to shun from.

bbatsov commented 1 month ago

I'm mostly worried about this part:

Please go ahead and ping me if you have further questions or problems adapting the style implementation. This is still a breaking change in company-mode's behavior, and I'd like to see all major completion providers onboard before tagging the next release.

I'm not sure if this will work fine with the current stable version of company, so I wanted to investigate. But if you're sure about this I guess we can proceed.

alexander-yakushev commented 1 month ago

It should be fine. The changes in Company introduced problems for the current flex-based solution but didn't touch the old custom completion-style solution. Besides, it's opt-in anyway, so it wouldn't impact users that don't have it enabled in the first place.

dgutov commented 1 month ago

@bbatsov

I'm not sure if this will work fine with the current stable version of company, so I wanted to investigate.

The new release came out a month ago, so this won't be a problem. I indeed hoped to get more backends onboard first, but that only had partial success. OT2H, the problem had been present with all (?) other UIs except company-mode, so it can't be too bad.

@alexander-yakushev

a custom completion style is an OK solution for many packages, not something to shun from

I agree this is more complicated than we'd want to, but for now it's what's recommended for CAPF. Also see eglot's and lsp-mode's styles.