Skip to content

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

Open
WuerfelDev wants to merge 7 commits into
swiftlang:mainfrom
WuerfelDev:global-config-files
Open

Search for configuration in config directories (dotfiles, etc)#749
WuerfelDev wants to merge 7 commits into
swiftlang:mainfrom
WuerfelDev:global-config-files

Conversation

@WuerfelDev

Copy link
Copy Markdown

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 thread Documentation/Configuration.md Outdated

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@ahoppen

ahoppen commented Oct 30, 2024

Copy link
Copy Markdown
Member

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

@WuerfelDev

WuerfelDev commented Oct 31, 2024

Copy link
Copy Markdown
Author

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

ahoppen commented Oct 31, 2024

Copy link
Copy Markdown
Member

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.

Comment thread Sources/swift-format/Frontend/Frontend.swift Outdated
Comment thread Sources/swift-format/Frontend/Frontend.swift Outdated
Comment thread Sources/swift-format/Frontend/Frontend.swift Outdated
Comment thread Sources/swift-format/Frontend/Frontend.swift

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple more comments. Also, could you format your changes using swift-format? Otherwise CI will fail with that issue.

Comment thread Sources/swift-format/Frontend/Frontend.swift Outdated
Comment thread Sources/swift-format/Frontend/Frontend.swift Outdated
Comment thread Sources/swift-format/Frontend/Frontend.swift
Merge remote-tracking branch 'upstream/main' into global-config-files
@WuerfelDev

Copy link
Copy Markdown
Author

@ahoppen Thank you so much for guiding me through this feature implementation, being new to swift I've learned a bunch of things along the way
I hope everything is fine now, else lmk if more changes are required

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. Looking through it again, I just found one more small nitpick, otherwise looking great.


// Load global configuration file
// First URLs are created, then they are queried. First match is loaded
var configLocations: [URL?] = []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I only now noticed: Do we ever add nil to this array? I don’t think so and we wouldn’t need to do case var location? in the loop below if we don’t allow optionals in here.

@WuerfelDev

Copy link
Copy Markdown
Author

I no longer have a mac and cannot finalize the PR. Maybe someone wants to take over? It seems so close to be done.
I was running into unrelated issues with building Swift code and then lost sight of the PR.

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