Racer - code completion for Rust
RACER = Rust Auto-Complete-er. A utility intended to provide rust code completion for editors and IDEs. Maybe one day the 'er' bit will be exploring + refactoring or something.
-
Does an ok job of static completions: functions, structs, enums etc..
-
Not so hot on the dynamic stuff: methods, fields etc.. (yet)
-
Also provides 'find-definition' support for jumping around source code
-
cd racer; make
-
Set the
RUST_SRC_PATH
env variable to point to the 'src' dir in your rust source installation(e.g.
% export RUST_SRC_PATH=/usr/local/src/rust/src
) -
Test on the command line:
./bin/racer complete std::io::B
(should show some completions)
-
Install emacs 24
-
Install rust-mode. (e.g. add the following to .emacs:
(require 'rust-mode)```)
-
Install company mode. (e.g. via ELPA:
M-x list-packages
, select'company'
) -
Edit the first couple of lines of editors/racer.el to reflect your environment
-
Load it. E.g. eval the buffer or add this to .emacs:
(require 'racer)```
-
Open a rust file and try typing
use std::io::B
and press <tab> -
Place your cursor over a symbol and hit M-. to jump to the definition
N.B. So far I've only tested this on ubuntu linux + emacs 24
-
Copy racer/editors/racer.vim into your .vim/plugin directory
-
Add g:racer_cmd and $RUST_SRC_PATH variables to your .vimrc. Also it's worth turning on 'hidden' mode for buffers otherwise you need to save the current buffer every time you do a goto-definition. E.g.:
set hidden let g:racer_cmd = "/home/pld/src/rust/racer/bin/racer" let $RUST_SRC_PATH="/usr/local/src/rust/src"
-
In insert mode use C-x-C-o to search for completions
-
In normal mode type 'gd' to go to a definition