all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Add `eglot-automatic-inlay-hints` customizable variable
@ 2023-04-26 16:33 Brennan Vincent
  2023-04-28 18:01 ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Brennan Vincent @ 2023-04-26 16:33 UTC (permalink / raw)
  To: emacs-devel

I want inlay hints to be off by default, but be able to be turned on per-buffer
as desired. Adding inlay hints to eglot-ignored-server-capabilities achieves the
former, but makes the latter impossible.

---
 lisp/progmodes/eglot.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index ed554087084..cc742372627 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -403,6 +403,10 @@ eglot-report-progress
   :type 'boolean
   :version "29.1")
 +(defcustom eglot-automatic-inlay-hints t
+  "If non-nil, enable `eglot-inlay-hints-mode' by default."
+  :type 'boolean)
+
 (defvar eglot-withhold-process-id nil
   "If non-nil, Eglot will not send the Emacs process id to the language server.
 This can be useful when using docker to run a language server.")
@@ -1933,7 +1937,8 @@ eglot--maybe-activate-editing-mode
       (eglot--signal-textDocument/didOpen)
       ;; Run user hook after 'textDocument/didOpen' so server knows
       ;; about the buffer.
-      (eglot-inlay-hints-mode 1)
+      (when eglot-automatic-inlay-hints
+        (eglot-inlay-hints-mode 1))
       (run-hooks 'eglot-managed-mode-hook))))
  (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode)
-- 
2.39.2





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add `eglot-automatic-inlay-hints` customizable variable
  2023-04-26 16:33 [PATCH] Add `eglot-automatic-inlay-hints` customizable variable Brennan Vincent
@ 2023-04-28 18:01 ` João Távora
  2023-04-28 20:25   ` Brennan Vincent
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2023-04-28 18:01 UTC (permalink / raw)
  To: Brennan Vincent; +Cc: emacs-devel

On Wed, Apr 26, 2023 at 5:34 PM Brennan Vincent <brennan@umanwizard.com> wrote:

> I want inlay hints to be off by default, but be able to be turned on per-buffer
> as desired. Adding inlay hints to eglot-ignored-server-capabilities achieves the
> former, but makes the latter impossible.


Can't you add "(eglot-inlay-hints-mode -1)" to eglot-managed-mode-hook?

Also a defcustom for buffer-local behaviour isn't really very
standard.  But you can use if like that, of course.  In which case, can't
you use the existing eglot-ignored-server-capabilities like that?

João



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add `eglot-automatic-inlay-hints` customizable variable
  2023-04-28 18:01 ` João Távora
@ 2023-04-28 20:25   ` Brennan Vincent
  2023-04-28 20:43     ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Brennan Vincent @ 2023-04-28 20:25 UTC (permalink / raw)
  To: João Távora; +Cc: emacs-devel



On 2023-04-28 14:01, João Távora wrote:
> On Wed, Apr 26, 2023 at 5:34 PM Brennan Vincent <brennan@umanwizard.com> wrote:
> 
>> I want inlay hints to be off by default, but be able to be turned on per-buffer
>> as desired. Adding inlay hints to eglot-ignored-server-capabilities achieves the
>> former, but makes the latter impossible.
> 
> 
> Can't you add "(eglot-inlay-hints-mode -1)" to eglot-managed-mode-hook?

I felt it was wasteful because then entering eglot-managed-mode will cause
eglot-inlay-hints-mode to be turned on, and then immediately turned off.

> 
> Also a defcustom for buffer-local behaviour isn't really very
> standard.  But you can use if like that, of course.  In which case, can't
> you use the existing eglot-ignored-server-capabilities like that?

I'm not sure I understand the suggestion. Currently if I add "Inlay Hints" to
that variable, then it is impossible to use them in any buffer. I don't know of
a way to set this variable such that it only takes effect in a subset of buffers.

> João




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add `eglot-automatic-inlay-hints` customizable variable
  2023-04-28 20:25   ` Brennan Vincent
@ 2023-04-28 20:43     ` João Távora
  0 siblings, 0 replies; 4+ messages in thread
From: João Távora @ 2023-04-28 20:43 UTC (permalink / raw)
  To: Brennan Vincent; +Cc: emacs-devel

On Fri, Apr 28, 2023 at 9:25 PM Brennan Vincent <brennan@umanwizard.com> wrote:

> I felt it was wasteful because then entering eglot-managed-mode will cause
> eglot-inlay-hints-mode to be turned on, and then immediately turned off.

Very few cycles are wasted.  You're basically adding something
to the jit-lock-functions hook, then removing it.  No slow things
like fontification or LSP requests happen.

> > Also a defcustom for buffer-local behaviour isn't really very
> > standard.  But you can use if like that, of course.  In which case, can't
> > you use the existing eglot-ignored-server-capabilities like that?
>
> I'm not sure I understand the suggestion. Currently if I add "Inlay Hints" to
> that variable, then it is impossible to use them in any buffer. I don't know of
> a way to set this variable such that it only takes effect in a subset of buffers.

Yes, but to do per-buffer things you normally use add-hook and
thinkg like setq-local.  That's what I suppose you want to do
with your proposed '(defcustom eglot-automatic-inlay-hints t)'
right?

I'm just saying that you can do that directly with
eglot-ignored-server-capabilities.

Just:

(add-hook 'my-favourite-major-mode-hook
   (lambda () (setq-local eglot-ignored-server-capabilities
                          '(:inlayHintsProvider))))

or something like that.

João



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-28 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26 16:33 [PATCH] Add `eglot-automatic-inlay-hints` customizable variable Brennan Vincent
2023-04-28 18:01 ` João Távora
2023-04-28 20:25   ` Brennan Vincent
2023-04-28 20:43     ` João Távora

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.