Skip to content

Commit be30db9

Browse files
committed
Changelog #78
1 parent 5beffef commit be30db9

File tree

5 files changed

+132
-18
lines changed

5 files changed

+132
-18
lines changed

generated_assists.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn main() {
187187

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

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

@@ -909,16 +909,16 @@ struct Person {
909909

910910
impl Person {
911911
/// Get a reference to the person's name.
912-
fn name(&self) -> &String {
913-
&self.name
912+
fn name(&self) -> &str {
913+
self.name.as_str()
914914
}
915915
}
916916
```
917917

918918

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

923923
Generate a mut getter method.
924924

@@ -937,7 +937,7 @@ struct Person {
937937

938938
impl Person {
939939
/// Get a mutable reference to the person's name.
940-
fn name_mut(&mut self) -> &mut String {
940+
fn name_mut(&mut self) -> &mut String {
941941
&mut self.name
942942
}
943943
}

generated_config.adoc

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
[[rust-analyzer.assist.importMergeBehavior]]rust-analyzer.assist.importMergeBehavior (default: `"crate"`)::
1+
[[rust-analyzer.assist.importGranularity]]rust-analyzer.assist.importGranularity (default: `"crate"`)::
22
+
33
--
4-
The strategy to use when inserting new imports or merging imports.
4+
How imports should be grouped into use statements.
5+
--
6+
[[rust-analyzer.assist.importEnforceGranularity]]rust-analyzer.assist.importEnforceGranularity (default: `false`)::
7+
+
8+
--
9+
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.
510
--
611
[[rust-analyzer.assist.importPrefix]]rust-analyzer.assist.importPrefix (default: `"plain"`)::
712
+
@@ -179,6 +184,15 @@ Controls file watching implementation.
179184
--
180185
These directories will be ignored by rust-analyzer.
181186
--
187+
[[rust-analyzer.highlighting.strings]]rust-analyzer.highlighting.strings (default: `true`)::
188+
+
189+
--
190+
Use semantic tokens for strings.
191+
192+
In some editors (e.g. vscode) semantic tokens override other highlighting grammars.
193+
By disabling semantic tokens for strings, other grammars can be used to highlight
194+
their contents.
195+
--
182196
[[rust-analyzer.hoverActions.debug]]rust-analyzer.hoverActions.debug (default: `true`)::
183197
+
184198
--
@@ -332,3 +346,13 @@ Additional arguments to `rustfmt`.
332346
Advanced option, fully override the command rust-analyzer uses for
333347
formatting.
334348
--
349+
[[rust-analyzer.workspace.symbol.search.scope]]rust-analyzer.workspace.symbol.search.scope (default: `"workspace"`)::
350+
+
351+
--
352+
Workspace symbol search scope.
353+
--
354+
[[rust-analyzer.workspace.symbol.search.kind]]rust-analyzer.workspace.symbol.search.kind (default: `"only_types"`)::
355+
+
356+
--
357+
Workspace symbol search kind.
358+
--

generated_features.adoc

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,19 @@ use self::auto_import;
3737
use super::AssistContext;
3838
```
3939

40-
.Merge Behavior
40+
.Import Granularity
4141

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

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

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

5554
.Import Prefix
5655

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

7170

71+
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
72+
73+
== Debug ItemTree
74+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/view_item_tree.rs#L5[view_item_tree.rs]
75+
76+
Displays the ItemTree of the currently open file, for debugging.
77+
78+
|===
79+
| Editor | Action Name
80+
81+
| VS Code | **Rust Analyzer: Debug ItemTree**
82+
|===
83+
84+
7285
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
7386

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

142155

156+
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
157+
158+
== Folding
159+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/folding_ranges.rs#L30[folding_ranges.rs]
160+
161+
Defines folding regions for curly braced blocks, runs of consecutive import
162+
statements, and `region` / `endregion` comment markers.
163+
164+
143165
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
144166

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

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

465487
Renames the item below the cursor and all of its references
466488

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

680+
Note that filtering does not currently work in VSCode due to the editor never
681+
sending the special symbols to the language server. Instead, you can configure
682+
the filtering via the `rust-analyzer.workspace.symbol.search.scope` and
683+
`rust-analyzer.workspace.symbol.search.kind` settings.
684+
658685
|===
659686
| Editor | Shortcut
660687

manual.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ nvim_lsp.rust_analyzer.setup({
306306
settings = {
307307
["rust-analyzer"] = {
308308
assist = {
309-
importMergeBehavior = "last",
309+
importGranularity = "module",
310310
importPrefix = "by_self",
311311
},
312312
cargo = {
@@ -323,6 +323,8 @@ EOF
323323

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

326+
Check out https://github.com/simrat39/rust-tools.nvim for a batteries included rust-analyzer setup for neovim.
327+
326328
// IMPORTANT: master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
327329

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

630632
* proc macros and build scripts are executed by default
631633
* `.cargo/config` can override `rustc` with an arbitrary executable
634+
* `rust-toolchain.toml` can override `rustc` with an arbitrary executable
632635
* 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.
633636
* rust-analyzer's syntax trees library uses a lot of `unsafe` and hasn't been properly audited for memory safety.
634637

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
= Changelog #78
2+
:sectanchors:
3+
:page-layout: post
4+
5+
Commit: commit:495c9586ec51e0cf9b06397d99ec4f65c55e7a28[] +
6+
Release: release:2021-05-24[]
7+
8+
== Sponsors
9+
10+
**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or
11+
https://github.com/sponsors/rust-analyzer[GitHub Sponsors].
12+
13+
== New Features
14+
15+
* pr:7698[], pr:8877[] (first contribution) add new LSP extension for workspace symbol lookup.
16+
* pr:8873[] implement import granularity guessing.
17+
* pr:8948[] "Generate getter" assist places the cursor at the generated function.
18+
* pr:8953[] "Generate getter" avoids generating types like `&Vec<T>`.
19+
20+
== Fixes
21+
22+
* pr:8345[] (first contribution) add `pub mod` option to the "Unlinked file" diagnostic fix.
23+
* pr:8766[] (first contribution) add `async` if required in "Extract function" assist.
24+
* pr:8945[] make expected type work in more situations:
25+
+
26+
image::https://user-images.githubusercontent.com/906069/119269023-dd5a5b00-bbf5-11eb-993a-b6e122c3b9a6.png[]
27+
+
28+
image::https://user-images.githubusercontent.com/906069/119269025-dfbcb500-bbf5-11eb-983c-fc415b8428e0.png[]
29+
* pr:8795[] allow semantic tokens for strings to be disabled.
30+
* pr:8858[] ignore macro imports from `extern crate self`.
31+
* pr:8863[] don't add extra whitespace around fields.
32+
* pr:8880[] fix module renaming.
33+
* pr:8875[] avoid false positive "Missing match arm" when an or-pattern has mismatched types.
34+
* pr:8884[] fix "Add explicit type" producing invalid code on `@` patterns.
35+
* pr:8893[] update outdated auto-import documentation.
36+
* pr:8902[] fix code completion not inserting borrow text when client supports `InsertAndReplace`.
37+
* pr:8910[] don't hang on unresolved attribute on extern block and its children.
38+
* pr:8918[] fix hang caused by non-unique attribute IDs.
39+
* pr:8901[] speed up `fill_match_arms` on tuples of large enums.
40+
* pr:8935[] mention `rust-tools.nvim` for `nvim-lsp` in the manual.
41+
* pr:8936[] improve nightly downloads with better local state management.
42+
* pr:8940[] give `unsafe` semantic token modifier to unsafe traits.
43+
* pr:8947[] correctly resolve crate name in use paths when import shadows it.
44+
45+
== Internal Improvements
46+
47+
* pr:8856[], pr:8921[], pr:8938[] use Chalk for unification.
48+
* pr:8862[] reorganize module structure of fixits.
49+
* pr:8871[] simplify `DefCollector::resolve_macros`.
50+
* pr:8882[], pr:8887[], pr:8888[] resolve attributes in name resolution (minimal version).
51+
* pr:8885[] greatly simplify eager macro representation.
52+
* pr:8889[] track in-scope derive helpers during name resolution.
53+
* pr:8898[] resolve derive helpers.
54+
* pr:8900[] support `#[register_attr]` and `#[register_tool]`.
55+
* pr:8914[] remove `StructDefKind`.
56+
* pr:8916[], pr:8932[] implement `ItemTree` pretty-printing.
57+
* pr:8868[] replace `AstTransformer` with mutable syntax trees.
58+
* pr:8922[], pr:8923[], pr:8924[] add more docs.
59+
* pr:8926[] drop uncompressed release artifacts and those following the old naming convention.
60+
* pr:8954[] document `ItemTree` design.

0 commit comments

Comments
 (0)