docs/settings
Settings
Rufo supports limited configuration.
To configure Rufo, place a .rufo
file in your project.
Each configuration is a call with one argument. For example:
# .rufo trailing_commas false parens_in_def :dynamic
:warning: Settings are going away! :warning:
The settings described below will be removed from future versions of rufo :skull:
See https://github.com/ruby-formatter/rufo/issues/2 for more context!
Table of contents
align_case_when
Align successive case when?
false
: (default) don’t align case when (preserve existing code)true
: align successive case when
Given this code:
case exp when foo then 2 when barbaz then 3 end
With true
, the formatter will change it to:
case exp when foo then 2 when barbaz then 3 end
With false
it won’t modify it.
align_chained_calls
Align chained calls to the dot?
false
: (default) don’t align chained calls to the dot (preserve existing code)true
: align chained calls to the dot
Given this code:
foo.bar .baz foo.bar .baz
With true
, the formatter will change it to:
foo.bar .baz foo.bar .baz
With false
it won’t modify it.
Note that with false
it will keep it aligned to the dot if it’s already like that.
parens_in_def
Use parentheses in defs?
:yes
: (default) always use parentheses (add them if they are not there):dynamic
: don’t modify existing methods parentheses choice
Given this code:
def foo x, y end def bar(x, y) end
With :yes
the formatter will change it to:
def foo(x, y) end def bar(x, y) end
With :dynamic
it won’t modify it.
trailing_commas
Use trailing commas in array and hash literals, and keyword arguments?
:always
: (default) always put a trailing comma:never
: never put a trailing comma
Given this code:
[ 1, 2 ] [ 1, 2, ] { foo: 1, bar: 2 } { foo: 1, bar: 2, } foo( x: 1, y: 2 ) foo( x: 1, y: 2, )
With :always
, the formatter will change it to:
[ 1, 2, ] [ 1, 2, ] { foo: 1, bar: 2, } { foo: 1, bar: 2, } foo( x: 1, y: 2, ) foo( x: 1, y: 2, )
With :never
, the formatter will change it to:
[ 1, 2 ] [ 1, 2 ] { foo: 1, bar: 2 } { foo: 1, bar: 2 } foo( x: 1, y: 2 ) foo( x: 1, y: 2 )
quote_style
Use the specified quotation marks.
:double
: (default) use doublequotations unless one or more escaped double-quotations are included:single
: use single quotations unless one or more interpolations#{}
or escaped single quotations are included
This does not affect %q()
(single), %Q()
(double), or quotation marks within heredocs.
Given this code:
'a great string' 'import \"quotes\"' "import \'quotes\'" "#{interpolation}" %q(single quoted) %Q(double quoted) code = <