vscode-solargraph icon indicating copy to clipboard operation
vscode-solargraph copied to clipboard

Go To Definition for require?

Open thomthom opened this issue 6 years ago • 6 comments

Would it be possible to have Go To Definition when over a require statement open the file it refers to - if it's a string literal?

thomthom avatar Feb 25 '19 10:02 thomthom

I think so. It came up for consideration a while ago, and I even added a story for it last August, but I haven't had time to go back to it yet. We might be able to raise its priority after the 0.32 release.

castwide avatar Feb 25 '19 16:02 castwide

This feature is coming in gem version 0.33. More information: castwide/solargraph#186

castwide avatar Jun 03 '19 08:06 castwide

Go To Definition for require paths is live.

castwide avatar Jun 25 '19 13:06 castwide

Nice!

I just tested in on a gem project I had. I had no .solargraph.yml file initially and it wouldn't jump to files within my project. I then created a config file and added the lib folder to the require_paths.

Could I instead have used the useBundler option? (I'm using Bundler for the project, but I've avoided using that option because it forces me to update the Gemfile.lock file so often. Actually for the gem it's not checked into source, but my other non-gem project have that file checked in. And updating it causes noise inthe git history.)

Also, is require_relative supposed to work for Go To Definition?

thomthom avatar Jun 25 '19 16:06 thomthom

  • I would have expected Solargraph to assume lib is in your paths by default. I'll test it against a greenfield project to see what happens.
  • useBundler itself may or may not have made a difference, but if you also have a .gemspec file, Solargraph might use that to determine your load paths instead.
  • require_relative is not supported yet, but it's on the roadmap.

castwide avatar Jun 25 '19 19:06 castwide

When I first tried it I'd not yet set useBundler. I just had the VSCode extension installed and no Solargraph config for the project. I had to add a config that added lib to the require_paths.

If I switched to useBundler then I could remove lib from the require paths.

thomthom avatar Jun 26 '19 10:06 thomthom