mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Make cargo linter lighter: (#408)
- Use `cargo check` instead of `cargo build` when `g:ale_rust_cargo_use_check` is truish. - Use `--frozen` to avoid locking the project.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
||||
" Description: rustc invoked by cargo for rust files
|
||||
|
||||
let g:ale_rust_cargo_use_check = get(g:, 'ale_rust_cargo_use_check', 0)
|
||||
|
||||
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
||||
if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
|
||||
return 'cargo'
|
||||
@@ -11,10 +13,18 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rust#cargo#GetCommand(buffer) abort
|
||||
let l:command = g:ale_rust_cargo_use_check
|
||||
\ ? 'check'
|
||||
\ : 'build'
|
||||
|
||||
return 'cargo ' . l:command . ' --frozen --message-format=json -q'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('rust', {
|
||||
\ 'name': 'cargo',
|
||||
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
||||
\ 'command': 'cargo build --message-format=json -q',
|
||||
\ 'command_callback': 'ale_linters#rust#cargo#GetCommand',
|
||||
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
|
||||
\ 'output_stream': 'stdout',
|
||||
\})
|
||||
|
||||
Reference in New Issue
Block a user