diff options
author | Idan Arye <IdanArye@gmail.com> | 2017-03-27 14:37:00 +0300 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-03-27 12:37:00 +0100 |
commit | 2f40953e037eb0d70f8052e6b035758ec3fc0d5c (patch) | |
tree | 36e9254769c972246bab63dd237550e257953d22 /ale_linters/rust | |
parent | 8ca82af4ab9e1d95f8b577eba68f2b443b7dba07 (diff) | |
download | ale-2f40953e037eb0d70f8052e6b035758ec3fc0d5c.zip |
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.
Diffstat (limited to 'ale_linters/rust')
-rw-r--r-- | ale_linters/rust/cargo.vim | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim index 7f821d2c..30600cf8 100644 --- a/ale_linters/rust/cargo.vim +++ b/ale_linters/rust/cargo.vim @@ -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', \}) |