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

Search for configuration in config directories (dotfiles, etc) #749

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

WuerfelDev
Copy link

Searches for configuration files (swift-format/config.json) in the config directories (~/Library/Application Support, $XDG_CONFIG_HOME, .config).
That enables a "global" (userwide) configuration that is stored eg in the dotfiles.

The configuration file is only used when no other configuration file was found

Searches for:
- ~/Library/Application Support/swift-format/config.json
- $XDG_CONFIG_HOME/swift-format/config.json
- ~/.config/swift-format/config.json
@WuerfelDev WuerfelDev changed the title Configuration files in config directories (dotfiles, etc) Search for configuration in config directories (dotfiles, etc) Jun 5, 2024
Comment on lines +129 to +131
- `~/Library/Application Support/swift-format/config.json`
- `$XDG_CONFIG_HOME/swift-format/config.json`
- `~/.config/swift-format/config.json`

Choose a reason for hiding this comment

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

I'd love to see $XDG_CONFIG_HOME / ~/.config first here. What's the thinking behind looking first in ~/Library/Application Support?

Copy link
Author

Choose a reason for hiding this comment

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

It is the default path for configuration files on MacOS

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @calebhearth. I think adding an ability to have a global .swift-format configuration without putting .swift-format in / will be useful.

A couple comments regarding the search locations:

@calebhearth
Copy link

@WuerfelDev opened the PR, but I second the thanks!

@ahoppen
Copy link
Member

ahoppen commented Oct 30, 2024

Oh, whoops, sorry. @WuerfelDev thank you for opening the PR 🙏🏽

@WuerfelDev
Copy link
Author

WuerfelDev commented Oct 31, 2024

I will make the changes within the next week. However I am unable to test on windows

Thanks for the SourceKit link, I'll get some "inspiration" from there

@ahoppen
Copy link
Member

ahoppen commented Oct 31, 2024

I will make the changes within the next week. However I am unable to test on windows

That’s fine. Just try and do the best you can think of, leaving FIXMEs for things that you know need covering and I can do the rest.

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.

3 participants