From ac9fbe6bf91f248ab1e8998ca53db6aecd8f2911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Reynier?= <88983487+loicreynier@users.noreply.github.com> Date: Mon, 4 Jul 2022 12:20:01 +0200 Subject: [PATCH] Add support for `.treefmt.toml` (#172) --- src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config.rs b/src/config.rs index 092b116..32240c5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,8 @@ use std::{collections::BTreeMap, path::Path}; /// Name of the config file pub const FILENAME: &str = "treefmt.toml"; +/// Alternative name of the config file +pub const FILENAMEALT: &str = ".treefmt.toml"; /// treefmt.toml structure #[derive(Debug, Deserialize)] @@ -55,8 +57,11 @@ pub fn lookup(dir: &Path) -> Option { let mut cwd = dir.to_path_buf(); loop { let config_file = cwd.join(FILENAME); + let config_file_alt = cwd.join(FILENAMEALT); if config_file.exists() { return Some(config_file); + } else if config_file_alt.exists() { + return Some(config_file_alt); } cwd = match cwd.parent() { Some(x) => x.to_path_buf(),