GNU bug report logs - #68699
Eglot completion has stopped working in some cases

Previous Next

Package: emacs;

Reported by: Brennan Vincent <brennan <at> umanwizard.com>

Date: Wed, 24 Jan 2024 20:38:01 UTC

Severity: normal

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Brennan Vincent <brennan <at> umanwizard.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: Eglot completion has stopped working in some cases
Date: Thu, 25 Jan 2024 01:35:08 +0000
On Thu, Jan 25, 2024 at 12:43 AM João Távora <joaotavora <at> gmail.com> wrote:
>
> On Wed, Jan 24, 2024 at 8:37 PM Brennan Vincent <brennan <at> umanwizard.com> wrote:
>
> > For example, in a Rust crate with the following main file:
> >
> > fn foo_len() {
> > }
> >
> > fn main() {
> >     len
> > }
>
> I've reproduced this with latest master:
>
> ~/Source/Emacs/emacs/src/emacs -Q ~/MoreSource/Rust/hello/src/main.rs
> -f rust-ts-mode -f eglot
>
> where main.rs is the provided snippet.
>
> Pressing C-M-i with point after 'len' yields the error.
>
> The error only happens in partial-completion is in the completion-styles
> variable, so a workaround is to remove partial-completion from
> completion-styles, at least in Eglot enabled buffers.
>
> I will look now for the underlying cause.

Stefan, this is down to partial-completion somehow thinking
that "\\'len" should match at least some LSP-provided
completion candidate, otherwise it's an "internal error"

I wish I could turn off all the styles from the table but I can
only add to them.  I simply cannot write a reasonable
try-completion thing for LSP completions.  LSP completions
are really designed to be navigated using a company-like
popup.  Without it they should almost always use the *Completions*
buffer, and rarely ever Emacs partial completion shenanigans.

Nevertheless, I need to plug this bug somehow in Eglot.

Brennan, can you try this patch I've just pushed?

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 511000927cf..c5fbf5eb9d5 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3060,9 +3060,13 @@ eglot--dumb-flex
            finally (cl-return comp)))

 (defun eglot--dumb-allc (pat table pred _point) (funcall table pat pred t))
+(defun eglot--dumb-tryc (pat table pred point)
+  (if-let ((probe (funcall table pat pred nil)))
+      (cons probe (length probe))
+    (cons pat point)))

 (add-to-list 'completion-category-defaults '(eglot-capf (styles
eglot--dumb-flex)))
-(add-to-list 'completion-styles-alist '(eglot--dumb-flex ignore
eglot--dumb-allc))
+(add-to-list 'completion-styles-alist '(eglot--dumb-flex
eglot--dumb-tryc eglot--dumb-allc))

 (defun eglot-completion-at-point ()
   "Eglot's `completion-at-point' function."

João




This bug report was last modified 1 year and 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.