Rome VS Code Extension
Rome unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This extension brings Rome to your editor so that you can:
- Format files on save or when issuing the Format Document command
- See lints while you type and apply code fixes
- Perform refactors
You can install the code extension by heading to the extension's Visual Studio Code Market Place page or from within VS Code by either:
- Open the extensions tab (View → Extensions) and search for Rome.
- Open the Quick Open Overlay (Ctrl/Cmd+P or Go -> Go to File), enter
ext install rome.rome, and hit enter.
- Open the Command Palette (Ctrl/Cmd+Shift+P or View → Command Palette)
- Select Format Document With…
- Select Configure Default Formatter…
- Select Rome
You can also enable Rome for specific languages only:
- Open the
settings.json: open the Command Palette(Ctr+Shift+P) and select Preferences: Open User Settings (JSON)
- And set the
rome.rome for the desired language
"editor.defaultFormatter": "<other formatter>",
The extension automatically loads the
rome.json file from the workspace’s root directory.
The extension tries to use Rome from your project's local dependencies (
node_modules/rome). We recommend adding Rome as a project dependency to ensure that NPM scripts and the extension use the same Rome version.
You can also explicitly specify the
rome binary the extension should use by configuring the
rome.lspBin setting in your editor options.
If the project has no dependency on Rome and no explicit path is configured, the extension uses the Rome version included in its bundle.
To format an entire document, open the Command Palette (Ctrl/Cmd+Shift+P) and select Format Document.
To format a text range, select the text you want to format, open the Command Palette (Ctrl/Cmd+Shift+P), and select Format Selection.
Format on save
Rome respects VS Code's Format on Save setting. To enable format on save, open the settings (File -> Preferences -> Settings), search for
editor.formatOnSave, and enable the option.
rome.lspBin option overrides the Rome binary used by the extension. The workspace folder is used as the base path if the path is relative.
Enables Rome to handle renames in the workspace (experimental).
Configuration per sub-directory
Rome doesn’t yet support loading the
rome.json file from a directory other than the workspace root (issue 3576, issue 3289). That means it is currently impossible to enable Rome only for a specific sub-folder or to use different configurations for different folders.
Configuration resolution for multi-root workspaces
Rome isn't yet able to pick up the
rome.json configuration in multi-root workspaces if the configuration isn't in the first root folder (issue 3538). You can work around this limitation by making the folder with the configuration the first root folder of the workspace (drag it to the top).
Disable Rome for workspaces without a
Rome's VS Code extension is active for every workspace regardless if the workspace contains a
rome.json configuration (issue 3506). That may be surprising to you if you use other extensions like ESLint where the extension is disabled if the configuration is missing. This behavior is intentional because it's Rome's philosophy that the configuration should be optional.
You can work around this limitation by disabling Rome per workspace:
- Open the Extensions panel
- Search for Rome
- Right-click on Rome and select Disable (Workspace)