Skip to content

Commit 3cd476d

Browse files
author
Keith Smiley
committed
Merge pull request #97 from keith/ks/swiftlint-syntastic
Add swiftlint syntastic checker
2 parents 9f9f8f2 + ae059d9 commit 3cd476d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

syntax_checkers/swift/swiftlint.vim

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if exists('g:loaded_syntastic_swift_swiftlint_checker')
2+
finish
3+
endif
4+
let g:loaded_syntastic_swift_swiftlint_checker = 1
5+
6+
let s:save_cpo = &cpo
7+
set cpo&vim
8+
9+
function! SyntaxCheckers_swift_swiftlint_GetLocList() dict
10+
let env_vars = 'SCRIPT_INPUT_FILE_COUNT=1 SCRIPT_INPUT_FILE_0=' . syntastic#util#shexpand('%:p')
11+
let makeprg = self.makeprgBuild({
12+
\ 'exe_before': env_vars,
13+
\ 'fname': '',
14+
\ 'args': 'lint --use-script-input-files' })
15+
16+
let errorformat =
17+
\ '%f:%l:%c: %trror: %m,' .
18+
\ '%f:%l:%c: %tarning: %m,' .
19+
\ '%f:%l: %trror: %m,' .
20+
\ '%f:%l: %tarning: %m'
21+
22+
let env = {}
23+
" let env = {
24+
" \ 'SCRIPT_INPUT_FILE_COUNT': 1,
25+
" \ 'SCRIPT_INPUT_FILE_0': syntastic#util#shexpand('%:p'),
26+
" \ }
27+
28+
return SyntasticMake({
29+
\ 'makeprg': makeprg,
30+
\ 'errorformat': errorformat,
31+
\ 'env': env })
32+
endfunction
33+
34+
call g:SyntasticRegistry.CreateAndRegisterChecker({
35+
\ 'filetype': 'swift',
36+
\ 'name': 'swiftlint' })
37+
38+
let &cpo = s:save_cpo
39+
unlet s:save_cpo

0 commit comments

Comments
 (0)