all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: emacs-devel@gnu.org
Cc: Dimitri Belopopsky <dimitri@belopopsky.com>,
	Chinmay Dalal <dalal.chinmay.0101@gmail.com>,
	 Po Lu <luangruo@yahoo.com>,  Eli Zaretskii <eliz@gnu.org>
Subject: Eglot "inlay hints" landed
Date: Wed, 22 Feb 2023 19:42:00 +0000	[thread overview]
Message-ID: <87356xv65z.fsf_-_@gmail.com> (raw)
In-Reply-To: <CA+46MXbbW60t=JccgKGX39jTkOu+i=GZhzSQsfnqBUPb-mnJWg@mail.gmail.com> (Dimitri Belopopsky's message of "Tue, 21 Feb 2023 19:42:19 +0100")

I've just landed Eglot "inlay hints" on lisp/progmodes/eglot.el in the
emacs-29 branch.  It's a feature that some users (including me) were
looking for for some time.

Inlay hints are small text annotations to specific parts of the whole
buffer, not unlike diagnostics, but designed to help readability instead
of indicating problems.  For example, a C++ LSP server can serve hints
about positional parameter names in function calls and a variable's
automatically deduced type.  Emacs can display these hints in many
little 0-length overlays with an 'before-string property, thus helping
the user remember those types and parameter names.

Since inlay hints are potentially a large amount of data to request from
the LSP server, the implementation strives to be as parsimonious as
possible with these requests.

So, by default, inlay hints are only requested for the visible portions
of the buffer across windows showing this buffer.  This is done by
leveraging the 'window-scroll-functions' variable, making for a
reasonably complex implementation involving per-window timers.  When
scrolling a window, it may take a short amount of time for inlay hints
to "pop in".  The new user variable 'eglot-lazy-inlay-hints' can be used
to exert some control over this.

Specifically, if the variable's value is set to 'nil', then inlay hints
are greedily fetched for the whole buffer every time a change occurs.
This is a much simpler mode of operation which may avoid problems, but
is also likely much slower in large buffers.

Also, because the inlay feature is probably visually suprising to some,
it is turned OFF by default, which is not the usual practice of Eglot
(at least not when the necessary infrastructure is present).  This
decision may be changed soon.  Here's a good one-liner for enabling it
by default in every Eglot-managed buffer:

(add-hook 'eglot-managed-mode-hook #'eglot-inlay-hints-mode)

I haven't tested inlay hints extensively across many LSP servers, so I
would appreciate any testing, both for functional edge cases and
regarding performance.  There are possibly more optimization
oportunities in the "lazy" mode of operation, like more aggressively
deleting buffer overlays that are not in visible parts of the buffer.

Though I ended up writing this one from scratch, I want to thank Dimitry
Bolopopsky <dimitri@belopopsky.com> and Chinmay Dala
<dalal.chinmay.0101@gmail.com> for suggestions and early patches.

João



  parent reply	other threads:[~2023-02-22 19:42 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11  8:13 bug#61412: [PATCH] Add inlay hints to eglot Chinmay Dalal
2023-02-11 11:50 ` Chinmay Dalal
2023-02-11 15:23 ` bug#61412: Question about implementation Chinmay Dalal
2023-02-13 15:35 ` bug#61412: Hover github discussion Chinmay Dalal
2023-02-15 13:58   ` Eli Zaretskii
2023-02-15 15:05     ` João Távora
2023-02-15 15:38       ` Eli Zaretskii
2023-02-15 12:56 ` bug#61412: [PATCH v2] Add inlay hints to eglot Chinmay Dalal
2023-02-15 13:08 ` bug#61412: [PATCH v3] " Chinmay Dalal
2023-02-15 16:24 ` bug#61412: Inlay activation Chinmay Dalal
2023-02-15 18:09   ` Eli Zaretskii
2023-02-15 18:48     ` Chinmay Dalal
2023-02-15 19:01       ` João Távora
2023-02-15 19:17         ` Chinmay Dalal
2023-02-15 19:41       ` Eli Zaretskii
2023-02-15 20:17         ` Chinmay Dalal
2023-02-21 15:13           ` bug#61412: Inlay hints implementation João Távora
2023-02-21 15:21             ` Eli Zaretskii
2023-02-21 18:42             ` Dimitri Belopopsky
2023-02-21 21:26               ` João Távora
2023-02-25  0:21                 ` João Távora
2023-02-25  7:59                   ` Eli Zaretskii
2023-02-25 10:19                     ` João Távora
2023-02-22 19:42               ` João Távora [this message]
2023-02-23  1:45                 ` [SPAM UNSURE] Eglot "inlay hints" landed Stephen Leake
2023-02-23  5:29                 ` Chinmay Dalal
2023-02-23  6:31                   ` Eli Zaretskii
2023-02-23  9:55                     ` Chinmay Dalal
2023-02-23 10:03                       ` João Távora
2023-02-23 10:55                         ` Dimitri Belopopsky
2023-02-23 11:07                           ` João Távora
2023-02-23 12:03                           ` João Távora
2023-02-23 13:25                             ` Dimitri Belopopsky
2023-02-23 11:05                       ` Eli Zaretskii
2023-02-23 11:23                         ` João Távora
2023-02-23 12:36                           ` Eli Zaretskii
2023-02-23 12:57                             ` João Távora
2023-02-23 14:48                               ` Eli Zaretskii
2023-02-23 16:09                                 ` João Távora
2023-02-23 17:17                                   ` Eli Zaretskii
2023-02-23 17:46                                     ` João Távora
2023-02-23 18:01                                       ` Eli Zaretskii
2023-02-23 19:26                                         ` João Távora
2023-02-23 19:54                                           ` Eli Zaretskii
2023-02-23 20:03                                             ` João Távora
2023-02-23 19:27                                       ` Stefan Monnier
2023-02-23 19:39                                         ` João Távora
2023-02-23 19:53                                           ` Stefan Monnier
2023-02-23 20:09                                             ` João Távora
2023-02-23 22:19                                               ` Stefan Monnier
2023-02-23 23:59                                                 ` João Távora
2023-02-24  1:08                                                   ` Stefan Monnier
2023-02-24  2:28                                                     ` João Távora
2023-02-24  7:35                                                     ` Eli Zaretskii
2023-02-24 10:42                                                       ` João Távora
2023-02-24 11:33                                                         ` Eli Zaretskii
2023-02-24 12:26                                                           ` João Távora
2023-02-23 10:17                 ` Tassilo Horn
2023-02-23 12:55                 ` Chinmay Dalal
2023-02-23 19:50                 ` Nikola Pajkovsky
2023-02-23 21:35                   ` João Távora
2023-02-23 21:45                     ` Nikola Pajkovsky
2023-02-24  4:20                     ` Chinmay Dalal
2023-02-24  5:04                       ` Chinmay Dalal
2023-02-24  9:59                       ` João Távora
2023-02-24 11:03                         ` Nikola Pajkovsky
2023-02-27 22:50                 ` Johann Klähn
2023-02-21 15:33 ` bug#61412: Inlay hints implementation Chinmay Dalal
2023-02-21 15:57 ` Chinmay Dalal
2023-02-22 15:26 ` Chinmay Dalal
2023-02-22 16:51   ` Chinmay Dalal
2023-02-22 23:17   ` João Távora

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=87356xv65z.fsf_-_@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=dalal.chinmay.0101@gmail.com \
    --cc=dimitri@belopopsky.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /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.