2018-03-31 10:55:20 -04:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: A language server for Rust
|
|
|
|
|
|
|
|
call ale#Set('rust_rls_executable', 'rls')
|
2019-05-17 10:09:13 -04:00
|
|
|
call ale#Set('rust_rls_toolchain', '')
|
2019-03-08 06:04:56 -05:00
|
|
|
call ale#Set('rust_rls_config', {})
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale_linters#rust#rls#GetCommand(buffer) abort
|
|
|
|
let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
|
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#rust#rls#GetProjectRoot(buffer) abort
|
|
|
|
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
|
|
|
|
|
|
|
|
return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('rust', {
|
|
|
|
\ 'name': 'rls',
|
|
|
|
\ 'lsp': 'stdio',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'lsp_config': {b -> ale#Var(b, 'rust_rls_config')},
|
|
|
|
\ 'executable': {b -> ale#Var(b, 'rust_rls_executable')},
|
|
|
|
\ 'command': function('ale_linters#rust#rls#GetCommand'),
|
|
|
|
\ 'project_root': function('ale_linters#rust#rls#GetProjectRoot'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\})
|