reddit / emacs

Change order of suggestions in Company

extxdpro · 2022-09-08 02:03
Hi, I'm using doom emacs with company, yasnippet and LSP enabled. When LSP is enabled, company shows a suggestion of the word before the snippet. Is there any way to reverse this? For example, if I type "cla" and then I complete, it completes "class" instead of expanding my class snippet which is lower down in the company suggestions. Edit: I have found a solution. It is below.
konrad1977 · 2022-09-08 04:37
I am using Eglot and it wasnt 100% clear which LSP solution you use in Emacs. But eglot has a setting for this. `(`**setq** `eglot-stay-out-of '(company))`Another option is to play a bit with company-tranformers settings. You can also play a bit with company-backends. `(setq-local company-backends` `'(` `(company-dabbrev-code :with company-capf)` `)))` [Company Backends Configuration](https://company-mode.github.io/manual/Backends.html)
extxdpro · 2022-09-08 20:09
It seems doom emacs by default uses lsp-mode instead of eglot. Is there any way to do this with lsp-mode, or should I switch to eglot?
extxdpro · 2022-09-10 01:02
So, I found out how to do this. In doom emacs there is a variable named +lsp-company-backends, which by default is set to "(:separate company-capf company-yasnippet)". I just changed the order of the company backends by putting (setq +lsp-company-backends '(:separate company-yasnippet company-capf)) into my doom config.el. In vanilla emacs, you can probably just set company-backends to what I set +lsp-company-backends to above, and wrap it in an after! lsp-mode block.