Commit Graph

1619 Commits

Author SHA1 Message Date
bors[bot]
bc0825d135
Merge #10802
10802: Allow clients to configure the global workspace search limit r=Veykril a=knutwalker

Playing around with [helix](https://helix-editor.com) I realized that the global worksapce symbol search works different compared to vs-code.
Helix requires all possible symbols in one query and does no subsequent refinement searched.
This PR adds a configuration option to override the default search limit with the default being the currently hardocded value.
Helix users can increment this limit for their instance with a config like

```toml
[[language]]
name = "rust"
language-server = { command = "rust-analyzer" }
[language.config]
workspace = { symbol = { search = { limit = 65536 }}}
```

Other editors are not affected by this change.


Co-authored-by: Paul Horn <dev@knutwalker.engineer>
2022-04-03 12:03:46 +00:00
bors[bot]
5b5ca0bd17
Merge #11866
11866: fix: Prevent underflow in range conversion  r=Veykril a=skyfmmf

Previously, when line numbers of Rust spans were converted to LSP ranges, they could underflow resulting in very large line numbers. As an underflow is always wrong, prevent it and use 0 instead.

This was noticed when opening an empty file in `src/bin/` of a library crate. In this case rustc produces a span with `"line_start": 0, "line_end": 0` resulting in the underflow.

Co-authored-by: Felix Maurer <felix@felix-maurer.de>
2022-04-03 11:49:23 +00:00
hkalbasi
003a6b74e4 suggest infered type in auto complete 2022-04-03 11:17:33 +04:30
Lukas Wirth
f610e2c2ed Simplify completion import insertion 2022-04-02 01:42:21 +02:00
bors[bot]
50225fe630
Merge #11869
11869: fix: code blocks with tilde also works like code block r=Veykril a=moreal

The `rustdoc` uses the `pulldown_cmark` package to parse *doc_comment* and the package also treat triple `~` characters also as code block fences. So when we run `cargo doc`, they will be placed also.

<img width="965" alt="image" src="https://user-images.githubusercontent.com/26626194/161208072-5a09a209-57fc-4a52-b190-b0a9be9ffcd6.png">

But `rust-analyzer` doesn't support it so it doesn't have any injected code highlights and any `Run doctest` hint. This pull request tries to allow also them. 🙇🏻‍♂️ 

Before:

<img width="224" alt="image" src="https://user-images.githubusercontent.com/26626194/161207405-b1d6cfda-82b1-4f60-8e42-c51d0ed98f38.png">

After:

<img width="161" alt="image" src="https://user-images.githubusercontent.com/26626194/161207693-8e39997c-9ca6-4e69-8c65-e9b70899f7db.png">


Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
2022-04-01 12:40:51 +00:00
Lee Dogeon
e3f32d13e1 Code blocks with tilde also works like code block 2022-04-01 20:29:32 +09:00
Felix Maurer
feb8ccacba Add test against line number underflow 2022-03-31 23:37:23 +02:00
Felix Maurer
a98ffe4268 Prevent underflow when converting line numbers
Previously, when line numbers of Rust spans were converted to LSP
ranges, they could underflow resulting in very large line numbers. As
an underflow is always wrong, prevent it and use 0 instead.
2022-03-31 23:00:48 +02:00
Jonas Schievink
ec2d023383 Add "view file text" command to debug sync issues 2022-03-31 14:50:33 +02:00
bors[bot]
e30747dfa8
Merge #11793
11793: LSIF: consolidate references into a single edge where possible. r=Veykril a=khuey



Co-authored-by: Kyle Huey <khuey@kylehuey.com>
2022-03-25 22:46:15 +00:00
Jonas Schievink
44a99d6e49 Disable experimental diagnostics by default 2022-03-24 17:00:17 +01:00
Kyle Huey
af1aa86ac0 Preserve order when grouping references. 2022-03-22 12:38:59 -07:00
Kyle Huey
0583919919 LSIF: consolidate references into a single edge where possible. 2022-03-22 12:00:52 -07:00
Lukas Wirth
8e91bb7660 minor: Bump dependencies 2022-03-22 17:42:24 +01:00
Lukas Wirth
ecf2c98859 fix: Fix lifetime elision hint configuration key 2022-03-22 16:28:36 +01:00
bors[bot]
966b692422
Merge #11771
11771: feat: Visualize compiler inserted reborrows via inlay hints r=Veykril a=Veykril

Disabled by default.

![image](https://user-images.githubusercontent.com/3757771/159165178-baaf968a-4381-468e-933f-5326ca1b203d.png)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/11275


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 13:47:16 +00:00
Lukas Wirth
37b48ceb8f feat: Visualize compiler inserted reborrows via inlay hints 2022-03-20 14:38:16 +01:00
bors[bot]
7315d97347
Merge #11755
11755: feat: Implement lifetime elision hints r=Veykril a=Veykril

With names on:
![Code_erl26zKvuf](https://user-images.githubusercontent.com/3757771/159134856-e2c75d2d-f17c-45c7-9a78-3da5ee8b1acd.png)
With names off:
![Code_MRP1Pbfe9d](https://user-images.githubusercontent.com/3757771/159134857-30fac3a1-825e-4f49-ba9b-9fa0bb215694.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-19 19:15:06 +00:00
Lukas Wirth
7da5b80f25 Change skip trivial behaviour 2022-03-19 20:12:14 +01:00
Lukas Wirth
7ab0aaa82a Add option to skip trivial cases 2022-03-19 19:01:19 +01:00
Lukas Wirth
45756c823f Use numbers for lifetimes by default, add setting to prefer using parameter names 2022-03-19 18:11:56 +01:00
Jonas Schievink
55d2a25123 Rename call info to "signature help"
It is no longer limited to just calls
2022-03-18 20:19:35 +01:00
Jonas Schievink
0642724e94 Provide signature help when editing generic args 2022-03-18 19:59:41 +01:00
Lukas Wirth
673e2b1d8f feat: Implement lifetime elision hints 2022-03-18 18:11:16 +01:00
Laurențiu Nicola
86b1ef9ab2 Bump deps 2022-03-17 19:24:37 +02:00
bors[bot]
3bff42fd14
Merge #11734
11734: internal: Bump `xshell` and fix `dist` r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-03-17 06:54:27 +00:00
Laurențiu Nicola
be6d5001e4 Bump xshell and fix dist 2022-03-17 08:53:33 +02:00
Lukas Wirth
bd17933c31 feat: Add return type hints for closures with block bodies 2022-03-16 21:25:03 +01:00
Laurențiu Nicola
620411df80 Mark chaining hints as types, since that's what they are 2022-03-16 07:46:09 +02:00
Aleksey Kladov
56e43c34e7 ⬆️ xshell 2022-03-14 14:57:24 +00:00
Matthias Krüger
56e4ea59d9 more clippy fixes:
clippy::match_like_matches_macro
clippy::to_string_in_format_args
clippy::single_char_add_str
clippy::filter_map_identity
clippy::clone_on_copy
clippy::useless_format
clippy::unused_unit
2022-03-12 16:50:49 +01:00
Matthias Krüger
77790f2b8e fix clippy::needless_return 2022-03-12 16:50:49 +01:00
Matthias Krüger
d64d711db2 fix clippy::map_flatten 2022-03-12 16:50:49 +01:00
Matthias Krüger
1f70886b15 fix clippy::single_char_pattern 2022-03-12 16:50:49 +01:00
Matthias Krüger
7912e33ed6 fix clippy::needless_borrow 2022-03-12 16:50:49 +01:00
Lukas Wirth
21af9ba4f0 minor: Pad type inlay hints if no colons are requested 2022-03-12 14:08:39 +01:00
Lukas Wirth
119ba82e4b minor: add missing definitions of lsp_ext::InlayHintLabel 2022-03-12 01:08:33 +01:00
Lukas Wirth
62265ee9cb fix: Allow configuration of colons in inlay-hints 2022-03-11 21:15:36 +01:00
Lukas Wirth
a9dd606387 fix: Show what file paths were expected for unresolved modules 2022-03-11 17:08:30 +01:00
Laurențiu Nicola
4a6ee4517a Add back colons around inlay hints 2022-03-08 12:01:02 +02:00
Laurențiu Nicola
8e3057d0a7 Improve inlay hint padding 2022-03-07 19:18:36 +02:00
bors[bot]
49646b71d4
Merge #11445
11445: Upstream inlay hints r=lnicola a=lnicola

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2797
Closes https://github.com/rust-analyzer/rust-analyzer/issues/3394 (since now resolve the hints for the range given only, not for the whole document. We don't actually resolve anything due to [hard requirement](https://github.com/rust-analyzer/rust-analyzer/pull/11445#issuecomment-1035227434) on label being immutable. Any further heavy actions could go to the `resolve` method that's now available via the official Code API for hints)

Based on `@SomeoneToIgnore's` branch, with a couple of updates:

 - I squashed, more or less successfully, the commits on that branch
 - downloading the `.d.ts` no longer works, but you can get it manually from https://raw.githubusercontent.com/microsoft/vscode/release/1.64/src/vscode-dts/vscode.proposed.inlayHints.d.ts
 - you might need to pass `--enable-proposed-api matklad.rust-analyzer`
 - if I'm reading the definition right, `InlayHintKind` needs to be serialized as a number, not string
 - this doesn't work anyway -- the client-side gets the hints, but they don't display

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-03-07 16:49:12 +00:00
Laurențiu Nicola
88a2141b77 Add inlayHints cap 2022-03-07 18:48:27 +02:00
Laurențiu Nicola
26d2e88b04 Fix parameter hint position 2022-03-07 15:24:54 +02:00
Laurențiu Nicola
b9d74fe2ed Update LSP docs 2022-03-07 15:09:31 +02:00
Lukas Wirth
93b09ca067 Update tidy ignore list 2022-03-06 19:18:40 +01:00
Lukas Wirth
ab21cf2f4f internal: Re-arrange ide_db modules 2022-03-06 19:04:04 +01:00
Lukas Wirth
5c0aee013e Fix highlighting of Self 2022-03-05 23:34:37 +01:00
Laurențiu Nicola
4b16b9b74b Fix formatting 2022-03-04 08:15:17 +02:00
Kirill Bulatov
5de5e450cb Remove debugging leftovers 2022-03-04 08:08:59 +02:00
Kirill Bulatov
b1d8dae930 Load hints for part of the file only 2022-03-04 07:45:51 +02:00
Kirill Bulatov
9c0c199e96 Clean up the redundant hints code and config 2022-03-04 07:45:51 +02:00
Laurențiu Nicola
0b69717ab6 Fixes 2022-03-04 07:45:51 +02:00
Laurențiu Nicola
5a49dbd2e0 Update inlay hints for upstream 2022-03-04 07:45:51 +02:00
Kirill Bulatov
55371be807 Add experimental VSCode api 2022-03-04 07:45:51 +02:00
bors[bot]
a2cc1d6b7b
Merge #11538
11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-25 21:17:24 +00:00
Lukas Wirth
2a7793d912 feat: Make private editable completions configurable, disable by default 2022-02-25 22:16:40 +01:00
Florian Diebold
f807ccd6c0 Add CSV output to analysis-stats
For easy diffing.
2022-02-25 11:45:44 +01:00
bors[bot]
979b5b32bc
Merge #11455
11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11212

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 16:56:37 +00:00
bors[bot]
b0e293bf69
Merge #11424
11424: Pass required features to cargo when using run action r=Veykril a=WaffleLapkin

When using `F1`->`Rust Analyzer: Run` action on an `example`, pass its `required-features` to `cargo run`. This allows to run examples that were otherwise impossible to run with RA.

Co-authored-by: Maybe Waffle <waffle.lapkin@gmail.com>
2022-02-21 10:21:39 +00:00
Felicián Németh
2bcde5953a Fix a typo in server_capabilities.experimental 2022-02-19 10:58:10 +01:00
doki
94b6038657
correct the description of Struct GlobalState 2022-02-14 19:30:21 +08:00
Felicián Németh
27c4be6b4f fix: add missing experimental capabilities
Fix #11389 by extending server_capabilities.experimental with
matchingBrace, externalDocs, moveItems.  Also, sort entries
alphabetically.
2022-02-12 15:37:13 +01:00
Lukas Wirth
cef8a17ea5 Handle proc-macro functions as the proc-macro they resolve to 2022-02-11 22:06:03 +01:00
Laurențiu Nicola
50a1319f46 Bump lsp-types 2022-02-09 09:22:25 +02:00
Laurențiu Nicola
c8f056a6db Revert "Revert "Bump dashmap""
This reverts commit 39674cd350.
2022-02-09 09:19:57 +02:00
Moritz Vetter
482533ea9a add missing snake case attribute, update hash 2022-02-07 04:57:20 +01:00
Maybe Waffle
662dd7c27d Pass required features to cargo when using run action
When using `F1`->`Rust Analyzer: Run` action on an `example`, pass its
`required-features` to `cargo run`. This allows to run examples that
were otherwise impossible to run with RA.
2022-02-06 19:02:25 +03:00
bors[bot]
0808ade4e4
Merge #11182
11182: fix: don't panic on seeing an unexpected offset r=Veykril a=dimbleby

Intended as a fix, or at least a sticking plaster, for #11081.

I have arranged that [offset()](1ba9a924d7/crates/ide_db/src/line_index.rs (L105-L107)) returns `Option<TextSize>` instead of going out of bounds; other changes are the result of following the compiler after doing this.

Perhaps there's still an issue here - I suppose the server and client have gotten out of sync and that probably shouldn't happen in the first place?  I see that https://github.com/rust-analyzer/rust-analyzer/issues/10138#issuecomment-913727554 suggests what sounds like a more substantial fix which I think might be aimed in this direction.  So perhaps that one should be left open to cover such things?

Meanwhile, I hope that not-crashing is a good improvement: and I can confirm that it works out just fine in the repro I have at #11081.

Co-authored-by: David Hotham <david.hotham@metaswitch.com>
2022-01-31 11:16:22 +00:00
Jonas Schievink
3c51aaf065 Fix merge commit check for git 2.35 2022-01-26 19:10:39 +01:00
bors[bot]
2cb85c14b6
Merge #11281
11281: ide: parallel prime caches r=jonas-schievink a=jhgg

cache priming goes brrrr... the successor to #10149

---

this PR implements a parallel cache priming strategy that uses a topological work queue to feed a pool of worker threads the crates to index in parallel.

## todo
- [x] should we keep the old prime caches?
- [x] we should use num_cpus to detect how many cpus to use to prime caches. should we also expose a config for # of worker CPU threads to use?
- [x] something is wonky with cancellation, need to figure it out before this can merge. 

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-25 16:03:35 +00:00
bors[bot]
e6e72809e3
Merge #11287
11287: fix: rust-analyzer spamming overly error message when workspace not being loaded r=lnicola a=Milo123459

Fixes #10120

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2022-01-16 15:13:52 +00:00
Jake Heinz
25f67b6939 make it a config 2022-01-15 02:47:47 +00:00
Milo
e1fe930845 fix overly 2022-01-14 22:06:30 +00:00
Jake Heinz
f83c0166be cleanup + detect num cpus 2022-01-14 09:48:59 +00:00
Jake Heinz
3168148cc6 ide: parallel prime caches 2022-01-14 09:16:35 +00:00
Wang Ruochen
01b3ce3006
Fix documentation of snippet 2022-01-10 21:29:41 -08:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Benjamin Coenen
8e0a05eb70 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 15:01:37 +01:00
Benjamin Coenen
b60a29ca94 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 14:13:34 +01:00
Coenen Benjamin
0a4239a815
Update crates/rust-analyzer/src/config.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 14:07:02 +01:00
Lukas Wirth
dd20a6f701 feat: poke user when supplying faulty configurations 2022-01-06 14:24:19 +01:00
Lukas Wirth
f6eba28ef8 Adjust config name 2022-01-06 13:50:35 +01:00
Lukas Wirth
dd4b53402d Regenrate docs and package.json 2022-01-06 13:50:24 +01:00
Lukas Wirth
aecf26d09b feat: Add config to replace specific proc-macros with dummy expanders 2022-01-06 13:50:18 +01:00
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
David Hotham
b7cabf1e44
fix: don't panic on seeing an unexpected offset 2022-01-03 14:49:47 +00:00
Lukas Wirth
3a525c831f internal: Handle macro calls better in highlighting 2022-01-02 19:10:10 +01:00
Laurențiu Nicola
53ddf48df4 Avoid collect_vec from itertools 2022-01-02 12:06:14 +02:00
Aleksey Kladov
a1c33c2e1a test: force client-side watching
The direct reason for this is to fix CI on windows, which seems to fail
for some reason after we fixed the watcher-selection logic which (I
think) changed the tests behavior to use notify rather than client.

But this patch seems to make sense in general -- file watching is
notoriously finicky, so controlling it explicitly leads to less fragile
tests.
2022-01-01 19:16:25 +03:00
Aleksey Kladov
0d1e23e968 better error message 2022-01-01 18:55:53 +03:00
Aleksey Kladov
b9417f3483 feat: correctly fallback to notify if the clinet-side file watching is not supported 2022-01-01 17:26:54 +03:00
Benjamin Coenen
df6fa50f92 feat(diagnostics): add new config to fill default expression
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-12-31 16:29:08 +01:00
bors[bot]
c5722a66c5
Merge #11073
11073: fix: Fix windows not finding the pdb file r=lnicola a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10371

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-20 18:20:08 +00:00
Lukas Wirth
4a5c8c6ad2 fix: Fix windows not finding the pdb file 2021-12-20 19:17:31 +01:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
Lukas Wirth
9fe0f0d1d9 Add a few default snippets for VSCode 2021-12-17 16:24:29 +01:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
Jonas Schievink
deb5c1426d internal: add "Shuffle Crate Graph" command 2021-12-07 16:37:19 +01:00
Laurențiu Nicola
3678cbd12e Bump tracing 2021-12-06 20:54:45 +02:00