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:
parent
8ca82af4ab
commit
2f40953e03
2 changed files with 25 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
||||||
" Description: rustc invoked by cargo for rust files
|
" 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
|
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
||||||
if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
|
if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
|
||||||
return 'cargo'
|
return 'cargo'
|
||||||
|
@ -11,10 +13,18 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
||||||
endif
|
endif
|
||||||
endfunction
|
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', {
|
call ale#linter#Define('rust', {
|
||||||
\ 'name': 'cargo',
|
\ 'name': 'cargo',
|
||||||
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
\ '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',
|
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
|
||||||
\ 'output_stream': 'stdout',
|
\ 'output_stream': 'stdout',
|
||||||
\})
|
\})
|
||||||
|
|
16
doc/ale.txt
16
doc/ale.txt
|
@ -43,7 +43,8 @@ CONTENTS *ale-contents*
|
||||||
4.31. yamllint........................|ale-linter-options-yamllint|
|
4.31. yamllint........................|ale-linter-options-yamllint|
|
||||||
4.32. cmakelint.......................|ale-linter-options-cmakelint|
|
4.32. cmakelint.......................|ale-linter-options-cmakelint|
|
||||||
4.33. perl-perl.......................|ale-linter-options-perl-perl|
|
4.33. perl-perl.......................|ale-linter-options-perl-perl|
|
||||||
4.34. asm-gcc.........................|ale-linter-options-asm-gcc|
|
4.34. rust-cargo......................|ale-linter-options-rust-cargo|
|
||||||
|
4.35. asm-gcc.........................|ale-linter-options-asm-gcc|
|
||||||
5. Linter Integration Notes.............|ale-linter-integration|
|
5. Linter Integration Notes.............|ale-linter-integration|
|
||||||
5.1. merlin..........................|ale-linter-integration-ocaml-merlin|
|
5.1. merlin..........................|ale-linter-integration-ocaml-merlin|
|
||||||
5.2. rust.............................|ale-integration-rust|
|
5.2. rust.............................|ale-integration-rust|
|
||||||
|
@ -1123,7 +1124,18 @@ g:ale_perl_perl_options *g:ale_perl_perl_options*
|
||||||
invocation.
|
invocation.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
4.34. asm-gcc *ale-linter-options-asm-gcc*
|
4.34. rust-cargo *ale-linter-options-rust-cargo*
|
||||||
|
|
||||||
|
g:ale_rust_cargo_use_check *g:ale_rust_cargo_use_check*
|
||||||
|
|
||||||
|
Type: |Number|
|
||||||
|
Default: `1`
|
||||||
|
|
||||||
|
When set to `1`, this option will cause ALE to use "cargo check" instead of
|
||||||
|
"cargo build". "cargo check" is supported since version 1.16.0 of Rust.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
4.35. asm-gcc *ale-linter-options-asm-gcc*
|
||||||
|
|
||||||
g:ale_asm_gcc_options *g:ale_asm_gcc_options*
|
g:ale_asm_gcc_options *g:ale_asm_gcc_options*
|
||||||
|
|
||||||
|
|
Reference in a new issue