ale/ale_linters/rust/rls.vim
eyenseo 6c93cded64 Fix rust rls linter toolchain argument
This removes the argument if the specified toolchain is empty.
As far as I can tell there is no +nighly (or similar) option [1] leading to
the termination of the server. But since people needed this option and
have yet to complain about it it stays the default for now.

[1] https://github.com/rust-lang-nursery/rls/blob/master/src/main.rs#L87
2018-04-12 20:42:38 +02:00

40 lines
1.3 KiB
VimL

" Author: w0rp <devw0rp@gmail.com>
" Description: A language server for Rust
call ale#Set('rust_rls_executable', 'rls')
call ale#Set('rust_rls_toolchain', 'nightly')
function! ale_linters#rust#rls#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'rust_rls_executable')
endfunction
function! ale_linters#rust#rls#GetCommand(buffer) abort
let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer)
let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
if empty(l:toolchain)
return ale#Escape(l:executable)
else
return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain)
endif
endfunction
function! ale_linters#rust#rls#GetLanguage(buffer) abort
return 'rust'
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',
\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable',
\ 'command_callback': 'ale_linters#rust#rls#GetCommand',
\ 'language_callback': 'ale_linters#rust#rls#GetLanguage',
\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot',
\})