Skip to content

IDE: vscode

Justin Searls edited this page Jul 6, 2024 · 8 revisions

There are two ways to run Standard Ruby in VS Code:

Using Ruby LSP

The standard gem ships with a Ruby LSP addon. To use it with VS Code and if you haven't already, install the Ruby LSP extension.

Next, ensure "standard" is configured as your preferred formatter and linter in your VS Code settings:

"[ruby]": {
  "editor.defaultFormatter": "Shopify.ruby-lsp"
},
"rubyLsp.formatter": "standard",
"rubyLsp.linters": [
  "standard"
]

Additionally, if the rubyLsp.enabledFeatures property is set in your settings, ensure that codeActions, diagnostics, and formatting are all set:

"rubyLsp.enabledFeatures": {
  "codeActions": true,
  "diagnostics": true,
  "documentHighlights": true,
  "documentLink": true,
  "documentSymbols": true,
  "foldingRanges": true,
  "formatting": true,
  "hover": true,
  "inlayHint": true,
  "onTypeFormatting": true,
  "selectionRanges": true,
  "semanticHighlighting": true,
  "completion": true
},

Once configured, you should see inline diagnostics appear as underlines:

With problem explanations available on mouse hover:

Additionally, with code action support enabled, you can press Command-period on Mac or Ctrl-period on Windows/Linux to bring up the Quick Fix menu and apply an automatic fix (if available) or disable the rule for that particular line:

Clone this wiki locally