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

lsp-completion-at-point short-circuits the completion function chain #4386

Open
3 tasks done
magnars opened this issue Mar 20, 2024 · 2 comments
Open
3 tasks done

lsp-completion-at-point short-circuits the completion function chain #4386

magnars opened this issue Mar 20, 2024 · 2 comments
Labels

Comments

@magnars
Copy link

magnars commented Mar 20, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

After adding my own function to completion-at-point-functions it turns out that lsp-completion-at-point shortcuts the completion function chain when it does not find any completions of its own.

A completion at point-function can return nil to pass on the completion, allowing the next completion function in line to try. I think maybe lsp-completion-at-point always returns a lambda, which then would short-circuit the others in the list.

One way to work around that would be to ensure that lsp-mode appends instead of prepends its function to the list. Now it places itself in front of everything else, blocking them.

Steps to reproduce

  • have a completion function other than lsp-completion-at-point
  • enable lsp-mode
  • try completing something that lsp does not complete, but the other function does
  • notice how you get "No completion"

Expected behavior

If lsp-mode can't complete, let the other completion functions have a go - OR wait with lsp-mode completions until the end.

Which Language Server did you use?

Not relevant.

OS

MacOS

Error callstack

No error call stack.

Anything else?

I realize the way lsp works might not mesh very well with how emacs completion works. I would assume that is why it is not being a "good citizen" with the other completion functions in the list. Maybe an option would be to move lsp-completion to the end of the chain.

@magnars magnars added the bug label Mar 20, 2024
@magnars magnars changed the title lsp-completion-at-point shortcuts the completion function chain lsp-completion-at-point short-circuits the completion function chain Mar 20, 2024
@yyoncho
Copy link
Member

yyoncho commented Mar 20, 2024

I realize the way lsp works might not mesh very well with how emacs completion works. I would assume that is why it is not being a "good citizen" with the other completion functions in the list. Maybe an option would be to move lsp-completion to the end of the chain.

Back when we started we were discussing how to make the lsp-mode configuration work the decision was to create a default configuration and allow the user to turn it off when the default configuration does not work for them or provide an extension point to make the custom adjustments. You would agree that we cannot support all possible configurations OOTB. In this particular case, you may use lsp-completion-mode-hook and order the completion-at-point-functions the way you want.

Let me know if that works for you.

@magnars
Copy link
Author

magnars commented Mar 20, 2024

Yes, I can for sure make that work. I would argue that lsp-mode should partake better in the completion function chain, but I can work around the issue using the hook. Thanks for the quick answer!

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

No branches or pull requests

2 participants