Different completion candidates in Corfu and Company
drcxd opened this issue · comments
I just tried Orderless with both Corfu and Company. I found that when prioritizing the orderless
completion style, Corfu and Company returns different completion candidates.
For example, in the scratch buffer, when I typed
(lam
Company would return a list of candidates like these:
--anonymous-lambda
-lambda
ad-lambada-expression
ad-lambda-p
ad-lambdafy
byte-compile-check-lambda-list
...
It looks like the list is sorted alphabetically and lambda
is near the end of the whole list.
However, when using Corfu, in the same situation, lambda
is the first candidate. I think Corfu's behavior is the desired one. Any idea how could I fix this problem?
Orderless does no sorting at all! Completion UIs (like Corfu and Company) can sort, and the underlying capf, in this case elisp-completion-at-point
might do some sorting of their own.
-
A quick persual of
elisp-completion-at-point
suggests it does not provide eithercycle-sort-function
ordisplay-sort-function
metadata, so it's not sorting either. -
Sorting in Corfu is configurable (see
corfu-sort-function
) and defaults to sorting first by length and breaking ties alphabetically. -
I don't use company and don't have it installed, but a very superficial look at its repository suggests its sorting is configurable too, controlled by the variable
company-transformers
and defaults to alphabetical sorting.
So, I wouldn't say "I think Corfu's behavior is the desired one", probably it's more correct to say "Corfu and Company chose different defaults". If you find Corfu's default sorting better (I think I would), I suggest you set company-transformers
to '(corfu-sort-length-alpha)
(which I believe I should work). But also check out the other options Corfu and Company suggest, you may find a type of sorting you find even more useful. Company's company-sort-by-occurrence
sounds pretty useful.
However, when using Corfu, in the same situation, lambda is the first candidate. I think Corfu's behavior is the desired one. Any idea how could I fix this problem?
There is no problem - just use Corfu ;)