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.
-
Clone the repository:
git clone https://github.com/phildawes/racer.git
-
cd racer; cargo build --release
. The binary will now be in./target/release/racer
-
Fetch the rust sourcecode from git, or download from https://www.rust-lang.org/install.html
-
Set the
RUST_SRC_PATH
env variable to point to the 'src' dir in the rust source installation(e.g.
% export RUST_SRC_PATH=/usr/local/src/rust/src
) -
Test on the command line:
./target/release/racer complete std::io::B
(should show some completions)
Emacs intergation has been moved to a separate project: emacs-racer
- Install using Pathogen, Vundle or NeoBundle. Or, copy racer/plugin/racer.vim into your .vim/plugin directory.
Vundle users:
Plugin 'phildawes/racer'
NeoBundle users:
NeoBundle 'phildawes/racer', {
\ 'build' : {
\ 'mac': 'cargo build --release',
\ 'unix': 'cargo build --release',
\ }
\ }
-
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 = "<path-to-racer>/target/release/racer" let $RUST_SRC_PATH="<path-to-rust-srcdir>/src/"
-
In insert mode use C-x-C-o to search for completions
-
In normal mode type 'gd' to go to a definition
The Kate community maintains a plugin. It will be bundled with future releases of Kate (read more here).
-
Enable 'Rust code completion' in the plugin list in the Kate config dialog
-
On the new 'Rust code completion' dialog page, make sure 'Racer command' and 'Rust source tree location' are set correctly