Skip to content

Changelog #78 #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions generated_assists.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn main() {

[discrete]
=== `auto_import`
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/auto_import.rs#L67[auto_import.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/auto_import.rs#L66[auto_import.rs]

If the name is unresolved, provides all possible imports for it.

Expand Down Expand Up @@ -909,16 +909,16 @@ struct Person {

impl Person {
/// Get a reference to the person's name.
fn name(&self) -> &String {
&self.name
fn name(&self) -> &str {
self.name.as_str()
}
}
```


[discrete]
=== `generate_getter_mut`
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_getter_mut.rs#L9[generate_getter_mut.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_getter.rs#L35[generate_getter.rs]

Generate a mut getter method.

Expand All @@ -937,7 +937,7 @@ struct Person {

impl Person {
/// Get a mutable reference to the person's name.
fn name_mut(&mut self) -> &mut String {
fn name_mut(&mut self) -> &mut String {
&mut self.name
}
}
Expand Down
28 changes: 26 additions & 2 deletions generated_config.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[[rust-analyzer.assist.importMergeBehavior]]rust-analyzer.assist.importMergeBehavior (default: `"crate"`)::
[[rust-analyzer.assist.importGranularity]]rust-analyzer.assist.importGranularity (default: `"crate"`)::
+
--
The strategy to use when inserting new imports or merging imports.
How imports should be grouped into use statements.
--
[[rust-analyzer.assist.importEnforceGranularity]]rust-analyzer.assist.importEnforceGranularity (default: `false`)::
+
--
Whether to enforce the import granularity setting for all files. If set to false rust-analyzer will try to keep import styles consistent per file.
--
[[rust-analyzer.assist.importPrefix]]rust-analyzer.assist.importPrefix (default: `"plain"`)::
+
Expand Down Expand Up @@ -179,6 +184,15 @@ Controls file watching implementation.
--
These directories will be ignored by rust-analyzer.
--
[[rust-analyzer.highlighting.strings]]rust-analyzer.highlighting.strings (default: `true`)::
+
--
Use semantic tokens for strings.

In some editors (e.g. vscode) semantic tokens override other highlighting grammars.
By disabling semantic tokens for strings, other grammars can be used to highlight
their contents.
--
[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
+
--
Expand Down Expand Up @@ -332,3 +346,13 @@ Additional arguments to `rustfmt`.
Advanced option, fully override the command rust-analyzer uses for
formatting.
--
[[rust-analyzer.workspace.symbol.search.scope]]rust-analyzer.workspace.symbol.search.scope (default: `"workspace"`)::
+
--
Workspace symbol search scope.
--
[[rust-analyzer.workspace.symbol.search.kind]]rust-analyzer.workspace.symbol.search.kind (default: `"only_types"`)::
+
--
Workspace symbol search kind.
--
47 changes: 37 additions & 10 deletions generated_features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@ use self::auto_import;
use super::AssistContext;
```

.Merge Behavior
.Import Granularity

It is possible to configure how use-trees are merged with the `importMergeBehavior` setting.
It is possible to configure how use-trees are merged with the `importGranularity` setting.
It has the following configurations:

- `full`: This setting will cause auto-import to always completely merge use-trees that share the
same path prefix while also merging inner trees that share the same path-prefix. This kind of
- `crate`: Merge imports from the same crate into a single use statement. This kind of
nesting is only supported in Rust versions later than 1.24.
- `last`: This setting will cause auto-import to merge use-trees as long as the resulting tree
will only contain a nesting of single segment paths at the very end.
- `none`: This setting will cause auto-import to never merge use-trees keeping them as simple
paths.
- `module`: Merge imports from the same module into a single use statement.
- `item`: Don't merge imports at all, creating one import per item.
- `preserve`: Do not change the granularity of any imports. For auto-import this has the same
effect as `item`.

In `VS Code` the configuration for this is `rust-analyzer.assist.importMergeBehavior`.
In `VS Code` the configuration for this is `rust-analyzer.assist.importGranularity`.

.Import Prefix

Expand All @@ -69,6 +68,20 @@ In `VS Code` the configuration for this is `rust-analyzer.assist.importPrefix`.
image::https://user-images.githubusercontent.com/48062697/113020673-b85be580-917a-11eb-9022-59585f35d4f8.gif[]


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Debug ItemTree
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/view_item_tree.rs#L5[view_item_tree.rs]

Displays the ItemTree of the currently open file, for debugging.

|===
| Editor | Action Name

| VS Code | **Rust Analyzer: Debug ItemTree**
|===


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Expand Macro Recursively
Expand Down Expand Up @@ -140,6 +153,15 @@ Shows all references of the item at the cursor location
image::https://user-images.githubusercontent.com/48062697/113020670-b7c34f00-917a-11eb-8003-370ac5f2b3cb.gif[]


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Folding
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/folding_ranges.rs#L30[folding_ranges.rs]

Defines folding regions for curly braced blocks, runs of consecutive import
statements, and `region` / `endregion` comment markers.


// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Format String Completion
Expand Down Expand Up @@ -460,7 +482,7 @@ The simplest way to use this feature is via the context menu:
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

== Rename
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/references/rename.rs#L75[rename.rs]
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/references/rename.rs#L77[rename.rs]

Renames the item below the cursor and all of its references

Expand Down Expand Up @@ -655,6 +677,11 @@ search. Specifically,
That is, `#` switches from "types" to all symbols, `*` switches from the current
workspace to dependencies.

Note that filtering does not currently work in VSCode due to the editor never
sending the special symbols to the language server. Instead, you can configure
the filtering via the `rust-analyzer.workspace.symbol.search.scope` and
`rust-analyzer.workspace.symbol.search.kind` settings.

|===
| Editor | Shortcut

Expand Down
5 changes: 4 additions & 1 deletion manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ nvim_lsp.rust_analyzer.setup({
settings = {
["rust-analyzer"] = {
assist = {
importMergeBehavior = "last",
importGranularity = "module",
importPrefix = "by_self",
},
cargo = {
Expand All @@ -323,6 +323,8 @@ EOF

See https://sharksforarms.dev/posts/neovim-rust/ for more tips on getting started.

Check out https://github.com/simrat39/rust-tools.nvim for a batteries included rust-analyzer setup for neovim.

// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository

=== vim-lsp
Expand Down Expand Up @@ -629,6 +631,7 @@ Here is a **non-exhaustive** list of ways to make rust-analyzer execute arbitrar

* proc macros and build scripts are executed by default
* `.cargo/config` can override `rustc` with an arbitrary executable
* `rust-toolchain.toml` can override `rustc` with an arbitrary executable
* VS Code plugin reads configuration from project directory, and that can be used to override paths to various executables, like `rustfmt` or `rust-analyzer` itself.
* rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety.

Expand Down
60 changes: 60 additions & 0 deletions thisweek/_posts/2021-05-24-changelog-78.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
= Changelog #78
:sectanchors:
:page-layout: post

Commit: commit:495c9586ec51e0cf9b06397d99ec4f65c55e7a28[] +
Release: release:2021-05-24[]

== Sponsors

**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or
https://github.com/sponsors/rust-analyzer[GitHub Sponsors].

== New Features

* pr:7698[], pr:8877[] (first contribution) add new LSP extension for workspace symbol lookup.
* pr:8873[] implement import granularity guessing.
* pr:8948[] "Generate getter" assist places the cursor at the generated function.
* pr:8953[] "Generate getter" avoids generating types like `&Vec<T>`.

== Fixes

* pr:8345[] (first contribution) add `pub mod` option to the "Unlinked file" diagnostic fix.
* pr:8766[] (first contribution) add `async` if required in "Extract function" assist.
* pr:8945[] make expected type work in more situations:
+
image::https://user-images.githubusercontent.com/906069/119269023-dd5a5b00-bbf5-11eb-993a-b6e122c3b9a6.png[]
+
image::https://user-images.githubusercontent.com/906069/119269025-dfbcb500-bbf5-11eb-983c-fc415b8428e0.png[]
* pr:8795[] allow semantic tokens for strings to be disabled.
* pr:8858[] ignore macro imports from `extern crate self`.
* pr:8863[] don't add extra whitespace around fields.
* pr:8880[] fix module renaming.
* pr:8875[] avoid false positive "Missing match arm" when an or-pattern has mismatched types.
* pr:8884[] fix "Add explicit type" producing invalid code on `@` patterns.
* pr:8893[] update outdated auto-import documentation.
* pr:8902[] fix code completion not inserting borrow text when client supports `InsertAndReplace`.
* pr:8910[] don't hang on unresolved attribute on extern block and its children.
* pr:8918[] fix hang caused by non-unique attribute IDs.
* pr:8901[] speed up `fill_match_arms` on tuples of large enums.
* pr:8935[] mention `rust-tools.nvim` for `nvim-lsp` in the manual.
* pr:8936[] improve nightly downloads with better local state management.
* pr:8940[] give `unsafe` semantic token modifier to unsafe traits.
* pr:8947[] correctly resolve crate name in use paths when import shadows it.

== Internal Improvements

* pr:8856[], pr:8921[], pr:8938[] use Chalk for unification.
* pr:8862[] reorganize module structure of fixits.
* pr:8871[] simplify `DefCollector::resolve_macros`.
* pr:8882[], pr:8887[], pr:8888[] resolve attributes in name resolution (minimal version).
* pr:8885[] greatly simplify eager macro representation.
* pr:8889[] track in-scope derive helpers during name resolution.
* pr:8898[] resolve derive helpers.
* pr:8900[] support `#[register_attr]` and `#[register_tool]`.
* pr:8914[] remove `StructDefKind`.
* pr:8916[], pr:8932[] implement `ItemTree` pretty-printing.
* pr:8868[] replace `AstTransformer` with mutable syntax trees.
* pr:8922[], pr:8923[], pr:8924[] add more docs.
* pr:8926[] drop uncompressed release artifacts and those following the old naming convention.
* pr:8954[] document `ItemTree` design.