Skip to content

Commit 84de2af

Browse files
committed
Only show swiftpm errors for current file.
1 parent 5e330f0 commit 84de2af

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

ale_linters/swift/swiftpm.vim

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function! ale_linters#swift#swiftpm#GetCommand(buffer)
2121
endfunction
2222

2323
function! ale_linters#swift#swiftpm#Handle(buffer, lines)
24-
" Match and ignore file path (anything but :)
24+
" Match and capture file path (anything but :)
2525
" Match and capture line number
2626
" Match and capture column number
2727
" Match and capture anything in the message
28-
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\s*\(error\|warning\):\s*\(.*\)$'
28+
let l:pattern = '^\([^:]\+\):\(\d\+\):\(\d\+\):\s*\(error\|warning\):\s*\(.*\)$'
2929
let l:output = []
3030

3131
for l:line in a:lines
@@ -35,10 +35,11 @@ function! ale_linters#swift#swiftpm#Handle(buffer, lines)
3535
continue
3636
endif
3737

38-
let l:line_number = l:match[1]
39-
let l:column = l:match[2]
40-
let l:type = l:match[3]
41-
let l:text = l:match[4]
38+
let l:file_name = l:match[1]
39+
let l:line_number = l:match[2]
40+
let l:column = l:match[3]
41+
let l:type = l:match[4]
42+
let l:text = l:match[5]
4243
let l:type_identifier = 'N'
4344

4445
if l:type == 'error'
@@ -47,14 +48,16 @@ function! ale_linters#swift#swiftpm#Handle(buffer, lines)
4748
let l:type_identifier = 'W'
4849
endif
4950

50-
call add(l:output, {
51-
\ 'bufnr': a:buffer,
52-
\ 'lnum': l:line_number,
53-
\ 'vcol': 0,
54-
\ 'col': l:column,
55-
\ 'text': l:text,
56-
\ 'type': l:type_identifier,
57-
\ })
51+
if l:file_name == expand('%:p')
52+
call add(l:output, {
53+
\ 'bufnr': a:buffer,
54+
\ 'lnum': l:line_number,
55+
\ 'vcol': 0,
56+
\ 'col': l:column,
57+
\ 'text': l:text,
58+
\ 'type': l:type_identifier,
59+
\ })
60+
endif
5861
endfor
5962

6063
return l:output

0 commit comments

Comments
 (0)