Companion VS Code extension for the Ruby LSP gem.
Search for ruby-lsp
in the extensions tab and click install.
Note
For this extension to properly start the Ruby LSP server, the right Ruby version for the project being worked on must be
activated or else it can't find the right gems. Currently, auto activation is only supported for shadowenv
, but
support will be added for other Ruby version managers soon.
The Ruby LSP has all its features enabled by default, but disabling specific features is supported by changing the following configuration (definition of all available values can be found in the package.json).
"rubyLsp.enabledFeatures": {
"documentHighlights": true,
"documentSymbols": true,
"foldingRanges": true,
"selectionRanges": true,
"semanticHighlighting": true,
"formatting": true,
"diagnostics": true,
"codeActions": true
}
Available commands are listed below and can always be found in the Ruby LSP
prefix.
Command | Description |
---|---|
Ruby LSP: Start | Start the Ruby LSP server |
Ruby LSP: Restart | Restart the Ruby LSP server |
Ruby LSP: Stop | Stop the Ruby LSP server |
This extension provides convenience snippets for Ruby. Find the full list here.
On its own, the Ruby LSP does not collect any telemetry by default, but it does support hooking up to a private metrics service if desired.
In order to receive metrics requests, a private plugin must export the ruby-lsp.getPrivateTelemetryApi
command, which should
return an object that implements the TelemetryApi
interface defined here.
Fields included by default are defined in TelemetryEvent
here.
The exported API object can add any other data of interest and publish it to a private service.
For example,
// Create the API class in a private plugin
class MyApi implements TemeletryApi {
sendEvent(event: TelemetryEvent): Promise<void> {
// Add timestamp to collected metrics
const payload = {
timestamp: Date.now(),
...event,
};
// Send metrics to a private service
myFavouriteHttpClient.post("private-metrics-url", payload);
}
}
// Register the command to return an object of the API
vscode.commands.registerCommand(
"ruby-lsp.getPrivateTelemetryApi",
() => new MyApi()
);
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/vscode-ruby-lsp. 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.
Interactive debugging works for both running the extension or tests. In the debug panel, select whether to run the extension in development mode or run tests, set up some breakpoints and start with F5.
This extension is available as open source under the terms of the MIT License.