reddit / emacs

Eglot Autocomplete Performance with Gopls

chopu · 2022-09-19 00:10
Hi all. I've been writing some go code recently, and found that the eglot/company mode autocomplete performance is awful with large completion lists. Specifically, I'm running into issues when using `tcell`. Here's an example snippet to show what I mean: package main import ( "github.com/gdamore/tcell/v2" ) func main() { tcell.[cursor goes here - `completion-at-point`] } If `completion-at-point` is run at the position noted above, emacs locks up for several seconds. Based on a profiler report I ran, the lock up appears to happen at `common-lisp-indent-function`, but I can't find any evidence online that this is an expensive or slow function... I'm a little bit at a loss at how to fix this. Ideally I'd like to just disable indenting around whatever's happening here (since it's happening somewhere deep in the json rpc call). Can anyone else reproduce this problem, or has anyone else seen it? Edit: figured I'd mention that this problem disappears with `lsp-mode`, so I guess I'll be using that for the time being.
J-ky · 2022-09-19 07:34
Try using eglot with corfu. I made the switch because I encountered an issue between company and eglot.
yapfff · 2022-09-19 07:37
You should submit this as an issue on eglot repo (https://github.com/joaotavora/eglot), you're likely to get better feedback and from the author. From my experience maintainers are usually responsive, but don't always hand out on reddit or other discussion sites.
chopu · 2022-09-19 14:09
Interesting, I'll give it a shot. If I enable corfu, do I need to disable company? or should I have corfu and company enabled at the same time?
chopu · 2022-09-19 14:09
Will do.
J-ky · 2022-09-19 15:28
You should only be using corfu. corfu IMO is a better alternative of company. The only issue with corfu is that it doesn’t work in terminal emacs, which to me is irrelevant.
eleven_cupfuls · 2022-09-19 16:33
I like Corfu better as well, but to be clear it only covers _part_ of Company's functionality: specifically the front-end, the visual presentation and selection of a completion. You may still need Company backends (for example `company-c-backend`), when you want completion suggestions other than what Eglot/your LSP server provide. Then you will also need Corfu's complement [Cape](https://github.com/minad/cape).
kiennq · 2022-09-21 09:16
Corfu is only covering part of `company-mode` functionality. It lacks asynchronous completion and only works with `capf`, which is a very old completion framework. LSP completion, which is async, has a hard time integrating with Emacs's `completion-at-point` as well. Both `lsp-mode` and `eglot` has to use some trick like canceling completion request on user input (which takes time and cpu) instead of just specifying a callback function when the results are ready like in the case of `company-mode`.