DEV Community

Discussion on: Configure neovim for rust development

Collapse
 
ashoutinthevoid profile image
Full Name

New to neovim (and vi variations in general). I'm definitely feeling a bit lost here. I'm now getting this error on startup:

E5108: Error executing lua vim.lua:282: module 'vim.uri' not found:
        no field package.preload['vim.uri']

And that's with my init.vim stripped down to only the lsp plugin

call plug#begin()
" language server
Plug 'neovim/nvim-lsp'
call plug#end()

" setup rust_analyzer LSP (IDE features)
lua require'nvim_lsp'.rust_analyzer.setup{}

The closest I've found via google is a gitter message that notes "you have a borked install" and provides no further detail. Any help would be cool.

Collapse
 
ashoutinthevoid profile image
Full Name

Nvm. I ended up building and installing the current HEAD from source. Pretty painless (instructions are on the neovim repo), definitely more successful for me than whacking archive contents somewhere on my path. The rest seemed to more or less work.

One quick easy win: add the autocommands to an augroup, and start it with au! to avoid duplication if you source your vim config while running. Probably obvious to vim veterans, but new and super useful for me.
eg

augroup rust_config
  " delete any old autocommands
  au!
  " rustfmt on write using autoformat
  autocmd BufWrite *.rs :Autoformat
augroup END

In hindsight perhaps your target audience did not include new vim users, but some of these basics (i guess?) would be helpful for any of us considering a switch and coincidentally also working in Rust.