-
Notifications
You must be signed in to change notification settings - Fork 637
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
Plug in/Extension architecture #256
Comments
@castus can you give some examples of the sort of rules you'd want to write? |
Yes of course:
|
@castus OK that makes sense. Some of those rules could probably just be added to the standard list as off-by-default, but a few are probably too esoteric for general use. I think it would probably be sufficient just to add the Another option would be to build a dylib and have SwiftFormat load it at runtime, but I guess that would be a lot more complex, and there would be issues with ABI compatibility and code signing, etc. |
@nicklockwood could you point what rules you think can be added to the standard list? I will try to make PR with them. The idea with the |
@castus so, IIUC rule 3 would convert something like:
to
I can imagine a lot of teams wanting this rule, although I've also seen the argument that it should always be the former so that you can put a breakpoint against the return line. So I think a rule that can be configured to convert either way would be useful. If you'd like to have a go at that I'd appreciate it (don't worry about adding the config to switch between modes - I can do that part). Rule number 5 clashes with the existing |
I love this tool. I want to use it to format code in my organization. We have some custom rules that are easy to write, but when I do it, I will lose ability to update this tool from your repository. Did you thought about custom rules, that every user can write and use it apart from the tool itself?
From what I saw it is be very difficult in the current architecture, but maybe it is easy, maybe there is something that I cannot see ;)
I have an idea, that is not perfect, but will allow me to have my custom rules and update the repo independently:
~/.swiftformat/CustomRules.swift
1.1. That file is a simple
CustomRulesTemplate.swift
which is a blank file. That file is bind to targets in Xcode.Before compilation script checks for
~/.swiftformat/CustomRules.swift
and if it exists it copies all the content toCustomRulesTemplate.swift
After compilation script erases all contents from
CustomRulesTemplate.swift
to not produce any git differences.With this approach I can easily checkout your repo and then build Command Line Tool with custom rules.
What do you think about it?
If you like it, I can make a PR.
The text was updated successfully, but these errors were encountered: