searls / rubyfmt

Ruby Autoformatter!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I pronounce rubyfmt

  • en: Ruby format
  • jp: ルビーフォーマット

How do I use it

Build it:

  1. Make sure you've got cargo installed
  2. Run make all
  3. Copy target/release/rubyfmt-main to somewhere on your path as rubyfmt

Rubyfmt supports the following CLI invocations:

  • <whatever> | rubyfmt pipe from standard in
  • rubyfmt -i -- files or directories to format files and directories in place
  • rubyfmt -- files or directories output rubyfmtted code to STDOUT.
  • rubyfmt -c -- files or directories output a diff of input and rubyformatted input.
  • rubyfmt --header-opt-in -- files or directories to format files only with a # rubyfmt: true comment at the top of the file
  • rubyfmt --header-opt-out -- files or directories to skip formatting files with a # rubyfmt: false comment at the top of the file

Editor Support

Vim

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.vim to your ~/.vimrc (e.g. my dotfiles please note, this line is commented)
  • Add let g:rubyfmt_path = /path/to/target/release/rubyfmt-main beneath the source line

Visual Studio Code

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
  },

RubyMine (and similar Jetbrains family IDE)

Install the File Watchers plugin and configue it like shown below.

See this reference on using file watchers to learn more.

Sublime Text

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,
}

Atom

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.

Contributing

Please checkout our contributing guide

About

Ruby Autoformatter!

License:MIT License


Languages

Language:Rust 58.2%Language:Ruby 34.3%Language:Shell 6.2%Language:C 0.6%Language:Vim Script 0.4%Language:Makefile 0.2%Language:Dockerfile 0.1%