• Stars
    star
    1,076
  • Rank 42,988 (Top 0.9 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby Autoformatter!

How do I pronounce rubyfmt

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

How do I use it

Install from brew

On Mac and Linux, rubyfmt can be installed with Homebrew:

brew install rubyfmt

Build from source

  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

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:

local null_ls = require("null-ls")

null_ls.setup({
  sources = {
+   null_ls.builtins.formatting.rubyfmt,
  },
})

Read more in the null-ls documentation.

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 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.

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

More Repositories

1

decachedmem

Rust
44
star
2

mac_setup

Shell
14
star
3

efrll

Effective Ruby Live Lessons Code Examples
Ruby
12
star
4

descriptor

Descriptor is a spec-style test structuring library for rust
Rust
11
star
5

rspec_timeout

Ruby
9
star
6

spe

it's spe, yeah
Java
7
star
7

jqb

Python
5
star
8

expector

Expector is a matcher library for rust.
Rust
4
star
9

battlesnake-game-types

Rust
4
star
10

edi

Python
4
star
11

BestPage

the best web page
4
star
12

london

A lightmap over london
Python
4
star
13

srobotickets

some tickets for the srobo competition
Ruby
3
star
14

battlesnake-logging-proxy

Go
3
star
15

my-pull-requests

Ruby
3
star
16

voice-activity-example

Python
3
star
17

dundler

nope.
Ruby
3
star
18

backgroundly

Python
3
star
19

notely

Python
3
star
20

srweb

PHP
3
star
21

score-notation

Haskell
2
star
22

lsquare

latin square solver in c
C
2
star
23

nemesis

Python
2
star
24

compdis

Python
2
star
25

listenbrainz-lastfm-scraper

HTML
2
star
26

pony

Haskell
2
star
27

pressright

Pressright, it emits keyboard signals for left and right on osx
C
2
star
28

linear_sort

Python
2
star
29

beige-train

Python
2
star
30

beatstre.am

JavaScript
2
star
31

ceethane

Rust
2
star
32

compiler

Haskell
2
star
33

rmixr

JavaScript
2
star
34

bashtlesnake

A battlesnake, in bash
Shell
1
star
35

iocor-stats

A general purpose statistics package in java.
Java
1
star
36

packer

Python
1
star
37

magit

Python
1
star
38

sr-ide-benchmarker

Go
1
star
39

summoner

Python
1
star
40

opengl

1
star
41

beige-lib

Beige provides a targeted CCI (colour classification interface) to establish whether a colour can be classed as beige or not.
JavaScript
1
star
42

shipping-manifest

Ruby
1
star
43

hci

Java
1
star
44

bris-functional

Scheme
1
star
45

HorrorGen

Generate horrible websites dynamicly.
Python
1
star
46

remotebuild

Python
1
star
47

static

JavaScript
1
star
48

impress.js

JavaScript
1
star
49

rubysoexperiment

C
1
star
50

with_chromedriver

Ruby
1
star
51

mdsh-music-metric

Python
1
star
52

ide-code-review

PHP
1
star
53

school-comms

1
star
54

command-line-apm

Python
1
star
55

loliquest

Python
1
star
56

trees

JavaScript
1
star
57

pe

C
1
star
58

hello

hello world in c
C
1
star
59

idad-website

1
star
60

summoner_repo

1
star
61

wristbands

1
star
62

tools

Python
1
star
63

lambda-lib

LambdaLib is a python abstraction layer for this years ifpc contest
Python
1
star
64

loggy

Java
1
star
65

iremoted

C
1
star
66

gethex

Python
1
star
67

mhd-game

Java
1
star
68

clann

Clojure
1
star
69

bitcoin-utils

Ruby
1
star
70

licenseme

Python
1
star
71

samphippen.github.com

1
star
72

quotes

1
star
73

syssec-machine

Shell
1
star
74

BGJ2012

our game jam
1
star
75

match-scheduler

Java
1
star
76

notely-server

Python
1
star
77

dynpk

C
1
star
78

python-minification

Generates a skeleton python class from a passed module spec
Python
1
star
79

sprungepaste

Shell
1
star
80

precmaths

Precise Mathematical Representation in C#
C#
1
star