]> git.proxmox.com Git - rustc.git/blame - rls/README.md
New upstream version 1.18.0+dfsg1
[rustc.git] / rls / README.md
CommitLineData
cc61c64b
XL
1[![Build Status](https://travis-ci.org/rust-lang-nursery/rls.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rls) [![Build status](https://ci.appveyor.com/api/projects/status/cxfejvsqnnc1oygs?svg=true)](https://ci.appveyor.com/project/jonathandturner/rls-x6grn)
2
3
4
5# Rust Language Server (RLS)
6
7**This project is in the alpha stage of development. It is likely to be buggy in
8some situations; proceed with caution.**
9
10The RLS provides a server that runs in the background, providing IDEs,
11editors, and other tools with information about Rust programs. It supports
12functionality such as 'goto definition', symbol search, reformatting, and code
13completion, and enables renaming and refactorings.
14
15The RLS gets its source data from the compiler and from
16[Racer](https://github.com/phildawes/racer). Where possible it uses data from
17the compiler which is precise and complete. Where its not possible, (for example
18for code completion and where building is too slow), it uses Racer.
19
20Since the Rust compiler does not yet support end-to-end incremental compilation,
21we can't offer a perfect experience. However, by optimising our use of the
22compiler and falling back to Racer, we can offer a pretty good experience for
23small to medium sized crates. As the RLS and compiler evolve, we'll offer a
24better experience for larger and larger crates.
25
26The RLS is designed to be frontend-independent. We hope it will be widely
27adopted by different editors and IDEs. To seed development, we provide a
28[reference implementation of an RLS frontend](https://github.com/jonathandturner/rls_vscode)
29for [Visual Studio Code](https://code.visualstudio.com/).
30
31
32## Setup
33
34### Step 1: Install rustup
35
36You can install [rustup](http://rustup.rs/) on many platforms. This will help us quickly install the
37rls and its dependencies.
38
39### Step 2: Switch to nightly
40
41Switch to the nightly compiler:
42
43```
44rustup default nightly
45rustup update nightly
46```
47
48### Step 3: Install the RLS
49
50Once you have rustup installed, run the following commands:
51
52```
53rustup component add rls
54rustup component add rust-analysis
55rustup component add rust-src
56```
57
58If you've never set up Racer before, you may also need follow the [Racer configuration
59steps](https://github.com/phildawes/racer#configuration)
60
61## Running
62
63Though the RLS is built to work with many IDEs and editors, we currently use
64VSCode to test the RLS.
65
66To run with VSCode, you'll need a
67[recent VSCode version](https://code.visualstudio.com/download) installed.
68
69Next, you'll need to run the VSCode extension (for this step, you'll need a
70recent [node](https://nodejs.org/en/) installed:
71
72```
73git clone https://github.com/jonathandturner/rls_vscode.git
74cd rls_vscode
75npm install
76code .
77```
78
79VSCode will open into the `rls_vscode` project. From here, click the Debug
80button on the left-hand side (a bug with a line through it). Next, click the
81green triangle at the top. This will launch a new instance of VSCode with the
82`rls_vscode` plugin enabled. From there, you can open your Rust projects using
83the RLS.
84
85You'll know it's working when you see this in the status bar at the bottom, with
86a spinning indicator:
87
88`RLS analysis: working /`
89
90Once you see:
91
92`RLS analysis: done`
93
94Then you have the full set of capabilities available to you. You can goto def,
95find all refs, rename, goto type, etc. Completions are also available using the
96heuristics that Racer provides. As you type, your code will be checked and
97error squiggles will be reported when errors occur. You can hover these
98squiggles to see the text of the error.
99
100## Configuration
101
102The RLS can be configured on a per-project basis by adding a file called
103`rls.toml` to the project root (i.e., next to Cargo.toml). Entries in this file
104will affect how the RLS operates and how it builds your project.
105
106Currently we accept the following options:
107
108* `build_lib` (`bool`, defaults to `false`) checks the project as if you passed
109 the `--lib` argument to cargo.
110* `cfg_test` (`bool`, defaults to `true`) checks the project as if you were
111 running `cargo test` rather than `cargo build`. I.e., compiles (but does not
112 run) test code.
113* `unstable_features` (`bool`, defaults to `false`) enables unstable features.
114 Currently, this includes renaming and formatting.
115* `sysroot` (`String`, defaults to `""`) if the given string is not empty, use
116 the given path as the sysroot for all rustc invocations instead of trying to
117 detect the sysroot automatically
118
119
120## Contributing
121
122You can look in the [contributing.md](https://github.com/rust-lang-nursery/rls/blob/master/contributing.md)
123in this repo to learn more about contributing to this project.