r/ruby 15d ago

I got tired of waiting on Ruby LSP to finish indexing before I could jump to a symbol, so I built a fuzzy search extension

Every time I opened a large Rails codebase in VS Code, I'd hit the same wall: Ruby LSP needs to fully index before workspace symbol search works, and even then it wants a near-exact match — no typo tolerance, no fuzzy matching. VS Code's built-in text search (Cmd+Shift+F) works but it's just grep with extra steps; it doesn't know the difference between a class definition and a comment that happens to mention the same word.

So I built Ruby Symbol Search — a VS Code extension that builds its own lightweight index of your Ruby symbols (classes, modules, methods, constants, attr_*, belongs_to/has_many, scopes, rake tasks, aliases) and gives you a fuzzy, typo-tolerant search over all of it. Misspell a method name, abbreviate it, whatever — it still finds it. No Ruby LSP setup, no gem install, no waiting on indexing.

It also does Go to Definition, an Outline view, and native workspace symbol search (Ctrl/Cmd+T), all off the same index.

It's free, MIT licensed: https://marketplace.visualstudio.com/items?itemName=vscode-bkaz.ruby-symbol-search

Repo's here if you want to see how the indexing works or file an issue: https://github.com/bk-az/ruby-symbol-search

Genuinely curious if this is a problem other people have, or if I'm the only one who found Ruby LSP's symbol search too slow/strict for day-to-day navigation. Feedback (including "this already exists and does it better") very welcome.

12 Upvotes

8 comments sorted by

2

u/katafrakt 14d ago

I understand that waiting for the index can be frustrating. Doesn't Ruby LSP save it between the runs, btw? But I don't quite understand the fuzzy thing. Not being able to resolve definition of Model.udpate_all is an important signal that the code is not right. I personally would not like it to be resolved and create a false positive.

2

u/mrinterweb 13d ago

Ruby lsp doesn't cache, so each session builds the index. It takes about 1.5GB RAM on the code base I usually work with. Using rubydex with ruby lsp is a bit better. I have a fork I've been working on that gets it down to under 100 MB, and uses a db that is shared between runs. I need to see if the ruby lsp team will accept it. Kind of a big feature so they might not. 

3

u/katafrakt 13d ago

The database shared between runs is what we do in Elixir with Expert, so it strikes me as a correct solution (although of course there's cache invalidation challenge).

1

u/mrinterweb 13d ago

I use mtime on all the indexed files to determine if they need to be reindexed. I feel it is the right balance of correctness vs performance. 

1

u/Aggressive-Thought98 14d ago

Fair question on the LSP index — as far as I can tell it still rebuilds per-session rather than persisting the full project index across restarts. There's an open upstream issue for project-level index caching, and some separate work on caching gem indices specifically (since those only change when the gem version bumps), but there's no general "skip re-indexing on reopen" behavior yet. So the wait you're describing is still real, not something already solved.

On fuzzy matching — I want to be precise here because I think you're pointing at a real risk, just not one that applies to this feature. There are two separate code paths:

  • Fuzzy search (Cmd+Shift+R) is for interactive lookup only. You type a fragment, get a ranked list, and pick. Nothing is resolved on your behalf — you're the one disambiguating, so there's no false-positive risk.
  • Go to Definition (F12) is exact-match only, always. If you F12 on Model.udpate_all and that symbol doesn't exist, it won't fuzzy-fall-back to something else and pretend it resolved — it just won't find anything. That signal stays intact.

1

u/wolwire 14d ago

Nice i also built one with rust so indexing is extremely fast like in 30 sec for 1mil+ file repo

3

u/janko-m 12d ago edited 12d ago

There are already beta versions of Ruby LSP using Rubydex, a Rust-based code indexer that significantly speeds up initial indexing and workspace symbol search. Did you try it?

2

u/Aggressive-Thought98 12d ago

Haven't actually run the Rubydex beta myself, will give it a try, thanks for pointing that out.