diff options
Diffstat (limited to 'src/tools/rust-analyzer/docs')
-rw-r--r-- | src/tools/rust-analyzer/docs/dev/lsp-extensions.md | 69 | ||||
-rw-r--r-- | src/tools/rust-analyzer/docs/user/generated_config.adoc | 66 | ||||
-rw-r--r-- | src/tools/rust-analyzer/docs/user/manual.adoc | 38 |
3 files changed, 145 insertions, 28 deletions
diff --git a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md index de1422032..bc58aa722 100644 --- a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md +++ b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@ <!--- -lsp_ext.rs hash: 37f31ae648632897 +lsp_ext.rs hash: 2d60bbffe70ae198 If you need to change the above hash to make the test pass, please check if you need to adjust this doc as well and ping this issue: @@ -333,7 +333,7 @@ Moreover, it would be cool if editors didn't need to implement even basic langua ### Unresolved Question -* Should we return a nested brace structure, to allow paredit-like actions of jump *out* of the current brace pair? +* Should we return a nested brace structure, to allow [paredit](https://paredit.org/)-like actions of jump *out* of the current brace pair? This is how `SelectionRange` request works. * Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? @@ -386,14 +386,26 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look ## Open External Documentation -This request is sent from client to server to get a URL to documentation for the symbol under the cursor, if available. +This request is sent from the client to the server to obtain web and local URL(s) for documentation related to the symbol under the cursor, if available. -**Method** `experimental/externalDocs` +**Method:** `experimental/externalDocs` -**Request:**: `TextDocumentPositionParams` +**Request:** `TextDocumentPositionParams` + +**Response:** `string | null` -**Response** `string | null` +## Local Documentation +**Experimental Client Capability:** `{ "localDocs": boolean }` + +If this capability is set, the `Open External Documentation` request returned from the server will have the following structure: + +```typescript +interface ExternalDocsResponse { + web?: string; + local?: string; +} +``` ## Analyzer Status @@ -422,6 +434,16 @@ Returns internal status message, mostly for debugging purposes. Reloads project information (that is, re-executes `cargo metadata`). +## Rebuild proc-macros + +**Method:** `rust-analyzer/rebuildProcMacros` + +**Request:** `null` + +**Response:** `null` + +Rebuilds build scripts and proc-macros, and runs the build scripts to reseed the build data. + ## Server Status **Experimental Client Capability:** `{ "serverStatusNotification": boolean }` @@ -538,6 +560,18 @@ For debugging or when working on rust-analyzer itself. Returns a textual representation of the MIR of the function containing the cursor. For debugging or when working on rust-analyzer itself. +## Interpret Function + +**Method:** `rust-analyzer/interpretFunction` + +**Request:** `TextDocumentPositionParams` + +**Response:** `string` + +Tries to evaluate the function using internal rust analyzer knowledge, without compiling +the code. Currently evaluates the function under cursor, but will give a runnable in +future. Highly experimental. + ## View File Text **Method:** `rust-analyzer/viewFileText` @@ -829,3 +863,26 @@ export interface Diagnostic { rendered?: string; }; } +``` + +## Dependency Tree + +**Method:** `rust-analyzer/fetchDependencyList` + +**Request:** + +```typescript +export interface FetchDependencyListParams {} +``` + +**Response:** +```typescript +export interface FetchDependencyListResult { + crates: { + name: string; + version: string; + path: string; + }[]; +} +``` +Returns all crates from this workspace, so it can be used create a viewTree to help navigate the dependency tree. diff --git a/src/tools/rust-analyzer/docs/user/generated_config.adoc b/src/tools/rust-analyzer/docs/user/generated_config.adoc index 6937a7ed9..ea00c9540 100644 --- a/src/tools/rust-analyzer/docs/user/generated_config.adoc +++ b/src/tools/rust-analyzer/docs/user/generated_config.adoc @@ -71,6 +71,11 @@ cargo check --quiet --workspace --message-format=json --all-targets Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to avoid checking unnecessary things. -- +[[rust-analyzer.cargo.cfgs]]rust-analyzer.cargo.cfgs (default: `{}`):: ++ +-- +List of cfg options to enable with the given values. +-- [[rust-analyzer.cargo.extraArgs]]rust-analyzer.cargo.extraArgs (default: `[]`):: + -- @@ -120,7 +125,7 @@ Compilation target override (target triple). [[rust-analyzer.cargo.unsetTest]]rust-analyzer.cargo.unsetTest (default: `["core"]`):: + -- -Unsets `#[cfg(test)]` for the specified crates. +Unsets the implicit `#[cfg(test)]` for the specified crates. -- [[rust-analyzer.checkOnSave]]rust-analyzer.checkOnSave (default: `true`):: + @@ -352,6 +357,11 @@ Controls file watching implementation. -- Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords. -- +[[rust-analyzer.highlightRelated.closureCaptures.enable]]rust-analyzer.highlightRelated.closureCaptures.enable (default: `true`):: ++ +-- +Enables highlighting of all captures of a closure while the cursor is on the `|` or move keyword of a closure. +-- [[rust-analyzer.highlightRelated.exitPoints.enable]]rust-analyzer.highlightRelated.exitPoints.enable (default: `true`):: + -- @@ -416,7 +426,32 @@ Whether to show keyword hover popups. Only applies when [[rust-analyzer.hover.links.enable]]rust-analyzer.hover.links.enable (default: `true`):: + -- -Use markdown syntax for links in hover. +Use markdown syntax for links on hover. +-- +[[rust-analyzer.hover.memoryLayout.alignment]]rust-analyzer.hover.memoryLayout.alignment (default: `"hexadecimal"`):: ++ +-- +How to render the align information in a memory layout hover. +-- +[[rust-analyzer.hover.memoryLayout.enable]]rust-analyzer.hover.memoryLayout.enable (default: `true`):: ++ +-- +Whether to show memory layout data on hover. +-- +[[rust-analyzer.hover.memoryLayout.niches]]rust-analyzer.hover.memoryLayout.niches (default: `false`):: ++ +-- +How to render the niche information in a memory layout hover. +-- +[[rust-analyzer.hover.memoryLayout.offset]]rust-analyzer.hover.memoryLayout.offset (default: `"hexadecimal"`):: ++ +-- +How to render the offset information in a memory layout hover. +-- +[[rust-analyzer.hover.memoryLayout.size]]rust-analyzer.hover.memoryLayout.size (default: `"both"`):: ++ +-- +How to render the size information in a memory layout hover. -- [[rust-analyzer.imports.granularity.enforce]]rust-analyzer.imports.granularity.enforce (default: `false`):: + @@ -469,11 +504,21 @@ Whether to show inlay hints after a closing `}` to indicate what item it belongs Minimum number of lines required before the `}` until the hint is shown (set to 0 or 1 to always show them). -- +[[rust-analyzer.inlayHints.closureCaptureHints.enable]]rust-analyzer.inlayHints.closureCaptureHints.enable (default: `false`):: ++ +-- +Whether to show inlay hints for closure captures. +-- [[rust-analyzer.inlayHints.closureReturnTypeHints.enable]]rust-analyzer.inlayHints.closureReturnTypeHints.enable (default: `"never"`):: + -- Whether to show inlay type hints for return types of closures. -- +[[rust-analyzer.inlayHints.closureStyle]]rust-analyzer.inlayHints.closureStyle (default: `"impl_fn"`):: ++ +-- +Closure notation in type and chaining inlay hints. +-- [[rust-analyzer.inlayHints.discriminantHints.enable]]rust-analyzer.inlayHints.discriminantHints.enable (default: `"never"`):: + -- @@ -639,6 +684,11 @@ Elements must be paths pointing to `Cargo.toml`, -- Number of syntax trees rust-analyzer keeps in memory. Defaults to 128. -- +[[rust-analyzer.lru.query.capacities]]rust-analyzer.lru.query.capacities (default: `{}`):: ++ +-- +Sets the LRU capacity of the specified queries. +-- [[rust-analyzer.notifications.cargoTomlNotFound]]rust-analyzer.notifications.cargoTomlNotFound (default: `true`):: + -- @@ -669,8 +719,7 @@ This config takes a map of crate names with the exported proc-macro names to ign [[rust-analyzer.procMacro.server]]rust-analyzer.procMacro.server (default: `null`):: + -- -Internal config, path to proc-macro server executable (typically, -this is rust-analyzer itself, but we override this in tests). +Internal config, path to proc-macro server executable. -- [[rust-analyzer.references.excludeImports]]rust-analyzer.references.excludeImports (default: `false`):: + @@ -729,6 +778,11 @@ Inject additional highlighting into doc comments. When enabled, rust-analyzer will highlight rust source in doc comments as well as intra doc links. -- +[[rust-analyzer.semanticHighlighting.nonStandardTokens]]rust-analyzer.semanticHighlighting.nonStandardTokens (default: `true`):: ++ +-- +Whether the server is allowed to emit non-standard tokens and modifiers. +-- [[rust-analyzer.semanticHighlighting.operator.enable]]rust-analyzer.semanticHighlighting.operator.enable (default: `true`):: + -- @@ -748,7 +802,7 @@ of the generic `operator` token type. [[rust-analyzer.semanticHighlighting.punctuation.enable]]rust-analyzer.semanticHighlighting.punctuation.enable (default: `false`):: + -- -Use semantic tokens for punctuations. +Use semantic tokens for punctuation. When disabled, rust-analyzer will emit semantic tokens only for punctuation tokens when they are tagged with modifiers or have a special role. @@ -762,7 +816,7 @@ calls. [[rust-analyzer.semanticHighlighting.punctuation.specialization.enable]]rust-analyzer.semanticHighlighting.punctuation.specialization.enable (default: `false`):: + -- -Use specialized semantic tokens for punctuations. +Use specialized semantic tokens for punctuation. When enabled, rust-analyzer will emit special token types for punctuation tokens instead of the generic `punctuation` token type. diff --git a/src/tools/rust-analyzer/docs/user/manual.adoc b/src/tools/rust-analyzer/docs/user/manual.adoc index cb96feeb5..b5c095fd9 100644 --- a/src/tools/rust-analyzer/docs/user/manual.adoc +++ b/src/tools/rust-analyzer/docs/user/manual.adoc @@ -172,7 +172,7 @@ $ cargo xtask install --server If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-lang/rust-analyzer/issues/1811[this issue]. On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help. -==== `rustup` +==== rustup `rust-analyzer` is available in `rustup`: @@ -181,19 +181,6 @@ On Unix, running the editor from a shell or changing the `.desktop` file to set $ rustup component add rust-analyzer ---- -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]. You can find the path to the binary using: -[source,bash] ----- -$ rustup which --toolchain stable rust-analyzer ----- -You can link to there from `~/.cargo/bin` or configure your editor to use the full path. - -Alternatively you might be able to configure your editor to start `rust-analyzer` using the command: -[source,bash] ----- -$ rustup run stable rust-analyzer ----- - ==== Arch Linux The `rust-analyzer` binary can be installed from the repos or AUR (Arch User Repository): @@ -257,7 +244,7 @@ Any other tools or libraries you will need to acquire from Flatpak. Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. -To use `rust-analyzer`, you need to install and enable one of the two popular two popular LSP client implementations for Emacs, https://github.com/joaotavora/eglot[Eglot] or https://github.com/emacs-lsp/lsp-mode[LSP Mode]. Both enable `rust-analyzer` by default in rust buffers if it is available. +To use `rust-analyzer`, you need to install and enable one of the two popular LSP client implementations for Emacs, https://github.com/joaotavora/eglot[Eglot] or https://github.com/emacs-lsp/lsp-mode[LSP Mode]. Both enable `rust-analyzer` by default in rust buffers if it is available. ==== Eglot @@ -589,7 +576,7 @@ Try **rust-analyzer: Show RA Version** in VS Code (using **Command Palette** fea If the date is more than a week ago, it's better to update rust-analyzer version. The next thing to check would be panic messages in rust-analyzer's log. -Log messages are printed to stderr, in VS Code you can see then in the `Output > Rust Analyzer Language Server` tab of the panel. +Log messages are printed to stderr, in VS Code you can see them in the `Output > Rust Analyzer Language Server` tab of the panel. To see more logs, set the `RA_LOG=info` environment variable, this can be done either by setting the environment variable manually or by using `rust-analyzer.server.extraEnv`, note that both of these approaches require the server to be restarted. To fully capture LSP messages between the editor and the server, set `"rust-analyzer.trace.server": "verbose"` config and check @@ -666,9 +653,28 @@ However, if you use some other build system, you'll have to describe the structu [source,TypeScript] ---- interface JsonProject { + /// Path to the sysroot directory. + /// + /// The sysroot is where rustc looks for the + /// crates that are built-in to rust, such as + /// std. + /// + /// https://doc.rust-lang.org/rustc/command-line-arguments.html#--sysroot-override-the-system-root + /// + /// To see the current value of sysroot, you + /// can query rustc: + /// + /// ``` + /// $ rustc --print sysroot + /// /Users/yourname/.rustup/toolchains/stable-x86_64-apple-darwin + /// ``` + sysroot?: string; /// Path to the directory with *source code* of /// sysroot crates. /// + /// By default, this is `lib/rustlib/src/rust/library` + /// relative to the sysroot. + /// /// It should point to the directory where std, /// core, and friends can be found: /// |