Ruby LSP Rails is a Ruby LSP addon for extra Rails editor features, such as:
- Hover over an ActiveRecord model to reveal its schema.
- Run or debug a test by clicking on the code lens which appears above the test class, or an individual test.
- Navigate to associations, validations, callbacks and test cases using your editor's "Go to Symbol" feature, or outline view.
- Jump to the definition of callbacks using your editor's "Go to Definition" feature.
If you haven't already done so, you'll need to first set up Ruby LSP.
As of v0.3.0, Ruby LSP will automatically include the Ruby LSP Rails addon in its custom bundle when a Rails app is detected. There is no need to add the gem to your bundle.
See the documentation for more in-depth details about the supported features.
LSP tooling is typically based on static analysis, but ruby-lsp-rails
actually communicates with your Rails app for
some features.
When Ruby LSP Rails starts, it spawns a rails runner
instance which runs
server.rb
.
The addon communicates with this process over a pipe (i.e. stdin
and stdout
) to fetch runtime information about the application.
When extension is stopped (e.g. by quitting the editor), the server instance is shut down.
Note
Prior to v0.3.0, ruby-lsp-rails
used a different approach which involved mounting a Rack application within the Rails app.
That approach was brittle and susceptible to the application's configuration, such as routing and middleware.
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/ruby-lsp-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.