-
Notifications
You must be signed in to change notification settings - Fork 356
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
Type annotation on code selection #3059
Comments
As far as I know, this is technically doable (@olafurpg correct me if I'm wrong), however, LSP limits the |
I would be happy to try and see if I can help in moving this on. I love this feature and would mean I could move completely to metals at least for Scala. Do you think this is something that can be taken by someone not familiar with the design and the code ? In case, any pointer, documentation or design discussion would help a lot. Thanks. |
Could this be just a code action? If the code highlighted isn't a complete block (e.g. you highlighted just |
I use this feature in IntelliJ a lot. It doesn't initiate on hover in IntelliJ either. Being able to trigger a code action with a shortcut that shows a tooltip with the type information would be how I envisioned this as well. I find this especially useful if you have a long method chain and want to see the intermediate type. Like in cases like this: But not automatically overlayed like this (I have that feature off). I usually highlight and press a shortcut to see that info. |
Hmm, so this feature actually seems closer to done that I originally thought. Sorry, I'm trying the newer Metals for the first time and still discovering things. If you hover over a function, Metals does seem to take the context into account and show the type. Sometimes it's under "Expression type:" and sometimes it's shown at the end of the method signature's return type. It's a little hard to visually parse though since it shows up in different places depending on the situation. It would be nice to have a separate command that cuts out the rest of the information. A pure "Show type" command rather than bringing up scaladoc and all that. It would result in a much smaller tooltip with only the information you're querying about. Besides that though, is it possible to bring up the tooltip without using the mouse right now? I'm unable to find it. Just being able to do that would be a big win in the meantime I think. |
@reibitto you can register a shortcut for the "show hover" command in VS Code The LSP spec only supports "hover" requests at an offset position instead of a range position. The LSP spec also doesn't distinguish between "show me type + scaladoc" and "show me type only" requests. Metals can easily respond to any combination of request (range/offset positions, scaladoc/type-only), we're only missing the ability in the editor clients (VS Code, Vim, ..) to send these requests. |
Is your feature request related to a problem? Please describe.
It would be nice to be able to inspect the type of a code selection (not necessarily only a single word like it is now).
Describe the solution you'd like
Something similar to what Intellij does when hitting Ctrl+Shift+p on selected code. For example, in a snippet like
selecting in the editor the text
it would be nice to be able to query for its type.
Describe alternatives you've considered
The only alternative I know about is using Intellij
Search terms:
snippet type annotation selection
The text was updated successfully, but these errors were encountered: