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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorConfig support #107

Open
scottrhoyt opened this issue Mar 14, 2017 · 7 comments
Open

EditorConfig support #107

scottrhoyt opened this issue Mar 14, 2017 · 7 comments

Comments

@scottrhoyt
Copy link

It would be awesome to see support for http:https://editorconfig.org for cross-language formatting consistency! 馃憤

@nicklockwood
Copy link
Owner

Looks like it would be doable, but the editorconfig spec only supports a fairly small subset of the styling properties that SwiftFormat supports.

I could add proprietary extensions for SwiftFormat, but the editorconfig naming convention doesn't match mine, so then I'd need two sets of documentation - one for the command-line properties, and one for the custom editorconfig properties, which would be hard for me to maintain and confusing for users.

Unless you have a better suggestion?

@scottrhoyt
Copy link
Author

scottrhoyt commented Mar 15, 2017

It's not super pretty, but what I had in mind was that configuration would be able to be done in 3 ways following this priority:

  1. command line options
  2. a SwiftFormat config file
  3. an editor config file

So command line options (if present) override any config file. A SwiftFormat config file (if present) overrides an editor config file. Editor config is only used when the other two aren't present.

The trickiest bit would be defining and supporting a SwiftFormat config. Once there was support for loading a configuration from a file, the editor config support could be viewed as a mapping of the editor config options to the superset of SwiftFormat options. I probably wouldn't suggest extending the editor config options set, opting instead to disable the features that aren't in the editor config spec. I think that would provide the most consistent experience for cross-language use.

@nicklockwood
Copy link
Owner

@scottrhoyt that makes sense. I was hoping to use an existing standard for the SwiftFormat config file though. Ah well...

@paulocoutinhox
Copy link

Hi,

This was done?

Thanks.

@nicklockwood
Copy link
Owner

@paulo-coutinho SwiftFormat now has a config file, but not editorconfig compatible

@fred-bowker
Copy link

I'm using swift-format as the default style for swift language as this looks to be the default that apple recommends, for example 2 space indent instead of 4. Am I correct in thinking this is the default recommended style I couldn't find any apple style guide with the recommended indentation.

I'm not using Xcode and other editors don't have the style set to be the same as swift-format, it would be great if we could have editor config so that I could easily set the style to match swift-format.

@Mordil
Copy link

Mordil commented Apr 4, 2022

My thoughts would be that EditorConfig and the SwiftFormat config file wouldn't be mutually exclusive: They'd be merged with EditorConfig taking the higher precedence as a cross-platform/language/IDE "standard" over any settings in SwiftFormat config file

The only thing that would completely override the files are options passed via command line

Precedence:

  1. Command line arguments
  2. Config files (merged, with conflicts prefering EditorConfig values)

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