diff --git a/generated_assists.adoc b/generated_assists.adoc index 92f4b17a..1cb9d242 100644 --- a/generated_assists.adoc +++ b/generated_assists.adoc @@ -1610,7 +1610,7 @@ fn handle(action: Action) { [discrete] === `move_arm_cond_to_match_guard` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L76[move_guard.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L77[move_guard.rs] Moves if expression from match arm body into a guard. @@ -1682,7 +1682,7 @@ fn t() {} [discrete] === `move_guard_to_arm_body` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L8[move_guard.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L9[move_guard.rs] Moves match guard into match arm body. @@ -1871,6 +1871,23 @@ fn main() { ``` +[discrete] +=== `reformat_number_literal` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/number_representation.rs#L7[number_representation.rs] + +Adds or removes seprators from integer literal. + +.Before +```rust +const _: i32 = 1012345┃; +``` + +.After +```rust +const _: i32 = 1_012_345; +``` + + [discrete] === `remove_dbg` **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/remove_dbg.rs#L9[remove_dbg.rs] @@ -2042,7 +2059,7 @@ fn main() { [discrete] === `replace_derive_with_manual_impl` -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L22[replace_derive_with_manual_impl.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L23[replace_derive_with_manual_impl.rs] Converts a `derive` impl into a manual one. diff --git a/generated_config.adoc b/generated_config.adoc index 9f6f0460..494051b3 100644 --- a/generated_config.adoc +++ b/generated_config.adoc @@ -141,7 +141,47 @@ Only applies when `#rust-analyzer.completion.addCallParenthesis#` is set. -- Whether to add parenthesis when completing functions. -- -[[rust-analyzer.completion.snippets]]rust-analyzer.completion.snippets (default: `{}`):: +[[rust-analyzer.completion.snippets]]rust-analyzer.completion.snippets (default: `{ + "Arc::new": { + "postfix": "arc", + "body": "Arc::new(${receiver})", + "requires": "std::sync::Arc", + "description": "Put the expression into an `Arc`", + "scope": "expr" + }, + "Rc::new": { + "postfix": "rc", + "body": "Rc::new(${receiver})", + "requires": "std::rc::Rc", + "description": "Put the expression into an `Rc`", + "scope": "expr" + }, + "Box::pin": { + "postfix": "pinbox", + "body": "Box::pin(${receiver})", + "requires": "std::boxed::Box", + "description": "Put the expression into a pinned `Box`", + "scope": "expr" + }, + "Ok": { + "postfix": "ok", + "body": "Ok(${receiver})", + "description": "Wrap the expression in a `Result::Ok`", + "scope": "expr" + }, + "Err": { + "postfix": "err", + "body": "Err(${receiver})", + "description": "Wrap the expression in a `Result::Err`", + "scope": "expr" + }, + "Some": { + "postfix": "some", + "body": "Some(${receiver})", + "description": "Wrap the expression in an `Option::Some`", + "scope": "expr" + } + }`):: + -- Custom completion snippets. diff --git a/generated_features.adoc b/generated_features.adoc index a724616a..35bc0477 100644 --- a/generated_features.adoc +++ b/generated_features.adoc @@ -174,7 +174,7 @@ Displays the ItemTree of the currently open file, for debugging. === Expand Macro Recursively -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/expand_macro.rs#L15[expand_macro.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/expand_macro.rs#L16[expand_macro.rs] Shows the full macro expansion of the macro at current cursor. @@ -862,8 +862,55 @@ The `body` field also has access to placeholders as visible in the example as `$ These placeholders take the form of `$number` or `${number:placeholder_text}` which can be traversed as tabstop in ascending order starting from 1, with `$0` being a special case that always comes last. -There is also a special placeholder, `${receiver}`, which will be replaced by the receiver expression for postfix snippets, or nothing in case of normal snippets. -It does not act as a tabstop. +There is also a special placeholder, `${receiver}`, which will be replaced by the receiver expression for postfix snippets, or a `$0` tabstop in case of normal snippets. +This replacement for normal snippets allows you to reuse a snippet for both post- and prefix in a single definition. + +For the VSCode editor, rust-analyzer also ships with a small set of defaults which can be removed +by overwriting the settings object mentioned above, the defaults are: +[source,json] +---- +{ + "Arc::new": { + "postfix": "arc", + "body": "Arc::new(${receiver})", + "requires": "std::sync::Arc", + "description": "Put the expression into an `Arc`", + "scope": "expr" + }, + "Rc::new": { + "postfix": "rc", + "body": "Rc::new(${receiver})", + "requires": "std::rc::Rc", + "description": "Put the expression into an `Rc`", + "scope": "expr" + }, + "Box::pin": { + "postfix": "pinbox", + "body": "Box::pin(${receiver})", + "requires": "std::boxed::Box", + "description": "Put the expression into a pinned `Box`", + "scope": "expr" + }, + "Ok": { + "postfix": "ok", + "body": "Ok(${receiver})", + "description": "Wrap the expression in a `Result::Ok`", + "scope": "expr" + }, + "Err": { + "postfix": "err", + "body": "Err(${receiver})", + "description": "Wrap the expression in a `Result::Err`", + "scope": "expr" + }, + "Some": { + "postfix": "some", + "body": "Some(${receiver})", + "description": "Wrap the expression in an `Option::Some`", + "scope": "expr" + } +} +---- === View Crate Graph diff --git a/manual.adoc b/manual.adoc index 1db6cb5c..1335f8df 100644 --- a/manual.adoc +++ b/manual.adoc @@ -74,6 +74,8 @@ The server binary is stored in: * macOS: `~/Library/Application\ Support/Code/User/globalStorage/matklad.rust-analyzer` * Windows: `%APPDATA%\Code\User\globalStorage\matklad.rust-analyzer` +However, if you are using a version of the extension with a bundled server binary and you are not running NixOS, the server binary might be instead running from: `~/.vscode/extensions/matklad.rust-analyzer-VERSION`. + Note that we only support two most recent versions of VS Code. ==== Updates @@ -445,7 +447,7 @@ 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. -To see more logs, set `RA_LOG=info` environmental variable. +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 `Output > Rust Analyzer Language Server Trace`. @@ -624,7 +626,7 @@ Relative paths are interpreted relative to `rust-project.json` file location or See https://github.com/rust-analyzer/rust-project.json-example for a small example. -You can set `RA_LOG` environmental variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading. +You can set the `RA_LOG` environment 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. diff --git a/thisweek/_posts/2021-10-18-changelog-99.adoc b/thisweek/_posts/2021-10-18-changelog-99.adoc index dccd4cd3..304e100e 100644 --- a/thisweek/_posts/2021-10-18-changelog-99.adoc +++ b/thisweek/_posts/2021-10-18-changelog-99.adoc @@ -36,10 +36,10 @@ image::https://user-images.githubusercontent.com/308347/137636737-06a3d47d-f647- * pr:10538[] (first contribution) make brace matching prefer the one to the right of the cursor. * pr:10542[] (first contribution) use workspace `cargo` to fetch `rust-src` metadata. * pr:10543[] (first contribution) narrow "Add missing match arms" assist range. +* pr:10491[] (first contribution) support nested type in "Replace `if-let` with ``match``". * pr:10533[] fix `AssistContext` panic on sole whitespace selection. * pr:10503[] only include targets of packages that are workspace members. * pr:10517[] report `cargo check` failures. -* pr:10491[] support nested type in "Replace `if-let` with ``match``". * pr:10552[] fix "Missing fields" diagnostic fix replacing wrong text ranges. * pr:10557[] fix qualified path completion not completing macros. * pr:10562[] fix clippy attribute completions always inserting `clippy::`. diff --git a/thisweek/_posts/2021-12-20-changelog-108.adoc b/thisweek/_posts/2021-12-20-changelog-108.adoc new file mode 100644 index 00000000..86f375cc --- /dev/null +++ b/thisweek/_posts/2021-12-20-changelog-108.adoc @@ -0,0 +1,46 @@ += Changelog #108 +:sectanchors: +:page-layout: post + +Commit: commit:0add6e95e58633fde2fff0bccaf6c7d71ebc130f[] + +Release: release:2021-12-20[] + +== Sponsors + +**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or +https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. + +== New Features + +* pr:11035[] include clippy lint groups in autocomplete: ++ +video::https://user-images.githubusercontent.com/23740172/146465758-bc7d5cdd-e2fb-48d6-abf7-804ba859c9b1.mov[] +* pr:10998[] add number representation assists: ++ +image::https://user-images.githubusercontent.com/462486/145726792-47700215-26f2-4fdc-9520-63d1487901e5.png[] ++ +image::https://user-images.githubusercontent.com/462486/145726802-f528a2f7-9159-41d3-b459-fc3fae033e60.png[] +* pr:11053[] (possibly breaking) publish platform-specific Code extensions. + + +== Fixes + +* pr:11054[] (first contribution) don't trim twice in `Unwrap block`. +* pr:11017[] (first contribution) support `Move condition to guard` with an `else` branch. +* pr:11030[] add missing comma in `Move condition to guard`. +* pr:11043[] fix incorrect `mismatched argument count` diagnostic with `std::arch` functions. +* pr:11050[] show primitive docs when hovering `fn` keyword inside function pointer type. +* pr:11004[] infer associated methods in local scope. +* pr:11040[] don't duplicate attribute completions. +* pr:11000[] insert whitespace into associated items for `Implement missing members` for macro-generated structs. +* pr:11002[] add support for v6 macro metadata format for recent nightly support. + + +== Internal Improvements + +* pr:10527[] remove a few snippet completions, replace them with user snippets definitions in VSCode. +* pr:11046[] move all lexing to the parser crate. +* pr:11009[] extract doc-links tests into a separate module. +* pr:11021[] use default XCode version on MacOS 11 builders. +* pr:11029[] refactor release workflow to reduce duplication, upgrade to MacOS 11 builders, set target version to 10.15. +* pr:11047[] prepare Code extension for server bundling.