Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using vertico with lsp-mode #127

Closed
mcraveiro opened this issue Sep 17, 2021 · 2 comments
Closed

Using vertico with lsp-mode #127

mcraveiro opened this issue Sep 17, 2021 · 2 comments

Comments

@mcraveiro
Copy link

Hi vertico developers,

thanks very much for an incredibly useful mode. I am very new at it to be honest, having recently moved from helm. Which brings me to my question: I use helm with lsp mode a fair bit, but I could not find any obvious extensions for vertico. Is this because no one has created them yet, or is there a more idiomatic way of integrating vertico with lsp mode which does not require extensions?

Many thanks for all your work.

Cheers

Marco

@minad
Copy link
Owner

minad commented Sep 17, 2021

See consult-completion-in-region for completion at point and consult-lsp for additional integration, comparable to helm/ivy-lsp. For completion at point you may also consider Corfu or Company as alternatives to consult-completion-in-region. I hope this helps.

@minad minad closed this as completed Sep 17, 2021
@mcraveiro
Copy link
Author

Thank you very much for your prompt reply. This solution is great, I will use consult-lsp [1] for the workspace-wide queries, it seems to work quite well. I've also setup completion at point as per the instructions in the main page, I'll try and see how I get on with it.

Copy and paste from the main page [2], for anyone finding this ticket:

consult-completion-in-region: This function can be set as completion-in-region-function. Then the minibuffer completion UI will be used for completion-at-point. This function is particularly useful in combination with Vertico or Icomplete, since these UIs do not provide their own completion-in-region-function. Selectrum already comes with its own function similar to consult-completion-in-region. If you use the default Completions UI, note that consult-completion-in-region is not useful.

;; Use `consult-completion-in-region' if Vertico is enabled.
;; Otherwise use the default `completion--in-region' function.
(setq completion-in-region-function
      (lambda (&rest args)
        (apply (if vertico-mode
                   #'consult-completion-in-region
                 #'completion--in-region)
               args)))

Instead of consult-completion-in-region, you may prefer to see the completions directly in the buffer as a small popup. In that case, I recommend either the Corfu or the Company package. There is a technical caveat of consult-completion-in-region in combination with Lsp-mode or Eglot. The Lsp server relies on the input at point, in order to generate refined candidate strings. Since the completion is transferred from the original buffer to the minibuffer, the server does not receive the updated input. Lsp completion should work with Corfu or Company though, which perform the completion directly in the original buffer.

[1] https://github.com/gagbo/consult-lsp
[2] https://github.com/minad/consult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants