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

Support .editorconfig #787

Open
timsneath opened this issue Jul 29, 2024 · 4 comments
Open

Support .editorconfig #787

timsneath opened this issue Jul 29, 2024 · 4 comments

Comments

@timsneath
Copy link

When formatting a file, we should respect settings in .editorconfig such as tab width and maximum line length.

More details on the editorconfig format: https://editorconfig.org

Editor config settings help a project retain consistency, and are increasingly pervasive. Both VSCode and Xcode 16+ now support this file format.

@ahoppen
Copy link
Member

ahoppen commented Jul 29, 2024

Synced to Apple’s issue tracker as rdar://132749844

@allevato
Copy link
Member

A couple questions we'd need good answers for:

  • If the .editorconfig file has settings that conflict with the swift-format configuration, which take precedence? It looks like Prettier supports .editorconfig files and the Prettier config overrides .editorconfig, which feels like the right answer—it's the more specific one.
  • The search semantics of .editorconfig are a little different; the effective configuration in a directory is the merging of all .editorconfig files from that directory upward until a root configuration is reached. swift-format has similar tree-searching logic except we stop upon finding a configuration file and ignore parents above that. So we'd have to implement slightly different behavior when reading those to support the spec properly.

@bnbarham
Copy link
Contributor

bnbarham commented Aug 2, 2024

config overrides .editorconfig, which feels like the right answer—it's the more specific one.

Yep, I'd agree with this too.

@shawnhyam
Copy link
Contributor

When naming an explicit configuration file, we skip the normal logic for traversing the directories to find a .swift-format file. In this case, do you think we would still want to follow the normal logic for finding .editorconfig files, or skip it as well?

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

5 participants