-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid sorting completion candidates #190
Comments
Thanks for the report. Either this is a bug in Emacs itself (it should be fetching :display-sort-function too) or eglot should do the sorting somewhere else. I'll look into it, but there's one thing I don't understand. If completions are being returned in a sensible order and Eglot isn't doing anything, why isn't this working? |
I think Eglot isn't doing anything, but for me it should actively do nothing :) This is the relevant part of minibuffer-completion-help: (setq completions
;; FIXME: This function is for the output of all-completions,
;; not completion-all-completions. Often it's the same, but
;; not always.
(let ((sort-fun (completion-metadata-get
all-md 'display-sort-function)))
(if sort-fun
(funcall sort-fun completions)
(sort completions 'string-lessp)))) So if sort-fun is not set, m-c-h will sort the completions anyway. Eglot sending an identity function (lambda (x) x) would be fine. Company has different logic for the display order, which might be adjusted without configuring/changing eglot, but I still don't understand that part. Thank you. |
Zooming out from the code for a little while, what are you seeing here in practice?
Are any of these two situations correct. The fix seems to lie in Eglot, but first I need a clear, code-free, description of what is happening in situations 1 and 2. |
The :display-sort-function property in capf functions (vs the 'display-sort-function metadata property) doesn't appear to anything, as pointed out by Felicián Németh. * eglot.el (eglot-completion-at-point): Move location of sort function.
The :display-sort-function property in capf functions (vs the 'display-sort-function metadata property) doesn't appear to anything, as pointed out by Felicián Németh. * eglot.el (eglot-completion-at-point): Move location of sort function.
I think label should be used as fallback (instead of the empty string).
|
Obviously, it was a mistake from me to talk about two separate things at the very beginning.
If I open this file and press
I get the same order with company (i.e. opening the file and press If my analysis is correct, pyls returns the available completions in my desired order.
This is what I used for my test:
Sorry for the confusion and thanks again |
The :display-sort-function property in capf functions (vs the 'display-sort-function metadata property) doesn't appear to anything, as pointed out by Felicián Németh. * eglot.el (eglot-completion-at-point): Move location of sort function.
So I think I fixed this. A couple of points.
I will probably e opening a bug report about 1. I think that either There has to be a very thorough understanding of Emacs's completion mechanism before tackling things like #181. It will be even more complicated for LSP servers returning incomplete completion results. |
* eglot.el (eglot-completion-at-point): Complicate severely.
* eglot.el (eglot-completion-at-point): Complicate severely.
* eglot.el (eglot-completion-at-point): Complicate severely. #190: joaotavora/eglot#190
* eglot.el (eglot-completion-at-point): Complicate severely. GitHub-reference: fix joaotavora/eglot#190
It seems pyls returns completions in a sensible order: class methods starting with an underscore are at the end. Is it possible to keep the server order in completion-at-point and in company-complete?
A bit indendent of the question, but I tried to look into this, and I think there's a bug in eglot around this line:
eglot/eglot.el
Line 1858 in 85711cc
minibuffer-completion-help sets afun like this:
but plist-get part is missing for sort-fun
so the lambda function of line 1859 set at eglot-completion-at-point seems to never get called.
The text was updated successfully, but these errors were encountered: