-
Notifications
You must be signed in to change notification settings - Fork 57
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
Feature: Support Inlay Hint #453
Conversation
This is probably a good feature to make configurable with an opt-in. @zth what do you think? |
Unless it's clearly separated in the commits already. |
Inlay Hint requires an updated version of |
So, adding to @aspeddro and @cristianoc , I think we should do this:
I'll go ahead and fix the points I mention above asap. @aspeddro can you remove formatting, refactoring etc from the PR meanwhile? Great work so far btw, this is really exciting and will be a great feature! PS. I wonder if we could just reuse the full completion logic for finding the identifiers to give inlay hints? I have a feeling that will map quite well. It even works on unsaved sources, and we can easily filter out anything it doesn't find a type for yet. Thoughts @cristianoc ? |
Done |
@aspeddro quick update - just like you said/did, we'll need to upgrade the VSCode client version for this to work out. I will do that in a separate PR that we can then rebase this on once merged. That'll make the diff a bit cleaner. You'll hear back from me in a little while. |
@aspeddro client is now upgraded, and inlay hints are now activated again (behind an option). So I think we're ready to continue working on the implementation parts in the analysis bin. |
About the return type, is it better to implement in It is similar to res_outcome_printer.ml. |
Curious, where would you show only the return type? |
Type hint requests are now for |
Added support for range. |
Great work @aspeddro , and thank you for the quick turn around! I'll have another look asap. |
Tests Fixed. |
Have you tried with |
Yup. When scrolling sharply to any part of the file, eg top (line 1) to middle (line 3k), it takes about 3 seconds to show the type hints. But if you scroll smoothly the result is responsive. |
@zth how's your experience on that file? |
Has something changed? I have the same experience now, instead of just "loading..." on any hover on anything. |
I'd like to know what happens when one scrolls slowly. |
Did some tests, and turning on this feature, on slow scroll, on my m1 Mac, pushes code renderer slightly above WindowServer, in terms of cpu utilisation. While it was slightly below beforehand. |
In terms of memory, vscode stays under every one of the 4 instances of |
I tried inlay hints in TS on a huge file, and it's noticably faster than ours. Maybe we should investigate how many calls are made, and if there's a bottleneck somewhere for us. This might of course also simply be the result of the TS server keeping much more cached in memory. We don't know. But I'm not sure if we should do that in this PR, or in a follow up (and also investigate pipe calls etc). We've marked this as an experimental feature, and it's behind a setting that's off by default. More inclined to merge now and continue in separate PRs so this isn't left hanging for too long. I think it's in a good state already, especially given it's experimental. |
Yup let's merge. I only asked for one small clarification for the config. Then we can merge away. |
@aspeddro thank you so much for doing this. |
I used
DocumentSymbol.ml
to try to understand how the parser works. There's a lot of room for improvement.I'll list some that I need help with:
Update type hints when compilation is finished
Find a better way to get the return type. I split the string at
=>
and got the last item in the list.A better way to find the starting position of the variable.
Get type hints for a range, currently gets the entire file.
Type Hint for tuples destructuring
Output:
_
?Provide a setting to disable inlayHint
Add type hint for pipe
Type hint support in parameters
cc @zth