• This repository has been archived on 29/Dec/2022
  • Stars
    star
    3,513
  • Rank 12,651 (Top 0.3 %)
  • Language
    Rust
  • License
    Other
  • Created about 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Repository for the Rust Language Server (aka RLS)

⚠️ RLS is no longer supported

RLS has been deprecated and is no longer supported. It has been replaced with rust-analyzer. Users are encouraged to uninstall RLS and follow the instructions in the rust-analyzer manual to install it for your editor.


Rust Language Server (RLS)

The RLS provides a server that runs in the background, providing IDEs, editors, and other tools with information about Rust programs. It supports functionality such as 'goto definition', symbol search, reformatting, and code completion, and enables renaming and refactorings.

A high-level overview of the architecture can be found here.

The RLS gets its source data from the compiler and from Racer. Where possible it uses data from the compiler which is precise and complete. Where it is not possible, (for example for code completion and where building is too slow), it uses Racer.

Since the Rust compiler does not yet support end-to-end incremental compilation, we can't offer a perfect experience. However, by optimising our use of the compiler and falling back to Racer, we can offer a pretty good experience for small to medium sized crates. As the RLS and compiler evolve, we'll offer a better experience for larger and larger crates.

The RLS is designed to be frontend-independent. We hope it will be widely adopted by different editors and IDEs. To seed development, we provide a reference implementation of an RLS frontend for Visual Studio Code.

Setup

Step 1: Install rustup

You can install rustup on many platforms. This will help us quickly install the RLS and its dependencies.

If you already have rustup installed, update to ensure you have the latest rustup and compiler:

rustup update

If you're going to use the VSCode extension, you can skip step 2.

Step 2: Install the RLS

Once you have rustup installed, run the following commands:

rustup component add rls rust-analysis rust-src

error: component 'rls' is unavailable for download (nightly)

The development of rustc's internals is quite fast paced. Downstream projects that rely on nightly internals, particularly clippy, can break fairly often because of this.

When such breakages occur the nightly release will be missing rls. This is a trade-off compared with the other option of just not publishing the night's release, but does avoid blocking the rust nightly releases for people that don't need clippy/rls.

To mitigate the issues we have:

  • rustup will warn if the update is missing any components you currently have. This means you can no longer accidentally update to a no-rls release. Once rls is available again it'll update.
  • rls, clippy are available on the stable channel. Meaning most developers installing for the first time should use stable.
  • However, if you need latest nightly rls you can use https://rust-lang.github.io/rustup-components-history/ to find and install a dated nightly release ie rustup install nightly-2018-12-06.

Also see #641.

Running

The RLS is built to work with many IDEs and editors, we mostly use VSCode to test the RLS. The easiest way is to use the published extension.

You'll know it's working when you see this in the status bar at the bottom, with a spinning indicator:

RLS: working ◐

Once you see:

RLS

Then you have the full set of capabilities available to you. You can goto def, find all refs, rename, goto type, etc. Completions are also available using the heuristics that Racer provides. As you type, your code will be checked and error squiggles will be reported when errors occur. You can hover these squiggles to see the text of the error.

Configuration

The RLS can be configured on a per-project basis; using the Visual Studio Code extension this will be done via the workspace settings file settings.json.

Other editors will have their own way of sending the workspace/DidChangeConfiguration method. Options are nested in the rust object, so your LSP client might send {"settings":{"rust":{"unstable_features":true}}} as parameters.

Entries in this file will affect how the RLS operates and how it builds your project.

Currently we accept the following options:

  • unstable_features (bool, defaults to false) enables unstable features. Currently no option requires this flag.
  • sysroot (String, defaults to "") if the given string is not empty, use the given path as the sysroot for all rustc invocations instead of trying to detect the sysroot automatically
  • target (String, defaults to "") if the given string is not empty, use the given target triple for all rustc invocations
  • wait_to_build (u64) overrides build debounce duration (ms). This is otherwise automatically inferred by the latest build duration.
  • all_targets (bool, defaults to true) checks the project as if you were running cargo check --all-targets. I.e., check all targets and integration tests too
  • crate_blacklist ([String], defaults to this list) allows to specify which crates should be skipped by the RLS. By default skips libraries that are of considerable size but which the user often may not be directly interested in, thus reducing the build latency.
  • build_on_save (bool, defaults to false) toggles whether the RLS should perform continuous analysis or only after a file is saved
  • features ([String], defaults to empty) list of Cargo features to enable
  • all_features (bool, defaults to false) enables all Cargo features
  • no_default_features (bool, defaults to false) disables default Cargo features
  • racer_completion (bool, defaults to true) enables code completion using racer (which is, at the moment, our only code completion backend). Also enables hover tooltips & go-to-definition to fall back to racer when save-analysis data is unavailable.
  • clippy_preference (String, defaults to "opt-in") controls eagerness of clippy diagnostics when available. Valid values are (case-insensitive):
    • "off" Disable clippy lints.
    • "on" Display the same diagnostics as command-line clippy invoked with no arguments (clippy::all unless overridden).
    • "opt-in" Only display the lints explicitly enabled in the code. Start by adding #![warn(clippy::all)] to the root of each crate you want linted.

and the following unstable options:

  • build_lib (bool, defaults to false) checks the project as if you passed the --lib argument to cargo. Mutually exclusive with, and preferred over, build_bin.
  • build_bin (String, defaults to "") checks the project as if you passed -- bin <build_bin> argument to cargo. Mutually exclusive with build_lib.
  • cfg_test (bool, defaults to false) checks the project as if you were running cargo test rather than cargo build. I.e., compiles (but does not run) test code.
  • full_docs (bool, defaults to false) instructs rustc to populate the save-analysis data with full source documentation. When set to false, only the first paragraph is recorded. This option currently has little to no effect on hover tooltips. The save-analysis docs are only used if source extraction fails. This option has no effect on the standard library.
  • show_hover_context (bool, defaults to true) show additional context in hover tooltips when available. This is often the local variable declaration. When set to false the content is only available when holding the ctrl key in some editors.

Troubleshooting

For tips on debugging and troubleshooting, see debugging.md.

Contributing

You can look in the contributing.md in this repo to learn more about contributing to this project.

If you want to implement RLS support in an editor, see clients.md.

More Repositories

1

rust

Empowering everyone to build reliable and efficient software.
Rust
85,122
star
2

rustlings

πŸ¦€ Small exercises to get you used to reading and writing Rust code!
Rust
47,148
star
3

mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
Rust
15,892
star
4

book

The Rust Programming Language
Rust
13,981
star
5

rust-analyzer

A Rust compiler front-end for IDEs
Rust
13,571
star
6

cargo

The Rust package manager
Rust
11,293
star
7

rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
Rust
9,860
star
8

rust-by-example

Learn Rust with examples (Live code editor included)
6,109
star
9

rustup

The Rust toolchain installer
Rust
5,558
star
10

rustfmt

Format Rust code
Rust
5,524
star
11

rfcs

RFCs for changes to Rust
Markdown
5,390
star
12

futures-rs

Zero-cost asynchronous programming in Rust
Rust
5,119
star
13

rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
Rust
3,830
star
14

rust.vim

Vim configuration for Rust.
Vim Script
3,628
star
15

miri

An interpreter for Rust's mid-level intermediate representation
Rust
3,581
star
16

regex

An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
Rust
3,083
star
17

crates.io

The Rust package registry
Rust
2,554
star
18

hashbrown

Rust port of Google's SwissTable hash map
Rust
2,266
star
19

log

Logging implementation for Rust
Rust
2,180
star
20

this-week-in-rust

Data for this-week-in-rust.org
HTML
1,826
star
21

libc

Raw bindings to platform APIs for Rust
Rust
1,786
star
22

chalk

An implementation and definition of the Rust trait system using a PROLOG-like logic solver
Rust
1,713
star
23

async-book

Asynchronous Programming in Rust
Shell
1,699
star
24

nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
CSS
1,698
star
25

rustc-dev-guide

A guide to how rustc works and how to contribute to it.
HTML
1,580
star
26

rustc_codegen_cranelift

Cranelift based backend for rustc
Rust
1,538
star
27

git2-rs

libgit2 bindings for Rust
Rust
1,520
star
28

cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
Rust
1,491
star
29

vscode-rust

Rust extension for Visual Studio Code
TypeScript
1,386
star
30

polonius

Defines the Rust borrow checker.
Rust
1,255
star
31

api-guidelines

Rust API guidelines
1,202
star
32

reference

The Rust Reference
Rust
1,140
star
33

rust-playground

The Rust Playground
Rust
1,076
star
34

rust-mode

Emacs configuration for Rust
Emacs Lisp
1,009
star
35

docs.rs

crates.io documentation generator
Rust
891
star
36

rustc_codegen_gcc

libgccjit AOT codegen for rustc
Rust
875
star
37

rustfix

Automatically apply the suggestions made by rustc
Rust
853
star
38

portable-simd

The testing ground for the future of portable SIMD in Rust
Rust
816
star
39

datafrog

A lightweight Datalog engine in Rust
Rust
783
star
40

flate2-rs

DEFLATE, gzip, and zlib bindings for Rust
Rust
730
star
41

socket2

Advanced configuration options for sockets.
Rust
681
star
42

unsafe-code-guidelines

Forum for discussion about what unsafe code can and can't do
641
star
43

rust-semverver

Automatic checking for semantic versioning in library crates
Rust
639
star
44

stdarch

Rust's standard library vendor-specific APIs and run-time feature detection
Rust
597
star
45

crater

Run experiments across parts of the Rust ecosystem!
Rust
588
star
46

packed_simd

Portable Packed SIMD Vectors for Rust standard library
Rust
575
star
47

rustc-perf

Website for graphing performance of rustc
Rust
539
star
48

libm

A port of MUSL's libm to Rust.
Rust
499
star
49

cfg-if

A if/elif-like macro for Rust #[cfg] statements
Rust
479
star
50

crates.io-index

Registry index for crates.io
476
star
51

backtrace-rs

Backtraces in Rust
Rust
473
star
52

style-team

Home of the Rust style team
Rust
438
star
53

docker-rust

The official Docker images for Rust
Dockerfile
414
star
54

glob

Support for matching file paths against Unix shell style patterns.
Rust
381
star
55

rust-forge

Information useful to people contributing to Rust
Rust
380
star
56

compiler-team

A home for compiler team planning documents, meeting minutes, and other such things.
HTML
380
star
57

wg-async

Working group dedicated to improving the foundations of Async I/O in Rust
Rust
365
star
58

www.rust-lang.org

The home of the Rust website
Fluent
358
star
59

compiler-builtins

Porting `compiler-rt` intrinsics to Rust
Rust
328
star
60

measureme

Support crate for rustc's self-profiling feature
Rust
324
star
61

rustc-hash

Custom hash algorithm used by rustc (plus hashmap/set aliases): fast, deterministic, not secure
Rust
312
star
62

blog.rust-lang.org

The Rust Programming Language Blog
HTML
302
star
63

team

Rust teams structure
Rust
293
star
64

glacier

A big 'ol pile of ICE.
Rust
289
star
65

project-error-handling

Error handling project group
264
star
66

atom-ide-rust

Rust IDE support for Atom, powered by the Rust Analyzer or Rust Language Server
JavaScript
259
star
67

stacker

Manual segmented stacks for Rust
Rust
252
star
68

a-mir-formality

a model of MIR and the Rust type/trait system
Rust
245
star
69

cmake-rs

Rust build dependency for running cmake
Rust
241
star
70

edition-guide

A guide to changes between various editions of Rust
238
star
71

getopts

The getopts repo maintained by the rust-lang project
Rust
229
star
72

annotate-snippets-rs

Library for snippet annotations
Rust
223
star
73

rust-roadmap-2017

Tracking Rust's roadmap
215
star
74

areweasyncyet.rs

Are we async yet?
Rust
211
star
75

rust-playpen

A web interface for running Rust code
Rust
208
star
76

wg-allocators

Home of the Allocators working group: Paving a path for a standard set of allocator traits to be used in collections!
199
star
77

rustc-demangle

Rust symbol demangling
Rust
196
star
78

lang-team

Home of the Rust lang team
JavaScript
191
star
79

highfive

Github hooks to provide an encouraging atmosphere for new contributors
Python
185
star
80

ferris-says

A Rust flavored implementation of `cowsay`
Rust
182
star
81

rust-guidelines

This repository has moved
179
star
82

cargo-bisect-rustc

Bisects rustc, either nightlies or CI artifacts
Rust
177
star
83

rustwide

Execute your code on the Rust ecosystem.
Rust
177
star
84

homu

A bot that integrates with GitHub and your favorite continuous integration service
Python
174
star
85

triagebot

Automation/tooling for Rust spaces
Rust
162
star
86

rfcbot-rs

Coordinates asynchronous decision making on Rust repositories. Status of tracked issues and PRs can be viewed at https://rfcbot.rs.
Rust
157
star
87

prev.rust-lang.org

The previous Rust website. The current website's code is at https://github.com/rust-lang/www.rust-lang.org.
HTML
153
star
88

pkg-config-rs

Build library for invoking pkg-config for Rust
Rust
147
star
89

thanks

Celebrate Rust contributors.
Rust
146
star
90

rustc-reading-club

Rust Code Reading Clubs
141
star
91

simpleinfra

Rust Infrastructure automation
HCL
140
star
92

gll

GLL parsing framework.
Rust
137
star
93

ena

An implementation of union-find / congruence-closure in Rust. Extracted from rustc for independent experimentation.
Rust
131
star
94

wg-cargo-std-aware

Repo for working on "std aware cargo"
130
star
95

rust-memory-model

Collecting examples and information to help design a memory model for Rust.
Python
125
star
96

rust-artwork

Official artwork for the Rust project.
122
star
97

libs-team

The home of the library team
Rust
107
star
98

google-summer-of-code

Rust project ideas for Google Summer of Code
105
star
99

rustup-components-history

Rustup package status history
Rust
102
star
100

wg-grammar

Where the work of WG-grammar, aiming to provide a canonical grammar for Rust, resides
Rust
101
star