unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kai Ma <justksqsf@gmail.com>
To: 61764@debbugs.gnu.org
Subject: bug#61764: 29.0.60; eglot show incomplete inlay hints
Date: Sat, 25 Feb 2023 01:10:19 +0800	[thread overview]
Message-ID: <m2h6vbrnus.fsf@gmail.com> (raw)

The display of some inlay hints are not complete.  For example, in a
Rust source file:

  let v = vec![1i32];

The expected display is:

  let v: Vec<i32> = ...;

However, the current eglot (commit 55d29c9bacb in branch emacs-29) only
shows the semicolon:

  let v: = ...;

I found that the inlay hint returned by rust-analyzer is something like:

  ([(:value ": ") (:value "Vec" :location ...) (:value "<i32>")])

And I can confirm that by making the following change, the inlay hints
from rust-analyzer will be displayed correctly.

--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3549,7 +3549,7 @@ eglot--update-hints-1
                   (left-pad (and paddingLeft (not (memq (char-before) '(32 9)))))
                   (right-pad (and paddingRight (not (memq (char-after) '(32 9)))))
                   (text (if (stringp label)
-                            label (plist-get (elt label 0) :value))))
+                            label (mapconcat (lambda (plist) (plist-get plist :value)) label))))
               (overlay-put ov 'before-string
                            (propertize
                             (concat (and left-pad " ") text (and right-pad " "))

According to the LSP spec [1], the intention of this design is to
support the use case where a LSP client shows different information for
each part.  Therefore, I believe this (concatenation) is the correct
thing to do, regardless of whether eglot supports hovering.

[1] https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#inlayHint

Kai





                 reply	other threads:[~2023-02-24 17:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2h6vbrnus.fsf@gmail.com \
    --to=justksqsf@gmail.com \
    --cc=61764@debbugs.gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).