]> git.madduck.net Git - etc/vim.git/blob - ale_linters/rust/rustc.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / rust / rustc.vim
1 " Author: Daniel Schemala <istjanichtzufassen@gmail.com>
2 " Description: rustc for rust files
3
4 call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null')
5
6 function! ale_linters#rust#rustc#RustcCommand(buffer) abort
7     " Try to guess the library search path. If the project is managed by cargo,
8     " it's usually <project root>/target/debug/deps/ or
9     " <project root>/target/release/deps/
10     let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
11
12     if l:cargo_file isnot# ''
13         let l:root = fnamemodify(l:cargo_file, ':h')
14         let l:dependencies = ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/debug/deps'))
15         \   . ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/release/deps'))
16     else
17         let l:dependencies = ''
18     endif
19
20     let l:options = ale#Var(a:buffer, 'rust_rustc_options')
21
22     return 'rustc --error-format=json'
23     \   . (!empty(l:options) ? ' ' . l:options : '')
24     \   . l:dependencies . ' -'
25 endfunction
26
27 call ale#linter#Define('rust', {
28 \   'name': 'rustc',
29 \   'executable': 'rustc',
30 \   'command': function('ale_linters#rust#rustc#RustcCommand'),
31 \   'callback': 'ale#handlers#rust#HandleRustErrors',
32 \   'output_stream': 'stderr',
33 \})