vknabel / vscode-swiftformat

SwiftFormat for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swiftformat
MIT License
43 stars 8 forks source link

Option to load .swiftformat file for current project? #5

Closed MaxDesiatov closed 5 years ago

MaxDesiatov commented 5 years ago

Thanks for this fantastic extension!

It currently looks like .swiftformat file in a project is ignored when formatting options are applied. Is there a way to make this extension to load this file and apply those options for formatting?

vknabel commented 5 years ago

Hey @MaxDesiatov. Thanks for opening this issue!

Does setting swiftformat.options to ["--config", ".swiftformat"] solve your issue?

MaxDesiatov commented 5 years ago

Hi @vknabel, thanks for the reply! That is a workaround I'm currently using, but it doesn't solve the issue itself: for every project I use, I need to manually convert its .swiftformat file to swiftformat.options, which also leads to duplication. It's unclear why this information would need to be stored in two places at once in different formats: one officially supported by SwiftFormat and the other converted in JSON specifically for vscode-swiftformat extension.

Given that different projects have different .swiftformat settings, this requires duplicating those settings manually in VSCode workspace settings for every project. I hope this can be avoided and vscode-swiftformat could load .swiftformat file from a workspace automatically if one's available.

vknabel commented 5 years ago

@MaxDesiatov I totally agree with you! I just wanted to let you know about a temporary workaround. As of 1.3.0 vscode-swiftformat will now search for your configuration file. In case .swiftformat doesn’t fit all your use cases, you are free to override swiftformat.configSearchPaths.

Can you confirm it works on your machine?

MaxDesiatov commented 5 years ago

Fantastic, great stuff, all works now! I appreciate your help @vknabel 🙏