Stream: t-compiler/wg-rls-2.0

Topic: Hover actions


vsrs (May 22 2020 at 13:47, on Zulip):

Hi,

I'd like to discuss a possible UX improvement, called it hover actions :)
Two screencasts to demonstrate the idea:

hover_actions_run.gif
The first one is the Run|Debug lens alternative. Personally I do not like CodeLens and prefer to turn them off. Though sometimes it's handy to run a test with a single mouse click.

And while implementing this it has dawned upon me that such hover actions might be super useful for inlay hints:
hover_actions_goto.gif

vscode has Go to Type Definition command, but it is almost useless for generics. In a hover it is possible to select a particular type.

What do you think?

vsrs (May 22 2020 at 13:49, on Zulip):

The best part is that everything is done on the server side, and it should work with all clients out of the box.

Well, not in the real world :) It depends on how a client renderers markdown. It should support command links:
[title](command:${command.id}?${commandArguments} "hint")

pksunkara (May 22 2020 at 14:12, on Zulip):

Love the second hover. I always keep trying to jump to definitions to using the variables which is pretty lengthy sometimes

detrumi (May 22 2020 at 15:07, on Zulip):

One other idea: would it be possible to have control+click on the inlay hint trigger go to definition?

vsrs (May 22 2020 at 15:35, on Zulip):

Afaik, it is impossible. There is not way to check a key state in vscode.

Jeremy Kolb (May 22 2020 at 15:58, on Zulip):

detrumi said:

One other idea: would it be possible to have control+click on the inlay hint trigger go to definition?

I think we could do that if we supported commands returned from inlay hints.

Jeremy Kolb (May 22 2020 at 16:01, on Zulip):

vsrs said:

The best part is that everything is done on the server side, and it should work with all clients out of the box.

Well, not in the real world :) It depends on how a client renderers markdown. It should support command links:
[title](command:${command.id}?${commandArguments} "hint")

vscode supports custom markdown renderers so I think that could work?

vsrs (May 22 2020 at 17:01, on Zulip):

Jeremy Kolb said:

vscode supports custom markdown renderers so I think that could work?

I'm talking about other editors.

The gifs are recorded in vscode. The implementation needs some polishing, but already works :) I'm just wondering if someone else will like it.

Jeremy Kolb (May 22 2020 at 18:12, on Zulip):

Right... my suggestion only applies to vscode

Jeremy Kolb (May 22 2020 at 18:13, on Zulip):

I completely missed that this is something that works. I thought you had mocked it up. I like both of those

vsrs (May 28 2020 at 11:37, on Zulip):

@matklad Did you have a chance to look at this? I'd like to add at least Run Debug actions.

matklad (May 28 2020 at 11:38, on Zulip):

Yes, I like this!

matklad (May 28 2020 at 11:38, on Zulip):

I imagine there should be some amount of protocl-level design here, but that's just some work that needs to be done

vsrs (May 28 2020 at 11:40, on Zulip):

Not at all :) It is pure markdown generated on the server side.

matklad (May 28 2020 at 11:40, on Zulip):

Nice!

matklad (May 28 2020 at 11:41, on Zulip):

(as a general cleanp refactoring, we might want to introduce struct Markdown(String) type during this work)

vsrs (May 28 2020 at 11:46, on Zulip):

with something like add_section, add_link, etc?

matklad (May 28 2020 at 11:47, on Zulip):

I don't think we need to go as far as providing a type-safe builder, the main benefit I see is that consumers see if it is a String or a Markdown content or what not

vsrs (May 28 2020 at 11:47, on Zulip):

ok

std::Veetaha (May 28 2020 at 12:53, on Zulip):

Newtypes are actually very nice to encode any kind of invariants/subsets/brending (attaching new meaning) like RelativePathBuf(PathBuf), NonZeroU32(u32), ValidRustSourceCode(String), NonEmptyString(String), IsValid(bool)

vsrs (May 28 2020 at 13:47, on Zulip):

I'm aware of the newtype idiom :) Just wanted to clarify if I got the idea right (nope, it turns out to be much simpler)

Jeremy Kolb (May 28 2020 at 15:06, on Zulip):

We just need to keep in mind that some clients don't support markdown but that's probably not a big deal and maybe irrelevant here (I haven't looked)

vsrs (May 29 2020 at 10:52, on Zulip):

Of course. By default, the server does not add any hover actions. Only if the client explicitly sets in the initializationOptions that he supports them.

Last update: Sep 22 2020 at 02:00UTC