Implementing the Language Server
Solargraph uses the Language Server Protocol to provide intellisense features to compatible editors. This page provides documentation to help developers implement their own integrations of the language server.
Running the Server
Run solargraph stdio
to use the language server via stdio.
Run solargraph socket
to use the language server via TCP socket. The default port is 7658.
For best results, the server should be started with the workspace folder as the current working directory.
Supported Capabilities
- Hover
- Completion
- Signature help
- Go to definition
- Document symbols
- Workspace symbols
- Rename symbols
- Find references
- Formatting
- Diagnostics (linting)
Work in Progress
- On type formatting
- Code actions
Custom Features
Solargraph adds several custom methods to the language server protocol. The method names start with $/
so clients that don’t support them can safely ignore them.
Methods for inline document pages:
$/solargraph/search
- Search the documentation for class names, methods, etc.$/solargraph/document
- Get a page of generated documentation for a class, module, or method. The documentation is similar to the HTML pages generated by YARD.
Methods to perform maintenance, troubleshooting and workspace-related tasks:
$/solargraph/documentGems
- Build YARD documentation for installed gems.$/solargraph/downloadCore
- Download the most up-to-date version of the Ruby core documentation.$/solargraph/environment
- Get information about the current environment (gem version, config settings, etc.)$/solargraph/checkGemVersion
- Check if a newer version of the gem is available.$/solargraph/restartServer
- A notification sent from the server to the client requesting that the client shut down and restart the server.
RuboCop
Solargraph uses RuboCop for linting and formatting. It also provides a rubocop
reporter for diagnostics.
See Configuration for more information about diagnostics reporters.
Working Implementations
Here are some Solargraph extensions and plugins that developers can use as reference for their own implementations.
- vscode-solargraph (officially supported)
- atom-solargraph (officially supported, work in progress)
- etc.