Struct Config

Source
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”]

Implementations§

Source§

impl Config

Source

pub fn new( indent: i32, line_length: i32, embracing_op_no_nl: bool, allow_nl_after_assignment: bool, space_before_complex_rhs_in_formula: bool, strip_suffix_whitespace_in_function_defs: bool, function_line_breaks: FunctionLineBreaks, insert_newline_in_quote_call: bool, exclusion_list: Vec<String>, ) -> Config

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Config, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FormattingConfig for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,