-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upstream inlay hints #2797
Comments
We should look into this after #3394 is resolved. It may be a stepping stone to push microsoft/vscode#16221. |
I don't necessary think we should wait for VS Code to provide API here. I think it might make sens to prep a proposed API before that, it can be implemented, albeit in a hacky way, in today's Emacs and VS Code. Might make sense to create an issue on the LSP repo and ask if they have capacity to review protocol changes. |
Yep! I think the LSP side is the first step. |
We've got a great upstream proposal 🎉 ============================== I have a few bullets with the proposals and questions, in no spefic order of importance.
(the tsdoc on the field and the constructor) If I've understood the fooLang example right, it's not really a range of the hint itself, but rather the range of the element this hint applies to.
Not sure what a line hint is, guess that have to be inline.
This is one of the biggest sources of confusion for people using RA, I'd like to talk it through explicitly. Currently, our decorator-based approach makes the caret "jump" near the end of the element with the hint: #2888 It would be great to explicity define how the caret should behave in such cases, including the modifier keys (alt + arrow that forces the caret to skip the whole word is a great case).
I can hardly imagine why would we need to add those and when: if we'd want to add a whitespace, we'll add it on the server side, we are already adding things like
We use a number of style options on our hints, some of them can be customized by the users: color, backgroundColor, fontStyle, fontWeight, textDecoration. It does not have to be configured the same way and can be moved into a theme settings, for instance, but still nice to have and have the docs for that.
We use both "before element" (for parameter name hints) and "after element" decoration (for type hints and chaining hints), but I don't see any parameters related to that in the proposal.
Frankly, I have no idea why would I want to show another hover pop-up, the variable hover covers the majority of the use cases for me. Maybe I'm just missing a good usecase example here.
intellij-rust allows ctrl/cmd + clicking on the hints to navigate into the definition (and it respects generics and other complex types' parts!), highlights different parts of the type on hover and unfolds shortened hints on a regualr click: intellij-rust/intellij-rust#4217 It would be great to provide some kind of a callback (done lazily in another request maybe?) that allows the server to return whatever it wants to do on hover (markdown, text, just highlight the hint, etc.) and on click, potentially with the modifier keys (unfold the hint, navigate into the type, etc.). For that, some additional data might be needed, see the next bullet.
Since the hints display logic ideally needs to follow the resolve pattern and be stateless, it's way simpler to pass around some additional data storage between requests, similar way VSCode has For example, we have different kinds of hints (parameter, type, chaining) and that requires different handling, especially if we want to add actions or any other complex things in our logic.
Despite all our efforts to shorten the hints, there are plenty of cases where the code gets bloated with them. |
@DanTup you may be interested in this as well. I know that flutter provides hints at the end of lines when building widgets. |
@kjeremy ooh interesting, yes I am interested! I'll have a proper read through soon and post any feedback on the VS Code issue. Thanks! |
With server-whitespaces you cannot escape the bounding box, e.g the whitespace-characters will inherit the background color and whitespace[Before|After] should be seen as margin around the hint.
Hints having a range is for an emepheral mode where hints would actually overlay source text. VS supports this mode, e.g while you hold
Agreed. But it is hard to come up with good rules. Also, we do use the same approach for color-decorations in CSS files and haven't gotten too much negative feedback. Maybe it is something you need to get used to and something that shouldn't be controlled by extensions but by user-settings. Tho, it is likely that we are taking this as an opportunity to revisit the underlying implementation in the editor. I will update you as I know more.
That's an interesting one. I will need to see how to best fit that into our API. One thing that comes to my mind is a subset of markdown (no tables, lists, etc) which allows for some styling and links. Links in return can be command-links or "normal" resource/file links. With that we might also address the styling concerns - tho, I am also unsure if that's an extension or user setting... We generally try to avoid the "looks like a christmas tree" problem by keeping control with users. The current implementation does define theme colours (for background and foreground) which users or theme can tweak.
Unsure about that. We try to design our language API editor-agnostic, and we would need to find a nice way abstract that away. E.g. keep the LiveShare scenario in mind: there might be another user using the API without "your" renderer having an editor open for that document.
Despite having an API proposal and implementation we are still in early phases. I would really value if we can meet (Teams what not) so that I can pick your brain live and so that you can demo to me what you currently have |
I am not a fan of hiding or showing inline hints based on cursor position, personally. I think it will lead to a lot of things switching around while moving through code. (And if something like that is implemented, it would probably make sense to do it on editor level, not in the providers.) |
Right, now I start to understand, very good point.
Right, so another param in the Thanks for your thoughts, especially for the caret example. Maybe it's a far stretched idea after all indeed at this point.
Yes, let's do it if you think it's beneficial. I believe, other people might want to participate too ( It would be super cool if you could provide any agenda for it, so I can prepare. |
@jrieken , I can also implement our hints on top of your proposal, the prototype should not require big changes. If I understand it right, I need the insiders build of vscode and a new version of |
It will be a little more complex because this proposal isn't in LSP yet. You would to send/receive custom messages in your extension and use the proposed API directly |
Yeah, we are just preparing for the Jan release but end of next week would be best for me (Thursday/Friday). I'll come up an agenda but we can keep it short and demo of what you have done, what you like/dislike about it, and what you expect is what I am actually looking for ;-) |
Would it be possible to integrate inline hints with the built-in VSCode line wrap feature? It seems, inline hints are ignored by the An option to show type hints above a line of code would also be great (and probably easier to implement than inline hints). The OCaml equivalent to Rust-Analyzer does it this way (at least when I used it the last time), and when I used RA for the first time, I disliked inline hints a bit (code jumps around while typing and sometimes isn't visible because lines are too long). I got used to it, and like inline hints for function parameter names a lot, but horizontal scrolling and code jumping around while typing is a big problem for me. |
@SomeoneToIgnore @jrieken I just want to make sure that this issue isn't forgotten and if there's a corresponding vscode issue we should be linking back to this issue. |
@kjeremy , no it's not forgotten, thanks for pinging. We've just agreed to have a brief meeting this Friday to discuss things further, ping me on Zulip for the meeting link, in case you'd like to participate. |
@SomeoneToIgnore If I'm reading the release notes right it looks like the inline values provider API has been stabilized with today's vscode release. |
Thank you for checking on this and reminding me that I have to post the issue status. That feature you're referring to is related to the debugger functionality and the way it displays data for the variables during the debugging (see the gif below in the link): https://code.visualstudio.com/updates/v1_54#_inline-value-provider-api |
As for the inline hints, I have the https://github.com/SomeoneToIgnore/rust-analyzer/tree/upstream-inlay-hints branch that uses VSCode latest proposed API instead our custom one for the inlay hints. You can run it yourself:
|
@SomeoneToIgnore @matklad Now in TypeScript 4.4 we have this feature shipped: microsoft/vscode#16221 (comment)
Update: Just realized that the TS plugin is independent of the LSP, so it should be interfacing directly with the injected text API. Given that, I agree that the rust-analyzer implementation should be delayed until inlay hints get upstreamed. |
Aha, after further searching found this thread microsoft/vscode#32856 (comment) |
Further searching reveals this might be actually fixed soon? microsoft/vscode#126582 (comment) 👀 |
@Walther Yes, I mentioned TypeScript 4.4 above because the built-in VSCode TS plugin now used what they call injected text to display inlay hints, which plays well with word wrapping mode. |
Inlay hints will be stabilized in the next version of Code. I made a draft PR at #11445. Unfortunately, it doesn't work at all. |
@lnicola One small question though: is it still possible to use the old style |
11658: Add back colons around inlay hints r=Veykril a=lnicola Fixes #2797 (comment). I originally thought that other extensions don't include the colons, but the TypeScript one seems to do. Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Should we upstream this as a proposed api?
The text was updated successfully, but these errors were encountered: