]>
Commit | Line | Data |
---|---|---|
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 | |
8 | some situations; proceed with caution.** | |
9 | ||
10 | The RLS provides a server that runs in the background, providing IDEs, | |
11 | editors, and other tools with information about Rust programs. It supports | |
12 | functionality such as 'goto definition', symbol search, reformatting, and code | |
13 | completion, and enables renaming and refactorings. | |
14 | ||
15 | The RLS gets its source data from the compiler and from | |
16 | [Racer](https://github.com/phildawes/racer). Where possible it uses data from | |
17 | the compiler which is precise and complete. Where its not possible, (for example | |
18 | for code completion and where building is too slow), it uses Racer. | |
19 | ||
20 | Since the Rust compiler does not yet support end-to-end incremental compilation, | |
21 | we can't offer a perfect experience. However, by optimising our use of the | |
22 | compiler and falling back to Racer, we can offer a pretty good experience for | |
23 | small to medium sized crates. As the RLS and compiler evolve, we'll offer a | |
24 | better experience for larger and larger crates. | |
25 | ||
26 | The RLS is designed to be frontend-independent. We hope it will be widely | |
27 | adopted by different editors and IDEs. To seed development, we provide a | |
28 | [reference implementation of an RLS frontend](https://github.com/jonathandturner/rls_vscode) | |
29 | for [Visual Studio Code](https://code.visualstudio.com/). | |
30 | ||
31 | ||
32 | ## Setup | |
33 | ||
34 | ### Step 1: Install rustup | |
35 | ||
36 | You can install [rustup](http://rustup.rs/) on many platforms. This will help us quickly install the | |
37 | rls and its dependencies. | |
38 | ||
39 | ### Step 2: Switch to nightly | |
40 | ||
41 | Switch to the nightly compiler: | |
42 | ||
43 | ``` | |
44 | rustup default nightly | |
45 | rustup update nightly | |
46 | ``` | |
47 | ||
48 | ### Step 3: Install the RLS | |
49 | ||
50 | Once you have rustup installed, run the following commands: | |
51 | ||
52 | ``` | |
53 | rustup component add rls | |
54 | rustup component add rust-analysis | |
55 | rustup component add rust-src | |
56 | ``` | |
57 | ||
58 | If you've never set up Racer before, you may also need follow the [Racer configuration | |
59 | steps](https://github.com/phildawes/racer#configuration) | |
60 | ||
61 | ## Running | |
62 | ||
63 | Though the RLS is built to work with many IDEs and editors, we currently use | |
64 | VSCode to test the RLS. | |
65 | ||
66 | To run with VSCode, you'll need a | |
67 | [recent VSCode version](https://code.visualstudio.com/download) installed. | |
68 | ||
69 | Next, you'll need to run the VSCode extension (for this step, you'll need a | |
70 | recent [node](https://nodejs.org/en/) installed: | |
71 | ||
72 | ``` | |
73 | git clone https://github.com/jonathandturner/rls_vscode.git | |
74 | cd rls_vscode | |
75 | npm install | |
76 | code . | |
77 | ``` | |
78 | ||
79 | VSCode will open into the `rls_vscode` project. From here, click the Debug | |
80 | button on the left-hand side (a bug with a line through it). Next, click the | |
81 | green 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 | |
83 | the RLS. | |
84 | ||
85 | You'll know it's working when you see this in the status bar at the bottom, with | |
86 | a spinning indicator: | |
87 | ||
88 | `RLS analysis: working /` | |
89 | ||
90 | Once you see: | |
91 | ||
92 | `RLS analysis: done` | |
93 | ||
94 | Then you have the full set of capabilities available to you. You can goto def, | |
95 | find all refs, rename, goto type, etc. Completions are also available using the | |
96 | heuristics that Racer provides. As you type, your code will be checked and | |
97 | error squiggles will be reported when errors occur. You can hover these | |
98 | squiggles to see the text of the error. | |
99 | ||
100 | ## Configuration | |
101 | ||
102 | The 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 | |
104 | will affect how the RLS operates and how it builds your project. | |
105 | ||
106 | Currently 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 | ||
122 | You can look in the [contributing.md](https://github.com/rust-lang-nursery/rls/blob/master/contributing.md) | |
123 | in this repo to learn more about contributing to this project. |