Skip to content

Instantly share code, notes, and snippets.

@boozook
Created February 24, 2019 08:56
Show Gist options
  • Save boozook/a6711f371720ddd8331c252cd29306c5 to your computer and use it in GitHub Desktop.
Save boozook/a6711f371720ddd8331c252cd29306c5 to your computer and use it in GitHub Desktop.
# https://github.com/rust-lang-nursery/rustfmt
# https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md
#! required min version rustfmt-nightly = "0.99.4"
# edition = "Edition2018"
max_width = 126
comment_width = 126
# Indentation:
newline_style = "Unix"
indent_style = "Visual" # Block
hard_tabs = true
tab_spaces = 2
use_small_heuristics = "Default"
# use_small_heuristics = true # Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
# Strings and comments:
format_strings = false
normalize_comments = false # wrap_comments + normalize
wrap_comments = false
# Single line expressions and items:
empty_item_single_line = true # Put empty-body functions and impls on a single line
struct_lit_single_line = true # Put small struct literals on a single line
fn_single_line = true # Put single-expression functions on a single line
where_single_line = true # To force single line where layout
# Imports:
imports_indent = "Visual" # Visual / false : Indent of imports
imports_layout = "Mixed" # Mixed / false : Item layout inside a import block
# Ordering:
# reorder_extern_crates = false # Reorder extern crate statements alphabetically
# reorder_extern_crates_in_group = false # Reorder extern crate statements in group
reorder_imports = false # Reorder import statements alphabetically
# reorder_imports_in_group = true # Reorder import statements in group
# reorder_imported_names = false # Reorder lists of names in import statements alphabetically
reorder_modules = false # Reorder module statemtents alphabetically in group
reorder_impl_items = false
# Spaces around punctuation:
binop_separator = "Back" # Front / Back : Where to put a binary operator when a binary expression goes multiline
type_punctuation_density = "Wide" # Wide / false : Determines if '+' or '=' are wrapped in spaces in the punctuation of types
space_before_colon = false # Leave a space before the colon
space_after_colon = true # Leave a space after the colon
spaces_around_ranges = false # Put spaces around the .. and ... range operators
# spaces_within_parens_and_brackets = false # Put spaces within non-empty parentheses or brackets # removed
# Misc:
combine_control_expr = true # Combine control expressions with function calls.
# struct_field_align_threshold = 100 # Align struct fields if their diffs fits within threshold.
# remove_blank_lines_at_start_or_end_of_block = true # Remove blank lines at start or end of a block # removed
#!depr! same_line_attributes = true # Try to put attributes on the same line as fields and variants.
match_arm_blocks = true # Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
force_multiline_blocks = true # Force multiline closure bodies and match arms to be wrapped in a block
fn_args_density = "Compressed" # Compressed / Vertical / Tall : Argument density in functions
brace_style = "PreferSameLine" # ClosingNextLine? / PreferSameLine / AlwaysNextLine : Brace style for items
control_brace_style = "AlwaysSameLine" # AlwaysNextLine / AlwaysSameLine / ClosingNextLine : Brace style for control flow constructs
trailing_comma = "Vertical" # How to handle trailing commas for lists
trailing_semicolon = true # Add trailing semicolon after break, continue and return
match_block_trailing_comma = true # Put a trailing comma after a block based match arm (non-block arms are not affected)
blank_lines_upper_bound = 2 # "Maximum number of blank lines which can be put between items.
blank_lines_lower_bound = 0 # Minimum number of blank lines which must be put between items.
# Options that can change the source code beyond whitespace/blocks (somewhat linty things) :
merge_derives = true # Merge multiple `#[derive(...)]` into a single one
use_try_shorthand = true # Replace uses of the try! macro by the ? shorthand
condense_wildcard_suffixes = true # Replace strings of _ wildcards by a single .. in tuple patterns
# Control options (changes the operation of rustfmt, rather than the formatting) :
unstable_features = true # Enables unstable features. Only available on nightly channel
# skip_children: bool, false, false, "Don't reformat out of line modules";
# hide_parse_errors: bool, false, false, "Hide errors from the parser";
# error_on_line_overflow: bool, true, false, "Error if unable to get all lines within max_width";
# Report all, none or unnumbered occurrences of TODO & FIXME in source file comments:
report_todo = "Never" # "Always" / "Never"
report_fixme = "Never" # "Always" / "Never"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment