This is the official Emacs package for Racer.
Table of Contents
racer.el supports code completion of variables, functions and modules.
You can also press F1 to pop up a help buffer for the current completion candidate.
Note that due to a limitation of racer, racer.el cannot offer completion for macros.
racer.el can jump to definition of functions and types.
You can use M-. to go to the definition, and M-, to go back.
racer.el can show a help buffer based on the docstring of the thing at point.
Use M-x racer-describe to open the help buffer.
-
Install Racer:
$ cargo install racer
-
Allow Emacs to install packages from MELPA:
(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
-
Install racer:
M-x package-install RET racer RET
-
Download the rust sourcecode, and configure emacs to find your rust source directory:
(setq racer-rust-src-path "<path-to-rust-srcdir>/src/")
-
Configure Emacs to activate racer when rust-mode starts:
(add-hook 'rust-mode-hook #'racer-mode) (add-hook 'racer-mode-hook #'eldoc-mode)
For completions, install company with
M-x package-install RET company RET
. A sample configuration:(add-hook 'racer-mode-hook #'company-mode) (require 'rust-mode) (define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common) (setq company-tooltip-align-annotations t)
For automatic completions, customize
company-idle-delay
andcompany-minimum-prefix-length
. -
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. -
Hit
M-,
to jump back to the symbol usage location.
racer.el includes tests. To run them, you need to install Cask, then:
$ cask install
$ cask exec ert-runner