Commit graph

455 commits

Author SHA1 Message Date
Aleksey Kladov
31f282636b Minor 2020-06-02 16:30:47 +02:00
veetaha
d605ec9c32 Change Runnable.bin -> Runnable.kind
As per matklad, we now pass the responsibility for finding the binary to the frontend.
Also, added caching for finding the binary path to reduce
the amount of filesystem interactions.
2020-05-31 05:21:45 +03:00
veetaha
a419cedb1c Fix tests, apply code review proposals 2020-05-31 03:10:23 +03:00
veetaha
030d78345f Fix invoking cargo without consulting CARGO or standard installation paths 2020-05-31 03:10:23 +03:00
Roland Ruckerbauer
18aa4bcb03 Add semantic highlight to QUESTION token
Made it an operator with controlFlow modifier.
2020-05-29 21:17:14 +02:00
Aaron Loucks
a047f10839 Hover tooltip module name is monospace once again
The line separator is moved below the function signature to split
regions between the docs. This is very similar to how IntelliJ
displays tooltips. Adding an additional separator between the module
name and function signature currently has rendering issues.

Fixes #4594
Alternative to #4615
2020-05-25 23:18:45 -04:00
bors[bot]
30f058dfea
Merge #4602 #4603
4602: Add boolean literal semantic token type to package.json r=matklad a=lnicola

Closes #4583.

CC @GrayJack

4603: Add self keyword semantic token type r=matklad a=lnicola

Not sure if this is warranted a new token type or just a modifier.

---

CC #4583, @GrayJack

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-25 14:08:21 +00:00
Aleksey Kladov
0ebb25b29b Document parentModule experimental LSP request 2020-05-25 15:59:49 +02:00
Aleksey Kladov
a30bdd9795 Cleanup lsp extensions on the client side 2020-05-25 14:56:26 +02:00
Aleksey Kladov
76e170c3d0 Less rust-analyzer specific onEnter 2020-05-25 14:28:47 +02:00
Laurențiu Nicola
c2358365ad Add self keyword semantic token type 2020-05-25 12:08:58 +03:00
bors[bot]
fbb8b884a2
Merge #4593
4593: Document some rust-analyzer specific protocol extensions r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-24 15:05:20 +00:00
Aleksey Kladov
5276bfff81 Fix formatting 2020-05-24 17:04:17 +02:00
Aleksey Kladov
dec4ba8023 Document some rust-analyzer specific protocol extensions 2020-05-24 17:01:40 +02:00
Aleksey Kladov
9342273616 Document matchingBrace LSP request 2020-05-24 16:53:18 +02:00
Matthew Jasper
e2d36cb692 Highlight true and false as literals 2020-05-24 15:12:17 +01:00
Aleksey Kladov
130318b823
Merge pull request #4548 from bnjjj/fix_4464
add support of feature flag for runnables
2020-05-24 15:34:35 +02:00
Aleksey Kladov
f26b7928e0
Merge pull request #4495 from vsrs/fixture_meta
Test fixtures parsing improvements
2020-05-24 15:32:52 +02:00
Aleksey Kladov
ce7144a93d
Merge pull request #4474 from georgewfraser/color_attrs
Color attribute functions
2020-05-24 15:32:31 +02:00
Benjamin Coenen
27ed376bc4 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-24 13:34:34 +02:00
Benjamin Coenen
48d7c61e26 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-23 20:59:18 +02:00
bors[bot]
ca5e4596a0
Merge #4578
4578: Remove unnecessary clone that prevented clippy from moving on r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-05-23 11:24:28 +00:00
bors[bot]
88c292b1c2
Merge #4559
4559: Module name on hover shows another newline after it r=matklad a=Arthamys

This changes the display of hover information to add a newline between the module path of the item and the signature of the item, as suggested in #3813 

**Before**

![before_3813](https://user-images.githubusercontent.com/11710698/82609224-5d517d80-9bbc-11ea-9a08-0a1558409c6b.png)

**After**

![after_3813](https://user-images.githubusercontent.com/11710698/82609208-562a6f80-9bbc-11ea-8cb6-4430269c5800.png)

Co-authored-by: Galilée 'Bill' Enguehard <galilee.enguehard@gmail.com>
2020-05-23 11:09:24 +00:00
Galilée 'Bill' Enguehard
6197a960df Fix resolve_proc_macro heavy test 2020-05-23 08:59:51 +02:00
kjeremy
7a46a99490 And a few drive-bys 2020-05-22 17:26:31 -04:00
bors[bot]
a95bb1355d
Merge #4571
4571: KISS SourceChange r=matklad a=matklad

The idea behind requiring the label is a noble one, but we are not
really using it consistently anyway, and it should be easy to retrofit
later, should we need it.

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-22 16:09:37 +00:00
Aleksey Kladov
2c04aad2d2 KISS SourceChange
The idea behind requiring the label is a noble one, but we are not
really using it consistently anyway, and it should be easy to retrofit
later, should we need it.
2020-05-22 18:04:26 +02:00
bors[bot]
2a36a2a3cc
Merge #4569
4569: CodeAction groups r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-22 15:33:12 +00:00
Aleksey Kladov
2075e77ee5 CodeAction groups 2020-05-22 17:32:46 +02:00
bors[bot]
5aa3a4c04f
Merge #4516
4516: LSP: Two stage initialization r=kjeremy a=kjeremy

Fills in server information.

Derives CodeAction capabilities from the client. If code action literals
are unsupported we fall back to the "simple support" which just sends back
commands (this is already supported in our config). The difference being
that we did not adjust our server capabilities so that if the client was
checking for `CodeActionProvider: "true"` in the response that would have failed.

Part of #144
Fixes #4130 (the specific case called out in that issue)

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-05-22 13:12:57 +00:00
Aleksey Kladov
5ef4ebff20 Use WorkspaceEdit for ssr 2020-05-22 00:28:49 +02:00
Aleksey Kladov
5b5ebec440 Formalize JoinLines protocol extension 2020-05-21 20:05:33 +02:00
Aleksey Kladov
5f57491c98 Cleanup TextEdit 2020-05-21 15:56:18 +02:00
Aleksey Kladov
ff28c79ebd Remove dead code for handling cursor positions 2020-05-21 15:08:03 +02:00
Aleksey Kladov
4b495da368 Transition OnEnter to WorkspaceSnippetEdit
This also changes our handiling of snippet edits on the client side.
`editor.insertSnippet` unfortunately forces indentation, which we
really don't want to have to deal with. So, let's just implement our
manual hacky way of dealing with a simple subset of snippets we
actually use in rust-analyzer
2020-05-21 15:08:03 +02:00
Benjamin Coenen
a7c8aa7c60 add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-21 10:53:29 +02:00
Benjamin Coenen
c6143742bd add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-21 10:48:42 +02:00
Aaron Loucks
63ffc17733 Use a flat play icon instead of the blue emoji with test code lens 2020-05-19 20:29:49 -04:00
Aleksey Kladov
4a3a525ea9 Use new format for all assists that don't change cursor positon 2020-05-20 01:23:05 +02:00
kjeremy
acc5e8d64b Add version 2020-05-19 18:12:07 -04:00
kjeremy
e3ae298e78 Fill code action capabilities with a function 2020-05-19 17:22:38 -04:00
Aleksey Kladov
3e9bf7ebab Update test data 2020-05-19 20:29:18 +02:00
Aleksey Kladov
2bf6b16a7f Server side of SnippetTextEdit 2020-05-19 20:28:27 +02:00
Aleksey Kladov
a752853350 Add snippetTextEdit protocol extension 2020-05-19 20:28:27 +02:00
Aleksey Kladov
c847c079fd Add AssistConfig 2020-05-19 20:28:27 +02:00
kjeremy
6bf4fc27d9 LSP: Two stage initialization
Fills in server information.

Derives CodeAction capabilities from the client. If code action literals
are unsupported we fall back to the "simple support" which just sends back
commands (this is already supported in our config). The difference being
that we did not adjust our server capabilities so that if the client was
checking for `CodeActionProvider: "true"` in the response that would have failed.
2020-05-19 11:56:51 -04:00
George Fraser
47ce5ea581 Color attribute functions 2020-05-18 22:55:46 -07:00
vsrs
78817a3194 Add "rust-analyzer.lens.enable" 2020-05-18 10:27:00 +03:00
vsrs
3d445256fe code formatting 2020-05-17 20:38:50 +03:00
vsrs
dc217bdf90 CodeLens configuration options. 2020-05-17 19:51:44 +03:00
vsrs
256fb7556e Remove temporary FixtureEntry parsed_meta field. 2020-05-16 12:25:26 +03:00
bors[bot]
d51c1f6217
Merge #4448
4448: Generate configuration for launch.json r=vsrs a=vsrs

This PR adds two new commands: `"rust-analyzer.debug"` and `"rust-analyzer.newDebugConfig"`. The former is a supplement to the existing `"rust-analyzer.run"` command and works the same way: asks for a runnable and starts new debug session. The latter allows adding a new configuration to **launch.json** (or to update an existing one).

If the new option `"rust-analyzer.debug.useLaunchJson"` is set to true then `"rust-analyzer.debug"` and Debug Lens will first look for existing debug configuration in **launch.json**. That is, it has become possible to specify startup arguments, env variables, etc.

`"rust-analyzer.debug.useLaunchJson"` is false by default, but it might be worth making true the default value. Personally I prefer true, but I'm not sure if it is good for all value.

----
I think that this PR also solves https://github.com/rust-analyzer/rust-analyzer/issues/3441.
Both methods to update launch.json mentioned in the issue do not work:
1. Menu. It is only possible to add a launch.json configuration template via a debug adapter. And anyway it's only a template and it is impossible to specify arguments from an extension.

2. DebugConfigurationProvider. The exact opposite situation: it is possible to specify all debug session settings, but it is impossible to export these settings to launch.json.

Separate `"rust-analyzer.newDebugConfig"` command looks better for me.

----
Fixes #4450
Fixes #3441

Co-authored-by: vsrs <vit@conrlab.com>
Co-authored-by: vsrs <62505555+vsrs@users.noreply.github.com>
2020-05-15 14:29:01 +00:00
Aleksey Kladov
08027c3075 Cleanups 2020-05-15 02:09:30 +02:00
Aleksey Kladov
f1a5c489fd Better structure 2020-05-15 01:58:39 +02:00
Aleksey Kladov
220813dcb0 Move LSP bits from flycheck to rust-analyzer
There should be only one place that knows about LSP, and that place is
right before we spit JSON on stdout.
2020-05-15 01:52:25 +02:00
Aleksey Kladov
acedad8134 Minor 2020-05-14 15:36:15 +02:00
Aleksey Kladov
fc0c5dfcd1 Put preselect items on top 2020-05-14 15:33:56 +02:00
vsrs
51d5a08255
Better label for a runnable.
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-14 16:28:18 +03:00
vsrs
20fdd14c62 Multiple binaries support for launch.json.
Generate unique names on the LSP side.
2020-05-14 16:02:01 +03:00
Pavan Kumar Sunkara
9f0a7eb97b Make some stuff public so that they can be reused by other tools 2020-05-14 11:14:46 +02:00
Laurențiu Nicola
55e914a2a1 Remove hidden VARIATION SELECTOR-16 2020-05-13 17:26:57 +03:00
bors[bot]
848aa56df5
Merge #4397
4397: Textmate cooperation r=matklad a=georgewfraser

This PR tweaks the fallback TextMate scopes to make them more consistent with the existing grammar and other languages, and edits the builtin TextMate grammar to align with semantic coloring. Before is on the left, after is on the right:

<img width="855" alt="Screen Shot 2020-05-10 at 1 45 51 PM" src="https://user-images.githubusercontent.com/1369240/81512320-a8be7e80-92d4-11ea-8940-2c03f6769015.png">

**Use keyword.other for regular keywords instead of keyword**. This is a really peculiar quirk of TextMate conventions, but virtually *all* TextMate grammars use `keyword.other` (colored blue in VSCode Dark+) for regular keywords and `keyword.control` (colored purple in VSCode Dark+) for control keywords. The TextMate scope `keyword` is colored like control keywords, not regular keywords. It may seem strange that the `keyword` scope is not the right fallback for the `keyword` semantic token, but TextMate has a long and weird history. Note how keywords change from purple back to blue (what they were before semantic coloring was added):

**(1) Use punctuation.section.embedded for format specifiers**. This aligns with how Typescript colors formatting directives:

<img width="238" alt="Screen Shot 2020-05-09 at 10 54 01 AM" src="https://user-images.githubusercontent.com/1369240/81481258-93b5f280-91e3-11ea-99c2-c6d258c5bcad.png">

**(2) Consistently use `entity.name.type.*` scopes for type names**. Avoid using `entity.name.*` which gets colored like a keyword.

**(3) Use Property instead of Member for fields**. Property and Member are very similar, but if you look at the TextMate fallback scopes, it's clear that Member is intended for function-like-things (methods?) and Property is intended for variable-like-things.

**(4) Color `for` as a regular keyword when it's part of `impl Trait for Struct`**. 

**(5) Use `variable.other.constant` for constants instead of `entity.name.constant`**. In the latest VSCode insiders, variable.other.constant has a subtly different color that differentiates constants from ordinary variables. It looks close to the green of types but it's not the same---it's a new color recently added to take advantage of semantic coloring.

I also made some minor changes that make the TextMate scopes better match the semantic scopes. The effect of this for the user is you observe less of a change when semantic coloring "activates". You can see the changes I made relative to the built-in TextMate grammar here:

a91d15c80c..97428b6d52 (diff-6966c729b862f79f79bf7258eb3e0885)


Co-authored-by: George Fraser <george@fivetran.com>
2020-05-11 17:33:38 +00:00
bors[bot]
de1fe23c1e
Merge #4403
4403: Check client capabilities before sending progress notifications r=kjeremy a=kjeremy

Fixes #4384

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-05-11 17:25:34 +00:00
Jeremy Kolb
d4471dccfe Check client capabilities before sending progress notifications
Fixes #4384
2020-05-11 13:16:46 -04:00
Aleksey Kladov
72e229fcb3 Use RA_LOG instead of RUST_LOG for logging
RUST_LOG might be set up for debugging the user's problem, slowing
down rust-analyzer considerably. That's the same reason why rustc uses
RUSTC_LOG.
2020-05-11 19:16:00 +02:00
George Fraser
cff0d6b6e6 Use Property instead of Member for fields 2020-05-10 13:07:28 -07:00
bors[bot]
74e72e9afa
Merge #4394 #4414
4394: Simplify r=matklad a=Veetaha



4414: Highlighting improvements r=matklad a=matthewjasper

- `static mut`s are highlighted as `mutable`.
- The name of the macro declared by `macro_rules!` is now highlighted.

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
2020-05-10 17:47:27 +00:00
Aleksey Kladov
3bec2be9de req -> lsp_ext 2020-05-10 19:27:12 +02:00
Aleksey Kladov
bec3bf701c Don't re-export lsp_types 2020-05-10 19:24:02 +02:00
Aleksey Kladov
a78e1573b1 Better fn signature 2020-05-10 19:14:02 +02:00
Aleksey Kladov
bd8422643a to_proto::semantic_tokens 2020-05-10 19:09:22 +02:00
Aleksey Kladov
1586bab0b9 Simplify proto conversion
Trait based infra in conv.rs is significantly more complicated than
what we actually need here.
2020-05-10 19:01:26 +02:00
veetaha
a42729a59d Simplify crate graph creation 2020-05-09 21:26:59 +03:00
veetaha
9970dd316b Simplify 2020-05-09 21:05:22 +03:00
Aaron Wood
beb79ed104 Begin transition to new fields for JsonProject crate cfgs
This starts the transition to a new method of documenting the cfgs that are
enabled for a given crate in the json file.  This is changing from a list
of atoms and a dict of key:value pairs, to a list of strings that is
equivalent to that returned by `rustc --print cfg ..`, and parsed in the
same manner by rust-analyzer.

This is the first of two changes, which adds the new field that contains
the list of strings.  Next change will complete the transition and remove
the previous fields.
2020-05-08 16:59:52 -07:00
veetaha
aca9aa8b7e Simplify 2020-05-09 02:27:44 +03:00
bors[bot]
1b136aae0b
Merge #4296
4296: Support cargo:rustc-cfg in build.rs r=matklad a=robojumper

Fixes #4238.

Co-authored-by: robojumper <robojumper@gmail.com>
2020-05-07 18:50:00 +00:00
Benjamin Coenen
c839d4f7a9 do not show runnables for main function outside of a binary target #4356
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 16:52:14 +02:00
bors[bot]
30eb458b4f
Merge #4332
4332: Refactor TextEdit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-05 21:50:47 +00:00
Aleksey Kladov
4a6fa8f0df Rename AtomTextEdit -> Indel 2020-05-05 23:15:49 +02:00
guigui64
c22660179c
add the allFeatures flag (true by default) 2020-05-05 22:46:42 +02:00
Aleksey Kladov
3908fad1fe Normalize naming of diagnostics 2020-05-05 21:35:30 +02:00
bors[bot]
8803e748a6
Merge #4166
4166: Defining a default target to support cross-compilation targets  r=matklad a=FuriouZz

Related to #4163 

Co-authored-by: Christophe MASSOLIN <christophe.massolin@gmail.com>
2020-05-05 17:25:52 +00:00
bors[bot]
df7b59081f
Merge #4323
4323: Add tests for #4306 r=kjeremy a=lnicola

CC @kjeremy 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-05 17:01:46 +00:00
Laurențiu Nicola
7ec1b63f81 Add tests for #4306 2020-05-05 19:39:45 +03:00
bors[bot]
f0411ff9e0
Merge #4320
4320: add doctest support r=matklad a=bnjjj

close #4317

preview:

<img width="253" alt="Capture d’écran 2020-05-05 à 17 39 58" src="https://user-images.githubusercontent.com/5719034/81086040-45110b80-8ef8-11ea-9c05-79c6fe400fc3.png">


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 16:22:31 +00:00
Christophe MASSOLIN
14dde99627 Pass cargo.target to rustc 2020-05-05 18:15:13 +02:00
Christophe MASSOLIN
0ab4340cdb Rename defaultTarget to target 2020-05-05 18:01:54 +02:00
Benjamin Coenen
fe52f8f028 add doctest support #4317
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 17:44:27 +02:00
robojumper
059fc86963 Merge heavy tests 2020-05-05 14:53:18 +02:00
Laurențiu Nicola
7c1d5f286a Fix line index rebuild during incremental changes 2020-05-04 20:04:30 +03:00
Laurențiu Nicola
191abf3685 Make incremental sync opt-out 2020-05-04 19:54:39 +03:00
robojumper
2980ba1fde Support build.rs cargo:rustc-cfg 2020-05-04 13:29:09 +02:00
Laurențiu Nicola
87a18b18ea Make incremental sync opt-in 2020-05-03 20:58:07 +03:00
bors[bot]
76c2f4ef49
Merge #4278
4278: Log panics in apply_document_changes r=matklad a=lnicola

This doesn't necessarily help (because of https://github.com/rust-analyzer/rust-analyzer/issues/4263#issuecomment-623078531), but maybe we could leave it in there for a while in case it catches something.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-03 09:48:44 +00:00
Laurențiu Nicola
074d1ac2f7 Log panics in apply_document_changes 2020-05-03 12:46:20 +03:00
bors[bot]
89e1f97515
Merge #4207 #4253
4207: Add unwrap block assist #4156 r=matklad a=bnjjj

close issue #4156 

4253: Remove `workspaceLoaded` setting r=matklad a=eminence

The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

    "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

    rust-analyzer: {}/{} packages

This was done as part of #3587

The change in this PR simply renames this setting from `workspaceLoaded` to
`progress` to better describe what it actually controls.  At the moment,
the only type of progress message that is controlled by this setting is
the initial load messages, but in theory other messages could also be
controlled by this setting.


Reviewer notes:

* If we didn't like the idea of causing minor breaking to user's config, we could keep the setting name as `workspaceLoaded`
* I think we can now close both #2719 and #3176 since the notification dialog in question no longer exists (actually I think you can close those issues even if you reject this PR 😄 )

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 12:44:55 +00:00
bors[bot]
235728319f
Merge #4256
4256: Improve formatting of analyzer status text r=flodiebold a=eminence

The old formatting had everything on 1 line, making it quite hard to read:

    requests:    1 textDocument/documentSymbol         2ms    2 textDocument/codeAction             2ms    3 rust-analyzer/inlayHints            20ms    4 textDocument/foldingRange           108ms    6 textDocument/codeLens               66ms    5 textDocument/semanticTokens/range   76ms    8 rust-analyzer/inlayHints            195ms    7 textDocument/semanticTokens         250ms    9 textDocument/semanticTokens/range   108ms


It now looks like this:

```
requests:
*   1 textDocument/documentSymbol         11ms
    2 textDocument/codeAction             15ms
    3 rust-analyzer/inlayHints            4ms
    5 textDocument/foldingRange           3ms
    4 textDocument/semanticTokens/range   45ms
    6 textDocument/codeLens               182ms
    8 rust-analyzer/inlayHints            124ms
    7 textDocument/semanticTokens         127ms
    9 textDocument/documentHighlight      2ms
   10 textDocument/codeAction             3ms
```

Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 09:45:37 +00:00
Aleksey Kladov
247d32cbfd Test/check the whole package
Closes #4255
2020-05-02 10:57:37 +02:00
Andrew Chin
65234e8828 Remove workspaceLoaded setting
The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

  "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

  rust-analyzer: {}/{} packages

This was done as part of #3587

The new status-bar indicator is unobtrusive and shouldn't need to be
disabled.  So this setting is removed.
2020-05-01 21:04:41 -04:00
Andrew Chin
76f34a15e6 Improve formatting of analyzer status text 2020-05-01 19:13:52 -04:00
kjeremy
810c961961 Update crates 2020-05-01 18:26:42 -04:00
bors[bot]
3232fd5179
Merge #4220 #4240
4220: Introduce LowerCtx r=matklad a=edwin0cheng

This PR introduces `LowerCtx` for path lowering. 

After this PR, there are only 2 places remains for using deprecated `Path::from_ast`, which is related to `AstTransform` I am not familiar. I would like to change these in another PR by others ;)

related disscusiion:  https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Path.3A.3Afrom_src

And also fixed part of https://github.com/rust-analyzer/rust-analyzer/issues/4176#issuecomment-620672930

4240: Bump deps r=matklad a=lnicola



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-01 20:16:25 +00:00
kjeremy
99826dab15 Address comments 2020-05-01 14:12:31 -04:00
kjeremy
ee1628dba0 Mark most assists as the base "refactor" type
Most of them area. We will separate them out later but this gets them to
show up in the "refactor" menu of vscode.
2020-05-01 13:44:32 -04:00
kjeremy
e75565c73f Advertise support for all the builtin CodeActionKinds
Even thought we don't return all of these we eventually will so might as
well advertise now.
2020-05-01 13:44:32 -04:00
kjeremy
e3ee61f5e8 Filter out CodeActions if a server only support commands. 2020-05-01 13:44:32 -04:00
Laurențiu Nicola
1e20467c3a Bump deps 2020-05-01 15:29:03 +03:00
Laurențiu Nicola
1a2d4e2921 Add support for incremental text synchronization 2020-04-30 21:26:57 +03:00
bors[bot]
07f690ddf6
Merge #4161
4161: lsp-types 0.74 r=kjeremy a=kjeremy

* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-04-28 20:12:44 +00:00
Aleksey Kladov
890938a48c Make it impossible to forget to add a semantic token type / modifier 2020-04-28 17:14:05 +02:00
Leander Tentrup
052e9faa90 Introduce new semantic highlight token for format specifier 2020-04-28 11:13:12 +02:00
Christophe MASSOLIN
ed5af989f4 [config] rename cargo.defaultTarget 2020-04-28 00:15:54 +02:00
Christophe MASSOLIN
b7edffe244 Started rust-analyzer.cargo.defaultTarget implementation 2020-04-27 00:11:04 +02:00
kjeremy
61f1c0a990 lsp-types 0.74
* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions
2020-04-26 16:05:22 -04:00
Aleksey Kladov
5ef0f44499 Add cargo test to the list of Run commands 2020-04-26 10:40:34 +02:00
bors[bot]
45832b990c
Merge #4145
4145: Remove dead code r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-25 19:30:04 +00:00
bors[bot]
7021352dc2
Merge #4113 #4136 #4141 #4142
4113: Support returning non-hierarchical symbols r=matklad a=kjeremy

If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144

4136: add support for cfg feature attributes on expression #4063 r=matklad a=bnjjj

close issue #4063

4141: Fix typo r=matklad a=Veetaha



4142: Remove unnecessary async from vscode language client creation r=matklad a=Veetaha



Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-25 19:23:15 +00:00
Aleksey Kladov
7623db1106 minor clenup 2020-04-25 19:30:00 +02:00
bors[bot]
fc57358efd
Merge #4133
4133: main: eagerly prime goto-definition caches r=matklad a=BurntSushi

This commit eagerly primes the caches used by goto-definition by
submitting a "phantom" goto-definition request. This is perhaps a bit
circuitous, but it does actually get the job done. The result of this
change is that once RA is finished its initial loading of a project,
goto-definition requests are instant. There don't appear to be any more
surprise latency spikes.

This _partially_ addresses #1650 in that it front-loads the latency of the
first goto-definition request, which in turn makes it more predictable and
less surprising. In particular, this addresses the use case where one opens
the text editor, starts reading code for a while, and only later issues the
first goto-definition request. Before this PR, that first goto-definition request
is guaranteed to have high latency in any reasonably sized project. But
after this PR, there's a good chance that it will now be instant.

What this _doesn't_ address is that initial loading time. In fact, it makes it
longer by adding a phantom goto-definition request to the initial startup
sequence. However, I observed that while this did make initial loading
slower, it was overall a somewhat small (but not insignificant) fraction
of initial loading time.

-----

At least, the above is what I _want_ to do. The actual change in this PR is just a proof-of-concept. I came up with after an evening of printf-debugging. Once I found the spot where this cache priming should go, I was unsure of how to generate a phantom input. So I just took an input I knew worked from my printf-debugging and hacked it in. Obviously, what I'd like to do is make this more general such that it will always work.

I don't know whether this is the "right" approach or not. My guess is that there is perhaps a cleaner solution that more directly primes whatever cache is being lazily populated rather than fudging the issue with a phantom goto-definition request.

I created this as a draft PR because I'd really like help making this general. I think whether y'all want to accept this patch is perhaps a separate question. IMO, it seems like a good idea, but to be honest, I'm happy to maintain this patch on my own since it's so trivial. But I would like to generalize it so that it will work in any project.

My thinking is that all I really need to do is find a file and a token somewhere in the loaded project, and then use that as input. But I don't quite know how to connect all the data structures to do that. Any help would be appreciated!

cc @matklad since I've been a worm in your ear about this problem. :-)

Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2020-04-25 14:30:10 +00:00
Andrew Gallant
0c12b7e8c8
main: fix bug where thread pool isn't joined
Pointed out here:
https://github.com/rust-analyzer/rust-analyzer/pull/4133#issuecomment-619386272
2020-04-25 10:26:33 -04:00
Andrew Gallant
c1a31d4261
main: eagerly prime goto-definition caches
This commit makes RA more aggressive about eagerly priming the caches.
In particular, this fixes an issue where even after RA was done priming
its caches, an initial goto-definition request would have very high
latency. This fixes that issue by requesting syntax highlighting for
everything. It is presumed that this is a tad wasteful, but not overly
so.

This commit also tweaks the logic that determines when the cache is
primed. Namely, instead of just priming it when the state is loaded
initially, we attempt to prime it whenever some state changes. This
fixes an issue where if a modification notification is seen before cache
priming is done, it would stop the cache priming early.
2020-04-25 09:28:34 -04:00
bors[bot]
f654f49435
Merge #4125
4125: Avoid lossy OsString conversions r=matklad a=lnicola

This is a bit invasive, and perhaps for not much benefit since non-UTF-8 environment variables don't work anyway.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-25 10:35:14 +00:00
Aleksey Kladov
dc2151085e Cleanups 2020-04-25 11:59:18 +02:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
Laurențiu Nicola
58dde891f8 Avoid lossy OsString conversions 2020-04-25 12:19:23 +03:00
Roberto Vidal
0dab5d5879 Adds attribute completions (#3941) 2020-04-24 17:54:52 +02:00
kjeremy
0619c67ac6 Support returning non-hierarchical symbols
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144
2020-04-24 10:11:57 -04:00
kjeremy
ae1f77e5e9 Add hierarchical symbols client capability 2020-04-24 10:08:45 -04:00
bors[bot]
44e6c2cb54
Merge #4101
4101: Panic proc macro srv if read request failed r=matklad a=edwin0cheng

This PR fixed a bug when the rust-analyzer is killed suddenly, the `rust-analyzer proc-macro` will become stale.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-24 01:28:53 +00:00
Aleksey Kladov
440cd05edb Honor snippet capability
closes #2518
2020-04-24 02:41:07 +02:00
Aleksey Kladov
b3050bded1 Introduce internal snippet cap 2020-04-24 02:06:12 +02:00
Aleksey Kladov
88d243c742 Don't set sortText
I might be reading this wrong, but it looks like we are setting it to
essentially arbitrary string at the moment, as there are no defined
order on the items in the *set* of completions.
2020-04-24 01:53:37 +02:00
bors[bot]
e833e03783
Merge #3954
3954: Improve autocompletion by looking on the type and name r=matklad a=bnjjj

This tweet (https://twitter.com/tjholowaychuk/status/1248918374731714560) gaves me the idea to implement that in rust-analyzer.

Basically for this first example I made some examples when we are in a function call definition. I look on the parameter list to prioritize autocompletions for the same types and if it's the same type + the same name then it's displayed first in the completion list.

So here is a draft, first step to open a discussion and know what you think about the implementation. It works (cf tests) but maybe I can make a better implementation at some places. Be careful the code needs some refactoring to be better and concise.

PS: It was lot of fun writing this haha

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-23 21:48:45 +00:00
Aleksey Kladov
27dd0086ea Fully get rid of SyntaxNodePtr::range 2020-04-23 21:23:36 +02:00
Edwin Cheng
1627b55028 Bubble up error 2020-04-24 01:38:58 +08:00
Aleksey Kladov
ca6d7bfe61 Cleanup proc_macro config
In general, there should be no reason to call `.to_string_lossy`.
If you want to display the path, use `.display()`.
If you want to pass the path to an OS API (like std::process::Command)
than use `PathBuf` or `OsString`.
2020-04-23 18:55:26 +02:00
bors[bot]
0502be3bf4
Merge #4093
4093: Simplify config r=matklad a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-23 09:49:03 +00:00
bors[bot]
604b936ca0
Merge #4092
4092: feat: run ignored tests r=matklad a=hdevalke

I started making some exercices on https://exercism.io/ and a lot of test have the `#[ignore]` attribute.
The `Run Test|Debug` code lens show up, but running the test results in:

```
running 1 test
test test_one_piece ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 5 filtered out
```

This pull request adds the `--ignored` flag if needed.

Co-authored-by: Hannes De Valkeneer <hannes@de-valkeneer.be>
2020-04-23 09:24:15 +00:00
veetaha
a3a8d10191 Fix typo 2020-04-23 02:00:56 +03:00
veetaha
364fbd7fc7 Simplify config 2020-04-23 01:30:55 +03:00
Hannes De Valkeneer
380a2870c7 feat: run ignored tests 2020-04-22 23:54:09 +02:00
bors[bot]
3f1f3a835a
Merge #4090
4090: Fix config naming r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-22 15:26:47 +00:00
Aleksey Kladov
9e16e2b279 Align the name of proc-macro enabling flag
We use `enable`, not `enabled` elsewhere
2020-04-22 17:22:59 +02:00
Aleksey Kladov
d436beeb04 Match implementation of diagnostics flag to the docs 2020-04-22 17:22:18 +02:00
Andrew Chin
165f5c6577 Don't panic on rust-analyzer --help
Special case handling for `-h` and `--help` if no subcommand is given.

Closes #4068
2020-04-21 20:23:01 -04:00
Benjamin Coenen
da6b136ea5 Improve autocompletion by looking on the type and name
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-21 17:19:18 +02:00
Benjamin Coenen
7f143b154e Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-21 14:32:02 +02:00
Aleksey Kladov
d9bed8aa45 Cleanup args a bit 2020-04-21 12:06:25 +02:00
bors[bot]
0ad6b6d407
Merge #4061
4061: ra_proc_macro: cleanups here and there r=edwin0cheng a=Veetaha

r? @edwin0cheng 

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-04-20 20:25:33 +00:00
veetaha
d3019164dc ra_proc_macro: cleanups here and there 2020-04-20 21:37:02 +03:00
Jeremy Kolb
d7f3d858ad Some clippy fixes 2020-04-19 15:15:49 -04:00
Aleksey Kladov
ca61356b01 Add semantic tag for unresolved references
This is a quick way to implement unresolved reference diagnostics.
For example, adding to VS Code config

    "editor.tokenColorCustomizationsExperimental": {
        "unresolvedReference": "#FF0000"
    },

will highlight all unresolved refs in red.
2020-04-18 21:28:51 +02:00
Benjamin Coenen
af3c19e85f Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-18 17:14:24 +02:00
bors[bot]
f8016b8194
Merge #3996
3996: Fix path for proc-macro in nightly / stable release r=matklad a=edwin0cheng

I messed up that I forget we use different executable names for nightly / stable release, I changed to use the current executable name instead.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-17 09:31:57 +00:00
Benjamin Coenen
0a1585075c Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-17 10:30:39 +02:00
Edwin Cheng
ef6ee16006 Fix path for proc-macro in nightly / stable build 2020-04-17 04:45:03 +08:00
bors[bot]
8d296be109
Merge #3995
3995: Separate project discovery from project loading r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-16 20:36:19 +00:00
Aleksey Kladov
422ae477ce Unmix error handling when discovering workspaces
Hitting an io::Error is a legit problem. Finding more than one
Cargo.toml is not.
2020-04-16 22:35:50 +02:00
Aleksey Kladov
be2654b0ed Decouple project loading from project discovery a bit 2020-04-16 22:02:10 +02:00
Benjamin Coenen
6ebc8bbeb0 feat: improve dot completions with scoring
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-16 18:30:08 +02:00
Edwin Cheng
177becea98 Add proc-macro cli command for rust-analyzer 2020-04-16 21:13:57 +08:00
Edwin Cheng
ca7dc69a8e Add tests for proc_macro 2020-04-16 19:28:06 +08:00
Edwin Cheng
a4b0ce07f8 Add config for proc_macro 2020-04-16 19:28:06 +08:00
Edwin Cheng
22e33f308a Add with-proc-macro in bench ,stats and diagnositcs 2020-04-16 19:27:44 +08:00
Josh Mcguigan
6be972770e diagnostics cli, iterate over members 2020-04-14 16:26:03 -07:00
Benjamin Coenen
c5d18f570c add sort_text to sort in editor view
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-14 19:28:33 +02:00
Josh Mcguigan
f9701efbe7 cli diagnostics walk files 2020-04-14 04:35:34 -07:00
Josh Mcguigan
f62c73a972 add diagnostics subcommand to rust-analyzer CLI 2020-04-13 18:40:41 -07:00
Aleksey Kladov
0aece75cdd Remove dead code 2020-04-11 19:36:31 +02:00
Edwin Cheng
73e512215a Fix non canonicallized path for crate file 2020-04-11 18:12:50 +08:00
Josh Mcguigan
8f7fceeb9c fix cargo check config with custom command 2020-04-06 21:41:31 -07:00
Aleksey Kladov
bf569f8b29 Check for eprintln on CI 2020-04-06 17:00:18 +02:00
Aleksey Kladov
ec3fb1cdb4
Merge pull request #3853 from matklad/cf
Make control token modifier less ambiguous
2020-04-06 11:53:56 +02:00
Aleksey Kladov
48bc0ca745 Make control token modifier less ambiguous
In textmate, keyword.control is used for all kinds of things; in fact,
the default scope mapping for keyword is keyword.control!

So let's add a less ambiguous controlFlow modifier

See Microsoft/vscode#94367
2020-04-06 09:57:50 +02:00
veetaha
a1773f8a67 Remove explicit generic type parameter 2020-04-04 16:12:09 +03:00
veetaha
b5a7cb331f Simplify config 2020-04-04 16:04:49 +03:00
veetaha
c0cf60dca2 Apply cargo xtask format 2020-04-02 21:12:28 +03:00
veetaha
6190caeeae Migrate to privacy as per review commets 2020-04-02 21:09:03 +03:00
veetaha
b7d5172f69 Simpify workspace handling 2020-04-02 21:07:05 +03:00
veetaha
4b2bf9cf66 Don't clone where you can copy 2020-04-02 21:07:05 +03:00
Aleksey Kladov
8a788c764f Allow fully overriding check and fmt commands 2020-04-02 14:35:51 +02:00
Aleksey Kladov
7a4ebd2c8d Remove vscode_lldb setting 2020-04-02 12:56:14 +02:00
Aleksey Kladov
e21bf1b2b9 Siplify 2020-04-02 12:50:34 +02:00
Aleksey Kladov
48c58309cc Lean onto default implementation of configs 2020-04-02 12:47:58 +02:00
Aleksey Kladov
e4cf40a152 New config in package.json 2020-04-02 12:27:09 +02:00
Aleksey Kladov
0dde0f92de Reorder fields 2020-04-02 11:33:49 +02:00
Aleksey Kladov
309fc70155 Remove old syntax highlighting 2020-04-02 09:52:27 +02:00
Aleksey Kladov
1225f719fe Fix pointer syntax 2020-04-01 19:27:45 +02:00
Aleksey Kladov
1ac345a9f6 Centralize defaults 2020-04-01 18:56:47 +02:00
Aleksey Kladov
4936abdd49 Reduce scope of deserialization 2020-04-01 18:51:16 +02:00
Aleksey Kladov
e870cbc23d Centralize client capabilities 2020-04-01 18:46:26 +02:00
Aleksey Kladov
a97e5eb85d Centralize all config 2020-04-01 18:41:43 +02:00
Aleksey Kladov
1e012eb991 Move all config to config 2020-04-01 17:22:56 +02:00
Aleksey Kladov
797cd34c7c Reduce feature flags 2020-04-01 17:00:37 +02:00
Aleksey Kladov
b9bf29019d Move config to config.rs 2020-04-01 14:32:04 +02:00
Aleksey Kladov
6ac9668998 Generalize rustfmt config 2020-04-01 14:26:08 +02:00
Aleksey Kladov
f01846b8ee Generalize Flycheckconfig 2020-04-01 13:14:38 +02:00
Aleksey Kladov
65c89c3a20 Cleanup 2020-04-01 12:34:12 +02:00
Aleksey Kladov
3990d971e5 Crisper name
https://www.flycheck.org/en/latest/
2020-04-01 11:09:19 +02:00