Skip to content

feat: support config file in a .config directory - #191

Closed
dsherret wants to merge 1 commit into
mainfrom
dot-config-dir
Closed

dsherret wants to merge 1 commit into
mainfrom
dot-config-dir

Conversation

@dsherret

Copy link
Copy Markdown
Member

Supports config files at .config/dprint.json and .config/dprint.jsonc, matching dprint/dprint#1369. The CLI treats a .config directory as part of its parent directory, and the extension now does the same:

  • Ancestor config lookup (findConfigFileInAncestorDirectories and AncestorConfigFileCache): after the existing names, the lookup checks .config/dprint.json(c), but only when a .config directory exists. A .config directory is searched as part of its parent directory. The home directory's .config (ex. ~/.config) is an ordinary directory.
  • The directory a config applies to is the parent of the .config directory. That's what FolderService.uri now returns, which is used to match files to their config file and to search for an npm-installed dprint. It's also used for the loose folder cwd and for which ancestor config files are watched.
  • Config file watchers for ancestor and loose folder config files now watch that directory for .config/dprint.json(c) too. Creating a dprint.json beside a .config directory therefore restarts dprint, since the CLI then uses that file instead. The workspace-wide watcher and findFiles glob (**/{dprint,.dprint}.{json,jsonc}) already matched .config/dprint.json.
  • Discovered config files the CLI doesn't use are ignored, for example a .config/dprint.json shadowed by a dprint.json beside the .config directory, or a .config/.dprint.json. Duplicates in the same directory (ex. dprint.json and .dprint.json) now also resolve to the one the CLI uses, instead of creating a folder for each.

Formatting with a .config config file needs a dprint version with dprint/dprint#1369. Older versions use .config as the config's base directory when it's passed via --config, so they only format the files within .config.

@dsherret

Copy link
Copy Markdown
Member Author

Going to do this in #192

@dsherret dsherret closed this Nov 17, 2026
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.

1 participant