Rust Language Client



Published June 16, 2020

I am (very) slowly starting to dive into nannou, a Rust framework for creative coding that aims to deliver pretty much the same functionality that openFrameworks does for C++ and Processing does for Java. My good friend Mads Kjeldgaard pointed me in the direction of the neovim plugin LanguageClient-neovim for autocompletion and syntax checking. And it is FAST. I have tried it for a few minutes and I am already blown away.

Installation it on Arch Linux / Neovim with vim-plug is slightly more involved than a regular plugin. First, put this into your init.vim:

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

Restart nvim or source init.vim and run PlugInstall. It will take a little while to download and install the binary, so a little bit of patience is in order.

Next, put this into your init.vim:

let g:LanguageClient_serverCommands = {
    \ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
    \ }

nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>

Note that the rustup path is a bit different than in the github example. This is because I installed rustup from Arch Linux’ community repo, and not from upstream.

Next thing you need to install rls. Fire up a terminal and type:

rustup component add rls

And that is hopefully it. Now you should be able to use languageclient in your rust projects. Happy rusting!