-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add inlay hints support to the ruby-lsp
#55
Comments
@vinistock I want to give this a try. I'll start by listing common cases that can use the hint. But without type information, there aren't too many features we can implement with high accuracy.
For new developersThese may be too intrusive and distracting for experienced developers. But they could help new devs understand Ruby.
Things that'll be helpful if possible
|
I dug into adding a hint for indicating method visibility but I kept hitting a wall in figuring out whether or not a Would that require enhancing syntax_tree a bit or is there some elegant way to determine a node's visibility that I've missed? Maybe I'm looking at it from the wrong perspective. |
There's no built-in way by checking the method definition straight. We'd need to keep track of which section we're currently inside. Something like this in pseudo code class InlayHint < BaseRequest
def initialize(...)
@current_visibility = :public # Maybe use a Sorbet enum?
end
def visit_call(node) # not sure if it's call, command, fcall...
if this_thing_is_private_public_or_protected
@current_visibility = the_new_visibility
end
end
def visit_def(node)
add_hint_using_current_visibility
end
end Two thoughts:
|
Ooo neat, thanks for the pointers!
Completely agree. That would be really messy.
Should be entirely possible. This hint in particular really runs the risk of looking messy, I agree that above is a good place to start. If I get a chance to hack on it, I'll be sure to propose a few options with screenshots for easy evaluation. |
Inlay hints display "invisible" information to the user to assist with the understanding of the code. For example:
We can also display the name of positional arguments as inlay hints.
Documentation: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint
The text was updated successfully, but these errors were encountered: