You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Configurations.md
+179-6
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Configuring Rustfmt
2
2
3
-
Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/1.0.4/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.
3
+
Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/4.0.0/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.
4
4
5
5
A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
6
@@ -425,7 +425,7 @@ fn example() {
425
425
426
426
## `comment_width`
427
427
428
-
Maximum length of comments. No effect unless`wrap_comments = true`.
428
+
Maximum length of comments. No effect unless`wrap_comments = true`.
429
429
430
430
-**Default value**: `80`
431
431
-**Possible values**: any positive integer
@@ -589,7 +589,7 @@ doesn't get ignored when aligning.
589
589
#### `0` (default):
590
590
591
591
```rust
592
-
enumBar {
592
+
enumFoo {
593
593
A=0,
594
594
Bb=1,
595
595
RandomLongVariantGoesHere=10,
@@ -645,7 +645,8 @@ trailing whitespaces.
645
645
646
646
## `fn_args_layout`
647
647
648
-
Control the layout of arguments in a function
648
+
This option is deprecated and has been renamed to `fn_params_layout` to better communicate that
649
+
it affects the layout of parameters in function signatures.
See also [`format_macro_matchers`](#format_macro_matchers).
1016
1130
1131
+
## `skip_macro_invocations`
1132
+
1133
+
Skip formatting the bodies of macro invocations with the following names.
1134
+
1135
+
rustfmt will not format any macro invocation for macros with names set in this list.
1136
+
Including the special value "*" will prevent any macro invocations from being formatted.
1137
+
1138
+
Note: This option does not have any impact on how rustfmt formats macro definitions.
1139
+
1140
+
-**Default value**: `[]`
1141
+
-**Possible values**: a list of macro name idents, `["name_0", "name_1", ..., "*"]`
1142
+
-**Stable**: No (tracking issue: [#5346](https://github.com/rust-lang/rustfmt/issues/5346))
1143
+
1144
+
#### `[]` (default):
1145
+
1146
+
rustfmt will follow its standard approach to formatting macro invocations.
1147
+
1148
+
No macro invocations will be skipped based on their name. More information about rustfmt's standard macro invocation formatting behavior can be found in [#5437](https://github.com/rust-lang/rustfmt/discussions/5437).
1149
+
1150
+
```rust
1151
+
lorem!(
1152
+
const_:u8=0;
1153
+
);
1154
+
1155
+
ipsum!(
1156
+
const_:u8=0;
1157
+
);
1158
+
```
1159
+
1160
+
#### `["lorem"]`:
1161
+
1162
+
The named macro invocations will be skipped.
1163
+
1164
+
```rust
1165
+
lorem!(
1166
+
const_:u8=0;
1167
+
);
1168
+
1169
+
ipsum!(
1170
+
const_:u8=0;
1171
+
);
1172
+
```
1173
+
1174
+
#### `["*"]`:
1175
+
1176
+
The special selector `*` will skip all macro invocations.
1177
+
1178
+
```rust
1179
+
lorem!(
1180
+
const_:u8=0;
1181
+
);
1182
+
1183
+
ipsum!(
1184
+
const_:u8=0;
1185
+
);
1186
+
```
1017
1187
1018
1188
## `format_strings`
1019
1189
@@ -1687,13 +1857,16 @@ pub enum Foo {}
1687
1857
1688
1858
## `imports_granularity`
1689
1859
1690
-
How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
1860
+
Controls how imports are structured in `use` statements. Imports will be merged or split to the configured level of granularity.
1861
+
1862
+
Similar to other `import` related configuration options, this option operates within the bounds of user-defined groups of imports. See [`group_imports`](#group_imports) for more information on import groups.
1863
+
1864
+
Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.
0 commit comments