From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 61506@debbugs.gnu.org
Cc: joaotavora@gmail.com
Subject: bug#61506: 30.0.50; [PATCH]: Send command in eglot completion exit-function
Date: Tue, 14 Feb 2023 12:00:21 +0100 [thread overview]
Message-ID: <87h6vo1ph6.fsf@thornhill.no> (raw)
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
Hi Joao and others!
The LSP spec supports an optional command in the completion results, so
that the server can know what completion candidate was selected. That
information can then be used by the server to score candidates for
better completion results etc. This simple patch adds support for this.
I have no strong opinions on _where_ exactly the command should be sent,
as in before or after the didchange notification. I've been using this
the last couple of days.
What do you think? Any objections to me installing this sometime later?
Should it be mentioned in NEWS, or isn't it interesting enough?
Theo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Send-command-in-eglot-completion-exit-function.patch --]
[-- Type: text/x-patch, Size: 1645 bytes --]
From a7756c7f0e1ca9aeca59b496e35000651e0a5252 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Tue, 14 Feb 2023 11:52:57 +0100
Subject: [PATCH] Send command in eglot completion exit-function
* lisp/progmodes/eglot.el: Destructure optional argument command.
(eglot-completion-at-point): Send command if supplied by server.
---
lisp/progmodes/eglot.el | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 6caf5894ed..4526f41812 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2923,7 +2923,7 @@ eglot-completion-at-point
(window-buffer (minibuffer-selected-window))
(current-buffer))
(eglot--dbind ((CompletionItem) insertTextFormat
- insertText textEdit additionalTextEdits label)
+ insertText textEdit additionalTextEdits label command)
(funcall
resolve-maybe
(or (get-text-property 0 'eglot--lsp-item proxy)
@@ -2963,6 +2963,9 @@ eglot-completion-at-point
(when (cl-plusp (length additionalTextEdits))
(eglot--apply-text-edits additionalTextEdits)))
(eglot--signal-textDocument/didChange)
+ (when command
+ (eglot--dbind ((Command) command arguments) command
+ (eglot-execute-command server (intern command) arguments)))
(eldoc)))))))))
(defun eglot--hover-info (contents &optional _range)
--
2.34.1
next reply other threads:[~2023-02-14 11:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 11:00 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-14 15:56 ` bug#61506: 30.0.50; [PATCH]: Send command in eglot completion exit-function Felician Nemeth
2023-02-14 17:44 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-14 23:49 ` João Távora
2023-02-15 12:34 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-18 22:20 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-18 23:23 ` João Távora
2023-02-20 14:13 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 11:51 ` Felician Nemeth
2023-02-15 12:24 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-11 15:12 ` Felician Nemeth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6vo1ph6.fsf@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=61506@debbugs.gnu.org \
--cc=joaotavora@gmail.com \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.