X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/rust/analyzer.vim?ds=inline diff --git a/.vim/bundle/ale/ale_linters/rust/analyzer.vim b/.vim/bundle/ale/ale_linters/rust/analyzer.vim new file mode 100644 index 00000000..e3141cd3 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/rust/analyzer.vim @@ -0,0 +1,37 @@ +" Author: Jon Gjengset +" 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 + " Try to find nearest Cargo.toml for cargo projects + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + 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 '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'analyzer', +\ 'aliases': ['rust_analyzer'], +\ 'lsp': 'stdio', +\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')}, +\ 'command': function('ale_linters#rust#analyzer#GetCommand'), +\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'), +\})