File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ function ! ale_linters#swift#swiftlint#GetExecutable (buffer )
2
+ if get (g: , ' ale_swift_swiftlint_use_defaults' , 0 ) || filereadable (' .swiftlint.yml' )
3
+ return ' swiftlint'
4
+ endif
5
+
6
+ return ' '
7
+ endfunction
8
+
9
+ function ! ale_linters#swift#swiftlint#Handle (buffer , lines )
10
+ " Match and ignore file path (anything but ':')
11
+ " Match and capture line number
12
+ " Match and capture optional column number
13
+ " Match and capture warning level ('error' or 'warning')
14
+ " Match and capture anything in the message
15
+ let l: pattern = ' ^[^:]\+:\(\d\+\):\(\d\+\)\?:\?\s*\(\w\+\):\s*\(.*\)$'
16
+ let l: output = []
17
+
18
+ for l: line in a: lines
19
+ let l: match = matchlist (l: line , l: pattern )
20
+
21
+ if len (l: match ) == 0
22
+ continue
23
+ endif
24
+
25
+ let l: line_number = l: match [1 ]
26
+ let l: column = l: match [2 ]
27
+ let l: type = toupper (l: match [3 ][0 ])
28
+ let l: text = l: match [4 ]
29
+
30
+ call add (l: output , {
31
+ \ ' bufnr' : a: buffer ,
32
+ \ ' lnum' : l: line_number ,
33
+ \ ' vcol' : 0 ,
34
+ \ ' col' : l: column ,
35
+ \ ' text' : l: text ,
36
+ \ ' type' : l: type ,
37
+ \ })
38
+ endfor
39
+
40
+ return l: output
41
+ endfunction
42
+
43
+ call ale#linter#Define (' swift' , {
44
+ \ ' name' : ' swiftlint' ,
45
+ \ ' executable_callback' : ' ale_linters#swift#swiftlint#GetExecutable' ,
46
+ \ ' command' : ' swiftlint lint --use-stdin' ,
47
+ \ ' callback' : ' ale_linters#swift#swiftlint#Handle' ,
48
+ \ })
You can’t perform that action at this time.
0 commit comments