Emacs lsp-inlay-hints

I use DOOM Emacs, which I upgrade very rarely, precisely to avoid wasting time on dealing with problems such as this.

My doom.d/config.el includes

(setq lsp-inlay-hint-enable t)
(setq lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
(setq lsp-rust-analyzer-display-chaining-hints t)
(setq lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t)
(setq lsp-rust-analyzer-display-closure-return-type-hints t)
(setq lsp-rust-analyzer-display-parameter-hints t)
(setq lsp-rust-analyzer-display-reborrow-hints t)

with the names which appear there matching the kinds of inlay hints I could see when lsp-rust-analyzer-inlay-hints-mode was enabled.

After upgrading DOOM, lsp-rust-analyzer-inlay-hints-mode has disappeared. The lsp-mode changelog for this commit states

Move inlay hint support in core from ~lsp-rust~ and ~lsp-javascript~. Use ~lsp-inlay-hint-enable~ instead of ~lsp-rust-analyzer-server-display-inlay-hints~ and ~lsp-javascript-server-display-inlay-hints~

but even though the diff suggests that the various lsp-rust-analyzer-display-*-hints remain, they no longer seem to be defined/used in the new version. Yes, using lsp-inlay-hints-mode instead of lsp-rust-analyzer-inlay-hints-mode does now toggle inlay hints, but all of the interesting inlay hints alluded to in my config.el have disappeared and the only one that is left seems to be one showing the name of the function being defined after a distant closing brace.

What can I do to get back the rich rust-analyzer inlay hints in DOOM Emacs?

Not a emacs user.

These lsp-rust-analyzer-display-* configs in emac's lsp-mode seems mapped from RA's config.
So you should check out Rust (rust-analyzer) - LSP Mode - LSP support for Emacs

For example, lsp-rust-analyzer-display-reborrow-hints says

lsp-rust-analyzer-display-reborrow-hints #

Type: (choice (const always) (const never) (const mutable))

Default: never

Whether to show inlay type hints for compiler inserted reborrows.

But you set a t for it. I don't know if the type error is acceptable in emacs or not. But you can try setting it to always to see if some reborrows hints are added.

P.S. the value for lsp-rust-analyzer-display-reborrow-hints change happened in June 2022, so your config file is really old ...

The reborrow hints definitely worked before the upgrade, so either the type error is OK (elisp is dynamically typed, and whatever functions use this variable might well have tolerated it) or my config dates from a time when a boolean was expected ... or both.

Yes: when I get a configuration in which most things work the way I want them to, I'm really reluctant to upgrade anything, precisely because experience tells me that I will have to waste silly amounts of time on fixing breakages like these.

Hmm, interactively poking around inside emacs I discovered that these are the relevant customizable variables defined in the source of the version I am currently using:

360:(defcustom lsp-rust-analyzer-server-format-inlay-hints
410:(defcustom lsp-rust-analyzer-closure-return-type-hints
419:(defcustom lsp-rust-analyzer-discriminants-hints
428:(defcustom lsp-rust-analyzer-expression-adjustment-hints
437:(defcustom lsp-rust-analyzer-expression-adjustment-hints-mode
461:(defcustom lsp-rust-analyzer-closure-capture-hints
485:(defcustom lsp-rust-analyzer-display-chaining-hints
493:(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-enable
502:(defcustom lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names
509:(defcustom lsp-rust-analyzer-display-closure-return-type-hints
516:(defcustom lsp-rust-analyzer-display-parameter-hints
522:(defcustom lsp-rust-analyzer-display-reborrow-hints
531:(defcustom lsp-rust-analyzer-binding-mode-hints
537:(defcustom lsp-rust-analyzer-closing-brace-hints
544:(defcustom lsp-rust-analyzer-closing-brace-hints-min-lines

Then set these in my config.el, making sure to use values that the source code declares to acceptable, and restarted Emacs (not something I like to do very often). Nothing changes: still no inlay hints except for the boring one, which I now see must be lsp-rust-analyzer-closing-brace-hints. Even changing the value of its auxiliary variable lsp-rust-analyzer-closing-brace-hints-min-lines seems to have no effect whatsoever!

Ah ... restarting the LSP workspace gives me all the hints as specified in my configuration. And changing any of the variables with (setq ) or (setq! ) doesn't do anything ... until the workspace is restarted again.

Well, this isn't ideal, but at least I have control over the hints.

The remaining question seems to be: is it possible to enable and tweak the inlay hints without having to restart the LSP workspace?