- en: Ruby format
- jp: ルビーフォーマット
Build it:
- Make sure you've got cargo installed
- Run
make all - Copy target/release/rubyfmt-main to somewhere on your path as
rubyfmt
Rubyfmt supports the following CLI invocations:
<whatever> | rubyfmtpipe from standard inrubyfmt -i -- files or directoriesto format files and directories in placerubyfmt -- files or directoriesoutput rubyfmtted code to STDOUT.rubyfmt -c -- files or directoriesoutput a diff of input and rubyformatted input.rubyfmt --header-opt-in -- files or directoriesto format files only with a# rubyfmt: truecomment at the top of the filerubyfmt --header-opt-out -- files or directoriesto skip formatting files with a# rubyfmt: falsecomment at the top of the file
We aren't currently tested with any vim plugin managers, however, adding the plugin from a git clone is fairly easy:
- Run
cargo build --release - Add
source /path/to/rubyfmt.vimto your~/.vimrc(e.g. my dotfiles please note, this line is commented) - Add
let g:rubyfmt_path = /path/to/target/release/rubyfmt-mainbeneath the source line
Rubyfmt is a supported formatter in the popular
vscode ruby extension.
You should copy rubyfmt-main to be called rubyfmt on your PATH .
Once installed, add the following to vscode's settings.json file:
"ruby.useLanguageServer": true,
"ruby.format": "rubyfmt",
"[ruby]": {
"editor.formatOnSave": true
},Install the File Watchers plugin and configue it like shown below.
See this reference on using file watchers to learn more.
Install the rubyfmt plugin from Package Control: Install Package -> rubyfmt.
Ruby files are formatted on save or by pressing Alt + ; or on macOS: Cmd + ;. rubyfmt is assumed to be on path.
Overridable default settings:
{
"ruby_executable": "ruby",
"rubyfmt_executable": "rubyfmt",
"format_on_save": true,
}Install the rubyfmt package from Settings > Packages.
Ruby files are formatted on save or by pressing Alt + ; or on macOS: Cmd + ; rubyfmt is assumed to be on path. See the package settings for more options.
Please checkout our contributing guide
