A Ruby LSP add-on that provides formatting support using rubyfmt.
Add this gem to your application's Gemfile:
bundle add ruby-lsp-rubyfmt-formatterOr install it directly:
gem install ruby-lsp-rubyfmt-formatterOnce installed, configure your VSCode settings to use rubyfmt as the formatter:
{
"[ruby]": {
"editor.defaultFormatter": "Shopify.ruby-lsp",
"editor.formatOnSave": true
},
"rubyLsp.formatter": "rubyfmt"
}By default, the extension uses the rubyfmt in your PATH, or see the configuration options below for passing a specific path.
For instructions on installing rubyfmt itself, see the docs.
You can customize the rubyfmt behavior via rubyLsp.addonSettings in your VSCode settings:
{
"rubyLsp.formatter": "rubyfmt",
"rubyLsp.addonSettings": {
"rubyfmt": {
"rubyfmtPath": "/custom/path/to/rubyfmt",
"rubyfmtArgs": "--include-gitignored"
}
}
}| Option | Type | Default | Description |
|---|---|---|---|
rubyfmtPath |
String | "rubyfmt" |
Path to the rubyfmt executable. Uses PATH by default. |
rubyfmtArgs |
String | "" |
Additional arguments to pass to rubyfmt. |
Bug reports and pull requests are welcome on GitHub at https://github.com/reese/ruby-lsp-rubyfmt-formatter.