X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/rust/rustc.vim diff --git a/.vim/bundle/ale/ale_linters/rust/rustc.vim b/.vim/bundle/ale/ale_linters/rust/rustc.vim new file mode 100644 index 00000000..bc6431ba --- /dev/null +++ b/.vim/bundle/ale/ale_linters/rust/rustc.vim @@ -0,0 +1,33 @@ +" Author: Daniel Schemala +" Description: rustc for rust files + +call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null') + +function! ale_linters#rust#rustc#RustcCommand(buffer) abort + " Try to guess the library search path. If the project is managed by cargo, + " it's usually /target/debug/deps/ or + " /target/release/deps/ + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + if l:cargo_file isnot# '' + let l:root = fnamemodify(l:cargo_file, ':h') + let l:dependencies = ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/debug/deps')) + \ . ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/release/deps')) + else + let l:dependencies = '' + endif + + let l:options = ale#Var(a:buffer, 'rust_rustc_options') + + return 'rustc --error-format=json' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . l:dependencies . ' -' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'rustc', +\ 'executable': 'rustc', +\ 'command': function('ale_linters#rust#rustc#RustcCommand'), +\ 'callback': 'ale#handlers#rust#HandleRustErrors', +\ 'output_stream': 'stderr', +\})