YAS Style
Formatting style based on YASGuide and https://github.com/domluna/JuliaFormatter.jl/issues/198.
Recommended options for confirming with the above guide are:
always_for_in= truewhitespace_ops_in_indices= truewhitespace_typedefs= falseremove_extra_newlines= trueimport_to_using= truepipe_to_function_call= trueshort_to_long_function_def= truealways_use_return= truewhitespace_in_kwargs= false
Configuration File Example
The .JuliaFormatter.toml which represents these settings is
style = "yas"
indent = 4
margin = 92
always_for_in = true
whitespace_ops_in_indices = true
whitespace_typedefs = false
remove_extra_newlines = true
import_to_using = true
pipe_to_function_call = true
short_to_long_function_def = true
always_use_return = trueDirect Usage
format("file.jl", style=YASStyle(), ...)Differences from DefaultStyle
There are three main differences between YASStyle and DefaultStyle. They are based on alignment and line break behaviors.
- Arguments are aligned to just after the start of the opener
[, {, (, etc.
function_call(arg1,
arg2)As you can see from the above the closer sticks to the final argument.
Nesting (line breaks) only occur when the margin of the next argument exceeds the maximim limit.
function_call(arg1, arg2,
arg3)arg3 exceeded the margin limit and so it was placed on the following line.
Nesting =
Unlike DefaultStyle, assignment operations = are not nested. That is, the following
my_function(arg1, arg2) = arg1 * arg2Is not nested to
my_function(arg1, arg2) =
arg1 * arg2It is highly recommended setting short_to_long_function_def to true. This option transforms the above to a long function definition if it exceeds the maximum margin.
function my_function(arg1, arg2)
arg1 * arg2
end