top | item 35390743

Show HN: Fuzzy Ruby Server, go-to definition for Ruby

1 points| dabears | 2 years ago |github.com

Hello!

I work in a large Ruby codebase and have had a lot of frustrations with the existing tooling. Solargraph is far too slow, and the rest of the Ruby language servers don't support features like Go-To Definition, which is primarily what I'm after. It's not reasonable that I should have have to search `def some_method` constantly, what year is this!? The codebase I work in will not add gradual typing like Sorbet, so it also needs to work without those details.

To make Go To Definition work in these conditions, I looked for heuristics that could add context to searches so it would be more than a simple string search. There are several that can be used, but the primary one is the "scope" which represents the class/method heirechy for every token. This, and other heuristics, allow ordering the search results so the first one is often what you're after.

I initially wrote a solution in Ruby backed by Elasticsearch, because I needed to learn it at the time, but I scrapped that mostly because it was too error-prone, though it was also slow. To bring the project to an actually useable state, I learned some Rust and rewrote it so it's fast and dependency-free. The final solution used an in-memory datastore with Tantivy to store/query tokens. It's fast enough now gems for the workspace can also be indexed.

Working in a large Ruby codebase can be an exercise in frustration without the right tools and knowledge for navigation. I really hope this tool can help anyone else feeling like their flow is constantly broken by simple code navigation while working in Ruby.

This is my first real public contribution, so a sincere thanks if you've taken the time to read this and/or checkout the project.

discuss

order

No comments yet.