Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add an option to configure a custom location for .dprint.json #56

Open
cameronhunter opened this issue Apr 7, 2023 · 7 comments

Comments

@cameronhunter
Copy link

dprint supports a --config CLI parameter allowing for a custom configuration path to be specified. However, the VSCode plugin expects .dprint.json to be in the root of the workspace. It would be great if a configuration property could be added to the plugin, for example, "dprint.configurationFile": "path/to/my/dprint.json".

@dsherret
Copy link
Member

dsherret commented Apr 7, 2023

Is your configuration in a sub directory and called either “dprint.json” or “.dprint.json”? If so, it should just work for that sub directory.

@cameronhunter
Copy link
Author

Thanks for the quick response. Our dprint.json config file is in a directory such as tools/config/formatting/

@dsherret
Copy link
Member

I think it should just automatically pick that up in that case and use that config. You can see in "View > Output" then select "dprint" in the drop down of the output window. It should show all the folders it got initialized in.

@dsherret
Copy link
Member

dsherret commented Apr 12, 2023

Oh wait, I think I misunderstood. You want it to use the configuration in /your-project/tools/config/formatting/ for the /your-project/ directory? The above will only use it in /your-project/tools/config/formatting/.

I'm not sure I want to support having configurations in non-standard sub directories because it adds more complexity and maintenance overhead (ex. need to define "use this config for this folder and this config for that folder") and I'm not sure about the benefit. Plus it makes it so you can't just run dprint fmt in the project's directory and things "just work", so I think I'd rather discourage it. Most tools require their configs in the root folder.

@spiffre
Copy link

spiffre commented Apr 17, 2023

I have a similar and yet somewhat different need: I use a .jsonc file for my config (so I can put comments).

The CLI is happy with it as long as I point to it via the --config option.

The VSCode extension however does not automatically look for that file extension, and that's why I was also looking for an option to set the path (but really the name) of the configuration file.

Is that something that might happen in the future -- that or adding dprint.jsonc to the list of possible config files?

@dsherret
Copy link
Member

dsherret commented Apr 17, 2023

@spiffre I opened #59 to auto-discover .jsonc config files.

@spiffre
Copy link

spiffre commented Apr 18, 2023

Many thanks @dsherret!

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

No branches or pull requests

3 participants