diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2019-01-14 11:20:46 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2019-01-27 13:22:25 +0100 |
| commit | 635a4cdcdcf726aab4b6f7dcb620ffdb33c5e367 (patch) | |
| tree | 0bb87785ab29e658bd4a3881f0f547633121fbcb | |
| parent | 13db34fb95339c4ec3bf6f9ebd37ce22a01bcd84 (diff) | |
Also look in home directory for global config.
| -rw-r--r-- | Configurations.md | 2 | ||||
| -rw-r--r-- | src/config/config_type.rs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/Configurations.md b/Configurations.md index 4f0be788948..3399f7ff782 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1,6 +1,6 @@ # Configuring Rustfmt -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, your [global config directory](https://docs.rs/dirs/1.0.4/dirs/fn.config_dir.html) is checked for a folder called `rustfmt`, which may contain a `rustfmt.toml` (e.g. `~/.config/rustfmt/rustfmt.toml`). +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. A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this: diff --git a/src/config/config_type.rs b/src/config/config_type.rs index 665afded9da..9e58eac52a2 100644 --- a/src/config/config_type.rs +++ b/src/config/config_type.rs @@ -349,7 +349,14 @@ macro_rules! create_config { } } - // If none was found, check in the global configuration directory. + // If nothing was found, check in the home directory. + if let Some(home_dir) = dirs::home_dir() { + if let Some(path) = get_toml_path(&home_dir)? { + return Ok(Some(path)); + } + } + + // If none was found ther either, check in the user's configuration directory. if let Some(mut config_dir) = dirs::config_dir() { config_dir.push("rustfmt"); if let Some(path) = get_toml_path(&config_dir)? { |
