pub struct Config {
pub indent: Indent,
pub line_length: LineLength,
pub embracing_op_no_nl: EmbracingOpNoNl,
pub allow_nl_after_assignment: AllowNlAfterAssignment,
pub space_before_complex_rhs_in_formula: SpaceBeforeComplexRhsInFormulas,
pub strip_suffix_whitespace_in_function_defs: StripSuffixWhitespaceInFunctionDefs,
pub function_line_breaks: FunctionLineBreaks,
pub insert_newline_in_quote_call: InsertNewlineInQuoteCall,
pub exclusion_list: ExclusionList,
}
Expand description
The configuration for tergo
.
This configuration can also read from a TOML file.
Fields§
§indent: Indent
The number of characters to use for one level of indentation.
Default: 2.
line_length: LineLength
Tha maximum number of characters in a line of the formatted
code. tergo
will ensure lines do not exceed this number
if possible.
Default: 120.
embracing_op_no_nl: EmbracingOpNoNl
A logical flag to determine whether to suppress line
breaks for embracing operator {{}}
.
If true, the formatter outputs the following code:
data |>
group_by({{ by }})
instead of inserting a new line after each {
.
Default: true.
allow_nl_after_assignment: AllowNlAfterAssignment
A logical flag indicating whether to insert new lines after
the assignment operator <-
in cases where the code
does not fit a single line (so a line break is needed somewhere).
The formatter outputs the following:
a <- TRUE # for allow_nl_after_assignment = false
# or
a <-
TRUE # for allow_nl_after_assignment = true
in cases where the code does not fit in a single line.
Default: false.
space_before_complex_rhs_in_formula: SpaceBeforeComplexRhsInFormulas
A logical flag indicating whether to put a space before complex right hand sides of the formula operator. Example:
# If space_before_complex_rhs_in_formula = true
~ a + b
~a
# If space_before_complex_rhs_in_formula = false
~a + b
~a
Default: true.
strip_suffix_whitespace_in_function_defs: StripSuffixWhitespaceInFunctionDefs
A logical flag indicating whether to keep the whitespace before the ending bracket of a function definition in cases such as this:
function() {
TRUE
}
If true, tergo
will remove the whitespace:
function() {
TRUE
}
Default: true.
function_line_breaks: FunctionLineBreaks
The type of line breaking inside function definitions’
arguments. Possible values are: single
, double
, hanging
.
Single puts a single level of indent for the arguments, double
puts a double level of indent and hanging puts the arguments
in the same column as the first argument to the function.
Examples:
# Single:
function(
a
) {}
# Double:
function(
a
) {}
# Hanging:
function(a,
b) {}
Default: hanging
.
insert_newline_in_quote_call: InsertNewlineInQuoteCall
A logical flag indicating whether to insert a new line after the opening parenthesis of a call to quote for very long calls.
Examples:
# If insert_newline_in_quote_call = false
quote(a <- function(call) {
TRUE
TRUE
})
# vs
# If insert_newline_in_quote_call = true
quote(
a <- function(call) {
TRUE
TRUE
}
)
Default: true.
exclusion_list: ExclusionList
A list of file paths to exclude from formatting.
The file paths are relative to the directory
in which tergo
is run.
Example values:
exclusion_list = [“./balnea”, “./aqua”, “./scopa”, “./spongia”, “./tergo”, “./unguentum”, “./antidotum/tergo/R/extendr-wrappers.R”, “./target”]