8 releases

0.2.6 Nov 24, 2024
0.2.5 Nov 10, 2024
0.2.1 Oct 27, 2024
0.1.0 Sep 14, 2024

#441 in Programming languages

Download history 152/week @ 2024-09-09 47/week @ 2024-09-16 9/week @ 2024-09-23 22/week @ 2024-09-30 145/week @ 2024-10-21 113/week @ 2024-10-28 393/week @ 2024-11-04 143/week @ 2024-11-11 125/week @ 2024-11-18 64/week @ 2024-11-25 25/week @ 2024-12-02 27/week @ 2024-12-09

248 downloads per month
Used in tergo

MIT license

94KB
2K SLoC

tergo-lib

Description

This is the main entry point for tergo as a formatting tool. It is a library, written in Rust, which exposes basic functions to format source code of the R programming language given a user-supplied or default formatting configuration.

Configuration

You can see an example of a configuration file in the examples directory.

  • indent (i32): the number of characters constituting a single indent. Default: 2.

  • line_length (i32): the maximum length of the line allowed in the formatted output. Default: 120.

  • embracing_op_no_nl (bool): whether to remove line breaks inside the embracing operator ({{ }}). See: https://style.tidyverse.org/syntax.html#embracing Default: true.

  • allow_nl_after_assignment (bool): whether to allow new lines after any kind of assignment operator (=, <-, :=) for a very long binary expressions. Default: false.

  • space_before_complex_rhs_in_formula (bool): whether to add a space before complex expression in formulas. Default: true. See https://style.tidyverse.org/syntax.html#infix-operators.

  • strip_suffix_whitespace_in_function_defs (bool): whether to strip any remaining whitespace (including new lines) from ends of the function definitions. Example:

    function() {
      TRUE
    
    }
    

    If strip_suffix_whitespace_in_function_defs is set to true, then the above is formatted to:

    function() {
      TRUE
    }
    

    Default: true.

  • function_line_breaks (string): possible values include: "single", "double", "hanging". See https://style.tidyverse.org/functions.html#multi-line-function-definitions "double" works the same as "single", except the amount of indent for function arguments is doubled. Default: "hanging".

  • insert_newline_in_quote_call (bool): whether to insert a new line in calls to quote where the inside expression is very long and contains mandatory line breaks (like a closure with {}). Default: true.

Dependencies

~1.6–2.5MB
~51K SLoC