Rust-analyzer doesn't work in vim with ALE

Hi, I'm having trouble getting the language server to work in vim. I installed rust-analyzer and configured ale to use it as a linter just as the manual says:

let g:ale_linters = {'rust': ['analyzer']}

but I'm getting no linting or any of the other language server features.

As a (neo)vim user I'd highly suggest you to use neovim (if you don't already) and rustaceanvim.

Neovim has (afaik) all the features vanilla vim has + some better features when it comes to LSPs etc and you can configure it with lua instead of bespoke vimscript

Rustaceanvim sets up rust analyzer with linting, code actions autocomplete etc (if you got cmp or similar installed)

Is there an alternative in vanilla vim? I don't really want to switch to a different editor and a configuration language I don't know right now.

NVim is a dropin replacement for vim. It does everything normal vim does. You CAN use lua, but you don't have to, you can stay with vimscript

AFAIK working with LSPs like rust analyzer is harder in vanilla vim but not impossible though I can't help there

Nice, I'll give it a try. I also found out that COC also works on vim 9+ in addition to nvim so I might try that as well.

Turns out I'm just an idiot. You have to be in a project directory, just opening a random .rs file in /tmp will not enable the linter.

But at least I managed to get COC working pretty well alongside ALE.

1 Like

Haven't thought of that but checks out since it needs to read the contents of the Cargo toml for stuff like edition and dependencies

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.