-
Notifications
You must be signed in to change notification settings - Fork 49
/
swiftlint.vim
45 lines (36 loc) · 1.09 KB
/
swiftlint.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
if exists('g:loaded_syntastic_swift_swiftlint_checker')
finish
endif
let g:loaded_syntastic_swift_swiftlint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_swift_swiftlint_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return get(g:, 'syntastic_swift_swiftlint_use_defaults', 0)
\ || filereadable('.swiftlint.yml')
endfunction
function! SyntaxCheckers_swift_swiftlint_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args': 'lint --use-script-input-files',
\ 'fname': '' })
let errorformat =
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l: %trror: %m,' .
\ '%f:%l: %tarning: %m'
let env = {
\ 'SCRIPT_INPUT_FILE_COUNT': 1,
\ 'SCRIPT_INPUT_FILE_0': expand('%:p'),
\ }
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'swift',
\ 'name': 'swiftlint' })
let &cpo = s:save_cpo
unlet s:save_cpo