2017-08-02 22:21:30 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: A language server for Rust
|
|
|
|
|
|
|
|
call ale#Set('rust_rls_executable', 'rls')
|
2019-04-11 13:25:08 +00:00
|
|
|
call ale#Set('rust_rls_toolchain', '')
|
2019-03-05 09:09:29 +00:00
|
|
|
call ale#Set('rust_rls_config', {})
|
2017-08-02 22:21:30 +00:00
|
|
|
|
|
|
|
function! ale_linters#rust#rls#GetCommand(buffer) abort
|
2017-11-26 18:47:30 +00:00
|
|
|
let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
|
2017-08-02 22:21:30 +00:00
|
|
|
|
2018-08-02 22:44:12 +00:00
|
|
|
return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
|
2017-08-02 22:21:30 +00: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-05 09:09:29 +00:00
|
|
|
\ 'lsp_config': {b -> ale#Var(b, 'rust_rls_config')},
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'rust_rls_executable')},
|
|
|
|
\ 'command': function('ale_linters#rust#rls#GetCommand'),
|
|
|
|
\ 'project_root': function('ale_linters#rust#rls#GetProjectRoot'),
|
2017-08-02 22:21:30 +00:00
|
|
|
\})
|