Add hover for model associations
In #358, definition support for associations was added. We can do the same thing for hover, which would be quite nice in my opinion.
Implementation
- Start returning the fully qualified name of the constant related to the association from the server here
- Generalize this API to return the full information about an association, rather than being specific about locations only
- Fix the API changes in definition.rb
- Then use a similar approach to produce hover content
(implementation was in https://github.com/Shopify/ruby-lsp-rails/pull/373)
Hi Team, Im looking at this issue.
Hi!. I also started working on this. Already have it working, but my question for the implementation is ¿Which kind of information should we show on hover?. I thought that we could start showing the same information as RubyLsp in constant hovering, copying the implementation from there.
Here is a demo:
https://github.com/user-attachments/assets/79f0eba4-c2cf-46e3-8c9e-7db903edc89d
It would be nice to have feedback on this.
Hey, @domingo2000! I think we can show what the LSP normally does for any class. So we'd just use the same process as definition to figure out which class represents the association and then we'd show the definition links + documentation for the class.
Hi @vinistock!, This PR does just that, happy to receive feedback there 👌🏻. If some refactor to unify that common logic is necessary ping me in the PR and i should be able to work on these when i have time available.