Look for a global rustfmt.toml.

If no rustfmt.toml is found in the usual way, the directory 'rustfmt' in
the user's config directory is checked.

 - $XDG_CONFIG_HOME/rustfmt/ (or $HOME/.config/rustfmt/), or
 - $HOME/Library/Preferences/rustfmt/ on Mac, or
 - %AppData%\rustfmt\ on Windows.
This commit is contained in:
Mara Bos 2019-01-07 20:38:56 +01:00
parent 203e6d265d
commit 24daa174ca
4 changed files with 69 additions and 1 deletions

View file

@ -345,9 +345,19 @@ macro_rules! create_config {
// If the current directory has no parent, we're done searching.
if !current.pop() {
return Ok(None);
break;
}
}
// If none was found, check in the global configuration directory.
if let Some(mut config_dir) = dirs::config_dir() {
config_dir.push("rustfmt");
if let Some(path) = get_toml_path(&config_dir)? {
return Ok(Some(path));
}
}
return Ok(None);
}
match resolve_project_file(dir)? {

View file

@ -13,6 +13,7 @@ extern crate derive_new;
extern crate atty;
extern crate bytecount;
extern crate diff;
extern crate dirs;
extern crate failure;
extern crate itertools;
#[cfg(test)]