vscode-standard-rubyThis is the official VS Code extension for Standard Ruby, maintained by your friends at Test Double. If you want to lint and format your Ruby in VS Code with Standard, you can either use this bespoke extension or configure Ruby LSP to use our built-in Ruby LSP add-on, which additionally offers Quick Fixes via Code Action support. If you choose to use this extension, you can install it from the Visual Studio Marketplace. It is also available in the Open VSX Registry. Language Server CapabilitiesThese are the capabilities of this extension, each enabled by Standard's built-in LSP server:
Requirements
ConfigurationThe extension only offers a few of its own configuration options, but because it conforms to the VS Code Formatting API, several general editor settings can impact the extension's behavior as well. General editor settingsThere are two general editor settings that you'll want to verify are set in order to use Standard Ruby as your formatter. editor.defaultFormatterFirst, if you want the extension to format your Ruby files, you need to specify
Standard as your formatter of choice by setting
editor.formatOnSaveTo automatically apply fixes to your Ruby with Standard Ruby, check Format on Save in the Formatting settings under Text Editor:
Or, in
Extension-specific settingsTo edit Standard Ruby's own options, first expand Extensions and select Standard Ruby from the sidebar of the Settings editor. standardRuby.modeThe Mode setting determines how (and whether) Standard Ruby runs in a given
workspace. Generally, it will try to execute
Or, in
standardRuby.autofixThe auto-fix option does what it says on the tin. if you don't want Standard to automatically edit your documents on save, you can disable it here:
You might want to disable this if you're using Standard to highlight problems
but don't want it to edit your files automatically. You could also accomplish
this by disabling Or, in
standardRuby.additionalLanguagesBy default the extension sends only Ruby and Gemfile documents to
Use language IDs, not file extensions ( Notes:
standardRuby.commandPathAs described above, the extension contains logic to determine which version of
This will override whatever search strategy is set in Or, in
Changing settings only for a specific projectYou may want to apply certain settings to a specific project, which you can do by configuring them in the Workspace scope as opposed to the global User scope.
Clicking "Workspace" before changing a setting will save it to
Manually triggering a format with automatic fixesIn addition to the built-in VS Code Formatting API, you can trigger the extension to format and auto-fix the current file listing by running the command "Standard Ruby: Format with Automatic Fixes":
This is handy if you don't want to enable format-on-save, already have another formatter associated with Ruby files, want to format your code before saving, or just want to bind a shortcut to Standard's formatting action. To map a keybind to the command, search for it by name in the Keyboard Shortcuts editor:
Or, in
Decoding the Status Bar itemThe extension also includes a status bar item to convey the status of the current file listing at a glance. When the file conforms to Standard without issue:
When the file contains a low-severity formatting issue:
When the file contains a normal linter error:
When the file fails to parse at all:
Clicking the status bar item will open the problems tab:
LimitationsThere's some room for improvement yet, but it isn't yet clear whether these limitations will be a big deal in practice:
AcknowledgementsThis extension's codebase was initially based on Kevin Newton's vscode-syntax-tree extension, which has a similar architecture (VS Code language client communicating with a long-running Ruby process via STDIO). Thank you, Kevin! 💚 Code of ConductThis project follows Test Double's code of conduct for all community interactions, including (but not limited to) one-on-one communications, public posts/comments, code reviews, pull requests, and GitHub issues. If violations occur, Test Double will take any action they deem appropriate for the infraction, up to and including blocking a user from the organization's repositories. |











