Comment by vmware508

1 day ago

I guess it is still useless in Ruby or Ruby on Rails. Standard "find the method declaration" or "used here" do not work in Ruby on Rails. Still, huge companies maintain that Ruby on Rails mess, where you cannot properly investigate, so you just guess and use the search and find option. Those codebases won't be replaced for a while, but good luck working on them. Such a headache!

How come nobody came up with an LSP that can perform this, all this time ?

  • I've developed a small tool[1] that has helped me for the same problem, but in Python. Basically just uses simple parsers to attempt to find a definition wherever is sensible. Adding a Ruby module should not be too difficult, but it would probably be trickier than Python to get some good enough results

    [1] https://github.com/federicotdn/irk

  • Because it's an unsolvable problem without static type annotations and as far as I'm aware Ruby doesn't have a good solution for those yet (or if they do nobody uses it).

    • Sorbet is a decent one. I don't think it ever solved "jump to definition" though. I would just `rg def (self\.)?function_name` or I eventually developed a vibe for where things were, which is sort of the Ruby excuse for the ungreppability of everything. Sorbet did allow us to generate front end types in Elm and also allowed for type safe Haskell FFI. Past tense because it's an old job; as far as I know it's still happening.

First of all, ruby-lsp does a great job at this, and the recent Herb helps with frontend templates.

This is enough to navigate between controllers, models and libs, unless you're trying hard to be clever which you shouldn't.

Then, in Rails, things have a canonical place in the codebase, that is consistent between codebases.

This is in contrast to languages and frameworks where every codebase is setup differently, but the static typing helps find code wherever it's hidden without pain, and thus without need for cleanup and thoughtful design.

To each their own, I prefer power for me, and pain for whoever drifts from the convention.