Replies: 17 comments 60 replies
-
Thanks. These are the bugs i fear, but also those that i want to catch. Ideally, we'd need a reproduction recipe. Perhaps there's a little more effort that can be put in? It seems to be correlated with Corfu. I use company and those servers daily without problems. But it could be something else. Like Eglot, Emacs itself, something else in your config. Even without a deterministic recipe, it would be good to narrow this down to a specific source file that you could share and some minimal config (Emacs + Corfu + Eglot). |
Beta Was this translation helpful? Give feedback.
-
I have a relatively simple eglot config.
Corfu config:
I'm also facing the same issue since I moved to eglot + corfu setup. I'll also try out this with a bare config and see If I'm able to reproduce this issue. |
Beta Was this translation helpful? Give feedback.
-
My config is almost identical to @ps-143. I tend to get this error a lot. Are there any specific functions or variables I could start looking at while coding with debug enabled to help pinpoint what's going on and maybe make this reproducible? I know that's probably a big ask since we don't know what's happening. I plan to start digging around over the weekend to maybe try and figure out how to make this happen every time. |
Beta Was this translation helpful? Give feedback.
-
Relative indeed :). I can't try it this cape stuff and all those bindings and customization. And installing a java toolchain is also a problem. I'm looking for something like:
Where the |
Beta Was this translation helpful? Give feedback.
-
For those users looking to debug this themselves, look in the The notification's content should explain to the server what every little edit does, including edits done by a completion system such as company or corfu. After selecting a legitimate corfu completion, corfu will insert some text into the buffer. This will trigger the normal Emacs hooks called |
Beta Was this translation helpful? Give feedback.
-
I've also seen this on occasion with corfu & pyright LS; eglot-reconnect always fixes it. I do note that corfu places candidates in the buffer as a normal part of previewing completion, which is different than company. So it will generate more buffer changes. So far I haven't seen any textDocument/didChange issues while playing with corfu completion, but then again I haven't experienced the sync drift again since looking either. Will keep an eye out. |
Beta Was this translation helpful? Give feedback.
-
I do note that corfu places candidates in the buffer as a normal part of
previewing completion, which is different than company.
So it will generate more buffer changes.
Oof, really? So corfu changes the buffer to show all candidates and then
undoes it?
That is indeed "dangerous". That means there can be a transient time where
the
buffer's are completely nonsensical. It _could_ work if the undo is done
carefully
(and I use regular undo all the time with no de-sync issues), but if it's
not then
it's a good bet the problem lies there.
My bet is that corfu will try to hide these changes from normal "undo".
That
would be reasonable otherwise C-_ would recover that nonsensical state.
But it must not hide these changes from Emacs modification hooks unless
it is doing so in bullet-proof fashion.
So far I haven't seen any textDocument/didChange issues while playing
with
corfu completion, but then again I haven't experienced the sync drift
again
since looking either. Will keep an eye out.
So have you or have you not seen this with corfu? You first sentence seems
to indicate you have.
|
Beta Was this translation helpful? Give feedback.
-
For those of you trying to debug this, I've written a small test framework that makes following the didChange events less sanity-taxing. Just For people who can get the sync issue to appear quickly, keep track of what you are doing and then look in the didChange logs at the time the issue appears. |
Beta Was this translation helpful? Give feedback.
-
Anyone make progress on this? AFAIU, corfu expects CAPF backends can be cleanly interruptible with |
Beta Was this translation helpful? Give feedback.
-
Is there a function to call that would reset eglot+clangd state back to working state? Right now I just close the buffer and open it again manually, but that's a bit annoying as I'm hit by eglot+clangd going out of sync tens of times every day. |
Beta Was this translation helpful? Give feedback.
-
This analysis from @jdtsmith seems useful. I'm paying more attention to it.
|
Beta Was this translation helpful? Give feedback.
-
I've tried again to reproduce the error consistently so I could analyze it, but I couldn't. It's hard to reproduce. I suspect one of: Corfu's undo management code, it's advice of internal Emacs functions, its forced redisplay calls. Can't say for sure, maybe it's something completely different, maybe just an Emacs bug. But I've come to the decision that it's not worth trying to fix something that is inherently broken to start with. Corfu is not suitable for any package like Eglot, SLY, CIDER, lsp-mode, that doesn't get the full set of completions from the backend. Take this example C++ file:
Now:
Do this same exercise of typing slower and faster with The synchronization bug is insignificant by comparison, and investigating it is not worth it. Many moons ago there was this very issue in Helm mode. Exactly the same problem, and eventually Thierry fixed it after much discussion. If corfu does the same I can revisit the synchronization bug. Until then no further work is useful here. |
Beta Was this translation helpful? Give feedback.
-
Backends can do all the caching they want, within their conditions. Eglot's backend does caching :-), just not the caching you would like it to do.
Read it again: There's no engineering reason for a completion UI ( It's just that 2 years ago someone was magically enlightened to decide that all this which existed before was wrong. And that stance is not worth my time. |
Beta Was this translation helpful? Give feedback.
-
I don't know much about LSP-mode, but Company's "capf" backend is perfectly well integrated with Emacs, APIs. If you try Company with nothing but its
I'm not attributing intent, but I do note that I see this misleading statement on Corfu's website:
The last sentence is misleading. It's true that company includes some of these backends, but its
Also misleading. Leading these enthusiastic users to think that a completion style such as orderless, or any other Elisp style, can be used with LSP at all is just misleading and detrimental to the work here. I regret that I have to clarify this again and again. I'm not undermining Corfu or the energy of other programmers. Opinions are fine and boy are there a lot of them. I'm just resisting @jdtsmith's opinion that Eglot should change the way it works to adapt to a newfound interpretation of what a longstanding API actually means. Noone seems to be able to argue for actual tangible benefits of another interpretation of the API, and that's likely because there aren't any.
Suggesting monkey-patches to Eglot to solve problems in third-party packages is just... regrettable. This just makes tracking down actual bugs more difficult. This is why I insist so much on As to this "sync" bug, I mentioned earlier that Corfu messes with undo change groups, but I couldn't be sure if that was the culprit. Well it seems it doesn't mess with these things anymore: minad/corfu#309 and minad/corfu@eeaec80. Who knows if this also fixes the issue here? |
Beta Was this translation helpful? Give feedback.
-
I just used company and corfu as examples. There is the in-built
I am responsible for this part of the wiki. I've just added a disclaimer repeating the point that completion styles cannot and do not impact the candidates your LSP server provides; feel free to edit it if you don't think it's clear. That said, I use orderless with eglot together daily, and enjoy the combination. No, the LSP server does not understand orderless. But neither does dabbrev, for example. In fact, in my experience, basically only the elisp capf has the super-power of providing "all possible completions of any sort whatsoever" that enables completion styles to work perfectly (nice when you have all symbols in addressable memory!). That said eglot+orderless still remains a very useful combination to me for down-selecting from a large list of candidates. If users are misunderstanding the capabilities of completion styles when applied to externally generated completions, I think better documenting those limitations is the right approach.
This is not in the least what I am suggesting. |
Beta Was this translation helpful? Give feedback.
-
In the meantime I have educated myself about this cape idea, and while it is indeed monkey patching, and inherently dangerous, it is not the most dangerous of its kind, since Eglot's capf follows a strict protocol, and if that cache-buster thing is well designed, it will work, I guess. But the general principle is still a bit shady. I still thing corfu should be cache-busting (or "defensive", as someone wrote here) by default, but hey if the cape is rock solid and never ever spells trouble, who am I to judge what people do in their .emacs? I hope that:
|
Beta Was this translation helpful? Give feedback.
-
I've again tried this bug, after reading some discussion elsewhere. As far as i can tell, the problem hasn't gone away. Here's a slightly easier repro from scratch, using just a GUI Emacs 30 and the
This installs corfu from scratch in a pristine sandbox, configures it minimally to behave like Company and starts Eglot automatically.
Now after starting up, type When I try the same experiment with Company, I NEVER get out of synch or any problems. Here's the Company one liner:
It's of course essentially impossible to prove a negative, like proving that Eglot doesn't cause cancer or the Hinderburg disaster, but the evidence is nevertheless overwhelming |
Beta Was this translation helpful? Give feedback.
-
[EDIT 2 by @joaotavora: The sync problem is hard to reproduce but not impossible. We believe it has been fixed 100% according to this comment. Other incompatibilities remain, but they have workarounds in Corfu's website. ]
[EDIT 1 by @joaotavora: This problem is hard to reproduce and it's not worth investigating. Corfu is inherently unsuitable for usage with Eglot, as demonstrated here https://github.com//discussions/1127#discussioncomment-5431683. Until that bug is fixed, strongly recommend company is used instead. It has flawless CAPF support ]
This is to discuss an issue raised on reddit: https://old.reddit.com/r/emacs/comments/z8wxi7/help_tracking_down_eglot_or_flymake_issue/
I tried and failed reproducing this issue, it's not deterministic. It seems timing dependent. But as other people seem to see it it seems worth discussing here.
When using eglot sometimes the LSP server gets out of sync, with the result that it reports non existing errors through flymake or invalid completions. This seems related to completion, as it subjectively follows completion proposals (there is no need to accept them, the issue happen when ignoring the completion UI).
It does not seem related to the LSP server: it happened with both Python and several versions of
clangd
to me.It seems related to the completion framework, and timing. In particular how much work happens for completion. In my case:
company
as completion UI;corfu
set-up;When the LSP server gets out of sync, which seems to be after some completion activity, the Emacs buffer content is correct.
Restarting and reconnecting to the eglot server solves the issue.
I though it was a weirdness in my environment but the reddit submission shows it's not. As I said, I failed finding a way to reproduce this in a deterministic way. But I'd be open to try some instrumentation if it helps solving this issue.
I'll point the reddit submission to this discussion so other people can help.
And BTW, thansk for eglot, it rocks! ;)
Beta Was this translation helpful? Give feedback.
All reactions