1
0
Fork 0
mirror of synced 2024-11-14 13:08:59 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/rust/analyzer.vim

38 lines
1.2 KiB
VimL
Raw Normal View History

2020-05-10 10:24:38 -04:00
" Author: Jon Gjengset <jon@thesquareplanet.com>
" Description: The next generation language server for Rust
call ale#Set('rust_analyzer_executable', 'rust-analyzer')
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
2022-08-08 09:45:56 -04:00
" Try to find nearest Cargo.toml for cargo projects
2020-05-10 10:24:38 -04:00
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
2022-08-08 09:45:56 -04:00
if !empty(l:cargo_file)
return fnamemodify(l:cargo_file, ':h')
endif
" Try to find nearest rust-project.json for non-cargo projects
let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json')
if !empty(l:rust_project)
return fnamemodify(l:rust_project, ':h')
endif
return ''
2020-05-10 10:24:38 -04:00
endfunction
call ale#linter#Define('rust', {
\ 'name': 'analyzer',
2024-01-07 10:14:20 -05:00
\ 'aliases': ['rust_analyzer'],
2020-05-10 10:24:38 -04:00
\ 'lsp': 'stdio',
2021-05-05 04:25:00 -04:00
\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')},
2020-05-10 10:24:38 -04:00
\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
\ 'command': function('ale_linters#rust#analyzer#GetCommand'),
\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
\})