-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
apple-swift-format linter & fixer #3671
Conversation
I'll fix the failing test, my bad. I did not run vader locally... |
In the Vader linting tests for Edit: fixed |
I think the PR is now ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think the proposed change is very good but also is important to consider that there may be users that already use this tool with the g:swift_swiftformat_executable configuration. Changing this is a breaking change that goes against ALE philosophy:
Never introduce any breaking changes ever, unless users have been previously warned about them.
We cannot remove g:swift_swiftformat_executable variable so both must be supported giving priority to g:swift_apple_swift_format_executable. And in the documentation we mention that g:swift_swiftformat_executable is deprecated by g:swift_apple_swift_format_executable. Also ensure there are tests for falling back to g:swift_swiftformat_executable if defined.
Finally create an issue to completely remove g:swift_swiftformat_executable from the code after a while. Maybe one or two releases in the future.
call ale#Set('swift_appleswiftformat_executable', 'swift-format') | ||
call ale#Set('swift_appleswiftformat_use_swiftpm', 0) | ||
|
||
function! ale#fixers#appleswiftformat#GetExecutable(buffer) abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is exactly the same used in the linter. Better move it to autoload/ale/swift.vim file to keep the code DRY.
Hi, thanks for the review! I will happily apply the requested changes. One clarification though: I think Back to your point on ALE philosophy (with which I agree), we need a migration path which does not break existing functionality. Here are the steps I have in mind:
I hope this sounds like a plan to solve this. I'll wait for your feedback to start coding. |
@bosr I think I understand better what the issue is and what you are trying to do. The fact that both SwiftFormat (Fixer) and Apple Swift Format (Linter) use the same variable name When refactoring |
@hsanson, before I make the changes, do you have a preference for the variable name?
In retrospect, I find the former to be more readable and aligned with others like |
@bosr I have no strong preference so please use whichever feels best for you that actually use this tool. I do like to take the official tool name and replace the "/" and "-" chars with "_" to make the variables:
|
Hi @hsanson, I made some progress factoring the code in
I've spent hours trying to fix it, so if you could help me, that would be great. Thanks |
@bosr this method is being used but does not seem to be defined anywhere: |
Thanks a lot, that was right under my nose 🤦♂️. Now all tests pass, the names could be changed, but if it up to me, I like them as they are because they are readable and match with other name. |
Note: I have some issues using it on my local machine, so I need more time to debug before merging. Thanks. |
Hello @hsanson, my local problems are solved, tests pass, and the local behavior is correct for the linter and fixer, with/without I would like to add one last test for the This test is commented in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bosr please check comments for tips on fixing the test.
test/test-files/swift/swift-package-project-with-confjg/.swift-format
Outdated
Show resolved
Hide resolved
Thanks for the hints! FYI, my last updates were about passing the tests with I think I'm good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work and patience.
My pleasure! Thank you for the patience and guidance. It was much more laborious than expected, but thanks to you I learned a lot. |
* origin/master: (219 commits) Updated `solhint` linter to be able to use a local installation (dense-analysis#3682) Don't exit visual mode on floating preview close (dense-analysis#3689) hadolint: fix color output and stdin shown as "-" (dense-analysis#3680) feat: Add protolint as linter and fixer (dense-analysis#2911) apple-swift-format: linter and fixer with config swiftpm support (dense-analysis#3671) improve DMD handler (dense-analysis#3647) Add support for V: "v" (compiler) and "vfmt" fixer. (dense-analysis#3622) Add nixfmt as a Nix fixer. (dense-analysis#3651) Switch to using buildifier's -path option (dense-analysis#3640) Add support for `ptop` fixer (dense-analysis#3652) Add more parameters to the DMD linting command (dense-analysis#3639) dense-analysis#3633 - Move linter tests into test/linter Allow more time before PRs become stale Add support for clangd with CUDA (dense-analysis#3598) add support for svelte via svelteserver language server (dense-analysis#3644) dense-analysis#3633 - Put all dummy test files in test/test-files Add desktop-file-validate Fix a typo in a test filename issue 3033 (dense-analysis#3620) dense-analysis#3632 Add ale#util#MapMatches ...
Hi, thanks for ALE, it is awesome!
In this PR I propose a name change for apple/swift-format from
swift-format
toapple-swift-format
. For instance, the global variable for the executable becomesg:ale_swift_appleswiftformat_executable
.apple-swift-format
fixer and its test.g:ale_swift_appleswiftformat_use_swiftpm
(for users using swift-format as their project dependency).I hope you will agree with this naming change, as it distinguishes clearly in ALE the SwiftFormat (the community supported project) and the newer apple/swift-format project, enabling both projects to have their own linter and fixer.
Before this PR the status for swift-format was a bit unfortunate:
doc/ale-swift.vim
I hope this is now improved.
FYI @w0rp @klaaspieter (#3007) @WhyNotHugo (#3462)
Cheers