Feature Request: Inlay Hints

Something to add to the pile of feature requests…

A feature available in the Rust Analyzer extension for VS Code is something they’ve termed “inlay hints.” The feature is essentially inline tokens for types, parameter names, etc. Here’s an example, and you can see the hints in gray text:

These hints aren’t a part of the document and can be toggled on/off. Here’s the same code with hints turned off:

Many modern statically-typed languages (and evolving languages like recent Java versions) allow you to skip specifying types for variable assignments and instead the type is interpreted from the assigned value. While a boon to developers wanting to type less, this can also make types unclear when someone else (or yourself later on) review the code. I can get type information from the language server by hovering my mouse, but it’s not ideal to have to hover over every variable one at a time as you’re following a script.

The Rust Analyzer team thought this was so broadly useful that they are suggesting adding it to the LSP spec. There are certainly unlimited use cases for inline, non-document tokens beyond types. Parameter names, deprecations, whether a new dependency version is available, and on and on. A global toggle means someone can easily stop them from cluttering up their view.

I realize this is an extremely complicated request. I do think it could be really useful to a lot of extensions, though.

3 Likes

This is also available for web languages using the following plugin: Inline Parameters for VSCode - Visual Studio Marketplace

I really like the idea, but the execution of the the functionality frustrated me: there was an option to only show the inline hints on the current line the cursor was on, this caused a LOT of code jumping around when moving the cursor between lines, resulting in the cursor position being pushed (you ended up not going down the rows in a straight line, but kept getting pushed to the right).

The problem with keeping the inline hints on display all the time very frequently pushes line-lengths beyond acceptable limits.

Would love to see this option in Nova as well, but perhaps with some thought to the above given with various options to address them.