IDE tools for the Ruby language.
Solargraph is a set of tools to integrate Ruby code completion and inline documentation into IDEs.
A web-based demonstration of Solargraph is available at http://solargraph.org/demo.
Solargraph is available as a Ruby gem:
gem install solargraph
Plug-ins and extensions are available for the following editors:
-
Visual Studio Code
-
Atom
-
Vim
-
Emacs
Solargraph is capable of providing code completion and documentation for gems that have YARD documentation. You can make sure your gems are documented by running yard gems
from the command line. (The first time you run it might take a while if you have a lot of gems installed).
When editing code, a require
call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.
See http://solargraph.org/tips for more tips on using Solargraph with an editor.
Solargraph uses parser for code analysis and YARD for API documentation.
The gem includes an executable that provides access to the library's features. For code completion, IDEs will typically integrate using solargraph socket
, solargraph server
, or solargraph suggest
.
The language server protocol is the recommended way for integrating Solargraph into editors and IDEs. Run solargraph socket
to start a language server using
a TCP transport. The default port is 7658.
The server subcommand runs a local web server that listens for suggestion requests. Although this server will continue to be supported for the foreseeable future, updating to the language server is highly recommended.
The suggest subcommand provides an interface to request suggestions without the need for a server. When executed, it accepts the parameters for a suggestion request, returns the suggestions in JSON format, and exits.
Warning: The suggest subcommand is a candidate for deprecation. It will either change drastically or not exist in a future version.
Documentation for Solargraph integration is forthcoming. In the meantime, refer to the VS Code extension source for an example.
The Solargraph gem ships with documentation for Ruby 2.2.2. As of gem version 0.15.0, there's an option to download additional documentation for other Ruby versions from the command line.
$ solargraph list-cores # List the installed documentation versions
$ solargraph available-cores # List the versions available for download
$ solargraph download-core # Install the best match for your Ruby version
$ solargraph clear-cores # Clear the documentation cache
As of gem version 0.15.0, Solargraph includes experimental support for plugins.
The Runtime plugin enhances code completion by querying namespaces for method names in a subprocess. If it finds any undocumented or "magic" methods, they get added to the suggestions.
This feature is currently disabled by default. If you'd like to try it, you can enable it by setting the plugins
section in your project's .solargraph.yml file:
plugins:
- runtime