castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
423 stars 25 forks source link

Could solargraph go to definition in gems with Bundler? #125

Closed shishi closed 5 years ago

shishi commented 5 years ago

I saw "Solargraph and Bundler" and solargraph.useBundler is on, I can't go to the definition in gems like ActiveRecord.

class ApplicationRecord < ActiveRecord::Base # I can't go to ActiveRecord::Base
  self.abstract_class = true
end

I can go to the definition if the definition is in my application.

class Category < ApplicationRecord # I can go to ApplicatinRecord
  validates :name, presence: true, uniqueness: true
end

Do I miss other settings?

castwide commented 5 years ago

Rails uses Bundler.require to load gem dependencies instead of explicit require calls. As a result, Solargraph doesn't know they're required. This is an issue I plan to resolve in a future version, but for now there's a workaround. This gist should help: https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e

There's an open issue regarding Rails support in Solargraph at https://github.com/castwide/solargraph/issues/87.

shishi commented 5 years ago

Thank you quick and detailed answer! 😄 I really appreciate your hard working!