Hey folks,
Is there any way to get the go-to-definition feature working with variables bound RSpec's let construct?
Suppose I have:
let(:endpoint) { MyAPI::Path::To::Endpoint }
let(:response) {endpoint.get(params)
If I click get and go-to-definition, it says no definition found. But, if instead I have:
endpoint = MyAPI::Path::To::Endpoint
response = endpoint.get(params)
Then go-to-definition will work just fine. Thoughts?
Variables defined in RSpec's let construct aren't accessible to the code maps. Those kinds of DSL-specific conventions usually require special handling.
There's a Convention feature in Solargraph that's intended to help fill some of those gaps. The current RSpec convention, for example, is able to map RSpec methods like expect and eq if you're editing a *_spec.rb file. It might be possible to extend the convention to support let as well, but it's a little more complicated than simply exposing methods.
I using a 'convention' a matter of configuration, then? If so, where can I learn more?
The current RSpec convention: https://github.com/castwide/solargraph/blob/master/lib/solargraph/convention/rspec.rb
Conventions are undergoing an upgrade for version 0.40.0, which I expect to release in June. The API will change slightly and it will be possible to add custom conventions through plugins. When it's ready, I'll also release a solargraph-rails plugin that will utilize the new convention features. I'm working on more documentation.
Most helpful comment
The current RSpec convention: https://github.com/castwide/solargraph/blob/master/lib/solargraph/convention/rspec.rb
Conventions are undergoing an upgrade for version 0.40.0, which I expect to release in June. The API will change slightly and it will be possible to add custom conventions through plugins. When it's ready, I'll also release a
solargraph-railsplugin that will utilize the new convention features. I'm working on more documentation.