]> git.lizzy.rs Git - rust.git/blob - README.md
Merge #712
[rust.git] / README.md
1 # Rust Analyzer
2
3 [![Build Status](https://travis-ci.org/rust-analyzer/rust-analyzer.svg?branch=master)](https://travis-ci.org/rust-analyzer/rust-analyzer)
4
5 Rust Analyzer is an **experimental** modular compiler frontend for the Rust
6 language, which aims to lay a foundation for excellent IDE support.
7
8 It doesn't implement much of compiler functionality yet, but the white-space
9 preserving Rust parser works, and there are significant chunks of overall
10 architecture (indexing, on-demand & lazy computation, snapshotable world view)
11 in place. Some basic IDE functionality is provided via a language server.
12
13 Work on the Rust Analyzer is sponsored by
14
15 [![Ferrous Systems](https://ferrous-systems.com/images/ferrous-logo-text.svg)](https://ferrous-systems.com/)
16
17 ## Quick Start
18
19 Rust analyzer builds on Rust >= 1.31.0 and uses the 2018 edition.
20
21 ```
22 # run tests
23 $ cargo test
24
25 # show syntax tree of a Rust file
26 $ cargo run --package ra_cli parse < crates/ra_syntax/src/lib.rs
27
28 # show symbols of a Rust file
29 $ cargo run --package ra_cli symbols < crates/ra_syntax/src/lib.rs
30
31 # install the language server
32 $ cargo install-lsp
33 or
34 $ cargo install --path crates/ra_lsp_server
35 ```
36
37 See [these instructions](./editors/README.md) for VS Code setup and the list of
38 features (some of which are VS Code specific).
39
40 ## Debugging
41
42 See [these instructions](./DEBUGGING.md) on how to debug the vscode extension and the lsp server.
43
44 ## Current Status and Plans
45
46 Rust analyzer aims to fill the same niche as the official [Rust Language
47 Server](https://github.com/rust-lang-nursery/rls), but uses a significantly
48 different architecture. More details can be found [in this
49 thread](https://internals.rust-lang.org/t/2019-strategy-for-rustc-and-the-rls/8361),
50 but the core issue is that RLS works in the "wait until user stops typing, run
51 the build process, save the results of the analysis" mode, which arguably is the
52 wrong foundation for IDE.
53
54 Rust Analyzer is an experimental project at the moment, there's exactly zero
55 guarantees that it becomes production-ready one day.
56
57 The near/mid term plan is to work independently of the main rustc compiler and
58 implement at least simplistic versions of name resolution, macro expansion and
59 type inference. The purpose is two fold:
60
61 - to quickly bootstrap usable and useful language server: solution that covers
62   80% of Rust code will be useful for IDEs, and will be vastly simpler than 100%
63   solution.
64
65 - to understand how the consumer-side of compiler API should look like
66   (especially it's on-demand aspects). If you have `get_expression_type`
67   function, you can write a ton of purely-IDE features on top of it, even if the
68   function is only partially correct. Pluging in the precise function afterwards
69   should just make IDE features more reliable.
70
71 The long term plan is to merge with the mainline rustc compiler, probably around
72 the HIR boundary? That is, use rust analyzer for parsing, macro expansion and
73 related bits of name resolution, but leave the rest (including type inference
74 and trait selection) to the existing rustc.
75
76 ## Supported LSP features
77
78 ### General
79 - [x] [initialize](https://microsoft.github.io/language-server-protocol/specification#initialize)
80 - [x] [initialized](https://microsoft.github.io/language-server-protocol/specification#initialized)
81 - [x] [shutdown](https://microsoft.github.io/language-server-protocol/specification#shutdown)
82 - [ ] [exit](https://microsoft.github.io/language-server-protocol/specification#exit)
83 - [x] [$/cancelRequest](https://microsoft.github.io/language-server-protocol/specification#cancelRequest)
84
85 ### Workspace
86 - [ ] [workspace/workspaceFolders](https://microsoft.github.io/language-server-protocol/specification#workspace_workspaceFolders)
87 - [ ] [workspace/didChangeWorkspaceFolders](https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWorkspaceFolders)
88 - [x] [workspace/didChangeConfiguration](https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeConfiguration)
89 - [ ] [workspace/configuration](https://microsoft.github.io/language-server-protocol/specification#workspace_configuration)
90 - [x] [workspace/didChangeWatchedFiles](https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWatchedFiles)
91 - [x] [workspace/symbol](https://microsoft.github.io/language-server-protocol/specification#workspace_symbol)
92 - [x] [workspace/executeCommand](https://microsoft.github.io/language-server-protocol/specification#workspace_executeCommand)
93  - `apply_code_action`
94 - [ ] [workspace/applyEdit](https://microsoft.github.io/language-server-protocol/specification#workspace_applyEdit)
95
96 ### Text Synchronization
97 - [x] [textDocument/didOpen](https://microsoft.github.io/language-server-protocol/specification#textDocument_didOpen)
98 - [x] [textDocument/didChange](https://microsoft.github.io/language-server-protocol/specification#textDocument_didChange)
99 - [ ] [textDocument/willSave](https://microsoft.github.io/language-server-protocol/specification#textDocument_willSave)
100 - [ ] [textDocument/willSaveWaitUntil](https://microsoft.github.io/language-server-protocol/specification#textDocument_willSaveWaitUntil)
101 - [x] [textDocument/didSave](https://microsoft.github.io/language-server-protocol/specification#textDocument_didSave)
102 - [x] [textDocument/didClose](https://microsoft.github.io/language-server-protocol/specification#textDocument_didClose)
103
104 ### Diagnostics
105 - [x] [textDocument/publishDiagnostics](https://microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics)
106
107 ### Lanuguage Features
108 - [x] [textDocument/completion](https://microsoft.github.io/language-server-protocol/specification#textDocument_completion)
109  - open close: false
110  - change: Full
111  - will save: false
112  - will save wait until: false
113  - save: false
114 - [x] [completionItem/resolve](https://microsoft.github.io/language-server-protocol/specification#completionItem_resolve)
115  - resolve provider: none
116  - trigger characters: `:`, `.`
117 - [x] [textDocument/hover](https://microsoft.github.io/language-server-protocol/specification#textDocument_hover)
118 - [x] [textDocument/signatureHelp](https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp)
119  - trigger characters: `(`,  `,`,  `)`
120 - [ ] [textDocument/declaration](https://microsoft.github.io/language-server-protocol/specification#textDocument_declaration)
121 - [x] [textDocument/definition](https://microsoft.github.io/language-server-protocol/specification#textDocument_definition)
122 - [ ] [textDocument/typeDefinition](https://microsoft.github.io/language-server-protocol/specification#textDocument_typeDefinition)
123 - [x] [textDocument/implementation](https://microsoft.github.io/language-server-protocol/specification#textDocument_implementation)
124 - [x] [textDocument/references](https://microsoft.github.io/language-server-protocol/specification#textDocument_references)
125 - [x] [textDocument/documentHighlight](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight)
126 - [x] [textDocument/documentSymbol](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol)
127 - [x] [textDocument/codeAction](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction)
128  - rust-analyzer.syntaxTree
129  - rust-analyzer.extendSelection
130  - rust-analyzer.matchingBrace
131  - rust-analyzer.parentModule
132  - rust-analyzer.joinLines
133  - rust-analyzer.run
134  - rust-analyzer.analyzerStatus
135 - [x] [textDocument/codeLens](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens)
136 - [ ] [textDocument/documentLink](https://microsoft.github.io/language-server-protocol/specification#codeLens_resolve)
137 - [ ] [documentLink/resolve](https://microsoft.github.io/language-server-protocol/specification#documentLink_resolve)
138 - [ ] [textDocument/documentColor](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor)
139 - [ ] [textDocument/colorPresentation](https://microsoft.github.io/language-server-protocol/specification#textDocument_colorPresentation)
140 - [x] [textDocument/formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting)
141 - [ ] [textDocument/rangeFormatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting)
142 - [x] [textDocument/onTypeFormatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting)
143  - first trigger character: `=`
144  - more trigger character `.`
145 - [x] [textDocument/rename](https://microsoft.github.io/language-server-protocol/specification#textDocument_rename)
146 - [x] [textDocument/prepareRename](https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename)
147 - [x] [textDocument/foldingRange](https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange)
148
149 ## Getting in touch
150
151 We have a Discord server dedicated to compilers and language servers
152 implemented in Rust: [https://discord.gg/sx3RQZB](https://discord.gg/sx3RQZB).
153
154 ## Contributing
155
156 See [CONTRIBUTING.md](./CONTRIBUTING.md) and [ARCHITECTURE.md](./ARCHITECTURE.md)
157
158 ## License
159
160 Rust analyzer is primarily distributed under the terms of both the MIT
161 license and the Apache License (Version 2.0).
162
163 See LICENSE-APACHE and LICENSE-MIT for details.