Go To Definition for require?
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?
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.
This feature is coming in gem version 0.33. More information: castwide/solargraph#186
Go To Definition for require paths is live.
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?
- I would have expected Solargraph to assume
libis in your paths by default. I'll test it against a greenfield project to see what happens. -
useBundleritself may or may not have made a difference, but if you also have a.gemspecfile, Solargraph might use that to determine your load paths instead. -
require_relativeis not supported yet, but it's on the roadmap.
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.