All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Authors: Klaas Pieter Annema <https://github.com/klaaspieter>, bosr <bosr@bosr.cc>
2 " Description: Support for swift-format https://github.com/apple/swift-format
4 function! ale_linters#swift#appleswiftformat#GetLinterCommand(buffer) abort
5 let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' lint %t'
6 let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer)
8 if l:config_args isnot# ''
9 let l:command_args = l:command_args . ' ' . l:config_args
15 function! ale_linters#swift#appleswiftformat#Handle(buffer, lines) abort
16 " Matches the typical output of swift-format, that is lines of the following pattern:
18 " Sources/main.swift:4:21: warning: [DoNotUseSemicolons] remove ';' and move the next statement to the new line
19 " Sources/main.swift:3:12: warning: [Spacing] remove 1 space
20 let l:pattern = '\v^.*:(\d+):(\d+): (\S+): \[(\S+)\] (.*)$'
23 for l:match in ale#util#GetMatches(a:lines, l:pattern)
25 \ 'lnum': l:match[1] + 0,
26 \ 'col': l:match[2] + 0,
27 \ 'type': l:match[3] is# 'error' ? 'E' : 'W',
36 call ale#linter#Define('swift', {
37 \ 'name': 'apple-swift-format',
38 \ 'executable': function('ale#swift#GetAppleSwiftFormatExecutable'),
39 \ 'command': function('ale_linters#swift#appleswiftformat#GetLinterCommand'),
40 \ 'output_stream': 'stderr',
41 \ 'language': 'swift',
42 \ 'callback': 'ale_linters#swift#appleswiftformat#Handle'