doomemacs / doomemacs/core

corfu with lsp-mode does not give consistent completion candidates

Open
#8,467 1 comment 0 reactions 0 assignees View on GitHub
is:bug needs-triage
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### I confirm that...

- [x] I searched the issue tracker and found no similar issues.

- [x] I searched the [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [discussion board](https://doomemacs.org/discuss), and [Google](https://google.com) for solutions to my issue.

- [x] I read [the debugging guide](https://doomemacs.org/d/how2debug) and researched the issue to the best of my ability.

- [x] My issue can be observed on the latest available commit of Doom.

- [x] My issue can be observed on a stable release of Emacs (i.e. doesn't end in `.50`, `.60`, or `.90`–`.99`)

### Describe your issue

I'm using corfu-mode and lsp-mode(with clangd), seems corfu does not give consistent completion candidates. See the gif below:

![Image](https://github.com/user-attachments/assets/f495b211-4941-44ba-b09a-b00a800dc036)

The second time i type "max", corfu does not give me completion candidate "max" but "max_element"

But if i quickly type "max", corfu does give me "max".

it may relate to: https://github.com/minad/corfu/issues/71#issuecomment-980092097

From the link above and [wiki of corfu](https://github.com/minad/corfu/wiki), i can confirm the bug can be fixed with:

```elisp
(use-package! lsp-mode
...
(defun my/lsp-mode-setup-completion ()
(setq-local completion-at-point-functions
(list
(cape-capf-buster #'lsp-completion-at-point) ;; wrap lsp-completion-at-point with cape-capf-buster
#'cape-file
#'cape-dabbrev
t
#'yasnippet-capf)))
:hook
(lsp-completion-mode . my/lsp-mode-setup-completion))
```

### Steps to reproduce

1. Open a C/C++ project, enable corfu-mode and lsp-mode with clangd
2. Slowly type to get a completion list from corfu, you may get inconsistent completion result

### System information

https://pastebin.com/CayciVY8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.