Commit graph

620 commits

Author SHA1 Message Date
Aleksey Kladov
b3fa7312a7 Simpler deserialization 2020-03-12 18:01:36 +01:00
bors[bot]
d98a5fab46
Merge #3543
3543: Parameter inlay hint separate from variable type inlay? #2876 r=matklad a=slyngbaek

Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-12 16:02:55 +00:00
Steffen Lyngbaek
a153b90875 Make maxLength nullable again 2020-03-12 08:43:07 -07:00
Steffen Lyngbaek
58248e24cd Switch from Vec<InlayKind> to object with props
- Instead of a single object type, use several individual nested types
  to allow toggling from the settings GUI
- Remove unused struct definitions
- Install and test that the toggles work
2020-03-11 20:14:39 -07:00
Hannes De Valkeneer
e903fd0d97 feat: add debug code lens
Refs #3539
2020-03-11 22:26:47 +01:00
Matthias Krüger
d48bae6ebb settings: rust-analyzer.cargo-watch.enable: clarify that the setting enables the cargo-watch command and not "cargo check" 2020-03-11 12:32:24 +01:00
bors[bot]
c48dcf7411
Merge #3549
3549: Implement env! macro r=matklad a=edwin0cheng

This PR implements `env!` macro by adding following things:

1. Added `additional_outdirs` settings in vscode. (naming to be bikeshed)
2. Added `ExternSourceId` which is a wrapping for SourceRootId but only used in extern sources. It is because `OUT_DIR` is not belonged to any crate and we have to access it behind an `AstDatabase`.
3. This PR does not implement the `OUT_DIR` parsing from `cargo check`. I don't have general design about this,  @kiljacken could we reuse some cargo watch code for that ?

~~Block on [#3536]~~

PS: After this PR , we (kind of) completed the `include!(concat!(env!('OUT_DIR'),  "foo.rs")` macro call combo. [Exodia Obliterate!](https://www.youtube.com/watch?v=RfqNH3FoGi0)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-11 10:51:07 +00:00
Steffen Lyngbaek
cfb48df149 Address Issues from Github
- Updated naming of config
- Define struct in ra_ide and use remote derive in rust-analyzer/config
- Make inlayConfig type more flexible to support more future types
- Remove constructor only used in tests
2020-03-10 14:36:01 -07:00
Steffen Lyngbaek
e98aff109a Parameter inlay hint separate from variable type inlay? #2876
Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side
2020-03-10 14:33:45 -07:00
kjeremy
dda6ce6f13 Force latest stable 2020-03-10 13:31:13 -04:00
Edwin Cheng
c1db5d26a0 Add additional_outdirs in config 2020-03-11 01:06:01 +08:00
bors[bot]
fcaab59451
Merge #3514
3514: vscode: askBeforeDownload option r=matklad a=Veetaha

This is a small step towards #3402, also implements my proposal stated in #3403

Also renamed `BinarySource` to `ArtifactSource` in anticipation of nightlies installation that requires downloading not a binary itself but `.vsix` package, thus generalized to `artifact` term.

@matklad @lnicola 

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-03-09 09:05:45 +00:00
Veetaha
ce65cc949f vscode: groupd updates-related config under updates section as per @matklad 2020-03-09 10:59:36 +02:00
Julien Roncaglia
a231172283 Use markdown description in vscode 2020-03-08 22:46:42 +01:00
Veetaha
de99fa7199 vscode: fix inversion of askBeforeDownload 2020-03-08 21:47:35 +02:00
Veetaha
6bd1ff16e5 vscode: rename alwaysDownloadServer -> askBeforeDownload
The new name seems much simpler and it doesn't limit
this config value only to downloading the server binary.
Thus we wouldn't need to create another config
properties to handle other downloads whatsoever.
Anyway, I believe (heuristically) that most of the users
would want to set "askBeforeDownload": false once
and never bother clicking on the notification again
(because otherwise there is no big point in installing rust-analyzer if it cannot install the server)
2020-03-08 18:58:02 +02:00
Veetaha
c29a502e25 vscode: care about alwaysDownloadServer option before asking
Also renamed BinarySource to ArtifactSource in anticipation of
nightlies installation that requires downloading
not a binary itself but .vsix package, thus generalized
to `artifact` term
2020-03-08 00:01:48 +02:00
Veetaha
9dae94a78d vscode: contribute "alwaysDownloadServer" option to config 2020-03-07 23:59:33 +02:00
Veetaha
65cecff316 vscode: post refactor HintsUpdater (simplify create() -> constructor call) 2020-03-07 14:39:42 +02:00
Veetaha
61a4ea2532 vscode: more privacy for HintsUpdater 2020-03-07 14:37:15 +02:00
Veetaha
2734ffa20c vscode: remove logging from inlays, run fix lint issues 2020-03-07 14:34:09 +02:00
Veetaha
ef52fd543f vscode: remove logic for caching editors as per @matklad 2020-03-07 14:08:35 +02:00
Veetaha
a63446f254 vscode: prerefactor util.ts and ctx.ts 2020-03-07 14:08:35 +02:00
Veetaha
3d93e2108e vscode: refresh all editors on text changes, simplify inlays api 2020-03-07 14:08:35 +02:00
Veetaha
057cd959da vscode: add dat semicolon 2020-03-07 14:08:35 +02:00
Veetaha
fd709c0c04 vscode: simpify 2020-03-07 14:08:35 +02:00
Veetaha
6441988d84 vscode: redesign inlay hints to be capable of handling multiple editors 2020-03-07 14:08:35 +02:00
Veetaha
0e6d066a29 vscode: extract Type and Param hint cases of InlayHint at type level (needed further) 2020-03-07 14:08:35 +02:00
Aleksey Kladov
dd4b001505 ⬆️ npm deps 2020-03-06 23:22:58 +01:00
Aleksey Kladov
80909f7698 Don't creat public APIs with typos 2020-03-06 18:38:56 +01:00
Aleksey Kladov
95a2755aa8 Concise mode for parameter hints
This works around VS Code bug where it tries to cram everything in a
tiny popup, and brings experience closer to Intellij.
2020-03-06 18:35:30 +01:00
Aleksey Kladov
4e7f6c2354 Feature flag for arg snippets 2020-03-06 17:51:10 +01:00
Aleksey Kladov
34d6e22fc1 Actually include readme into .vsix 2020-03-03 18:40:27 +01:00
bors[bot]
b55d22e060
Merge #3388
3388: Remove inlay hint in diff views r=matklad a=vbfox

If the left side of a diff view that contain the old version of the file apply inlays they are misplaced and produce a weird display:

![image](https://user-images.githubusercontent.com/131878/75628802-b1ac1900-5bdc-11ea-8c26-6722d8e38371.png)

After the change:

![image](https://user-images.githubusercontent.com/131878/75628831-e91ac580-5bdc-11ea-9039-c6b4ffbdb2be.png)

The detection is done by blacklisting the url schemes used by git and subversion scm extensions, whitelisting `file` is also possible but neither is perfect as VSCode now support both pluggable scm extensions and pluggable remote filesystems. But I suspect that the list of scm extensions is more easily manageable.

**Note**: I can rebase on #3378 if needed as it touches the same lines of code

Co-authored-by: Julien Roncaglia <julien@roncaglia.fr>
2020-03-03 13:45:26 +00:00
Jeremy Kolb
f51b655fef Update code dependencies 2020-03-03 08:05:59 -05:00
Julien Roncaglia
2f54c1d653 Centralize the check for languageId on document
Also move visibleRustEditors to Ctx
2020-03-02 22:54:29 +01:00
Aleksey Kladov
dbd1698e02 Don't fail loudly if the old highlighting breaks 2020-03-02 14:46:46 +01:00
Aleksey Kladov
57d0f238cc Minimal viable meta 2020-03-02 14:27:26 +01:00
Julien Roncaglia
b95756d21b Remove inlay in diff views
If the left side of a diff view that contain the old
version of the file apply inlays they are misplaced.

The detection is done by blacklisting the url schemes used
by git and subversion scm extensions.
2020-03-01 16:54:56 +01:00
Veetaha
6dc598fa63 vscode: simplify assert.eq() to assert() as per matklad 2020-02-29 00:59:42 +02:00
Veetaha
e7bf99e6fd vscode: add dat semicolon 2020-02-29 00:33:34 +02:00
Veetaha
3ad0574d7e vscode: add equality assertion 2020-02-29 00:26:22 +02:00
Veetaha
9cf2577054 vscode: rename nodeAssert -> nativeAssert 2020-02-29 00:07:29 +02:00
Veetaha
b88887e70e vscode: add error loging on failed assertion 2020-02-29 00:02:19 +02:00
Veetaha
1b9ab04d4b vscode: migrate to more type-safe assert impl 2020-02-28 23:56:17 +02:00
Aleksey Kladov
da40149572 Fix union classification 2020-02-28 15:03:09 +01:00
bors[bot]
2995fd2c87
Merge #3363
3363: Cleanup highlighting tags r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-28 13:48:42 +00:00
Jason Williams
8e88db90bc removing ctrl+r key binding fixes #2733 2020-02-28 12:50:11 +00:00
Aleksey Kladov
701cf43606 Cleanup highlighting tags 2020-02-28 12:13:37 +01:00
bors[bot]
3e25b17cfd
Merge #3361
3361: Reset fontStyle for inlay hints r=matklad a=matklad

Otherwise, we get bold hints on `true` and `false`



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-28 10:32:18 +00:00
Aleksey Kladov
84b009cbf7 Reset fontStyle for inlay hints
Otherwise, we get bold hints on `true` and `false`
2020-02-28 11:31:53 +01:00
Aleksey Kladov
996e18846d add more tags 2020-02-28 10:39:31 +01:00
Veetaha
9251cd8440 vscode: added feature flags for better short-term ux 2020-02-27 22:04:57 +02:00
Aleksey Kladov
873156640d Map builtin 2020-02-27 18:37:25 +01:00
Aleksey Kladov
00fc17272d Set attr scope 2020-02-27 18:31:54 +01:00
Aleksey Kladov
4e5c1f5608 Map unsafe keyword 2020-02-27 17:28:59 +01:00
Aleksey Kladov
b8d7c4e1ad Fix style 2020-02-27 11:10:58 +01:00
Aleksey Kladov
cfa5afa02d Fix lint 2020-02-27 10:46:43 +01:00
Aleksey Kladov
356395139c Actually gate CI on eslint 2020-02-27 10:40:53 +01:00
bors[bot]
ebeca1990e
Merge #3339
3339: Fix flickering with new syntax highlighting r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-27 09:25:34 +00:00
Aleksey Kladov
b49508ffe3 Fix flickering with new syntax highlighting 2020-02-27 10:19:56 +01:00
bors[bot]
04b3bd5ee8
Merge #3308
3308: vscode: fix vscode-vim keybindings conflict r=matklad a=Veetaha

Closes #3013 I hope

vscode-vim extension overrides the `type` command so that it prevents
some keypresses to reach the text document editor.
It conflicts with our `onEnter` keybinding
that is used to support automatic doc comments extending and
indentation insertion.

The VSCode-native way to implement this would be
to use regular expressions, but as per matklad it is
considered not acceptable for the language server.

Thus we implement it via a `Enter` keybinding that
invokes our `onEnter` command which does it via the language-server.

At the end of the day we may only apply
ad hoc workarounds for conflicting extensions.
But vscode has another bug for that. You
either cannot use parantheses in `when` condition
of a keybinding or it just malfunctions.

See an issue about that here: https://github.com/microsoft/vscode/issues/91473
To get the ultimate context, follow this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Enhanced.20typing)

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-27 09:00:31 +00:00
Aleksey Kladov
a8e68ff814 Color constants 2020-02-27 09:32:00 +01:00
Aleksey Kladov
f7db49bfc6 Better highlightign API 2020-02-27 09:32:00 +01:00
Aleksey Kladov
723e83fb25 wip 2020-02-26 22:08:21 +01:00
Aleksey Kladov
225ef6dea2 Config to switch to semantic tokens 2020-02-26 16:03:30 +01:00
Aleksey Kladov
8c0d0894b6
Merge pull request #3321 from kjeremy/semantic-client
Enable SemanticTokens on the client
2020-02-26 15:59:30 +01:00
Jeremy Kolb
74125d012e Enable SemanticTokens on the client
This will crash the extension on stable and insiders without the "--enable-proposed-api matklad.rust-analyzer" command line switch.
2020-02-26 08:42:26 -05:00
Aleksey Kladov
1f1bda2c5a Remove unnecessary dep 2020-02-26 14:21:23 +01:00
Veetaha
655c8337c0 vscode: fix vscode-vim keybindings conflict
vscode-vim extension overrides the `type` command so that it prevents
some keypresses to reach the text document editor.
It conflicts with our `onEnter` keybinding
that is used to support automatic doc comments extending and
indentation insertion.

The VSCode-native way to implement this would be
to use regular expressions, but as per matklad it is
considered not acceptable for the language server.

Thus we implement it via a `Enter` keybinding that
invokes our `onEnter` command which sends
a request to rust-analyzer process and applies
the appropriate source change recieved from it.

At the end of the day we may only apply
ad hoc workarounds for conflicting extensions.
But vscode has another bug for that. You
either cannot use parantheses in `when` condition
of a keybinding or it just malfunctions.

See an issue about that here: https://github.com/microsoft/vscode/issues/91473
To get the ultimate context, follow this zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Enhanced.20typing
2020-02-25 23:20:07 +02:00
bors[bot]
c4c15363fb
Merge #3295
3295: Refactoring fetchArtifactReleaseInfo() r=matklad a=Veetaha

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md

I fact this rule doesn't work when you put an unnecessary non-null assertion in an expression (as we had `(awat f())!`, but it is useful in other cases...

Closes #3295, i guess...

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-25 10:09:14 +00:00
bors[bot]
5e6f4ca690
Merge #3299
3299: vscode: migrate to request type api r=matklad a=Veetaha

More type-safety to the god of type-safety.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-25 09:55:56 +00:00
Veetaha
6ec4a7db42 vscode: wrap non-single-line if body with curlies as per matklad 2020-02-25 01:58:43 +02:00
Veetaha
18b97d9d36 vscode: migrate rust-analyzer-api to import * as lc as per matklad and kjeremy 2020-02-25 01:43:52 +02:00
Veetaha
72e81dae71 vscode: run fmt 2020-02-25 01:00:00 +02:00
Veetaha
c9230b88b4 vscode: migrate inlay_hints to rust-analyzer-api.ts 2020-02-25 00:57:49 +02:00
Veetaha
8aea0ec511 vscode: migrate syntax_tree to rust-analyzer-api.ts 2020-02-25 00:57:14 +02:00
Veetaha
9ea63d5a86 vscode: migrate ssr to rust-analyzer-api.ts 2020-02-25 00:56:57 +02:00
Veetaha
8a8a4d08ef vscode: migrate runnables to rust-analyzer-api.ts 2020-02-25 00:56:38 +02:00
Veetaha
d6a96a90f4 vscode: migrate parent_module to rust-analyzer-api.ts 2020-02-25 00:56:19 +02:00
Veetaha
8c6581dcc3 vscode: migrate on_enter to rust-analyzer-api.ts 2020-02-25 00:55:48 +02:00
Veetaha
56d1ff6532 vscode: migrate matching_brace to rust-analyzer-api.ts 2020-02-25 00:55:13 +02:00
Veetaha
38d7945ec7 vscode: migrate join_lines to rust-analyzer-api.ts 2020-02-25 00:54:50 +02:00
Veetaha
c9a2fa1835 vscode: migrate collectGarbage to rust-analyzer-api.ts 2020-02-25 00:50:57 +02:00
Veetaha
31d9932d18 vscode: migrate expand_macro to rust-analyzer-api.ts 2020-02-25 00:50:36 +02:00
Veetaha
603bc71a57 vscode: migrate analyzer_status to rust-analyzer-api.ts 2020-02-25 00:50:14 +02:00
Veetaha
8c4409b3bb vscode: migrate highlighting to rust-analyzer-api.ts 2020-02-25 00:49:54 +02:00
Veetaha
21ab133966 vscode: migrate source_cnage.rs to rust-analyzer-api.rs 2020-02-25 00:49:19 +02:00
Veetaha
39efb301ff vscode: create rust-analyzer-api.ts 2020-02-25 00:48:44 +02:00
Veetaha
6d15f89a4b vscode: bump TypeScript version 2020-02-24 21:37:53 +02:00
Veetaha
af57251c31 vscode: remove type assertion 2020-02-24 21:23:56 +02:00
Veetaha
b4db089a6b add error handling to fetchArtifactReleaseInfo(), throw Error when no artifact found 2020-02-24 21:13:10 +02:00
Aleksey Kladov
cc1469fe9e Cleanp 2020-02-24 15:41:13 +01:00
bors[bot]
e2a8e891c1
Merge #3290
3290: Don't block onEnter if request fails r=matklad a=matklad

closes #3286



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-24 11:48:15 +00:00
Aleksey Kladov
910adb9dc7 Don't block onEnter if request fails
closes #3286
2020-02-24 12:45:34 +01:00
bors[bot]
223a6676fd
Merge #3288
3288: Quick fix circular json error when sanity-check fails r=matklad a=Veetaha

Related issue: #3280

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-24 11:40:06 +00:00
Aleksey Kladov
b12cbd6062 Don't break onEnter if rust-analyzer fails to start
closes #3253
2020-02-24 12:32:15 +01:00
Veetaha
ef4dfab3cc
Quick fix circular json error when sanity-check fails
Related issue: #3280
2020-02-24 11:56:52 +02:00
Veetaha
4cee7cddc8 vscode: gracefully handle cancellation errors 2020-02-23 15:49:09 +02:00
Aleksey Kladov
49844ab717 Extract client-side logging 2020-02-22 16:03:47 +01:00