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

Add an EditorConfig file #2714

Merged
merged 1 commit into from
Jul 1, 2024
Merged

Add an EditorConfig file #2714

merged 1 commit into from
Jul 1, 2024

Conversation

j-f1
Copy link
Contributor

@j-f1 j-f1 commented Jun 29, 2024

Xcode 16 supports the EditorConfig standard, which allows a project to specify basic formatting rules so the editor can behave correctly. This means no additional configuration is required to get automatic 2-space indentation in Xcode rather than its default 4-space indentation. (You may need to quit and relaunch Xcode for it to pick up the editorconfig file after switching to a branch with it present)

Unfortunately, this does introduce duplication with .swift-format because both specify the indentation width. (It would be nice if swift-format picked up these settings automatically!)

@j-f1 j-f1 requested review from ahoppen and bnbarham as code owners June 29, 2024 17:10
@j-f1
Copy link
Contributor Author

j-f1 commented Jun 29, 2024

@swift-ci please test

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.

Thank you!

@ahoppen ahoppen merged commit 9d00296 into main Jul 1, 2024
3 checks passed
@ahoppen ahoppen deleted the jed/editorconfig branch July 1, 2024 07:57
mbrandonw pushed a commit to pointfreeco/swift-clocks that referenced this pull request Jul 4, 2024
Xcode 16 added support for the [EditorConfig
standard](https://editorconfig.org/)[^1]. This allows a project/repo to
specify basic formatting rules so the editor can behave correctly.[^2]

> [!NOTE]
> You may need to quit and relaunch Xcode for it to pick up the
`.editorconfig` file after switching to a branch where it's present.[^3]

The added `.editorconfig` file contains:

```
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
```

- `root = true`: Specifies that this is the top-most .editorconfig file.
The file search will stop here.
- `indent_style = space`: Uses soft tabs (spaces) for indentation
instead of hard tabs.
- `indent_size = 2`: Sets the indentation to 2 columns.
- `trim_trailing_whitespace = true`: Removes any whitespace characters
preceding newline characters.
- `insert_final_newline = true`: Ensures the file ends with a newline
when saving.

These settings apply to all files in the project (`[*]`).

**This change make much easier the process of switch between projects
that use 2-space and 4-space indentation (what is quite common in your
community).**

[^1]: [Xcode 16 Beta 2 Release Notes–Source Editor New
Features](https://arc.net/l/quote/zuzqnfeq)
[^2]: Inspired by: [Add an EditorConfig
file](swiftlang/swift-syntax#2714)
[^3]: [Xcode 16 Beta 2 Release Notes–Source Editor Known
Issues](https://arc.net/l/quote/olmnhsqo)
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.

2 participants