### Minimal Bug Reproduction Setup Source: https://rust-analyzer.github.io/book/troubleshooting.html Steps to create a minimal, reproducible example for bug reporting. This involves cloning a specific commit and running version and analysis commands. ```bash git clone https://github.com/username/repo.git && cd repo && git switch --detach commit-hash rust-analyzer --version rust-analyzer dd12184e4 2021-05-08 dev rust-analyzer analysis-stats . ``` -------------------------------- ### Install rust-analyzer on Linux Source: https://rust-analyzer.github.io/book/rust_analyzer_binary.html Installs the rust-analyzer binary to ~/.local/bin on Linux. Ensure ~/.local/bin is in your PATH. ```bash mkdir -p ~/.local/bin curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer chmod +x ~/.local/bin/rust-analyzer ``` -------------------------------- ### Install rustc-josh-sync Tool Source: https://rust-analyzer.github.io/book/contributing/index.html Installs the rustc-josh-sync tool from its Git repository. Ensure you have Cargo installed. ```bash cargo install --locked --git https://github.com/rust-lang/josh-sync ``` -------------------------------- ### Build and Test Rust-Analyzer Source: https://rust-analyzer.github.io/book/print.html This command builds and tests the Rust-Analyzer project. It's the primary way to get started with the project locally. ```bash cargo test ``` -------------------------------- ### Install rust-analyzer from Source Source: https://rust-analyzer.github.io/book/vs_code.html Clone the rust-analyzer repository and install the extension and language server from source using cargo xtask. ```bash git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer cargo xtask install ``` -------------------------------- ### Install rust-analyzer via Homebrew Source: https://rust-analyzer.github.io/book/rust_analyzer_binary.html Installs the rust-analyzer binary using the Homebrew package manager. ```bash brew install rust-analyzer ``` -------------------------------- ### Install rust-analyzer Server Only from Source Source: https://rust-analyzer.github.io/book/vs_code.html Compile and install only the LSP server from source if not using VS Code. ```bash cargo xtask install --server ``` -------------------------------- ### Install rust-analyzer from Source Source: https://rust-analyzer.github.io/book/rust_analyzer_binary.html Installs rust-analyzer from source using cargo xtask. Requires the latest stable Rust toolchain. ```bash git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer cargo xtask install --server ``` -------------------------------- ### Install rust-analyzer Extension from VSIX Source: https://rust-analyzer.github.io/book/vs_code.html Use this command to install the rust-analyzer extension from a downloaded VSIX file. ```bash code --install-extension /path/to/rust-analyzer.vsix ``` -------------------------------- ### Install TypeScript Dependencies Source: https://rust-analyzer.github.io/book/print.html Navigate to the code directory and install necessary TypeScript dependencies using npm. ```bash __ cd editors/code npm ci ``` -------------------------------- ### Generate Rustdoc Example Source: https://rust-analyzer.github.io/book/assists.html Generates a rustdoc example when editing an item's documentation. Use to quickly scaffold documentation tests. ```rust __ /// Adds two numbers.┃ pub fn add(a: i32, b: i32) -> i32 { a + b } ``` ```rust __ /// Adds two numbers. /// /// # Examples /// /// ``` /// use ra_test_fixture::add; /// /// assert_eq!(add(a, b), ); /// ``` pub fn add(a: i32, b: i32) -> i32 { a + b } ``` -------------------------------- ### Install Rust-Analyzer Language Server Source: https://rust-analyzer.github.io/book/print.html Installs only the language server for rust-analyzer. Use `--code-bin` to target a specific editor and `--dev-rel` to build in release mode with debug info. ```bash # Install only the language server cargo xtask install --server \ --code-bin code-insiders \ --dev-rel ``` -------------------------------- ### Install rust-analyzer using rustup Source: https://rust-analyzer.github.io/book/rust_analyzer_binary.html Adds the rust-analyzer component to your rustup installation. ```bash rustup component add rust-analyzer ``` -------------------------------- ### Install rust-analyzer Language Server Locally Source: https://rust-analyzer.github.io/book/contributing/setup.html Installs the rust-analyzer language server, targeting a specific editor and building in release mode with debug info. Use this to set up your local development environment. ```bash cargo xtask install --server \ --code-bin code-insiders \ --dev-rel ``` -------------------------------- ### Example: Discover Project via Buildfile Source: https://rust-analyzer.github.io/book/configuration.html Demonstrates invoking the discover command with a build file argument. This method is used to update an existing workspace configuration. ```shell rust-project develop-json '{ "buildfile": "myproject/BUCK" }' ``` -------------------------------- ### Install Rust Standard Library Source Source: https://rust-analyzer.github.io/book/installation.html Manually install the Rust standard library source code using rustup. This is required for rust-analyzer to understand the Rust source. ```bash rustup component add rust-src ``` -------------------------------- ### Example Runnable Configuration in rust-project.json Source: https://rust-analyzer.github.io/book/non_cargo_based_projects.html Illustrates how to configure runnables for executing tests, specifying the program, arguments, and current working directory. ```json { "program": "buck", "args": [ "test", "{label}", "--", "{test_id}", "--print-passing-details" ], "cwd": "/home/user/repo-root/", "kind": "testOne" } ``` -------------------------------- ### Cargo Check Command Example Source: https://rust-analyzer.github.io/book/print.html An example of a command to run cargo check for diagnostics. The command must be specified as an array of arguments. ```json [ "cargo", "check", "--workspace", "--message-format=json", "--all-targets" ] ``` -------------------------------- ### Install rust-analyzer on Arch Linux Source: https://rust-analyzer.github.io/book/rust_analyzer_binary.html Installs rust-analyzer using pacman on Arch Linux. Choose between the latest tagged source or latest Git version. ```bash pacman -S rust-analyzer ``` -------------------------------- ### Example: Discover Project via Path Source: https://rust-analyzer.github.io/book/configuration.html Illustrates how to invoke the discover command with a project path argument. This is used by rust-analyzer to find and generate a `rust-project.json` for a workspace. ```shell rust-project develop-json '{ "path": "myproject/src/main.rs" }' ``` -------------------------------- ### Join Lines Example (After) Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Demonstrates the result after the 'experimental/joinLines' request is processed, where curly braces are removed and lines are joined. ```rust fn main() { let x = 92; } ``` -------------------------------- ### Join Lines Example (Before) Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Shows the code state before the 'experimental/joinLines' request is applied, with a cursor positioned within a block that will be joined. ```rust fn main() { /*cursor here*/let x = { 92 }; } ``` -------------------------------- ### Cargo Check Command Example Source: https://rust-analyzer.github.io/book/configuration.html This example shows how to configure the command rust-analyzer uses for diagnostics on save. It specifies running `cargo check` with specific arguments for workspace, message format, and all targets. ```json ["cargo", "check", "--workspace", "--message-format=json", "--all-targets"] ``` -------------------------------- ### Install TypeScript Dependencies Source: https://rust-analyzer.github.io/book/contributing/debugging.html Run this command in the `editors/code` directory to install all necessary TypeScript dependencies for the VS Code extension. ```bash cd editors/code npm ci ``` -------------------------------- ### Install coc-rust-analyzer with coc.nvim Source: https://rust-analyzer.github.io/book/other_editors.html Install the rust-analyzer extension for coc.nvim. This extension supports automatic installation/upgrades and mirrors VSCode configurations and commands. ```vimscript run :CocInstall coc-rust-analyzer ``` -------------------------------- ### JSONL Finished Event Example Source: https://rust-analyzer.github.io/book/configuration.html An example of a finished event in JSONL format, detailing the successful completion of project discovery. It includes the build file and project data, with comments for clarity. ```json { // the internally-tagged representation of the enum. "kind": "finished", // the file used by a non-Cargo build system to define // a package or target. "buildfile": "rust-analyzer/BUCK", // the contents of a rust-project.json, elided for brevity "project": { "sysroot": "foo", "crates": [] } } ``` -------------------------------- ### Example Usage of Matching Brace Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Demonstrates a scenario where the 'matchingBrace' LSP method can be used to find the position of a '<' character. ```rust fn main() { let x: Vec<()>/*cursor here*/ = vec![]; } ``` -------------------------------- ### Run Linter and Tests in Code Editor Source: https://rust-analyzer.github.io/book/contributing/index.html Install npm dependencies and run the linter for changes in the `editors/code` directory. ```bash cd editors/code npm ci npm run lint ``` -------------------------------- ### Goto Parent Module Example Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Illustrates how the 'experimental/parentModule' request can be used to navigate to a parent module declaration, such as a 'mod foo;' statement. ```rust // src/main.rs mod foo; // src/foo.rs /* cursor here*/ ``` -------------------------------- ### JSONL Progress Event Example Source: https://rust-analyzer.github.io/book/configuration.html An example of a progress event in JSONL format, indicating the status of the rust-project.json generation. This format is used by the discover command to provide real-time feedback. ```json {"kind":"progress","message":"generating rust-project.json"} ``` -------------------------------- ### Join Lines Code Example Source: https://rust-analyzer.github.io/book/print.html Demonstrates the 'experimental/joinLines' request by showing code before and after the operation. Curly braces are automatically removed. ```rust fn main() { /*cursor here*/let x = { 92 }; } ``` ```rust fn main() { let x = 92; } ``` -------------------------------- ### Install vim-lsp Plugin Source: https://rust-analyzer.github.io/book/other_editors.html Add the vim-lsp plugin to your .vimrc to enable LSP support. ```vimscript Plug 'prabirshrestha/vim-lsp' ``` -------------------------------- ### Open Cargo.toml Request Example Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Illustrates the context for the experimental/openCargoToml request, showing a typical file structure where the cursor might be placed. ```rust // Cargo.toml [package] // src/main.rs /* cursor here*/ ``` -------------------------------- ### experimental/openCargoToml Source: https://rust-analyzer.github.io/book/print.html Opens the Cargo.toml file for the current project. This is an experimental feature and returns a link to the start of the [package] section. ```APIDOC ## experimental/openCargoToml ### Description This request is sent from client to server to open the current project’s Cargo.toml. ### Method experimental/openCargoToml ### Request OpenCargoTomlParams ### Response Location | null ``` -------------------------------- ### Auto Import Basic Example Source: https://rust-analyzer.github.io/book/features.html Demonstrates how rust-analyzer suggests imports for unqualified names within the current scope. The name must contain all input symbols in order, with case sensitivity depending on the input. ```rust fn main() { pda$0 } # pub mod std { pub mod marker { pub struct PhantomData { } } } ``` ```rust use std::marker::PhantomData; fn main() { PhantomData } # pub mod std { pub mod marker { pub struct PhantomData { } } } ``` -------------------------------- ### Code Action Example: Importing Entry Source: https://rust-analyzer.github.io/book/print.html Demonstrates a scenario where invoking a code action at a specific cursor position would offer multiple import options for 'Entry', grouped under a common 'import' action. ```rust __ fn main() { let x: Entry/*cursor here*/ = todo!(); } ``` -------------------------------- ### Auto-Import Assist Example Source: https://rust-analyzer.github.io/book/features.html Demonstrates the structured import grouping used by the auto-import assist. Imports are ordered by scope: std/core, external crates, current crate, current module, and super module. ```rust use std::fs::File; use itertools::Itertools; use syntax::ast; use crate::utils::insert_use; use self::auto_import; use super::AssistContext; ``` -------------------------------- ### experimental/runnables Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html This method is sent from the client to the server to get a list of items that can be run, such as tests or binaries. The server advertises its support for runnables via its capabilities. ```APIDOC ## experimental/runnables ### Description This method is used to request a list of runnable items (e.g., tests, binaries, `cargo check -p`) from the language server. The server must advertise its support for runnables in its capabilities. ### Method EXPERIMENTAL ### Endpoint `experimental/runnables` ### Parameters #### Request Body - **textDocument** (TextDocumentIdentifier) - Required - The document for which to compute runnables. - **position** (Position) - Optional - If null, compute runnables for the whole file. ### Response #### Success Response - **Runnable[]** - An array of runnable items. ### Runnable Interface ``` interface Runnable { label: string; /// If this Runnable is associated with a specific function/module, etc., the location of this item location?: LocationLink; /// Running things is necessary technology specific, `kind` needs to be advertised via server capabilities, // the type of `args` is specific to `kind`. The actual running is handled by the client. kind: string; args: any; } ``` #### Cargo Runnable Args ``` { /** * Environment variables to set before running the command. */ environment?: Record; /** * The working directory to run the command in. */ cwd: string; /** * The workspace root directory of the cargo project. */ workspaceRoot?: string; /** * The cargo command to run. */ cargoArgs: string[]; /** * Arguments to pass to the executable, these will be passed to the command after a `--` argument. */ executableArgs: string[]; /** * Command to execute instead of `cargo`. */ overrideCargo?: string; } ``` #### Shell Runnable Args ``` { /** * Environment variables to set before running the command. */ environment?: Record; /** * The working directory to run the command in. */ cwd: string; kind: string; program: string; args: string[]; } ``` ``` -------------------------------- ### Structural Search Replace Example Source: https://rust-analyzer.github.io/book/features.html Demonstrates using structural search and replace with named wildcards to refactor code. Paths must resolve in the current context. Placeholders can have constraints. ```rust __ // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)] // BEFORE String::from(foo(y + 5, z)) // AFTER String::from((y + 5).foo(z)) ``` -------------------------------- ### VS Code Settings for rust-analyzer Path Source: https://rust-analyzer.github.io/book/contributing/index.html Configure VS Code to use the rust-analyzer binary from your PATH. This is necessary when running the 'Run Installed Extension' launch configuration. ```json { "rust-analyzer.server.path": "rust-analyzer" } ``` -------------------------------- ### Configure Kakoune for rust-analyzer LSP Source: https://rust-analyzer.github.io/book/print.html This snippet configures Kakoune to enable LSP, auto-formatting on save, and inlay hints for rust-analyzer. It assumes `kak-lsp` is installed and configured. ```kakoune eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak. hook global WinSetOption filetype=rust %{ # Enable LSP lsp-enable-window # Auto-formatting on save hook window BufWritePre .* lsp-formatting-sync # Configure inlay hints (only on save) hook window -group rust-inlay-hints BufWritePost .* rust-analyzer-inlay-hints hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-inlay-hints } } ``` -------------------------------- ### Set Up Project Directories for Release Source: https://rust-analyzer.github.io/book/contributing/index.html Ensure rust-analyzer, rust-analyzer.github.io, and rust-lang/rust repositories are checked out in the same directory for the release process. ```shell ./rust-analyzer ./rust-analyzer.github.io ./rust-rust-analyzer # Note the name! ``` -------------------------------- ### Automatically Initialize Eglot in Rust Mode Source: https://rust-analyzer.github.io/book/other_editors.html This hook ensures Eglot is automatically started when a Rust buffer is opened. It's a common setup for Eglot users. ```emacs-lisp (add-hook 'rust-mode-hook 'eglot-ensure) ``` -------------------------------- ### Automatically Initialize LSP Mode in Rust Mode Source: https://rust-analyzer.github.io/book/other_editors.html This hook ensures LSP Mode is deferred and started when a Rust buffer is opened. It's a common setup for LSP Mode users. ```emacs-lisp (add-hook 'rust-mode-hook 'lsp-deferred) ``` -------------------------------- ### Example Rust Code for Code Action Grouping Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Illustrates a scenario where invoking a code action at a specific cursor position might yield multiple import suggestions. These suggestions are intended to be grouped under a common 'import' action in the UI. ```rust fn main() { let x: Entry/*cursor here*/ = todo!(); } ``` -------------------------------- ### Check Project and Reinstall Server Source: https://rust-analyzer.github.io/book/print.html Runs `cargo check` to verify the project and then reinstalls the language server with the specified options. ```bash cargo check cargo xtask install --server --code-bin code-insiders --dev-rel ``` -------------------------------- ### Configure vim-lsp with Initialization Options Source: https://rust-analyzer.github.io/book/other_editors.html Register rust-analyzer with vim-lsp and enable proc-macro support and build scripts via initialization options. ```vimscript if executable('rust-analyzer') au User lsp_setup call lsp#register_server({ \ 'name': 'Rust Language Server', \ 'cmd': {server_info->['rust-analyzer']}, \ 'whitelist': ['rust'], \ 'initialization_options': { \ 'cargo': { \ 'buildScripts': { \ 'enable': v:true, \ }, \ }, \ 'procMacro': { \ 'enable': v:true, \ }, \ }, \ }) endif ``` -------------------------------- ### Analyze Performance with analysis-stats Source: https://rust-analyzer.github.io/book/contributing/index.html Measure time for from-scratch analysis by running the analysis-stats command with a specific path. ```shell cargo run --release -p rust-analyzer -- analysis-stats ../chalk/ ``` -------------------------------- ### Hierarchical Profiler Output Example Source: https://rust-analyzer.github.io/book/contributing/architecture.html An example of the output generated by the hierarchical profiler (`hprof`), enabled via the `RA_PROFILE` environment variable. It shows time spent in various functions, aiding in performance analysis. ```text 85ms - handle_completion 68ms - import_on_the_fly 67ms - import_assets::search_for_relative_paths 0ms - crate_def_map:wait (804 calls) 0ms - find_path (16 calls) 2ms - find_similar_imports (1 calls) 0ms - generic_params_query (334 calls) 59ms - trait_solve_query (186 calls) 0ms - Semantics::analyze_impl (1 calls) 1ms - render_resolution (8 calls) 0ms - Semantics::analyze_impl (5 calls) ``` -------------------------------- ### VS Code Insiders User Settings for Local Server Source: https://rust-analyzer.github.io/book/contributing/setup.html Configures Visual Studio Code Insiders to use a locally installed rust-analyzer binary. Ensure the `rust-analyzer.server.path` is set to the correct path provided after installation. ```json { "rust-analyzer.server.path": "" } ``` -------------------------------- ### Check Project and Reinstall Server Source: https://rust-analyzer.github.io/book/contributing/setup.html Runs a project check and then reinstalls the rust-analyzer server after adding debugging statements. This ensures the changes are reflected and the server is ready for testing. ```bash cargo check cargo xtask install --server --code-bin code-insiders --dev-rel ``` -------------------------------- ### Check rust-analyzer Version Source: https://rust-analyzer.github.io/book/troubleshooting.html Verify the installed version of rust-analyzer. Update if the version is older than a week. ```bash rust-analyzer --version ``` -------------------------------- ### Flip Range Expression Operands Source: https://rust-analyzer.github.io/book/assists.html Flips the operands of a range expression. This changes the start and end points of the range. ```rust fn main() { let _ = 90..2; } ``` ```rust fn main() { let _ = 2..90; } ``` -------------------------------- ### experimental/changeTestState Notification Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Reports changes in the state of a specific test. The state can be passed, failed, started, enqueued, or skipped. ```APIDOC ## experimental/changeTestState ### Description Reports changes in the state of a specific test. The state can be passed, failed, started, enqueued, or skipped. ### Method Notification ### Endpoint experimental/changeTestState ### Parameters #### Request Body - **testId** (string) - Required - The ID of the test whose state is changing. - **state** (TestState) - Required - The new state of the test. - **TestState**: - `{ tag: "passed" }` - `{ tag: "failed", message: string }` - The standard error of the test, containing the panic message. - `{ tag: "started" }` - `{ tag: "enqueued" }` - `{ tag: "skipped" }` ``` -------------------------------- ### Configure nvim-lspconfig for Rust-analyzer Source: https://rust-analyzer.github.io/book/other_editors.html Set up rust-analyzer using nvim-lspconfig in Neovim 0.5+. This includes enabling LSP, configuring settings, and setting up autocommands for features like inlay hints and completion. ```lua lua << EOF -- You can pass LSP settings to the server: vim.lsp.config("rust_analyzer", { settings = { ["rust-analyzer"] = { imports = { granularity = { group = "module", }, prefix = "self", }, cargo = { buildScripts = { enable = true, }, }, procMacro = { enable = true }, }, }, }) -- You can enable different LSP features vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local client = assert(vim.lsp.get_client_by_id(ev.data.client_id)) -- Inlay hints display inferred types, etc. if client:supports_method("inlayHint/resolve") then vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) end -- Completion can be invoked via ctrl+x ctrl+o. It displays a list of -- names inferred from the context (e.g. method names, variables, etc.) if client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, ev.buf, {}) end end, }) EOF ``` -------------------------------- ### Example Rust Code with Shadowing Source: https://rust-analyzer.github.io/book/contributing/syntax.html Demonstrates variable shadowing in Rust, where a new variable with the same name redefines the previous one. ```rust fn main() { let x = 90i8; let x = x + 2; let x = 90i64; let x = x + 2; } ``` -------------------------------- ### Configure rust-analyzer Server Path Source: https://rust-analyzer.github.io/book/vs_code.html Manually set the path to the rust-analyzer server binary in VS Code's settings.json for unsupported platforms. ```json { "rust-analyzer.server.path": "~/.local/bin/rust-analyzer-linux" } ``` -------------------------------- ### Get Failed Obligations Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Retrieves information about failed trait obligations at a specific position. Useful for debugging or development of rust-analyzer. ```json { "method": "rust-analyzer/getFailedObligations", "params": { "textDocument": { "uri": "file:///path/to/your/code.rs" }, "position": { "line": 10, "character": 5 } } } ``` -------------------------------- ### List of Features to Activate Source: https://rust-analyzer.github.io/book/print.html Defines a list of features to activate for cargo builds. Set to "all" to pass --all-features. Defaults to an empty list. ```toml features = [] ``` -------------------------------- ### Enable Proc-Macro Support via LSP Initialization Source: https://rust-analyzer.github.io/book/configuration.html This JSON configuration is sent as part of the `initializationOptions` field in the LSP `InitializeParams` message to enable proc-macro support and build script execution. ```json { "cargo": { "buildScripts": { "enable": true, }, }, "procMacro": { "enable": true, } } ``` -------------------------------- ### Example Parsed Syntax Tree Source: https://rust-analyzer.github.io/book/contributing/syntax.html Illustrates the hierarchical structure of a parsed code snippet 'fn f() { 90 + 2 }' as a syntax tree. ```text FN@0..17 FN_KW@0..2 "fn" WHITESPACE@2..3 " " NAME@3..4 IDENT@3..4 "f" PARAM_LIST@4..6 L_PAREN@4..5 "(" R_PAREN@5..6 ")" WHITESPACE@6..7 " " BLOCK_EXPR@7..17 L_CURLY@7..8 "{" WHITESPACE@8..9 " " BIN_EXPR@9..15 LITERAL@9..11 INT_NUMBER@9..11 "90" WHITESPACE@11..12 " " PLUS@12..13 "+" WHITESPACE@13..14 " " LITERAL@14..15 INT_NUMBER@14..15 "2" WHITESPACE@15..16 " " R_CURLY@16..17 "} ``` -------------------------------- ### DiscoverTestParams Interface Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Defines the parameters for the `experimental/discoverTest` request. Use this to specify a test ID for resolving its children or omit it to get top-level tests. ```typescript interface DiscoverTestParams { // The test that we need to resolve its children. If not present, // the response should return top level tests. testId?: string | undefined; } ``` -------------------------------- ### Run Tests Source: https://rust-analyzer.github.io/book/contributing/index.html Build and test the rust-analyzer project using Cargo. This is the primary command for verifying your changes. ```bash cargo test ``` -------------------------------- ### Example Rust Code for Hover Range Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Illustrates a Rust code snippet where triggering a hover within the selection is expected to show the type of the expression. ```rust fn main() { let expression = $01 + 2 * 3$0; } ``` -------------------------------- ### experimental/parentModule Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Handles the 'Goto Parent Module' editor action by providing a link to the parent module declaration. ```APIDOC ## experimental/parentModule ### Description This request is sent from the client to the server to handle the “Goto Parent Module” editor action. It returns a link to the parent module declaration. ### Method experimental/parentModule ### Request TextDocumentPositionParams ### Response Location | Location[] | LocationLink[] | null ``` -------------------------------- ### TestState Type Source: https://rust-analyzer.github.io/book/contributing/lsp-extensions.html Defines the possible states for a test during execution. Includes states like 'passed', 'failed' (with error message), 'started', 'enqueued', and 'skipped'. ```typescript type TestState = { tag: "passed" } | { tag: "failed"; // The standard error of the test, containing the panic message. Clients should // render it similar to a terminal, and e.g. handle ansi colors. message: string; } | { tag: "started" } | { tag: "enqueued" } | { tag: "skipped" }; ``` -------------------------------- ### Get Failed Obligations Source: https://rust-analyzer.github.io/book/print.html Retrieves information about failed trait obligations at a specific text document position. Useful for debugging or internal rust-analyzer development. ```rust rust-analyzer/getFailedObligations ``` -------------------------------- ### Show Full Signature in Completion Docs Source: https://rust-analyzer.github.io/book/configuration.html Configures whether to display full function or method signatures in completion documentation. Defaults to `false`. ```toml completion.show_full_signature = false ``` -------------------------------- ### Configure Kakoune for rust-analyzer LSP Source: https://rust-analyzer.github.io/book/other_editors.html This snippet configures Kakoune to enable LSP, auto-formatting on save, and inlay diagnostics for rust-analyzer. It assumes `kak-lsp` is installed and configured. ```kakoune eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak. hook global WinSetOption filetype=rust %{ # Enable LSP lsp-enable-window # Auto-formatting on save hook window BufWritePre .* lsp-formatting-sync # Configure inlay hints (only on save) hook window -group rust-inlay-hints BufWritePost .* rust-analyzer-inlay-hints hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-inlay-hints } } ``` -------------------------------- ### Enable Specific Cfg Options Source: https://rust-analyzer.github.io/book/configuration.html Configure a list of `cfg` options with specific values. Use `"key"` for boolean flags, `"key=value"` for options with values, and `"!key"` to disable. ```json [ "debug_assertions", "miri" ] ```