Skip to content

Instantly share code, notes, and snippets.

@zilder
Created April 8, 2022 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zilder/4ad9de68a96387dfd3ced3b352391627 to your computer and use it in GitHub Desktop.
Save zilder/4ad9de68a96387dfd3ced3b352391627 to your computer and use it in GitHub Desktop.
Install coc-rust-analyzer
  1. Install Coc (via vim-plug, for instance). Requires nodejs.
Plug 'neoclide/coc.nvim', {'branch': 'release'}
  1. Install rust-src. For ubuntu:
sudo apt-get install rust-src
  1. :CocInstall coc-rust-analyzer

  2. Some useful key bindings (copied from somewhere long time ago):

" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  else
    call CocAction('doHover')
  endif
endfunction

nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
  1. In case of problems with Coc or coc-rust-analyzer there is a Vim command which may shed some light:
:CocOpenLog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment