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

Renamed plugin configuration parameter #696

Merged

Conversation

dmonagle
Copy link
Contributor

@dmonagle dmonagle commented Mar 4, 2024

As trivial as this is, this change is to prevent a conflict with running the plugin with the --configuration parameter which is recognised and parsed by the Swift Package Manager and expects to be either debug or release.

The replacement of --swift-format-configuration is verbose, but other choices looked too ambiguous or confusing whereas this is at least clear as to what the parameter is doing.

resolves #668

As trivial as this is, this change is to prevent a conflict with running the plugin with the `--configuration` parameter which is recognised and parsed by the Swift Package Manager and expects to be either `debug` or `release`.

The replacement of `--swift-format-configuration` is verbose, but other choices looked too ambiguous or confusing whereas this is at least clear as to what the parameter is doing.
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we can change this as tooling might depend on the parameter being named --configuration. sourcekit-lsp, for example, does: https://github.com/apple/sourcekit-lsp/blob/cbb569320831d2aa48d251cadf63199c8f7ce840/Sources/SourceKitLSP/Swift/DocumentFormatting.swift#L185

We could add swift-format-configuration as another spelling of the same option, but I think we should keep --configuration as well.

@allevato
Copy link
Member

allevato commented Mar 5, 2024

sourcekit-lsp is invoking the swift-format tool directly, right, not using the plugin? In that case, I don't think it wouldn't be affected; from what I can tell, this PR is only changing the name of the flag that the SPM plugins look for, not the flag that swift-format itself uses.

Separately, the macOS CI is failing but I'm not sure why—I don't see anything relevant there, the failure appears to be a TSAN issue.

@dmonagle
Copy link
Contributor Author

dmonagle commented Mar 5, 2024

As @allevato said, existing tooling that is using --configuration would be doing it via the swift-format executable, not via the plugin. There doesn't seem to be any valid way to use custom configuration via the plugin due to the bug that this PR was created to resolve. I don't believe this will have an adverse affects, but it certainly makes the plugin usable for those of us that need to change the default behaviour.

@ahoppen
Copy link
Member

ahoppen commented Mar 5, 2024

Ah, OK. Sorry, I missed the distinction between the binary and the plugin. LGTM then

@dmonagle
Copy link
Contributor Author

dmonagle commented Mar 5, 2024

Ah, OK. Sorry, I missed the distinction between the binary and the plugin. LGTM then

All good. I still think it’s a bit cringey to have to do this, but unless SPM changes its behaviour to ignore command line options after the module name, this is the only way around it. Might be worth raising to avoid things like this in the future.

Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI looks good now that the sourcekit-lsp build has been fixed (unrelated to this PR). Thanks for the contribution!

@allevato allevato merged commit e4ce680 into swiftlang:main Mar 7, 2024
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.

Can't run plugin with --configuration argument
3 participants