-
Notifications
You must be signed in to change notification settings - Fork 280
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
Options to control swift-format #1811
Comments
Synced to Apple’s issue tracker as rdar://139514618 |
What would be the benefit of that? If you don’t want it, you can choose to not invoke formatting. Or am I missing something?
What would be the use case? I would prefer to not add configuration options unless we know that they solve real-world problems.
Which arguments would you pass here?
What would be the reason to not have
Similar here, when would this be useful? |
@ahoppen right. I didn't make these up, I just looked at what options the vknabel formatter extension gives and assumed there are reasons for existence of those options.
I'm not 100% sure how it plays in VSCode but someone might want to use one of the vknabel extensions and format their Swift files, just not use the swift-extension's formatter. But then you can choose another formatter in VSCode UI so i can get behind not having this option for now.
swift-format is bundled with the toolchains which means it's not updated too frequently. Maybe someone wants to use an updated version of swift-format.
Not sure what I'd pass here ... I guess in swift-format's case there may not be too many options to modify (yet?). But I can see this being useful in the future. Maybe there is an experimental flag or something added?
I personally don't mind it but the root directory can get pretty crowded with 20 different config files sitting there in the bigger projects. VSCode does show the
This should be helpful to avoid swift-format running with its default configuration just because no config exists. |
For me personally it would be important to be able to disable/enable swift-format's "Format Document" behavior when no Because if a project has It could be valuable to have options to disable each of |
Thanks for your detailed reply. I don’t think there are any concrete needs for the options you mentioned in the original post and I’d prefer to not add options just for the sake of having more options. If there are use cases that are enabled by the options, I’m happy to add them.
I think this option makes sense to add. |
If we want to do minimal options for now unless a need appears, then I want to mention that i think We currently use This has already happened to us with different |
I agree that having an option to point to a different |
It would be great if custom format tool flags could be provided, similar to the options offered by the Go extension. However, I'm not sure whether this option configuration should be provided by sourcekit-lsp or by VSCode-Swift. Personally, I'm not very accustomed to the apple/swift-format tied to sourcekit-lsp; I usually prefer using nicklockwood/SwiftFormat. |
@MartinLau7 what flags would you want to provide that you can't now? |
@MahdiBM I believe I may have expressed myself incorrectly. What I am looking for is for sourcekit-lsp to provide options to switch between different formatting tools, such as apple/swift-format and nicklockwood/SwiftFormat. As for flags, I hope apple/swift-format could provide a default flag to ignore line breaks, instead of requiring me to add |
Ah that's an issue for https://github.com/swiftlang/swift-format if it doesn't already exist.
I'd like that as well to be honest. I can see that this adds a decent amount of complexity. |
Yes, I think if we want to support arbitrary formatting tools, I think SourceKit-LSP should specify a command line option format that these formatting tools would need to follow – I haven’t checked but I wouldn’t be surprised if such a de-facto standard already exists. The tricky part is passing down options like indentation width (what we currently do here). |
There should be some options to control swift-format that is bundled with the toolchains.
I'm not sure how this'll play with the fact that the formatter is called by sourcekit-lsp, not directly by the vscode extension. Perhaps @ahoppen can enlighten me.
Some possible options:
swift-format
..swift-format
.Package.swift
or if there is no.swift-format
file.The text was updated successfully, but these errors were encountered: