mirror of
https://github.com/dense-analysis/ale
synced 2024-12-26 08:02:25 +00:00
Fix rust linting with cargo when multiple targets are present
This commit is contained in:
parent
744d7d789f
commit
0143eb6a53
@ -15,7 +15,7 @@ endfunction
|
||||
call ale#linter#Define('rust', {
|
||||
\ 'name': 'cargo',
|
||||
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
||||
\ 'command': 'cargo rustc -- --error-format=json -Z no-trans',
|
||||
\ 'command': 'cargo build --message-format=json -q',
|
||||
\ 'callback': 'ale_linters#rust#rustc#HandleRustcErrors',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'output_stream': 'stdout',
|
||||
\})
|
||||
|
@ -17,12 +17,20 @@ function! ale_linters#rust#rustc#HandleRustcErrors(buffer_number, errorlines) ab
|
||||
endif
|
||||
|
||||
let l:error = json_decode(l:errorline)
|
||||
if !has_key(l:error, 'code') && !has_key(l:error, 'message')
|
||||
continue
|
||||
endif
|
||||
|
||||
if has_key(l:error, 'message')
|
||||
let l:error = l:error.message
|
||||
endif
|
||||
|
||||
if !empty(l:error.code) && index(g:ale_rust_ignore_error_codes, l:error.code.code) > -1
|
||||
continue
|
||||
endif
|
||||
|
||||
for l:span in l:error.spans
|
||||
let l:span.file_name = fnamemodify(l:span.file_name, ':t')
|
||||
if l:span.is_primary &&
|
||||
\ (l:span.file_name ==# l:file_name || l:span.file_name ==# '<anon>')
|
||||
call add(l:output, {
|
||||
|
Loading…
Reference in New Issue
Block a user