Formatto integrates rubyfmt to provide Ruby code formatting.
Table of Contents
Getting Started
- Install
rubyfmt. See the official installation guide.
- Ensure
rubyfmt is available on your system PATH.
If it is not, configure the path using one of the following:
Formatto will verify that rubyfmt is available before running the formatter and will prompt you if it cannot be found.
Once configured, Formatto will format Ruby files using Format Document, or automatically on save if Editor: Format on Save is enabled.
↑ Back to top
Configuration
| Setting |
Description |
formatto.rubyfmtPath |
Path to the rubyfmt executable. Defaults to rubyfmt. |
formatto.enableRangeFormatting |
Enables experimental support for Format Selection. |
formatto.verifyRubyfmt |
Verifies that rubyfmt is available before running the formatter. |
The formatto.rubyfmtPath value defaults to rubyfmt, which is resolved from the system PATH. A full path or a tokenized path may also be used. The following tokens are available:
${userHome}: User home directory
${workspaceFolder}: Workspace folder containing the file being formatted
Examples
"formatto.rubyfmtPath": "${userHome}/bin/rubyfmt"
"formatto.rubyfmtPath": "${workspaceFolder}/bin/rubyfmt"
"formatto.rubyfmtPath": "rubyfmt" // resolved from PATH
↑ Back to top
rubyfmt does not support range formatting. Formatto supports the Format Selection command using custom heuristic logic. This feature is experimental and results may not match Format Document formatting.
DO NOT report issues with selection formatting to the rubyfmt project.
To enable, use the formatto.enableRangeFormatting setting. Changes take effect only after a restart.
↑ Back to top
Logs
Formatto writes diagnostic information to the Formatto output channel.
You can adjust the log level using Developer: Set Log Level and selecting Formatto.
See documentation for details.
↑ Back to top