diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/README.md | 70 | ||||
-rw-r--r-- | editors/code/package-lock.json | 17 | ||||
-rw-r--r-- | editors/code/package.json | 62 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 5 | ||||
-rw-r--r-- | editors/code/src/config.ts | 8 | ||||
-rw-r--r-- | editors/code/src/main.ts | 6 | ||||
-rw-r--r-- | editors/code/src/net.ts | 25 |
7 files changed, 146 insertions, 47 deletions
diff --git a/editors/code/README.md b/editors/code/README.md index 336695d9f..241489226 100644 --- a/editors/code/README.md +++ b/editors/code/README.md | |||
@@ -2,4 +2,72 @@ | |||
2 | 2 | ||
3 | Provides support for rust-analyzer: novel LSP server for the Rust programming language. | 3 | Provides support for rust-analyzer: novel LSP server for the Rust programming language. |
4 | 4 | ||
5 | See https://rust-analyzer.github.io/ for more information. | 5 | **Note** the extension may cause conflicts with the official Rust extension. It is recommended to disable the Rust extension when using the rust-analyzer extension. |
6 | |||
7 | **Note** the project is in alpha status: it is already useful in practice, but can't be considered stable. | ||
8 | |||
9 | ## Sponsor | ||
10 | |||
11 | Work on rust-analyzer is sponsored by | ||
12 | |||
13 | [<img src="https://user-images.githubusercontent.com/1711539/58105231-cf306900-7bee-11e9-83d8-9f1102e59d29.png" alt="Ferrous Systems" width="300">](https://ferrous-systems.com/) | ||
14 | |||
15 | - [Mozilla](https://www.mozilla.org/en-US/) | ||
16 | - [Embark Studios](https://embark-studios.com/) | ||
17 | - [freiheit.com](https://www.freiheit.com) | ||
18 | |||
19 | If you want to sponsor: | ||
20 | |||
21 | - [OpenCollective](https://opencollective.com/rust-analyzer/) | ||
22 | - [Github Sponsors](https://github.com/sponsors/rust-analyzer) | ||
23 | |||
24 | ## Features | ||
25 | |||
26 | - [code completion], [imports insertion] | ||
27 | - [go to definition], [implementation], [type definition] | ||
28 | - [find all references], [workspace symbol search], [rename] | ||
29 | - [types and documentation on hover] | ||
30 | - [inlay hints] | ||
31 | - [semantic syntax highlighting] | ||
32 | - a lot of [assist(code actions)] | ||
33 | - apply suggestions from errors | ||
34 | - ... and many more, checkout the [manual] to see them all | ||
35 | |||
36 | [code completion]: https://rust-analyzer.github.io/manual.html#magic-completions | ||
37 | [imports insertion]: https://rust-analyzer.github.io/manual.html#auto-import | ||
38 | [go to definition]: https://rust-analyzer.github.io/manual.html#go-to-definition | ||
39 | [implementation]: https://rust-analyzer.github.io/manual.html#go-to-implementation | ||
40 | [type definition]: https://rust-analyzer.github.io/manual.html#go-to-type-definition | ||
41 | [find all references]: https://rust-analyzer.github.io/manual.html#find-all-references | ||
42 | [workspace symbol search]: https://rust-analyzer.github.io/manual.html#workspace-symbol | ||
43 | [rename]: https://rust-analyzer.github.io/manual.html#rename | ||
44 | [types and documentation on hover]: https://rust-analyzer.github.io/manual.html#hover | ||
45 | [inlay hints]: https://rust-analyzer.github.io/manual.html#inlay-hints | ||
46 | [semantic syntax highlighting]: https://rust-analyzer.github.io/manual.html#semantic-syntax-highlighting | ||
47 | [assist(code actions)]: https://rust-analyzer.github.io/manual.html#assists-code-actions | ||
48 | |||
49 | [manual]: https://rust-analyzer.github.io/manual.html | ||
50 | |||
51 | ## Quick start | ||
52 | |||
53 | 1. Install [rustup] | ||
54 | 2. Install the [rust-analyzer extension] | ||
55 | |||
56 | [rustup]: https://rustup.rs | ||
57 | [rust-analyzer extension]: https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer | ||
58 | |||
59 | ## Configuration | ||
60 | |||
61 | This extension provides configurations through VSCode's configuration settings. All the configurations are under `rust-analyzer.*`. | ||
62 | |||
63 | See <https://rust-analyzer.github.io/manual.html#vs-code-2> for more information on VSCode specific configurations. | ||
64 | |||
65 | ## Communication | ||
66 | |||
67 | For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum: | ||
68 | |||
69 | <https://users.rust-lang.org/c/ide/14> | ||
70 | |||
71 | ## Documentation | ||
72 | |||
73 | See <https://rust-analyzer.github.io/> for more information. | ||
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 9d0d1d4ec..198c17556 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -9,6 +9,7 @@ | |||
9 | "version": "0.4.0-dev", | 9 | "version": "0.4.0-dev", |
10 | "license": "MIT OR Apache-2.0", | 10 | "license": "MIT OR Apache-2.0", |
11 | "dependencies": { | 11 | "dependencies": { |
12 | "https-proxy-agent": "^5.0.0", | ||
12 | "node-fetch": "^2.6.1", | 13 | "node-fetch": "^2.6.1", |
13 | "vscode-languageclient": "^7.1.0-next.4" | 14 | "vscode-languageclient": "^7.1.0-next.4" |
14 | }, | 15 | }, |
@@ -515,7 +516,6 @@ | |||
515 | "version": "6.0.2", | 516 | "version": "6.0.2", |
516 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", | 517 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", |
517 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", | 518 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", |
518 | "dev": true, | ||
519 | "dependencies": { | 519 | "dependencies": { |
520 | "debug": "4" | 520 | "debug": "4" |
521 | }, | 521 | }, |
@@ -830,6 +830,7 @@ | |||
830 | "dependencies": { | 830 | "dependencies": { |
831 | "anymatch": "~3.1.1", | 831 | "anymatch": "~3.1.1", |
832 | "braces": "~3.0.2", | 832 | "braces": "~3.0.2", |
833 | "fsevents": "~2.3.1", | ||
833 | "glob-parent": "~5.1.0", | 834 | "glob-parent": "~5.1.0", |
834 | "is-binary-path": "~2.1.0", | 835 | "is-binary-path": "~2.1.0", |
835 | "is-glob": "~4.0.1", | 836 | "is-glob": "~4.0.1", |
@@ -959,7 +960,6 @@ | |||
959 | "version": "4.3.1", | 960 | "version": "4.3.1", |
960 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", | 961 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", |
961 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", | 962 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", |
962 | "dev": true, | ||
963 | "dependencies": { | 963 | "dependencies": { |
964 | "ms": "2.1.2" | 964 | "ms": "2.1.2" |
965 | }, | 965 | }, |
@@ -1759,7 +1759,6 @@ | |||
1759 | "version": "5.0.0", | 1759 | "version": "5.0.0", |
1760 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", | 1760 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", |
1761 | "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", | 1761 | "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", |
1762 | "dev": true, | ||
1763 | "dependencies": { | 1762 | "dependencies": { |
1764 | "agent-base": "6", | 1763 | "agent-base": "6", |
1765 | "debug": "4" | 1764 | "debug": "4" |
@@ -2236,8 +2235,7 @@ | |||
2236 | "node_modules/ms": { | 2235 | "node_modules/ms": { |
2237 | "version": "2.1.2", | 2236 | "version": "2.1.2", |
2238 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", | 2237 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", |
2239 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", | 2238 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" |
2240 | "dev": true | ||
2241 | }, | 2239 | }, |
2242 | "node_modules/mute-stream": { | 2240 | "node_modules/mute-stream": { |
2243 | "version": "0.0.8", | 2241 | "version": "0.0.8", |
@@ -2682,6 +2680,9 @@ | |||
2682 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.39.1.tgz", | 2680 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.39.1.tgz", |
2683 | "integrity": "sha512-9rfr0Z6j+vE+eayfNVFr1KZ+k+jiUl2+0e4quZafy1x6SFCjzFspfRSO2ZZQeWeX9noeDTUDgg6eCENiEPFvQg==", | 2681 | "integrity": "sha512-9rfr0Z6j+vE+eayfNVFr1KZ+k+jiUl2+0e4quZafy1x6SFCjzFspfRSO2ZZQeWeX9noeDTUDgg6eCENiEPFvQg==", |
2684 | "dev": true, | 2682 | "dev": true, |
2683 | "dependencies": { | ||
2684 | "fsevents": "~2.3.1" | ||
2685 | }, | ||
2685 | "bin": { | 2686 | "bin": { |
2686 | "rollup": "dist/bin/rollup" | 2687 | "rollup": "dist/bin/rollup" |
2687 | }, | 2688 | }, |
@@ -3843,7 +3844,6 @@ | |||
3843 | "version": "6.0.2", | 3844 | "version": "6.0.2", |
3844 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", | 3845 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", |
3845 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", | 3846 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", |
3846 | "dev": true, | ||
3847 | "requires": { | 3847 | "requires": { |
3848 | "debug": "4" | 3848 | "debug": "4" |
3849 | } | 3849 | } |
@@ -4190,7 +4190,6 @@ | |||
4190 | "version": "4.3.1", | 4190 | "version": "4.3.1", |
4191 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", | 4191 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", |
4192 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", | 4192 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", |
4193 | "dev": true, | ||
4194 | "requires": { | 4193 | "requires": { |
4195 | "ms": "2.1.2" | 4194 | "ms": "2.1.2" |
4196 | } | 4195 | } |
@@ -4798,7 +4797,6 @@ | |||
4798 | "version": "5.0.0", | 4797 | "version": "5.0.0", |
4799 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", | 4798 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", |
4800 | "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", | 4799 | "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", |
4801 | "dev": true, | ||
4802 | "requires": { | 4800 | "requires": { |
4803 | "agent-base": "6", | 4801 | "agent-base": "6", |
4804 | "debug": "4" | 4802 | "debug": "4" |
@@ -5175,8 +5173,7 @@ | |||
5175 | "ms": { | 5173 | "ms": { |
5176 | "version": "2.1.2", | 5174 | "version": "2.1.2", |
5177 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", | 5175 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", |
5178 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", | 5176 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" |
5179 | "dev": true | ||
5180 | }, | 5177 | }, |
5181 | "mute-stream": { | 5178 | "mute-stream": { |
5182 | "version": "0.0.8", | 5179 | "version": "0.0.8", |
diff --git a/editors/code/package.json b/editors/code/package.json index 7ee5d82ad..923e9b35a 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -35,6 +35,7 @@ | |||
35 | "test": "node ./out/tests/runTests.js" | 35 | "test": "node ./out/tests/runTests.js" |
36 | }, | 36 | }, |
37 | "dependencies": { | 37 | "dependencies": { |
38 | "https-proxy-agent": "^5.0.0", | ||
38 | "node-fetch": "^2.6.1", | 39 | "node-fetch": "^2.6.1", |
39 | "vscode-languageclient": "^7.1.0-next.4" | 40 | "vscode-languageclient": "^7.1.0-next.4" |
40 | }, | 41 | }, |
@@ -390,13 +391,18 @@ | |||
390 | "Force import paths to be absolute by always starting them with `crate` or the crate name they refer to." | 391 | "Force import paths to be absolute by always starting them with `crate` or the crate name they refer to." |
391 | ] | 392 | ] |
392 | }, | 393 | }, |
394 | "rust-analyzer.assist.importGroup": { | ||
395 | "markdownDescription": "Group inserted imports by the [following order](https://rust-analyzer.github.io/manual.html#auto-import). Groups are separated by newlines.", | ||
396 | "default": true, | ||
397 | "type": "boolean" | ||
398 | }, | ||
393 | "rust-analyzer.callInfo.full": { | 399 | "rust-analyzer.callInfo.full": { |
394 | "markdownDescription": "Show function name and docs in parameter hints.", | 400 | "markdownDescription": "Show function name and docs in parameter hints.", |
395 | "default": true, | 401 | "default": true, |
396 | "type": "boolean" | 402 | "type": "boolean" |
397 | }, | 403 | }, |
398 | "rust-analyzer.cargo.autoreload": { | 404 | "rust-analyzer.cargo.autoreload": { |
399 | "markdownDescription": "Automatically refresh project info via `cargo metadata` on `Cargo.toml` changes.", | 405 | "markdownDescription": "Automatically refresh project info via `cargo metadata` on\n`Cargo.toml` changes.", |
400 | "default": true, | 406 | "default": true, |
401 | "type": "boolean" | 407 | "type": "boolean" |
402 | }, | 408 | }, |
@@ -413,9 +419,9 @@ | |||
413 | "type": "string" | 419 | "type": "string" |
414 | } | 420 | } |
415 | }, | 421 | }, |
416 | "rust-analyzer.cargo.loadOutDirsFromCheck": { | 422 | "rust-analyzer.cargo.runBuildScripts": { |
417 | "markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs.", | 423 | "markdownDescription": "Run build scripts (`build.rs`) for more precise code analysis.", |
418 | "default": false, | 424 | "default": true, |
419 | "type": "boolean" | 425 | "type": "boolean" |
420 | }, | 426 | }, |
421 | "rust-analyzer.cargo.noDefaultFeatures": { | 427 | "rust-analyzer.cargo.noDefaultFeatures": { |
@@ -442,7 +448,7 @@ | |||
442 | "type": "boolean" | 448 | "type": "boolean" |
443 | }, | 449 | }, |
444 | "rust-analyzer.checkOnSave.allFeatures": { | 450 | "rust-analyzer.checkOnSave.allFeatures": { |
445 | "markdownDescription": "Check with all features (`--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`.", | 451 | "markdownDescription": "Check with all features (`--all-features`).\nDefaults to `#rust-analyzer.cargo.allFeatures#`.", |
446 | "default": null, | 452 | "default": null, |
447 | "type": [ | 453 | "type": [ |
448 | "null", | 454 | "null", |
@@ -468,7 +474,7 @@ | |||
468 | ] | 474 | ] |
469 | }, | 475 | }, |
470 | "rust-analyzer.checkOnSave.target": { | 476 | "rust-analyzer.checkOnSave.target": { |
471 | "markdownDescription": "Check for a specific target. Defaults to `#rust-analyzer.cargo.target#`.", | 477 | "markdownDescription": "Check for a specific target. Defaults to\n`#rust-analyzer.cargo.target#`.", |
472 | "default": null, | 478 | "default": null, |
473 | "type": [ | 479 | "type": [ |
474 | "null", | 480 | "null", |
@@ -484,7 +490,7 @@ | |||
484 | } | 490 | } |
485 | }, | 491 | }, |
486 | "rust-analyzer.checkOnSave.features": { | 492 | "rust-analyzer.checkOnSave.features": { |
487 | "markdownDescription": "List of features to activate. Defaults to `#rust-analyzer.cargo.features#`.", | 493 | "markdownDescription": "List of features to activate. Defaults to\n`#rust-analyzer.cargo.features#`.", |
488 | "default": null, | 494 | "default": null, |
489 | "type": [ | 495 | "type": [ |
490 | "null", | 496 | "null", |
@@ -495,7 +501,7 @@ | |||
495 | } | 501 | } |
496 | }, | 502 | }, |
497 | "rust-analyzer.checkOnSave.overrideCommand": { | 503 | "rust-analyzer.checkOnSave.overrideCommand": { |
498 | "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message-format=json` or similar option.", | 504 | "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for\nchecking. The command should include `--message-format=json` or\nsimilar option.", |
499 | "default": null, | 505 | "default": null, |
500 | "type": [ | 506 | "type": [ |
501 | "null", | 507 | "null", |
@@ -521,7 +527,7 @@ | |||
521 | "type": "boolean" | 527 | "type": "boolean" |
522 | }, | 528 | }, |
523 | "rust-analyzer.completion.autoimport.enable": { | 529 | "rust-analyzer.completion.autoimport.enable": { |
524 | "markdownDescription": "Toggles the additional completions that automatically add imports when completed. Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.", | 530 | "markdownDescription": "Toggles the additional completions that automatically add imports when completed.\nNote that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.", |
525 | "default": true, | 531 | "default": true, |
526 | "type": "boolean" | 532 | "type": "boolean" |
527 | }, | 533 | }, |
@@ -531,7 +537,7 @@ | |||
531 | "type": "boolean" | 537 | "type": "boolean" |
532 | }, | 538 | }, |
533 | "rust-analyzer.diagnostics.enableExperimental": { | 539 | "rust-analyzer.diagnostics.enableExperimental": { |
534 | "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual.", | 540 | "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might\nhave more false positives than usual.", |
535 | "default": true, | 541 | "default": true, |
536 | "type": "boolean" | 542 | "type": "boolean" |
537 | }, | 543 | }, |
@@ -545,7 +551,7 @@ | |||
545 | "uniqueItems": true | 551 | "uniqueItems": true |
546 | }, | 552 | }, |
547 | "rust-analyzer.diagnostics.warningsAsHint": { | 553 | "rust-analyzer.diagnostics.warningsAsHint": { |
548 | "markdownDescription": "List of warnings that should be displayed with info severity.\\n\\nThe warnings will be indicated by a blue squiggly underline in code and a blue icon in the `Problems Panel`.", | 554 | "markdownDescription": "List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code\nand a blue icon in the `Problems Panel`.", |
549 | "default": [], | 555 | "default": [], |
550 | "type": "array", | 556 | "type": "array", |
551 | "items": { | 557 | "items": { |
@@ -553,7 +559,7 @@ | |||
553 | } | 559 | } |
554 | }, | 560 | }, |
555 | "rust-analyzer.diagnostics.warningsAsInfo": { | 561 | "rust-analyzer.diagnostics.warningsAsInfo": { |
556 | "markdownDescription": "List of warnings that should be displayed with hint severity.\\n\\nThe warnings will be indicated by faded text or three dots in code and will not show up in the `Problems Panel`.", | 562 | "markdownDescription": "List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code\nand will not show up in the `Problems Panel`.", |
557 | "default": [], | 563 | "default": [], |
558 | "type": "array", | 564 | "type": "array", |
559 | "items": { | 565 | "items": { |
@@ -574,7 +580,7 @@ | |||
574 | } | 580 | } |
575 | }, | 581 | }, |
576 | "rust-analyzer.hoverActions.debug": { | 582 | "rust-analyzer.hoverActions.debug": { |
577 | "markdownDescription": "Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", | 583 | "markdownDescription": "Whether to show `Debug` action. Only applies when\n`#rust-analyzer.hoverActions.enable#` is set.", |
578 | "default": true, | 584 | "default": true, |
579 | "type": "boolean" | 585 | "type": "boolean" |
580 | }, | 586 | }, |
@@ -584,17 +590,17 @@ | |||
584 | "type": "boolean" | 590 | "type": "boolean" |
585 | }, | 591 | }, |
586 | "rust-analyzer.hoverActions.gotoTypeDef": { | 592 | "rust-analyzer.hoverActions.gotoTypeDef": { |
587 | "markdownDescription": "Whether to show `Go to Type Definition` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", | 593 | "markdownDescription": "Whether to show `Go to Type Definition` action. Only applies when\n`#rust-analyzer.hoverActions.enable#` is set.", |
588 | "default": true, | 594 | "default": true, |
589 | "type": "boolean" | 595 | "type": "boolean" |
590 | }, | 596 | }, |
591 | "rust-analyzer.hoverActions.implementations": { | 597 | "rust-analyzer.hoverActions.implementations": { |
592 | "markdownDescription": "Whether to show `Implementations` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", | 598 | "markdownDescription": "Whether to show `Implementations` action. Only applies when\n`#rust-analyzer.hoverActions.enable#` is set.", |
593 | "default": true, | 599 | "default": true, |
594 | "type": "boolean" | 600 | "type": "boolean" |
595 | }, | 601 | }, |
596 | "rust-analyzer.hoverActions.run": { | 602 | "rust-analyzer.hoverActions.run": { |
597 | "markdownDescription": "Whether to show `Run` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", | 603 | "markdownDescription": "Whether to show `Run` action. Only applies when\n`#rust-analyzer.hoverActions.enable#` is set.", |
598 | "default": true, | 604 | "default": true, |
599 | "type": "boolean" | 605 | "type": "boolean" |
600 | }, | 606 | }, |
@@ -618,7 +624,7 @@ | |||
618 | "minimum": 0 | 624 | "minimum": 0 |
619 | }, | 625 | }, |
620 | "rust-analyzer.inlayHints.parameterHints": { | 626 | "rust-analyzer.inlayHints.parameterHints": { |
621 | "markdownDescription": "Whether to show function parameter name inlay hints at the call site.", | 627 | "markdownDescription": "Whether to show function parameter name inlay hints at the call\nsite.", |
622 | "default": true, | 628 | "default": true, |
623 | "type": "boolean" | 629 | "type": "boolean" |
624 | }, | 630 | }, |
@@ -628,7 +634,7 @@ | |||
628 | "type": "boolean" | 634 | "type": "boolean" |
629 | }, | 635 | }, |
630 | "rust-analyzer.lens.debug": { | 636 | "rust-analyzer.lens.debug": { |
631 | "markdownDescription": "Whether to show `Debug` lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | 637 | "markdownDescription": "Whether to show `Debug` lens. Only applies when\n`#rust-analyzer.lens.enable#` is set.", |
632 | "default": true, | 638 | "default": true, |
633 | "type": "boolean" | 639 | "type": "boolean" |
634 | }, | 640 | }, |
@@ -638,27 +644,27 @@ | |||
638 | "type": "boolean" | 644 | "type": "boolean" |
639 | }, | 645 | }, |
640 | "rust-analyzer.lens.implementations": { | 646 | "rust-analyzer.lens.implementations": { |
641 | "markdownDescription": "Whether to show `Implementations` lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | 647 | "markdownDescription": "Whether to show `Implementations` lens. Only applies when\n`#rust-analyzer.lens.enable#` is set.", |
642 | "default": true, | 648 | "default": true, |
643 | "type": "boolean" | 649 | "type": "boolean" |
644 | }, | 650 | }, |
645 | "rust-analyzer.lens.run": { | 651 | "rust-analyzer.lens.run": { |
646 | "markdownDescription": "Whether to show `Run` lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | 652 | "markdownDescription": "Whether to show `Run` lens. Only applies when\n`#rust-analyzer.lens.enable#` is set.", |
647 | "default": true, | 653 | "default": true, |
648 | "type": "boolean" | 654 | "type": "boolean" |
649 | }, | 655 | }, |
650 | "rust-analyzer.lens.methodReferences": { | 656 | "rust-analyzer.lens.methodReferences": { |
651 | "markdownDescription": "Whether to show `Method References` lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | 657 | "markdownDescription": "Whether to show `Method References` lens. Only applies when\n`#rust-analyzer.lens.enable#` is set.", |
652 | "default": false, | 658 | "default": false, |
653 | "type": "boolean" | 659 | "type": "boolean" |
654 | }, | 660 | }, |
655 | "rust-analyzer.lens.references": { | 661 | "rust-analyzer.lens.references": { |
656 | "markdownDescription": "Whether to show `References` lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | 662 | "markdownDescription": "Whether to show `References` lens. Only applies when\n`#rust-analyzer.lens.enable#` is set.", |
657 | "default": false, | 663 | "default": false, |
658 | "type": "boolean" | 664 | "type": "boolean" |
659 | }, | 665 | }, |
660 | "rust-analyzer.linkedProjects": { | 666 | "rust-analyzer.linkedProjects": { |
661 | "markdownDescription": "Disable project auto-discovery in favor of explicitly specified set of projects.\\n\\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format.", | 667 | "markdownDescription": "Disable project auto-discovery in favor of explicitly specified set\nof projects.\n\nElements must be paths pointing to `Cargo.toml`,\n`rust-project.json`, or JSON objects in `rust-project.json` format.", |
662 | "default": [], | 668 | "default": [], |
663 | "type": "array", | 669 | "type": "array", |
664 | "items": { | 670 | "items": { |
@@ -683,12 +689,12 @@ | |||
683 | "type": "boolean" | 689 | "type": "boolean" |
684 | }, | 690 | }, |
685 | "rust-analyzer.procMacro.enable": { | 691 | "rust-analyzer.procMacro.enable": { |
686 | "markdownDescription": "Enable Proc macro support, `#rust-analyzer.cargo.loadOutDirsFromCheck#` must be enabled.", | 692 | "markdownDescription": "Enable support for procedural macros, implies `#rust-analyzer.cargo.runBuildScripts#`.", |
687 | "default": false, | 693 | "default": false, |
688 | "type": "boolean" | 694 | "type": "boolean" |
689 | }, | 695 | }, |
690 | "rust-analyzer.procMacro.server": { | 696 | "rust-analyzer.procMacro.server": { |
691 | "markdownDescription": "Internal config, path to proc-macro server executable (typically, this is rust-analyzer itself, but we override this in tests).", | 697 | "markdownDescription": "Internal config, path to proc-macro server executable (typically,\nthis is rust-analyzer itself, but we override this in tests).", |
692 | "default": null, | 698 | "default": null, |
693 | "type": [ | 699 | "type": [ |
694 | "null", | 700 | "null", |
@@ -704,7 +710,7 @@ | |||
704 | ] | 710 | ] |
705 | }, | 711 | }, |
706 | "rust-analyzer.runnables.cargoExtraArgs": { | 712 | "rust-analyzer.runnables.cargoExtraArgs": { |
707 | "markdownDescription": "Additional arguments to be passed to cargo for runnables such as tests or binaries.\\nFor example, it may be `--release`.", | 713 | "markdownDescription": "Additional arguments to be passed to cargo for runnables such as\ntests or binaries. For example, it may be `--release`.", |
708 | "default": [], | 714 | "default": [], |
709 | "type": "array", | 715 | "type": "array", |
710 | "items": { | 716 | "items": { |
@@ -712,7 +718,7 @@ | |||
712 | } | 718 | } |
713 | }, | 719 | }, |
714 | "rust-analyzer.rustcSource": { | 720 | "rust-analyzer.rustcSource": { |
715 | "markdownDescription": "Path to the rust compiler sources, for usage in rustc_private projects, or \"discover\" to try to automatically find it.", | 721 | "markdownDescription": "Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private\nprojects, or \"discover\" to try to automatically find it.\n\nAny project which uses rust-analyzer with the rustcPrivate\ncrates must set `[package.metadata.rust-analyzer] rustc_private=true` to use it.\n\nThis option is not reloaded automatically; you must restart rust-analyzer for it to take effect.", |
716 | "default": null, | 722 | "default": null, |
717 | "type": [ | 723 | "type": [ |
718 | "null", | 724 | "null", |
@@ -728,7 +734,7 @@ | |||
728 | } | 734 | } |
729 | }, | 735 | }, |
730 | "rust-analyzer.rustfmt.overrideCommand": { | 736 | "rust-analyzer.rustfmt.overrideCommand": { |
731 | "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for formatting.", | 737 | "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for\nformatting.", |
732 | "default": null, | 738 | "default": null, |
733 | "type": [ | 739 | "type": [ |
734 | "null", | 740 | "null", |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index d43db7307..694f445bc 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -254,11 +254,10 @@ export function ssr(ctx: Ctx): Cmd { | |||
254 | export function serverVersion(ctx: Ctx): Cmd { | 254 | export function serverVersion(ctx: Ctx): Cmd { |
255 | return async () => { | 255 | return async () => { |
256 | const { stdout } = spawnSync(ctx.serverPath, ["--version"], { encoding: "utf8" }); | 256 | const { stdout } = spawnSync(ctx.serverPath, ["--version"], { encoding: "utf8" }); |
257 | const commitHash = stdout.slice(`rust-analyzer `.length).trim(); | 257 | const versionString = stdout.slice(`rust-analyzer `.length).trim(); |
258 | const { releaseTag } = ctx.config.package; | ||
259 | 258 | ||
260 | void vscode.window.showInformationMessage( | 259 | void vscode.window.showInformationMessage( |
261 | `rust-analyzer version: ${releaseTag ?? "unreleased"} (${commitHash})` | 260 | `rust-analyzer version: ${versionString}` |
262 | ); | 261 | ); |
263 | }; | 262 | }; |
264 | } | 263 | } |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index ddb5cfbd3..82f0a0566 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -100,6 +100,14 @@ export class Config { | |||
100 | get channel() { return this.get<UpdatesChannel>("updates.channel"); } | 100 | get channel() { return this.get<UpdatesChannel>("updates.channel"); } |
101 | get askBeforeDownload() { return this.get<boolean>("updates.askBeforeDownload"); } | 101 | get askBeforeDownload() { return this.get<boolean>("updates.askBeforeDownload"); } |
102 | get traceExtension() { return this.get<boolean>("trace.extension"); } | 102 | get traceExtension() { return this.get<boolean>("trace.extension"); } |
103 | get httpProxy() { | ||
104 | const httpProxy = vscode | ||
105 | .workspace | ||
106 | .getConfiguration('http') | ||
107 | .get<null | string>("proxy")!; | ||
108 | |||
109 | return httpProxy || process.env["https_proxy"] || process.env["HTTPS_PROXY"]; | ||
110 | } | ||
103 | 111 | ||
104 | get inlayHints() { | 112 | get inlayHints() { |
105 | return { | 113 | return { |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index f1a2020aa..925103f56 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -184,7 +184,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi | |||
184 | } | 184 | } |
185 | 185 | ||
186 | const release = await downloadWithRetryDialog(state, async () => { | 186 | const release = await downloadWithRetryDialog(state, async () => { |
187 | return await fetchRelease("nightly", state.githubToken); | 187 | return await fetchRelease("nightly", state.githubToken, config.httpProxy); |
188 | }).catch(async (e) => { | 188 | }).catch(async (e) => { |
189 | log.error(e); | 189 | log.error(e); |
190 | if (state.releaseId === undefined) { // Show error only for the initial download | 190 | if (state.releaseId === undefined) { // Show error only for the initial download |
@@ -210,6 +210,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi | |||
210 | url: artifact.browser_download_url, | 210 | url: artifact.browser_download_url, |
211 | dest, | 211 | dest, |
212 | progressTitle: "Downloading rust-analyzer extension", | 212 | progressTitle: "Downloading rust-analyzer extension", |
213 | httpProxy: config.httpProxy, | ||
213 | }); | 214 | }); |
214 | }); | 215 | }); |
215 | 216 | ||
@@ -332,7 +333,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
332 | 333 | ||
333 | const releaseTag = config.package.releaseTag; | 334 | const releaseTag = config.package.releaseTag; |
334 | const release = await downloadWithRetryDialog(state, async () => { | 335 | const release = await downloadWithRetryDialog(state, async () => { |
335 | return await fetchRelease(releaseTag, state.githubToken); | 336 | return await fetchRelease(releaseTag, state.githubToken, config.httpProxy); |
336 | }); | 337 | }); |
337 | const artifact = release.assets.find(artifact => artifact.name === `rust-analyzer-${platform}.gz`); | 338 | const artifact = release.assets.find(artifact => artifact.name === `rust-analyzer-${platform}.gz`); |
338 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); | 339 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); |
@@ -344,6 +345,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
344 | progressTitle: "Downloading rust-analyzer server", | 345 | progressTitle: "Downloading rust-analyzer server", |
345 | gunzip: true, | 346 | gunzip: true, |
346 | mode: 0o755, | 347 | mode: 0o755, |
348 | httpProxy: config.httpProxy, | ||
347 | }); | 349 | }); |
348 | }); | 350 | }); |
349 | 351 | ||
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index d39dc1baf..07ebc615c 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts | |||
@@ -1,4 +1,6 @@ | |||
1 | import fetch from "node-fetch"; | 1 | import fetch from "node-fetch"; |
2 | var HttpsProxyAgent = require('https-proxy-agent'); | ||
3 | |||
2 | import * as vscode from "vscode"; | 4 | import * as vscode from "vscode"; |
3 | import * as stream from "stream"; | 5 | import * as stream from "stream"; |
4 | import * as crypto from "crypto"; | 6 | import * as crypto from "crypto"; |
@@ -17,6 +19,7 @@ const REPO = "rust-analyzer"; | |||
17 | export async function fetchRelease( | 19 | export async function fetchRelease( |
18 | releaseTag: string, | 20 | releaseTag: string, |
19 | githubToken: string | null | undefined, | 21 | githubToken: string | null | undefined, |
22 | httpProxy: string | null | undefined, | ||
20 | ): Promise<GithubRelease> { | 23 | ): Promise<GithubRelease> { |
21 | 24 | ||
22 | const apiEndpointPath = `/repos/${OWNER}/${REPO}/releases/tags/${releaseTag}`; | 25 | const apiEndpointPath = `/repos/${OWNER}/${REPO}/releases/tags/${releaseTag}`; |
@@ -30,7 +33,14 @@ export async function fetchRelease( | |||
30 | headers.Authorization = "token " + githubToken; | 33 | headers.Authorization = "token " + githubToken; |
31 | } | 34 | } |
32 | 35 | ||
33 | const response = await fetch(requestUrl, { headers: headers }); | 36 | const response = await (() => { |
37 | if (httpProxy) { | ||
38 | log.debug(`Fetching release metadata via proxy: ${httpProxy}`); | ||
39 | return fetch(requestUrl, { headers: headers, agent: new HttpsProxyAgent(httpProxy) }); | ||
40 | } | ||
41 | |||
42 | return fetch(requestUrl, { headers: headers }); | ||
43 | })(); | ||
34 | 44 | ||
35 | if (!response.ok) { | 45 | if (!response.ok) { |
36 | log.error("Error fetching artifact release info", { | 46 | log.error("Error fetching artifact release info", { |
@@ -73,6 +83,7 @@ interface DownloadOpts { | |||
73 | dest: string; | 83 | dest: string; |
74 | mode?: number; | 84 | mode?: number; |
75 | gunzip?: boolean; | 85 | gunzip?: boolean; |
86 | httpProxy?: string; | ||
76 | } | 87 | } |
77 | 88 | ||
78 | export async function download(opts: DownloadOpts) { | 89 | export async function download(opts: DownloadOpts) { |
@@ -91,7 +102,7 @@ export async function download(opts: DownloadOpts) { | |||
91 | }, | 102 | }, |
92 | async (progress, _cancellationToken) => { | 103 | async (progress, _cancellationToken) => { |
93 | let lastPercentage = 0; | 104 | let lastPercentage = 0; |
94 | await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => { | 105 | await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, opts.httpProxy, (readBytes, totalBytes) => { |
95 | const newPercentage = Math.round((readBytes / totalBytes) * 100); | 106 | const newPercentage = Math.round((readBytes / totalBytes) * 100); |
96 | if (newPercentage !== lastPercentage) { | 107 | if (newPercentage !== lastPercentage) { |
97 | progress.report({ | 108 | progress.report({ |
@@ -113,9 +124,17 @@ async function downloadFile( | |||
113 | destFilePath: fs.PathLike, | 124 | destFilePath: fs.PathLike, |
114 | mode: number | undefined, | 125 | mode: number | undefined, |
115 | gunzip: boolean, | 126 | gunzip: boolean, |
127 | httpProxy: string | null | undefined, | ||
116 | onProgress: (readBytes: number, totalBytes: number) => void | 128 | onProgress: (readBytes: number, totalBytes: number) => void |
117 | ): Promise<void> { | 129 | ): Promise<void> { |
118 | const res = await fetch(url); | 130 | const res = await (() => { |
131 | if (httpProxy) { | ||
132 | log.debug(`Downloading ${url} via proxy: ${httpProxy}`); | ||
133 | return fetch(url, { agent: new HttpsProxyAgent(httpProxy) }); | ||
134 | } | ||
135 | |||
136 | return fetch(url); | ||
137 | })(); | ||
119 | 138 | ||
120 | if (!res.ok) { | 139 | if (!res.ok) { |
121 | log.error("Error", res.status, "while downloading file from", url); | 140 | log.error("Error", res.status, "while downloading file from", url); |