2019-10-16 15:34:06 +00:00
|
|
|
" Author: Jon Gjengset <jon@thesquareplanet.com>
|
|
|
|
" Description: The next generation language server for Rust
|
|
|
|
|
2020-04-09 12:57:02 +00:00
|
|
|
call ale#Set('rust_analyzer_executable', 'rust-analyzer')
|
2019-10-16 15:34:06 +00:00
|
|
|
call ale#Set('rust_analyzer_config', {})
|
|
|
|
|
|
|
|
function! ale_linters#rust#analyzer#GetCommand(buffer) abort
|
|
|
|
return '%e'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#rust#analyzer#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', {
|
2019-10-18 16:01:31 +00:00
|
|
|
\ 'name': 'analyzer',
|
2019-10-16 15:34:06 +00:00
|
|
|
\ 'lsp': 'stdio',
|
2020-11-19 01:39:07 +00:00
|
|
|
\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')},
|
2019-10-16 15:34:06 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
|
|
|
|
\ 'command': function('ale_linters#rust#analyzer#GetCommand'),
|
|
|
|
\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
|
|
|
|
\})
|