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
Add SwiftLint and Swift Maker #2463
base: master
Are you sure you want to change the base?
Conversation
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 your contribution!
I've left some comments.
I'm currently refactoring signs / types so that we can finally have type="style", which would make sense here.
I currently plan to have "S", "SE", and "SW" as new types (for internal lists, the qflist would get "S").
For current types "E" is the default, and here it would be "W", i.e. "S" == "SW".
See also #584.
What do you think?
endfunction | ||
|
||
function! s:get_swiftpm_config() abort | ||
return neomake#utils#FindGlobFile('Package.swift') | ||
endfunction | ||
|
||
function! s:get_swiftlint_config() abort | ||
return executable('swiftlint') && !empty(neomake#utils#FindGlobFile('.swiftlint.yml')) | ||
endfunction |
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.
Isn't there also such a thing as a global config?
I think it makes sense to not require a local config for linters to be enabled.
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.
SwiftLint officially does not support global configs. It does have a default configuration which I think many wouldn't want to be enabled for every file they open. E.g. it marks every variable shorter than two letters as an error.
The convention is having a config file in your project or provide it via an argument.
I think the best solution would be to search for a config file then run swiftlint
, check for ~/.swiftlint.yml if it exists run swiftlintglobal
(with config provided).
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.
But wouldn't people not liking swiftlint then just not install it?
I.e. if you have it it should be used - not only if you have some explicit config for it.
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 have it installed because some projects I work on use it, but others don't.
I cannot speak for everyone but I wouldn't want the default rules enabled and I'm not sure many are using a global config (there is a pretty old issue requesting this, though)
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've had a look at swift.vim.
There swiftlint is also only enabled when a .swiftlint.yml
is present or the user requests it.
https://github.com/keith/swift.vim/blob/master/syntax_checkers/swift/swiftlint.vim#L14
What is your opinion? I would leave the current implementation as is. The user can always opt in and run/enable swiftlint for himself.
I think SW would match well. |
When using the wrong swift toolchain an error without line or column can occur: /path: error: package at '/path' is using Swift tools version 5.2.0 but the installed version is 5.1.0
This Pull Request adds a new Maker for SwiftLint.
It also adds a Maker for compiling a swift script with swift (instead of swiftc).
SwiftLint will automatically be enabled when a
.swiftlint.yml
is found.swiftfile
won't be enabled per default. In my own vimrc I'll replaceswiftc
with it though.Rationale:
Having a
~/.swiftlint.yml
will enable SwiftLint but won't use this configuration but the default instead.As this is also true for the existing
swiftpm
, I did ignore it.Possible solutions:
FindGlobFile
with a function which only searches up until the project root..swiftlint.yml
** This would result in having support for global a SwiftLint config. But as SwiftLint can merge multiple configurations this feature would be lost.