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

style(macos): cleanup trailing spaces #2129

Merged
merged 1 commit into from
Aug 22, 2024
Merged

Conversation

pnodet
Copy link
Member

@pnodet pnodet commented Aug 21, 2024

No description provided.

@qwerasd205
Copy link
Collaborator

So, adding indentation to blank lines is the default style XCode applies when formatting (^I to reindent). It would be nice if there's some way to specify the style of trimming trailing whitespace on blank lines in the XCode project (idk if there is). It can be done as an XCode setting via Settings -> Text Editing -> Editing -> While Editing: Automatically trim trailing whitespace -> Including whitespace-only lines. I'll try to find if there's a way to make it a project setting.

@qwerasd205
Copy link
Collaborator

Some cursory searching doesn't turn anything up, so perhaps a note should just be made in the README explaining how to enable automatic trimming of trailing whitespace from blank lines.

@mitchellh mitchellh merged commit 0b87eb7 into ghostty-org:main Aug 22, 2024
17 of 19 checks passed
@mitchellh
Copy link
Contributor

Thanks, yeah I'll set that up in the README. I wish we could automate this better but most of these files are edited in Xcode as was pointed out so getting consistency is harder compared to say... Vim where I edit the rest.

@mitchellh mitchellh deleted the patch-4 branch August 22, 2024 17:49
@pnodet
Copy link
Member Author

pnodet commented Aug 22, 2024

@mitchellh Sure honestly I have no swift experience, I was just browsing through and vscode was doing its thing so I figured I might as well commit it 🤷‍♂️

@jcollie
Copy link
Collaborator

jcollie commented Aug 22, 2024

We could supply a git pre-commit hook that would check files for trailing whitespace before allowing a commit. Would take some evangelizing to get everyone to add the hook client-side and everyone would need to remember to add the hooks every time that they do a fresh checkout. A CI action to check for trailing whitespace could be added too.

@jparise
Copy link
Collaborator

jparise commented Aug 22, 2024

A comprehensive approach could involve something like https://github.com/nicklockwood/SwiftFormat, but that might be more maintenance and onboarding overhead than we want to take on.

@mitchellh
Copy link
Contributor

I really dislike pre-commit hooks. I think something like SwiftFormat makes the most sense but I haven't looked at it closely.

@jcollie
Copy link
Collaborator

jcollie commented Aug 22, 2024

Nix has it packaged, but it only runs on Darwin so it would be difficult for non-macOS users to run. I was curious as to how much it would change but no luck. We do enforce some fairly opinionated code formatters on other languages...

@pnodet
Copy link
Member Author

pnodet commented Aug 22, 2024

From the readme SwitFormat can be configured is the xcode build phase.

https://github.com/nicklockwood/SwiftFormat?tab=readme-ov-file#xcode-build-phase

it only runs on Darwin so it would be difficult for non-macOS users to run.

@jcollie Since Xcode only runs on macOS this might not be an issue?

@jcollie
Copy link
Collaborator

jcollie commented Aug 22, 2024

@jcollie Since Xcode only runs on macOS this might not be an issue?

That would be fine, but it should probably be in a CI step too just in case someone edits the Swift code outside of Xcode.

@jparise
Copy link
Collaborator

jparise commented Aug 23, 2024

Timely! Xcode 16 introduces support for EditorConfig (on by default): https://www.polpiella.dev/xcode-editor-config/

... and I added an initial .editorconfig in 8218a19 that we should extend for Swift files.

@jparise
Copy link
Collaborator

jparise commented Aug 23, 2024

#2142 adds an .editorconfig entry for *.swift files that enables trailing whitespace trimming.

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.

5 participants