Fix #1031 - Make the rust flags configurable
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
||||
" Description: rustc for rust files
|
||||
|
||||
function! ale_linters#rust#rustc#RustcCommand(buffer_number) abort
|
||||
call ale#Set('rust_rustc_options', '-Z no-trans')
|
||||
|
||||
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 <project root>/target/debug/deps/ or
|
||||
" <project root>/target/release/deps/
|
||||
let l:cargo_file = ale#path#FindNearestFile(a:buffer_number, 'Cargo.toml')
|
||||
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
|
||||
|
||||
if l:cargo_file isnot# ''
|
||||
let l:project_root = fnamemodify(l:cargo_file, ':h')
|
||||
let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' .
|
||||
\ l:project_root . '/target/release/deps'
|
||||
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
|
||||
|
||||
return 'rustc --error-format=json -Z no-trans ' . l:dependencies . ' -'
|
||||
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', {
|
||||
|
||||
Reference in New Issue
Block a user