You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
DISCLAIMER
Racer is not actively developped now.
Please consider using newer software such as
rust-analyzer.
Note: The second command adds the rustc-dev component to the nightly
toolchain, which is necessary to compile Racer.
Cargo
Internally, racer calls cargo as a CLI tool, so please make sure cargo is installed
With cargo install
Simply run:
cargo +nightly install racer
As mentioned in the command output, don't forget to add the installation directory to your PATH.
From sources
Clone the repository: git clone https://github.com/racer-rust/racer.git
cd racer; cargo +nightly build --release. The binary will now be in ./target/release/racer
Add the binary to your PATH. This can be done by moving it to a directory already in your PATH (i.e. /usr/local/bin) or by adding the ./target/release/ directory to your PATH
Configuration
Fetch the Rust sourcecode
automatically via rustup and run rustup component add rust-src in order to install the source to $(rustc --print sysroot)/lib/rustlib/src/rust/library (or $(rustc --print sysroot)/lib/rustlib/src/rust/src in older toolchains). Rustup will keep the sources in sync with the toolchain if you run rustup update.
If you want to use racer with multiple release channels (Rust has 3 release channels: stable, beta and nightly), you have to also download Rust source code for each release channel you install.
e.g. (rustup case) Add a nightly toolchain build and install nightly sources too
rustup toolchain add nightly
rustup component add rust-src
(Optional) Set RUST_SRC_PATH environment variable to point to the 'src' dir in the Rust source installation
e.g. % export RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/library or % export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src" (older)
It's recommended to set RUST_SRC_PATH for speed up, but racer detects it automatically if you don't set it.
Test on the command line:
racer complete std::io::B (should show some completions)
Note
To complete names in external crates, Racer needs Cargo.lock.
So, when you add a dependency in your Cargo.toml, you have to run a build command
such as cargo build or cargo test, to get completions.