Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

feat: swiftformat.path workspace-local overrides - #61

Merged
vknabel merged 1 commit into
vknabel:mainfrom
maximkrouk:feature/path-glob-support
Sep 4, 2025
Merged

feat: swiftformat.path workspace-local overrides#61
vknabel merged 1 commit into
vknabel:mainfrom
maximkrouk:feature/path-glob-support

Conversation

@maximkrouk

Copy link
Copy Markdown
Contributor

I'm not sure if it works, so it would be cool if you could check it, but the idea is to resolve relative paths so that users of this extension will be able to set project-specific executables.

Current implementation should try to resolve local path and in case it fails (no matching local path found) it will run fallback logic for the global path.

@vknabel

vknabel commented Aug 28, 2025

Copy link
Copy Markdown
Owner

While I get the use case for this PR, I am not really convinced regarding the potential security risk vs actual use tradeoff.

In my opinion project specifics should not require global solutions that might conflict with other projects.

Instead you could create a global shell script that performs the check up and decides which path of swiftformat to use and set swiftformat.path accordingly to that script.

If #59 (comment) is correct, could you have a look what it does different there? In theory the 3 extensions for swiftformat, apple's swift-format and SwiftLint should behave similarly. If there is such a central difference, this is likely a bug or unwanted inconsistency.

In the end take all of this with a grain of salt as I am no longer part of the swift or vscode communities and don't use any of these anymore. Also I will only be notified by pull requests, not issues.

I can review this, but cannot provide any guarantees when or if I do as it requires me quite a lot of ceremony to set everything up before the review and frankly does not provide any benefit for me.

I hope you understand and that I could be a little bit helpful here and there.

@SimplyDanny

Copy link
Copy Markdown
Collaborator

The decisive difference to the SwiftLint extension is this line. Changing it to machine-overridable here will make the option available to project/workspace scopes as well.

At the moment, local paths work, but they need to be configured centrally in the user settings.json which is a bit odd.

@SimplyDanny SimplyDanny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would you like to the make the necessary adaptions in the package manifest, @maximkrouk?

The proposed changes are not required to make it work.

@maximkrouk

maximkrouk commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

I guess if changes in package manifest are sufficient (those changes are at least necessary) and path option allows to set relative path to swiftformat binary than it's much better to just introduce mentioned manifest mods.

From readme and high level code overview it looked like only global binaries are supported 🤔

@SimplyDanny

Copy link
Copy Markdown
Collaborator

If you set an explicit (local) path, it will be preferred.

@maximkrouk

Copy link
Copy Markdown
Contributor Author

If you set an explicit (local) path, it will be preferred.

Yes, but afaiu it returns string as it is and is used here so the path should be global, not workspace-related 🤔

I'm a bit confused because from looking at code it shouldn't work with local paths, but even release version seem to work (with global settings override) with workspace-local path 🌚

@maximkrouk
maximkrouk force-pushed the feature/path-glob-support branch from 45130f3 to 91c93d1 Compare August 29, 2025 10:35
@maximkrouk

maximkrouk commented Aug 29, 2025

Copy link
Copy Markdown
Contributor Author

I reverted changes in Current.ts, modified package.json and updated readme so it is a bit clearer that users can specify workspace-related path
But I'm still not sure how to test it locally

@SimplyDanny

Copy link
Copy Markdown
Collaborator

If you set an explicit (local) path, it will be preferred.

Yes, but afaiu it returns string as it is and is used here so the path should be global, not workspace-related 🤔

The code you are referring to falls back to swiftformat.path eventually in its implementation. The returned local/relative path is finally called and is not resolved globally. At least for me, it looks reasonable at the moment.

@maximkrouk maximkrouk changed the title feat: swiftformat.path glob support feat: swiftformat.path workspace-local overrides Aug 30, 2025
@maximkrouk

Copy link
Copy Markdown
Contributor Author

I guess it should be fine now to be merged and released 👉👈

@vknabel

vknabel commented Sep 4, 2025

Copy link
Copy Markdown
Owner

Great work from you two!

@SimplyDanny I trust you, if it's fine for you, it's fine for me. Feel free to merge and release PRs. :)

@vknabel
vknabel merged commit f61cacc into vknabel:main Sep 4, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants