-
Notifications
You must be signed in to change notification settings - Fork 54
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
Formatter situation? #1190
Comments
From a discussion in the Swift Open Source slack workspace: https://swift-open-source.slack.com/archives/C02PV8T5HQD/p1730480017329059 The Swift extension is getting formatting "for free" right now from SourceKit-LSP's implementation of the It might be worthwhile to have the extension call |
I'd love to have range based formatting. We could use it on the built in snippets and comment blocks after they're inserted so they can be more seamlessly provided to match the existing formatting. |
@plemarquand I could work something out, formatting is one the weakest points of VSCode and kinds of pushes me away from fully moving to VSCode, so I'll be happy to contribute something to make the formatting lives of everyone easier. |
Let me know if there are any special concerns you'd have with that 🙂 |
You sure it doesn't trigger swift-format. The formatter appears because sourcekit-lsp says it can format the code. |
@adam-fowler no I wasn't sure, I just briefly tried it and saw prettier triggered which could have been due to some mis-config on my part. |
Just put a PR together, though I have yet to locally test it so you shouldn't bother testing it until my next notice hopefully. |
Worth noting I took a look at how rust registers a formatting provider. |
The formatter is available via SourceKit-LSP (select Swift when asked to select a formatter). I have verified this by adding a Adding support via the extension is unnecessary |
@adam-fowler like we discussed, we'd want to have full support for formatting. Does the current thing support these? If not, how should we proceed then? I think one concern was that it might take a bit for things to be merged into sourcekit-lsp then end up in the toolchains. |
swift-format doesn't support formatting on range, as it needs to load the full swift syntax tree. So sourcekit-lsp won't either. Having it called directly won't make it any quicker to implement I don't know what you mean by selection-formatting |
@adam-fowler I noticed range-formatting / selection-formatting was implemented in swift-format a while ago. Might not be perfect but yeah. Not sure about sourcekit-lsp and how it works though. |
I'm not looking to make things faster. |
Perhaps @ahoppen can enlighten us to what the current situation is with formatting of ranges and access to it via LSP command |
Implementing |
@ahoppen should I create an issue in the sourcekit-lsp / swift repo? If yes, which one? |
An issue in https://github.com/swiftlang/sourcekit-lsp would be great. |
@ahoppen issue filed: swiftlang/sourcekit-lsp#1805 I agree that the proper place for this would be right in sourcekit-lsp, although it might take a bit to reach end users like me. I'll be closing the half-implemented PR I did. |
What are the plans about providing a formatter in this repo now that
swift-format
is bundled with the toolchains?Currently it this extension does show up as a formatter but apparently it just triggers prettier?
EDIT: that's not true, see below.
This would look like a bit unfair for
SwiftFormat
(Nick Lockwood's) which is what we currently use, sinceswift-format
can be hard to bear with at times ... but it still makes sense sinceswift-format
is part of the toolchain.The text was updated successfully, but these errors were encountered: