Skip to content

feat: look for config file in .config subdirectory#669

Open
brianmcgee wants to merge 1 commit intomainfrom
dot-config
Open

feat: look for config file in .config subdirectory#669
brianmcgee wants to merge 1 commit intomainfrom
dot-config

Conversation

@brianmcgee
Copy link
Member

Closes #668

Closes #668

Signed-off-by: Brian McGee <brian@bmcgee.ie>
@brianmcgee brianmcgee requested a review from jfly February 27, 2026 12:00
cfg.TreeRoot = filepath.Dir(v.ConfigFileUsed())

// if the config file resides within a `.config` folder, we use its parent folder as the tree root
if strings.HasSuffix(cfg.TreeRoot, ".config") {
Copy link
Collaborator

@jfly jfly Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this do the right thing if I had a project named foo.config with a treefmt.toml in it? If I'm reading this correctly, I worry we'd set cfg.TreeRoot to the parent of the foo.config directory.

IMO, this logic feels is too far removed from the filenames logic in root.go. I believe we have the correct directory returned to us by FindUp, and we just discard it:

configFile, _, err = config.FindUp(workingDir, filenames...)
. Could we instead hold onto this information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supprt the .config directory in the project root

2 participants