This repository has been archived on 2022-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
emacs/emacs-racer
2017-09-09 17:54:23 +01:00
..
images Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
test Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
.ert-runner Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
.gitignore Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
.travis.yml Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
Cask Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
CHANGELOG.md Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
Makefile Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00
racer.el Remove deferred code override 2017-09-09 17:54:23 +01:00
README.md Merge commit 'f7471da19a1c773aaab8d97243b3e5ad0de23626' as 'emacs-racer' 2017-09-09 00:25:09 +01:00

Racer for Emacs

MELPA MELPA Stable Build Status Coverage Status

This is the official Emacs package for Racer.

Table of Contents

Completion

racer.el supports code completion of variables, functions and modules.

racer completion screenshot

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.

Find Definitions

racer.el can jump to definition of functions and types.

racer go to definition

You can use M-. to go to the definition, and M-, to go back.

Describe Functions and Types

racer.el can show a help buffer based on the docstring of the thing at point.

racer completion screenshot

Use M-x racer-describe to open the help buffer.

Installation

  1. Install Racer and download the source code of Rust:

    $ rustup component add rust-src
    $ cargo install racer
    
  2. Allow Emacs to install packages from MELPA:

    (require 'package)
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
    
  3. Install the Emacs package for Racer: M-x package-install RET racer RET

  4. 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 and company-minimum-prefix-length.

Testing your setup

To test completion: Open a rust file and try typing use std::io::B and press TAB.

To test go to definition: Place your cursor over a symbol and press M-. to jump to its definition.

Press M-, to jump back to the previous cursor location.

If it doesn't work, try M-x racer-debug to see what command was run and what output was returned.

Tests

racer.el includes tests. To run them, you need to install Cask, then:

$ cask install
$ cask exec ert-runner