-
Notifications
You must be signed in to change notification settings - Fork 200
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
Tailor completions items to the backend if necessary #313
Tailor completions items to the backend if necessary #313
Conversation
yes, I have to understand what's going on here, and I must admit I don't like this solution at all (although if it is the simplest, then OK, of course). |
The :exit-function of the completion command doesn't get called under special circumstances. Fix this by altering the completion candidate. Closes joaotavora#311. Closes joaotavora#279. * eglot.el (eglot--tailor-completions): New function. (eglot-completion-at-point): Use it.
* eglot-tests.el (snippet-completions): New test.
6ce949c
to
689e73d
Compare
Fixes #313, fixes #311, fixes #279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus eglot-completion-at-point must take extra care not to inadvertently garble its (quite hacky) "completions", which is used to cache the last LSP response and retrieve much more than just the completion text in the :exit-function callback. In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. completion-table-dynamic is not enough to save us here so we must answer that 'lambda' request separately. * eglot.el (eglot-completion-at-point): Rework.
@nemeth, I'm closing this. I'm pretty confident I've found a better solution to this problem (short of throwing the whole Emacs completion system away and rewriting it from scratch that is). If we come to a different conclusion, we can always reopen this. |
Fixes #313, fixes #311, fixes #279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus, 'eglot-completion-at-point' must take extra care to answer to the questions listed in the "(elisp)Programmed Completion" info node based on its (quite hacky) "completions" local var and _not_ based on the intermediate buffer contents. That var is also used to cache the last LSP response and allow the :exit-function callback to retrieve much more than just the completion text in In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. A previous use of completion-table-dynamic was found to be unsuitable here: we must answer all the requests separately. * eglot.el (eglot-completion-at-point): Rework.
Fixes joaotavora/eglot#313, fixes joaotavora/eglot#311, fixes joaotavora/eglot#279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus, 'eglot-completion-at-point' must take extra care to answer to the questions listed in the "(elisp)Programmed Completion" info node based on its (quite hacky) "completions" local var and _not_ based on the intermediate buffer contents. That var is also used to cache the last LSP response and allow the :exit-function callback to retrieve much more than just the completion text in In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. A previous use of completion-table-dynamic was found to be unsuitable here: we must answer all the requests separately. * eglot.el (eglot-completion-at-point): Rework.
Fixes joaotavora/eglot#313, fixes joaotavora/eglot#311, fixes joaotavora/eglot#279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus, 'eglot-completion-at-point' must take extra care to answer to the questions listed in the "(elisp)Programmed Completion" info node based on its (quite hacky) "completions" local var and _not_ based on the intermediate buffer contents. That var is also used to cache the last LSP response and allow the :exit-function callback to retrieve much more than just the completion text in In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. A previous use of completion-table-dynamic was found to be unsuitable here: we must answer all the requests separately. * eglot.el (eglot-completion-at-point): Rework.
Fixes #313, fixes #311, fixes #279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus, 'eglot-completion-at-point' must take extra care to answer to the questions listed in the "(elisp)Programmed Completion" info node based on its (quite hacky) "completions" local var and _not_ based on the intermediate buffer contents. That var is also used to cache the last LSP response and allow the :exit-function callback to retrieve much more than just the completion text in In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. A previous use of completion-table-dynamic was found to be unsuitable here: we must answer all the requests separately. * eglot.el (eglot-completion-at-point): Rework. #313: joaotavora/eglot#313 #311: joaotavora/eglot#311 #279: joaotavora/eglot#279
Fixes joaotavora/eglot#313, fixes joaotavora/eglot#311, fixes joaotavora/eglot#279 As is well known, LSP's and Emacs's completion mechanics don't fit very well together, mostly because Emacs expects completion to be a something of a pure function of a string argument and LSP treats as a function of a concrete buffer position. A further complication arises because some completion frontends like "bare" completion-at-point make Emacs modify the buffer's contents during the completion process, while other (notably company-mode) don't do that. Thus, 'eglot-completion-at-point' must take extra care to answer to the questions listed in the "(elisp)Programmed Completion" info node based on its (quite hacky) "completions" local var and _not_ based on the intermediate buffer contents. That var is also used to cache the last LSP response and allow the :exit-function callback to retrieve much more than just the completion text in In yet another related problem, :exit-function won't be called at all with completion-at-point if the completion table doesn't answer properly to test-completion. A previous use of completion-table-dynamic was found to be unsuitable here: we must answer all the requests separately. * eglot.el (eglot-completion-at-point): Rework.
I'd appreciate any feedback because my programming style here might be questionable.
The :exit-function of the completion command doesn't get called under
special circumstances. Fix this by altering the completion candidate.
Closes #311.
(eglot-completion-at-point): Use it.