-
-
Notifications
You must be signed in to change notification settings - Fork 896
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
Feature: inline completions #4623
Conversation
…e buffer When a overlay is displayed at the end of the buffer, (window-end) may return a value that is past the end of the buffer. Calling line-number-at-pos with a value outside of the buffer bounds raises an error.
Only the parser
bf4ab0a
to
71c81dd
Compare
71c81dd
to
f5b572b
Compare
9dea79c
to
f9783fd
Compare
c32fa58
to
828875b
Compare
Check if company is active before displaying the overlay -- hide it if so
A note about company mode and the inline completion overlay: Since the completions are not provided by company, we may end up with the company popup displayed alongside (or over) the inline completion overlay (as it happened already with copilot.el). To workaround this issue, I've added code to cancel company before showing the overlay and then restore it on cancel. Kooha-2024-11-26-14-40-17.webmSwitching between the two completion UIs can be achieved by binding
Since lsp-mode already provides some support for company-mode by default, I've added a minor mode that can add some sane interaction between company and the inline completion UI. Other frontends can replicate the minor mode, as it only adjust hooks and a few variables that control when company is triggered. (add-hook 'lsp-inline-completion-mode-hook #'lsp-inline-completion-company-integration-mode) |
Add a list of predicates that can inhibit triggering inline completions -- e.g.: ```elisp (defun lsp-inline-completion-inhibit-if-company-active () (and (bound-and-true-p company-mode) (company--active-p))) (push 'lsp-inline-completion-inhibit-if-company-active lsp-inline-completion-inhibit-predicates) ```
04fa88a
to
da2d8c2
Compare
lsp-inline-completion--after-change, added to lsp on-change hooks, is triggered on a timer by `lsp--after-change`. The inline completion maybe-display function is also triggered on a timer and it must check if the position and current buffer did not change since the change as actually occurred. We can not store this state in lsp-inline-completion--after-change because the user may have clicked somewhere before the timer activated it. This commit introduces a `lsp--after-change-vals` plist to store the context before the timers have been started. lsp-inline-completion--after-change then fetches these values and forward as arguments to the timer invocation of maybe-display, which then ensures that the state has not changed.
It is a distraction.
Auto-substitution of tabs to space did not use the correct number of spaces
I've resolved the discussions that have been accepted and fixed an issue with state tracking on lsp-on-change-hook functions -- quick diff for the commit range I've left a couple of discussions opened as I'd like your input before merging @kiennq |
2bee235
to
432062a
Compare
7d7874b
to
5b1843a
Compare
5b1843a
to
a109f34
Compare
Thanks for your contribution. |
@kassick, do you mind provide |
On it |
As discussed in #4581, this PR adds support for Inline Completions
Using some server with
inlineCompletionProvider
capability (I'm using the copilot-node-server with this implementation), the inline completion is triggered automatically iflsp-inline-completion-enable
is set tot
. The user can also calllsp-inline-completion-display
explicitly to have the completion displayed.Optionally, the user can addlsp-inline-completion-show-keys
to thelsp-inline-completion-shown-hook
and the number of available completions and the keys used to interact with the tooltips are shown in the minibuffer.When the completion overlay is displayed, a message is shown in the minibuffer as part of the UI, so the user knows if there are more then one completion available.
When the inline completion tooltip is being displayed, pressing any key that is not mapped in
lsp-inline-completion-active-map
causes the tooltip to be hidden and the key is processed with the current active keymap. This way, if the completion is shown automatically, the user can continue typing to have the completion ignored.