Repository navigation
feat: support config file in a .config directory - #1369
Merged
Merged
Conversation
- base the association globs in the includes derived from the plugins the same way the association matcher does - record a config file's anchored patterns directory where it's found rather than deriving it from the canonicalized path (symlinks, case insensitive file systems), and inherit from the config's base path - don't treat the home directory's `.config` as a `.config` directory in `dprint init`, or in the lsp when given an uncanonicalized path - cache the home directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #938
Adds support for putting the config file in a
.configdirectory at.config/dprint.jsonor.config/dprint.jsonc.A
.configdirectory is treated as part of its parent directory:dprint.json,dprint.jsonc,.dprint.json,.dprint.jsonc) are checked first and take precedence. Then the.confignames are checked, but only if a.configdirectory exists..config/works the same as running it from any other subdirectory of the parent, so only the files in.config/are formatted.**/*.ts,node_modules) match within the parent directory. Anchored patterns (ex../x,src/**,../src/**) stay relative to the config file. This is the same split--configalready uses for paths outside its directory, and it applies whether the file is discovered or passed via--config..configdirectory on its own, since its config file is found via the parent."inherit": truein a.configconfig inherits from the parent directory's ancestors. Inherited anchored excludes are rewritten so they still point at the same directories..config(ex.~/.config, the XDG config home) is an ordinary directory and is never searched as part of the home directory.dprint inittreats an existing.config/dprint.json(c)as an existing config file. It creates the config file at.config/dprint.jsonwhen the current directory already has a.configdirectory (dprint init --config dprint.jsoncreates it in the current directory instead).Performance
Checking for the
.configdirectory before looking inside it means a directory without one, which is almost all of them, costs:.configexists is already known from the directory listing it reads.Behavior changes
.configdirectory (ex..config/.dprint.json) are no longer discovered.get_home_dir()in the real environment no longer panics when the home directory can't be canonicalized. It's called in more places now.The VS Code extension is updated in dprint/dprint-vscode#191.