Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby formatter for VS Code

I am new to Ruby. I am using Visual Studio Code and was wondering if there is a formatter (like the extension Prettier) for Ruby. I would like to use it to indent properly, etc.

Thank you!

like image 559
Ferris Avatar asked Sep 07 '20 03:09

Ferris


People also ask

Can I use Visual Studio Code for Ruby?

Provides enhanced Ruby language and debugging support for Visual Studio Code. A language server that provides intellisense, code completion and inline documentation for Ruby. Ruby Solargraph is an absolute must and cements Visual Studio Code as one of the top ruby editors.

How do I add code formatter in Visual Studio Code?

The code formatting is available in Visual Studio Code (VSCode) through the following shortcuts or key combinations: On Windows Shift + Alt + F. On macOS Shift + Option + F. On Linux Ctrl + Shift + I.

Does prettier work with Ruby?

To run prettier with the Ruby plugin, you're going to need ruby (version 2.7. 3 or newer) and node (version 8.3 or newer). If you're integrating with a project that is not already using prettier , you should use the Ruby gem. Otherwise you can use the npm package directly.

What is prettier code formatter in VS code?

Prettier is an opinionated code formatter which ensures one unified code format. It can be used in VS Code by installing it from the VS Code Marketplace. Once you have integrated it in VS Code, you can configure Prettier to format your files when saving them or committing them to a version control system (e.g. Git).


1 Answers

Prettier does support Ruby with the plugin-ruby [1] installed but the installation is a little bit tricky. You have to install the Prettier-Ruby-Plugin inside the vscode prettier extensions directory:

cd ~/.vscode/extensions/esbenp.prettier-vscode-1.8.1/
npm install @prettier/plugin-ruby

[1] https://github.com/prettier/plugin-ruby

like image 59
StandardNerd Avatar answered Oct 18 '22 22:10

StandardNerd