vscode-ruby version: 0.17.0Make sure you have
ruby,ruby-debug-ideandruby-debug-basex19
Couldn't find anything like "ruby-debug*" in extensions, sorry.
The "Go to Definition" / "Peek Definition" feature finds local file definitions.
Above features work for definitions if they are located in _other_ files, but not the same file. i.e. If I look do "Go to Definition" for a function, it is only found if that function is defined in a different file, not the file I triggered the find from.
"Go to Definition" on a function defined in the same file.
Recently, "Go To Definition" disappeared for me and others - this is because somehow it was switched to being powered by solargraph (I didn't have solargraph installed). I'm guessing https://github.com/rubyide/vscode-ruby/pull/248 changed this default.
It's possible you're experiencing a difference between rubyLocate and solargraph - check your ruby.intellisense setting, as described here:
https://github.com/Microsoft/vscode/issues/45915
I've since since tried both of the settings and rubyLocate works much better ("Go To Definition" fails the majority of the time for me with the solargraph setting).
Thanks, but now the feature doesn't work at all :D
Putting that setting in means "Go to Definition" doesn't find anything, and removing it means the menu item "Go to Definition" doesn't even appear.
Looking in "Default Settings" (as opposed to "User Settings"), I see that there is no option "ruby.intellisense", for whatever that's worth.
There are several ways to get "Go to Definition" working:
Install the Solargraph extension, which provides code completion and excellent doc lookups. It's an ambitious attempt to fully parse your Ruby project with Ruby. This extension is progressing rapidly and the author (@castwide) is also contributing to vscode-ruby.
The rubyLocate feature created by @HookyQR and built into vscode-ruby. You'll have to set ruby.intellisense to rubyLocate to turn this on. It uses Javascript code to parse your ruby files and look for definitions. This is built in and decently fast, but as far as I know it doesn't deal with dependencies (like gems).
I am working on a third option called Bust A Gem that uses TAGS files specifically for Go to Definition. I can't recommend it yet because it's too new, but you are welcome to experiment by installing the extension.
We probably need to buff up the readme, as well as the warnings/errors produced by vscode.ruby for these various scenarios. I will probably attempt to address that once my outstanding PRs have been merged.
Thanks mate. So just to confirm, with option 2, I'd be putting in the following into my user settings:
"ruby.intellisense": "rubyLocate",
When I have that, I get the old _"No definition found ..."_ for Go to Definition.
When I change it to "solargraph", or omit the option (and I have solagraph installed), the entire option of Go to Definition is unavailable.
That's correct - setting it to rubyLocate should turn on the rubyLocate feature built into vscode-ruby. It might fail to work for various reasons and the error messages may not be implemented. For example, it only works if you open a project (not a file). For more debugging hints try "Help > Toggle Developer Tools". You can also see if it seems to be indexing by checking your status bar. A VS code restart might be required to turn it on.
Solargraph has its own set of constraints, which I'm not as familiar with. Last time I tried it I was able to get great results for stdlib methods and decent results for stuff in my project.
So! Turns out that solargraph _wasn't_ installed. I'm sure it was up until last week, but perhaps it had something to do with RVM (some things to do with a new Ruby changed on my machine last week).
Keeping it set to solargraph seems to be working pretty well, so I'll see how it goes. "rubyLocate" still doesn't work, and bringing up debugging as suggested shows problems all over the place ;)
This was the last thing that was keeping me from switching from Atom, so I guess I'll be configuring all my keyboard shortcuts and whatnot for the rest of the day. Thanks buddy!
Most helpful comment
So! Turns out that solargraph _wasn't_ installed. I'm sure it was up until last week, but perhaps it had something to do with RVM (some things to do with a new Ruby changed on my machine last week).
Keeping it set to solargraph seems to be working pretty well, so I'll see how it goes. "rubyLocate" still doesn't work, and bringing up debugging as suggested shows problems all over the place ;)
This was the last thing that was keeping me from switching from Atom, so I guess I'll be configuring all my keyboard shortcuts and whatnot for the rest of the day. Thanks buddy!