]> git.lizzy.rs Git - rust.git/blobdiff - docs/user/manual.adoc
Amend the instruction for rustup.
[rust.git] / docs / user / manual.adoc
index 816e094c212facec7545894253f6c823bedfff05..3bb9c8d8befc808384594135cbef8cf9b9466b5a 100644 (file)
@@ -6,6 +6,10 @@
 :source-highlighter: rouge
 :experimental:
 
+////
+IMPORTANT: the master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
+////
+
 At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time.
 This manual focuses on a specific usage of the library -- running it as part of a server that implements the
 https://microsoft.github.io/language-server-protocol/[Language Server Protocol] (LSP).
@@ -169,9 +173,11 @@ On Unix, running the editor from a shell or changing the `.desktop` file to set
 `rust-analyzer` is available in `rustup`, but only in the nightly toolchain:
 
 [source,bash]
----
+----
 $ rustup +nightly component add rust-analyzer-preview
----
+----
+
+However, in contrast to `component add clippy` or `component add rustfmt`, this does not actually place a `rust-analyzer` binary in `~/.cargo/bin`, see https://github.com/rust-lang/rustup/issues/2411[this issue].
 
 ==== Arch Linux
 
@@ -279,7 +285,7 @@ let g:ale_linters = {'rust': ['analyzer']}
 
 ==== nvim-lsp
 
-NeoVim 0.5 (not yet released) has built-in language server support.
+NeoVim 0.5 has built-in language server support.
 For a quick start configuration of rust-analyzer, use https://github.com/neovim/nvim-lspconfig#rust_analyzer[neovim/nvim-lspconfig].
 Once `neovim/nvim-lspconfig` is installed, use `+lua require'lspconfig'.rust_analyzer.setup({})+` in your `init.vim`.
 
@@ -423,6 +429,10 @@ With
 ----
 Then click on apply, and restart the LSP server for your rust project.
 
+=== juCi++
+
+https://gitlab.com/cppit/jucipp[juCi++] has built-in support for the language server protocol, and since version 1.7.0 offers installation of both Rust and rust-analyzer when opening a Rust file.
+
 == Troubleshooting
 
 Start with looking at the rust-analyzer version.
@@ -458,6 +468,9 @@ $ rust-analyzer analysis-stats .
 
 It is especially useful when the `repo` doesn't use external crates or the standard library.
 
+If you want to go as far as to modify the source code to debug the problem, be sure to take a look at the
+https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/dev[dev docs]!
+
 == Configuration
 
 **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/config.rs[config.rs]
@@ -576,8 +589,10 @@ interface Crate {
     target?: string;
     /// Environment variables, used for
     /// the `env!` macro
-    env: { [key: string]: string; },
+    env: { [key: string]: string; },
 
+    /// Whether the crate is a proc-macro crate.
+    is_proc_macro: boolean;
     /// For proc-macro crates, path to compiled
     /// proc-macro (.so file).
     proc_macro_dylib_path?: string;
@@ -595,9 +610,9 @@ interface Dep {
 This format is provisional and subject to change.
 Specifically, the `roots` setup will be different eventually.
 
-There are tree ways to feed `rust-project.json` to rust-analyzer:
+There are three ways to feed `rust-project.json` to rust-analyzer:
 
-* Place `rust-project.json` file at the root of the project, and rust-anlayzer will discover it.
+* Place `rust-project.json` file at the root of the project, and rust-analyzer will discover it.
 * Specify `"rust-analyzer.linkedProjects": [ "path/to/rust-project.json" ]` in the settings (and make sure that your LSP client sends settings as a part of initialize request).
 * Specify `"rust-analyzer.linkedProjects": [ { "roots": [...], "crates": [...] }]` inline.
 
@@ -607,6 +622,15 @@ See https://github.com/rust-analyzer/rust-project.json-example for a small examp
 
 You can set `RA_LOG` environmental variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading.
 
+Note that calls to `cargo check` are disabled when using `rust-project.json` by default, so compilation errors and warnings will no longer be sent to your LSP client. To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the `checkOnSave.overrideCommand` configuration. As an example, the following configuration explicitly sets `cargo check` as the `checkOnSave` command.
+
+[source,json]
+----
+{ "rust-analyzer.checkOnSave.overrideCommand": ["cargo", "check", "--message-format=json"] }
+----
+
+The `checkOnSave.overrideCommand` requires the command specified to output json error messages for rust-analyzer to consume. The `--message-format=json` flag does this for `cargo check` so whichever command you use must also output errors in this format. See the <<Configuration>> section for more information.
+
 == Security
 
 At the moment, rust-analyzer assumes that all code is trusted.