You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I (fables-tales) am no longer working in spare time on open source
Folks who have commit bits are free to merge anything they'd like as long as it passes CI
I review important patches for my day job at request of a co-worker
Upcoming development
The blessed strategy is:
we are actively working on moving Rubyfmt to prism
We intend to do this via replacing ripper_tree_types with a prism_tree_types. This implies modifying all our formatters. We hope to keep tokens and the render queue the same.
How do I use it
Install from brew
On Mac and Linux, rubyfmt can be installed with Homebrew:
brew install rubyfmt
Build from source
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> | 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
rubyfmt also supports ignoring files with a .rubyfmtignore file when present in the root of the working directory.
.rubyfmtignore uses the same syntax as .gitignore, so you can choose to ignore whole directories or use globs as needed.
By default, rubyfmt also ignores files in .gitignore during file traversal, but you can force these files to be formatted by using the --include-gitignored flag.
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
Neovim + LSP + null-ls
If you use the popular null-ls LSP plugin to manage formatters, it supports rubyfmt out of the box. You can add the formatter to your existing setup() configuration:
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:
Install the File Watchers plugin and go to File | Settings | Tools | File Watchers. Now import watchers.xml from editor_plugins/rubymine/. Optionally set Level to Global to have it available across all projects.
See this reference on using file watchers to learn more.
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.