racer

https://github.com/phildawes/racer.git

git clone 'git://github.com/phildawes/racer.git'
1067

Racer - code completion for Rust

Build Status

alt text

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.

Installation

  1. cd racer; cargo build --release

  2. 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 )

  1. Test on the command line:

./target/release/racer complete std::io::B (should show some completions)

Emacs integration

  1. Install emacs 24

  2. Install rust-mode.

  3. Install company mode. (e.g. via ELPA: M-x list-packages, select 'company')

  4. Configure Emacs to find racer:

(setq racer-rust-src-path "<path-to-rust-srcdir>/src/") (setq racer-cmd "<path-to-racer>/target/release/racer") (add-to-list 'load-path "<path-to-racer>/editors/emacs") (eval-after-load "rust-mode" '(require 'racer))

  1. Configure Emacs to activate racer and setup some key bindings when rust-mode starts:

(add-hook 'rust-mode-hook '(lambda () (racer-activate) (local-set-key (kbd "M-.") #'racer-find-definition) (local-set-key (kbd "TAB") #'racer-complete-or-indent)))

  1. Open a rust file and try typing use std::io::B and press <tab>

  2. Place your cursor over a symbol and hit M-. to jump to the definition.

Vim integration

  1. Install using Pathogen, Vundle or NeoBundle. Or, copy racer/plugin/racer.vim into your .vim/plugin directory.

Vundle users: Vundle 'phildawes/racer'

NeoBundle users: NeoBundle 'phildawes/racer', { \ 'build' : { \ 'mac': 'cargo build --release', \ 'unix': 'cargo build --release', \ } \ }

  1. 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/"

  2. In insert mode use C-x-C-o to search for completions

  3. In normal mode type ‘gd’ to go to a definition

Kate integration

The Kate community maintains a plugin. It will be bundled with future releases of Kate (read more here).

  1. Enable ‘Rust code completion’ in the plugin list in the Kate config dialog

  2. On the new ‘Rust code completion’ dialog page, make sure ‘Racer command’ and ‘Rust source tree location’ are set correctly