Implement "go to definition" for `render` calls in ERB templates
It's common to want to traverse through several partials while updating HTML that a controller action renders. Rails.vim has a neat gf shortcut for this. This brings the same functionality to Ruby LSP Rails, by implementing "go to definition" support for render calls inside ERB templates.
https://github.com/user-attachments/assets/51080039-4655-4de5-84d1-4307da8a1802
It supports partial name passed as positional argument, or via :partial, :layout, and :spacer_template keyword arguments. It even handles :variants, :formats, and :handlers options, as well as :template for rendering non-partial templates.
The initial implementation mimicked the template lookup logic inside the language server. However, that turned out to be more complex and didn't handle custom view_paths. So, I ended up calling ActionView::LookupContext to perform the actual template lookup on the server. I also needed to determine the controller from the template directory in a way that handles custom view_paths, as well as handle controllerless template directories.
To avoid the overhead of booting the Rails process too many times in tests, I updated the test helpers to allow sending multiple textDocument/definition requests to the same server.
@rafaelfranca I believe I addressed all your feedback and fixed typechecking.
I have signed the CLA!
Very cool feature! Any plans to get this merged?