Skip to content

Configurable Command Plugin Build Configuration #1409

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

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Feb 26, 2025

Packages can define their own plugins either directly or through their dependencies. These plugins define commands, and the extension exposes a list of these when you use > Swift: Run Command Plugin.

It may be desirable to build and run these plugins with specific arguments. This patch introduces a new setting that can be specified globally or on a per workspace folder basis that allows users to configure arguments to pass to plugin command invocations.

The setting is defined under swift.pluginArguments, and is specified as an object in the following form:

{
  "PluginCommandName:intent-name": ["--some", "--args"]
}
  • The top level string key is the command id in the form PluginCommandName:intent-name. For instance, swift-format's format-source-code command would be specified as swift-format:format-source-code
  • Specifying PluginCommandName will apply the arguments to all intents in the command plugin
  • Specifying * will apply the arguments to all commands.

This patch also adds this wildcard functionality to the swift.pluginPermissions setting.

Issue: #1365

Packages can define their own plugins either directly or through
their dependencies. These plugins define commands, and the extension
exposes a list of these when you use `> Swift: Run Command Plugin`.

It may be desirable to build and run these plugins with specific
arguments. This patch introduces a new setting that can be specified
globally or on a per workspace folder basis that allows users to
configure arguments to pass to plugin command invocations.

The setting is defined under `swift.pluginArguments`, and is specified
as an object in the following form:

```json
{
	"PluginCommandName:intent-name": ["--some", "--args"]
}
```

- The top level string key is the command id in the form
  `PluginCommandName:intent-name`. For instance, swift-format's
  format-source-code command would be specified as
  `swift-format:format-source-code`
- Specifying `PluginCommandName` will apply the arguments to all intents
  in the command plugin
- Specifying `*` will apply the arguments to all commands.

This patch also adds this wildcard functionality to the
`swift.pluginPermissions` setting.

Issue: swiftlang#1365
@plemarquand
Copy link
Contributor Author

@MahdiBM please take a look and let me know if this addresses all your concerns from #1365

Copy link
Contributor

@MahdiBM MahdiBM left a comment

Choose a reason for hiding this comment

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

Thank you, looks good.

Maybe it would be nicer to have a combined "pluginSettings" instead of pluginPermissions and pluginArguments?

@plemarquand
Copy link
Contributor Author

@MahdiBM I think because for backwards compatibility sake, because we've already released with pluginPermissions, we shouldn't roll it in to the more generic pluginArguments. It would also make the settings validation more tricky since it could be either one of the permissions values, or a freeform argument.

@plemarquand plemarquand merged commit 263a0e0 into swiftlang:main Mar 11, 2025
13 of 15 checks passed
@award999
Copy link
Contributor

Verified with 82fb69c

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.

5 participants