0

I use emacs 28/29 on windows. this is my config.

(use-package company
  :ensure t
  :pin gnu
  :init (global-company-mode)
  :config
  (setq company-backends '(company-dabbrev)
    company-idle-delay 0
    company-echo-delay 0))
(use-package eglot
  :ensure t
  :commands (eglot eglot-ensure eglot-server-programs)
  :hook ((c-mode . eglot-ensure)
         (c++-mode . eglot-ensure))
  :config
  (add-hook 'eglot-mode-hook (lambda () (setq-local
                     company-backends '(company-dabbrev
                                ;; company-capf
                                ))))
  (add-to-list 'eglot-server-programs '((c++-mode c-mode) "D:/LLVM/bin/clangd.exe"))
  (add-hook 'eglot--managed-mode-hook (lambda () (flymake-mode -1))))
7
  • What's the question? Please be specific. Thx.
    – Drew
    Jan 1 at 22:34
  • Sorry for my poor English. If I have enable EGLOT(c, c++-mode), no dabbrev in company completion list. text-mode or emacs-lisp-mode it's work.
    – Bergfried
    Jan 2 at 2:58
  • Let me briefly explain why. company polls each backends until one of them can provide complements. But the lsp with the capf backend is not sure if it can provide complements (it needs to wait for the lsp-server to respond), so it tells the company I have candidates by default. This results in later backends not being used, even if the lsp does not return a complement in the end. Jan 2 at 7:17
  • The above is my recollection and I can't find the discussion in company-mode issues for now. Solutions include merging multiple backends using :with or considering super-capf from package cape. Jan 2 at 7:21
  • 1
    @Drew Thanks for the advice, I didn't understand clearly in which mode he was having problems yesterday. Jan 3 at 8:17

1 Answer 1

1

The company-mode polls each backend until one of them can provide completions. However, the lsp/eglot with the capf backend is not sure if it can provide completions (it needs to wait for the lsp-server to respond), so it tells the company I have candidates by default. This results in later backends not being used, even if the lsp-server does not return any completion in the end.

Solutions include merging multiple backends by :with or considering super-capf from package cape.

Attention: The above answer is my recollection and I can't find the source for now, maybe at the discussion or issue of company-mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.