aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package-lock.json78
-rw-r--r--editors/code/package.json18
-rw-r--r--editors/code/rollup.config.js4
-rw-r--r--editors/code/src/client.ts2
-rw-r--r--editors/code/src/color_theme.ts4
-rw-r--r--editors/code/src/commands/index.ts47
-rw-r--r--editors/code/src/commands/syntax_tree.ts2
-rw-r--r--editors/code/src/ctx.ts22
-rw-r--r--editors/code/src/highlighting.ts31
-rw-r--r--editors/code/src/inlay_hints.ts6
-rw-r--r--editors/code/src/main.ts2
-rw-r--r--editors/code/src/status_display.ts4
-rw-r--r--editors/code/tsconfig.json3
-rw-r--r--editors/code/tslint.json3
14 files changed, 106 insertions, 120 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index f92ce1fe2..353af06bf 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -25,56 +25,49 @@
25 } 25 }
26 }, 26 },
27 "@rollup/plugin-commonjs": { 27 "@rollup/plugin-commonjs": {
28 "version": "11.0.1", 28 "version": "11.0.2",
29 "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.1.tgz", 29 "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.2.tgz",
30 "integrity": "sha512-SaVUoaLDg3KnIXC5IBNIspr1APTYDzk05VaYcI6qz+0XX3ZlSCwAkfAhNSOxfd5GAdcm/63Noi4TowOY9MpcDg==", 30 "integrity": "sha512-MPYGZr0qdbV5zZj8/2AuomVpnRVXRU5XKXb3HVniwRoRCreGlf5kOE081isNWeiLIi6IYkwTX9zE0/c7V8g81g==",
31 "dev": true, 31 "dev": true,
32 "requires": { 32 "requires": {
33 "@rollup/pluginutils": "^3.0.0", 33 "@rollup/pluginutils": "^3.0.0",
34 "estree-walker": "^0.6.1", 34 "estree-walker": "^1.0.1",
35 "is-reference": "^1.1.2", 35 "is-reference": "^1.1.2",
36 "magic-string": "^0.25.2", 36 "magic-string": "^0.25.2",
37 "resolve": "^1.11.0" 37 "resolve": "^1.11.0"
38 } 38 }
39 }, 39 },
40 "@rollup/plugin-node-resolve": { 40 "@rollup/plugin-node-resolve": {
41 "version": "6.1.0", 41 "version": "7.1.1",
42 "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", 42 "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.1.tgz",
43 "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", 43 "integrity": "sha512-14ddhD7TnemeHE97a4rLOhobfYvUVcaYuqTnL8Ti7Jxi9V9Jr5LY7Gko4HZ5k4h4vqQM0gBQt6tsp9xXW94WPA==",
44 "dev": true, 44 "dev": true,
45 "requires": { 45 "requires": {
46 "@rollup/pluginutils": "^3.0.0", 46 "@rollup/pluginutils": "^3.0.6",
47 "@types/resolve": "0.0.8", 47 "@types/resolve": "0.0.8",
48 "builtin-modules": "^3.1.0", 48 "builtin-modules": "^3.1.0",
49 "is-module": "^1.0.0", 49 "is-module": "^1.0.0",
50 "resolve": "^1.11.1" 50 "resolve": "^1.14.2"
51 } 51 },
52 }, 52 "dependencies": {
53 "@rollup/plugin-typescript": { 53 "resolve": {
54 "version": "2.1.0", 54 "version": "1.15.0",
55 "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-2.1.0.tgz", 55 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz",
56 "integrity": "sha512-7lXKGY06aofrceVez/YnN2axttFdHSqlUBpCJ6ebzDfxwLDKMgSV5lD4ykBcdgE7aK3egxuLkD/HKyRB5L8Log==", 56 "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==",
57 "dev": true, 57 "dev": true,
58 "requires": { 58 "requires": {
59 "@rollup/pluginutils": "^3.0.0", 59 "path-parse": "^1.0.6"
60 "resolve": "^1.13.1" 60 }
61 }
61 } 62 }
62 }, 63 },
63 "@rollup/pluginutils": { 64 "@rollup/pluginutils": {
64 "version": "3.0.6", 65 "version": "3.0.8",
65 "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.6.tgz", 66 "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.8.tgz",
66 "integrity": "sha512-Nb6U7sg11v8D+E4mxRxwT+UumUL7MSnwI8V1SJB3THyW2MOGD/Q6GyxLtpnjrbT3zTRPSozzDMyVZwemgldO3w==", 67 "integrity": "sha512-rYGeAc4sxcZ+kPG/Tw4/fwJODC3IXHYDH4qusdN/b6aLw5LPUbzpecYbEJh4sVQGPFJxd2dBU4kc1H3oy9/bnw==",
67 "dev": true, 68 "dev": true,
68 "requires": { 69 "requires": {
69 "estree-walker": "^1.0.1" 70 "estree-walker": "^1.0.1"
70 },
71 "dependencies": {
72 "estree-walker": {
73 "version": "1.0.1",
74 "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
75 "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
76 "dev": true
77 }
78 } 71 }
79 }, 72 },
80 "@types/estree": { 73 "@types/estree": {
@@ -98,12 +91,6 @@
98 "@types/node": "*" 91 "@types/node": "*"
99 } 92 }
100 }, 93 },
101 "@types/seedrandom": {
102 "version": "2.4.28",
103 "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.28.tgz",
104 "integrity": "sha512-SMA+fUwULwK7sd/ZJicUztiPs8F1yCPwF3O23Z9uQ32ME5Ha0NmDK9+QTsYE4O2tHXChzXomSWWeIhCnoN1LqA==",
105 "dev": true
106 },
107 "@types/vscode": { 94 "@types/vscode": {
108 "version": "1.41.0", 95 "version": "1.41.0",
109 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz", 96 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz",
@@ -348,9 +335,9 @@
348 "dev": true 335 "dev": true
349 }, 336 },
350 "estree-walker": { 337 "estree-walker": {
351 "version": "0.6.1", 338 "version": "1.0.1",
352 "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", 339 "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
353 "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", 340 "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
354 "dev": true 341 "dev": true
355 }, 342 },
356 "esutils": { 343 "esutils": {
@@ -675,9 +662,9 @@
675 } 662 }
676 }, 663 },
677 "rollup": { 664 "rollup": {
678 "version": "1.30.1", 665 "version": "1.31.0",
679 "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.30.1.tgz", 666 "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.31.0.tgz",
680 "integrity": "sha512-Uus8mwQXwaO+ZVoNwBcXKhT0AvycFCBW/W8VZtkpVGsotRllWk9oldfCjqWmTnFRI0y7x6BnEqSqc65N+/YdBw==", 667 "integrity": "sha512-9C6ovSyNeEwvuRuUUmsTpJcXac1AwSL1a3x+O5lpmQKZqi5mmrjauLeqIjvREC+yNRR8fPdzByojDng+af3nVw==",
681 "dev": true, 668 "dev": true,
682 "requires": { 669 "requires": {
683 "@types/estree": "*", 670 "@types/estree": "*",
@@ -691,11 +678,6 @@
691 "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", 678 "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
692 "dev": true 679 "dev": true
693 }, 680 },
694 "seedrandom": {
695 "version": "3.0.5",
696 "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz",
697 "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg=="
698 },
699 "semver": { 681 "semver": {
700 "version": "6.3.0", 682 "version": "6.3.0",
701 "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", 683 "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@@ -896,7 +878,7 @@
896 "vscode-languageclient": { 878 "vscode-languageclient": {
897 "version": "6.1.0", 879 "version": "6.1.0",
898 "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.0.tgz", 880 "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.0.tgz",
899 "integrity": "sha1-7mfAt4GMQs4CgVctBcia38xPWjg=", 881 "integrity": "sha512-Tcp0VoOaa0YzxL4nEfK9tsmcy76Eo8jNLvFQZwh2c8oMm02luL8uGYPLQNAiZ3XGgegfcwiQFZMqbW7DNV0vxA==",
900 "requires": { 882 "requires": {
901 "semver": "^6.3.0", 883 "semver": "^6.3.0",
902 "vscode-languageserver-protocol": "^3.15.2" 884 "vscode-languageserver-protocol": "^3.15.2"
diff --git a/editors/code/package.json b/editors/code/package.json
index 55d470fa0..c0d8f0183 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -8,7 +8,8 @@
8 "version": "0.1.0", 8 "version": "0.1.0",
9 "publisher": "matklad", 9 "publisher": "matklad",
10 "repository": { 10 "repository": {
11 "url": "https://github.com/matklad/rust-analyzer/" 11 "url": "https://github.com/rust-analyzer/rust-analyzer.git",
12 "type": "git"
12 }, 13 },
13 "categories": [ 14 "categories": [
14 "Other" 15 "Other"
@@ -17,28 +18,25 @@
17 "vscode": "^1.41.0" 18 "vscode": "^1.41.0"
18 }, 19 },
19 "scripts": { 20 "scripts": {
20 "vscode:prepublish": "rollup -c", 21 "vscode:prepublish": "tsc && rollup -c",
21 "package": "vsce package", 22 "package": "vsce package",
22 "watch": "tsc -watch -p ./", 23 "watch": "tsc --watch",
23 "fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix" 24 "fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix"
24 }, 25 },
25 "dependencies": { 26 "dependencies": {
26 "jsonc-parser": "^2.1.0", 27 "jsonc-parser": "^2.1.0",
27 "seedrandom": "^3.0.5",
28 "vscode-languageclient": "^6.1.0" 28 "vscode-languageclient": "^6.1.0"
29 }, 29 },
30 "devDependencies": { 30 "devDependencies": {
31 "@rollup/plugin-commonjs": "^11.0.1", 31 "@rollup/plugin-commonjs": "^11.0.2",
32 "@rollup/plugin-node-resolve": "^6.1.0", 32 "@rollup/plugin-node-resolve": "^7.1.1",
33 "@rollup/plugin-typescript": "^2.1.0",
34 "@types/node": "^12.12.25", 33 "@types/node": "^12.12.25",
35 "@types/seedrandom": "^2.4.28",
36 "@types/vscode": "^1.41.0", 34 "@types/vscode": "^1.41.0",
37 "rollup": "^1.30.1", 35 "rollup": "^1.31.0",
38 "tslib": "^1.10.0", 36 "tslib": "^1.10.0",
39 "tslint": "^5.20.1", 37 "tslint": "^5.20.1",
40 "typescript": "^3.7.5",
41 "typescript-formatter": "^7.2.2", 38 "typescript-formatter": "^7.2.2",
39 "typescript": "^3.7.5",
42 "vsce": "^1.71.0" 40 "vsce": "^1.71.0"
43 }, 41 },
44 "activationEvents": [ 42 "activationEvents": [
diff --git a/editors/code/rollup.config.js b/editors/code/rollup.config.js
index de6a3b2b7..f8d320f46 100644
--- a/editors/code/rollup.config.js
+++ b/editors/code/rollup.config.js
@@ -1,12 +1,10 @@
1import typescript from '@rollup/plugin-typescript';
2import resolve from '@rollup/plugin-node-resolve'; 1import resolve from '@rollup/plugin-node-resolve';
3import commonjs from '@rollup/plugin-commonjs'; 2import commonjs from '@rollup/plugin-commonjs';
4import nodeBuiltins from 'builtin-modules'; 3import nodeBuiltins from 'builtin-modules';
5 4
6export default { 5export default {
7 input: 'src/main.ts', 6 input: 'out/main.js',
8 plugins: [ 7 plugins: [
9 typescript(),
10 resolve({ 8 resolve({
11 preferBuiltins: true 9 preferBuiltins: true
12 }), 10 }),
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 15e1a0873..1778c4e9f 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -68,7 +68,7 @@ PATH=${process.env.PATH}
68 // This also requires considering our settings strategy, which is work which needs doing 68 // This also requires considering our settings strategy, which is work which needs doing
69 // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests 69 // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests
70 res._tracer = { 70 res._tracer = {
71 log: (messageOrDataObject: string | any, data?: string) => { 71 log: (messageOrDataObject: string | unknown, data?: string) => {
72 if (typeof messageOrDataObject === 'string') { 72 if (typeof messageOrDataObject === 'string') {
73 if ( 73 if (
74 messageOrDataObject.includes( 74 messageOrDataObject.includes(
diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts
index d816f617d..7e10c7f79 100644
--- a/editors/code/src/color_theme.ts
+++ b/editors/code/src/color_theme.ts
@@ -61,7 +61,7 @@ export class ColorTheme {
61} 61}
62 62
63function loadThemeNamed(themeName: string): ColorTheme { 63function loadThemeNamed(themeName: string): ColorTheme {
64 function isTheme(extension: vscode.Extension<any>): boolean { 64 function isTheme(extension: vscode.Extension<unknown>): boolean {
65 return ( 65 return (
66 extension.extensionKind === vscode.ExtensionKind.UI && 66 extension.extensionKind === vscode.ExtensionKind.UI &&
67 extension.packageJSON.contributes && 67 extension.packageJSON.contributes &&
@@ -69,7 +69,7 @@ function loadThemeNamed(themeName: string): ColorTheme {
69 ); 69 );
70 } 70 }
71 71
72 let themePaths = vscode.extensions.all 72 const themePaths = vscode.extensions.all
73 .filter(isTheme) 73 .filter(isTheme)
74 .flatMap(ext => { 74 .flatMap(ext => {
75 return ext.packageJSON.contributes.themes 75 return ext.packageJSON.contributes.themes
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index dc075aa82..5a4c1df5e 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -4,24 +4,24 @@ import * as lc from 'vscode-languageclient';
4import { Ctx, Cmd } from '../ctx'; 4import { Ctx, Cmd } from '../ctx';
5import * as sourceChange from '../source_change'; 5import * as sourceChange from '../source_change';
6 6
7import { analyzerStatus } from './analyzer_status'; 7export * from './analyzer_status';
8import { matchingBrace } from './matching_brace'; 8export * from './matching_brace';
9import { joinLines } from './join_lines'; 9export * from './join_lines';
10import { onEnter } from './on_enter'; 10export * from './on_enter';
11import { parentModule } from './parent_module'; 11export * from './parent_module';
12import { syntaxTree } from './syntax_tree'; 12export * from './syntax_tree';
13import { expandMacro } from './expand_macro'; 13export * from './expand_macro';
14import { run, runSingle } from './runnables'; 14export * from './runnables';
15 15
16function collectGarbage(ctx: Ctx): Cmd { 16export function collectGarbage(ctx: Ctx): Cmd {
17 return async () => { 17 return async () => {
18 ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null); 18 ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null);
19 }; 19 };
20} 20}
21 21
22function showReferences(ctx: Ctx): Cmd { 22export function showReferences(ctx: Ctx): Cmd {
23 return (uri: string, position: lc.Position, locations: lc.Location[]) => { 23 return (uri: string, position: lc.Position, locations: lc.Location[]) => {
24 let client = ctx.client; 24 const client = ctx.client;
25 if (client) { 25 if (client) {
26 vscode.commands.executeCommand( 26 vscode.commands.executeCommand(
27 'editor.action.showReferences', 27 'editor.action.showReferences',
@@ -33,13 +33,13 @@ function showReferences(ctx: Ctx): Cmd {
33 }; 33 };
34} 34}
35 35
36function applySourceChange(ctx: Ctx): Cmd { 36export function applySourceChange(ctx: Ctx): Cmd {
37 return async (change: sourceChange.SourceChange) => { 37 return async (change: sourceChange.SourceChange) => {
38 sourceChange.applySourceChange(ctx, change); 38 sourceChange.applySourceChange(ctx, change);
39 }; 39 };
40} 40}
41 41
42function selectAndApplySourceChange(ctx: Ctx): Cmd { 42export function selectAndApplySourceChange(ctx: Ctx): Cmd {
43 return async (changes: sourceChange.SourceChange[]) => { 43 return async (changes: sourceChange.SourceChange[]) => {
44 if (changes.length === 1) { 44 if (changes.length === 1) {
45 await sourceChange.applySourceChange(ctx, changes[0]); 45 await sourceChange.applySourceChange(ctx, changes[0]);
@@ -51,26 +51,9 @@ function selectAndApplySourceChange(ctx: Ctx): Cmd {
51 }; 51 };
52} 52}
53 53
54function reload(ctx: Ctx): Cmd { 54export function reload(ctx: Ctx): Cmd {
55 return async () => { 55 return async () => {
56 vscode.window.showInformationMessage('Reloading rust-analyzer...'); 56 vscode.window.showInformationMessage('Reloading rust-analyzer...');
57 await ctx.restartServer(); 57 await ctx.restartServer();
58 }; 58 };
59} 59}
60
61export {
62 analyzerStatus,
63 expandMacro,
64 joinLines,
65 matchingBrace,
66 parentModule,
67 syntaxTree,
68 onEnter,
69 collectGarbage,
70 run,
71 runSingle,
72 showReferences,
73 applySourceChange,
74 selectAndApplySourceChange,
75 reload
76};
diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts
index 02ea9f166..211f2251f 100644
--- a/editors/code/src/commands/syntax_tree.ts
+++ b/editors/code/src/commands/syntax_tree.ts
@@ -55,7 +55,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
55 55
56// We need to order this after LS updates, but there's no API for that. 56// We need to order this after LS updates, but there's no API for that.
57// Hence, good old setTimeout. 57// Hence, good old setTimeout.
58function afterLs(f: () => any) { 58function afterLs(f: () => void) {
59 setTimeout(f, 10); 59 setTimeout(f, 10);
60} 60}
61 61
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index a2a4e42a9..05d21ae56 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,5 +1,6 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3
3import { Config } from './config'; 4import { Config } from './config';
4import { createClient } from './client'; 5import { createClient } from './client';
5 6
@@ -20,7 +21,7 @@ export class Ctx {
20 } 21 }
21 22
22 async restartServer() { 23 async restartServer() {
23 let old = this.client; 24 const old = this.client;
24 if (old) { 25 if (old) {
25 await old.stop(); 26 await old.stop();
26 } 27 }
@@ -52,12 +53,12 @@ export class Ctx {
52 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { 53 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) {
53 const defaultCmd = `default:${name}`; 54 const defaultCmd = `default:${name}`;
54 const override = factory(this); 55 const override = factory(this);
55 const original = (...args: any[]) => 56 const original = (...args: unknown[]) =>
56 vscode.commands.executeCommand(defaultCmd, ...args); 57 vscode.commands.executeCommand(defaultCmd, ...args);
57 try { 58 try {
58 const d = vscode.commands.registerCommand( 59 const d = vscode.commands.registerCommand(
59 name, 60 name,
60 async (...args: any[]) => { 61 async (...args: unknown[]) => {
61 if (!(await override(...args))) { 62 if (!(await override(...args))) {
62 return await original(...args); 63 return await original(...args);
63 } 64 }
@@ -66,16 +67,18 @@ export class Ctx {
66 this.pushCleanup(d); 67 this.pushCleanup(d);
67 } catch (_) { 68 } catch (_) {
68 vscode.window.showWarningMessage( 69 vscode.window.showWarningMessage(
69 'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings', 70 'Enhanced typing feature is disabled because of incompatibility ' +
71 'with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: ' +
72 'https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
70 ); 73 );
71 } 74 }
72 } 75 }
73 76
74 get subscriptions(): { dispose(): any }[] { 77 get subscriptions(): Disposable[] {
75 return this.extCtx.subscriptions; 78 return this.extCtx.subscriptions;
76 } 79 }
77 80
78 pushCleanup(d: { dispose(): any }) { 81 pushCleanup(d: Disposable) {
79 this.extCtx.subscriptions.push(d); 82 this.extCtx.subscriptions.push(d);
80 } 83 }
81 84
@@ -84,12 +87,15 @@ export class Ctx {
84 } 87 }
85} 88}
86 89
87export type Cmd = (...args: any[]) => any; 90export interface Disposable {
91 dispose(): void;
92}
93export type Cmd = (...args: any[]) => unknown;
88 94
89export async function sendRequestWithRetry<R>( 95export async function sendRequestWithRetry<R>(
90 client: lc.LanguageClient, 96 client: lc.LanguageClient,
91 method: string, 97 method: string,
92 param: any, 98 param: unknown,
93 token?: vscode.CancellationToken, 99 token?: vscode.CancellationToken,
94): Promise<R> { 100): Promise<R> {
95 for (const delay of [2, 4, 6, 8, 10, null]) { 101 for (const delay of [2, 4, 6, 8, 10, null]) {
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index fc7cd5a1c..66216e0fc 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -1,6 +1,5 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import seedrandom from 'seedrandom';
4 3
5import { ColorTheme, TextMateRuleSettings } from './color_theme'; 4import { ColorTheme, TextMateRuleSettings } from './color_theme';
6 5
@@ -40,7 +39,7 @@ export function activateHighlighting(ctx: Ctx) {
40 async (editor: vscode.TextEditor | undefined) => { 39 async (editor: vscode.TextEditor | undefined) => {
41 if (!editor || editor.document.languageId !== 'rust') return; 40 if (!editor || editor.document.languageId !== 'rust') return;
42 if (!ctx.config.highlightingOn) return; 41 if (!ctx.config.highlightingOn) return;
43 let client = ctx.client; 42 const client = ctx.client;
44 if (!client) return; 43 if (!client) return;
45 44
46 const params: lc.TextDocumentIdentifier = { 45 const params: lc.TextDocumentIdentifier = {
@@ -70,9 +69,9 @@ interface Decoration {
70 69
71// Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 70// Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76
72function fancify(seed: string, shade: 'light' | 'dark') { 71function fancify(seed: string, shade: 'light' | 'dark') {
73 const random = seedrandom(seed); 72 const random = randomU32Numbers(hashString(seed))
74 const randomInt = (min: number, max: number) => { 73 const randomInt = (min: number, max: number) => {
75 return Math.floor(random() * (max - min + 1)) + min; 74 return Math.abs(random()) % (max - min + 1) + min;
76 }; 75 };
77 76
78 const h = randomInt(0, 360); 77 const h = randomInt(0, 360);
@@ -106,7 +105,7 @@ class Highlighter {
106 } 105 }
107 106
108 public setHighlights(editor: vscode.TextEditor, highlights: Decoration[]) { 107 public setHighlights(editor: vscode.TextEditor, highlights: Decoration[]) {
109 let client = this.ctx.client; 108 const client = this.ctx.client;
110 if (!client) return; 109 if (!client) return;
111 // Initialize decorations if necessary 110 // Initialize decorations if necessary
112 // 111 //
@@ -175,7 +174,7 @@ function initDecorations(): Map<string, vscode.TextEditorDecorationType> {
175 const res = new Map(); 174 const res = new Map();
176 TAG_TO_SCOPES.forEach((scopes, tag) => { 175 TAG_TO_SCOPES.forEach((scopes, tag) => {
177 if (!scopes) throw `unmapped tag: ${tag}`; 176 if (!scopes) throw `unmapped tag: ${tag}`;
178 let rule = theme.lookup(scopes); 177 const rule = theme.lookup(scopes);
179 const decor = createDecorationFromTextmate(rule); 178 const decor = createDecorationFromTextmate(rule);
180 res.set(tag, decor); 179 res.set(tag, decor);
181 }); 180 });
@@ -246,3 +245,23 @@ const TAG_TO_SCOPES = new Map<string, string[]>([
246 ["keyword.unsafe", ["keyword.other.unsafe"]], 245 ["keyword.unsafe", ["keyword.other.unsafe"]],
247 ["keyword.control", ["keyword.control"]], 246 ["keyword.control", ["keyword.control"]],
248]); 247]);
248
249function randomU32Numbers(seed: number) {
250 let random = seed | 0;
251 return () => {
252 random ^= random << 13;
253 random ^= random >> 17;
254 random ^= random << 5;
255 random |= 0;
256 return random
257 }
258}
259
260function hashString(str: string): number {
261 let res = 0;
262 for (let i = 0; i < str.length; ++i) {
263 const c = str.codePointAt(i)!!;
264 res = (res * 31 + c) & ~0;
265 }
266 return res;
267}
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 6357e44f1..ae7510183 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -127,13 +127,13 @@ class HintsUpdater {
127 } 127 }
128 128
129 private async queryHints(documentUri: string): Promise<InlayHint[] | null> { 129 private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
130 let client = this.ctx.client; 130 const client = this.ctx.client;
131 if (!client) return null; 131 if (!client) return null;
132 const request: InlayHintsParams = { 132 const request: InlayHintsParams = {
133 textDocument: { uri: documentUri }, 133 textDocument: { uri: documentUri },
134 }; 134 };
135 let tokenSource = new vscode.CancellationTokenSource(); 135 const tokenSource = new vscode.CancellationTokenSource();
136 let prev = this.pending.get(documentUri); 136 const prev = this.pending.get(documentUri);
137 if (prev) prev.cancel(); 137 if (prev) prev.cancel();
138 this.pending.set(documentUri, tokenSource); 138 this.pending.set(documentUri, tokenSource);
139 try { 139 try {
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 0494ccf63..6813c3c4c 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -11,7 +11,7 @@ let ctx!: Ctx;
11export async function activate(context: vscode.ExtensionContext) { 11export async function activate(context: vscode.ExtensionContext) {
12 ctx = new Ctx(context); 12 ctx = new Ctx(context);
13 13
14 // Commands which invokes manually via command pallet, shortcut, etc. 14 // Commands which invokes manually via command palette, shortcut, etc.
15 ctx.registerCommand('analyzerStatus', commands.analyzerStatus); 15 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
16 ctx.registerCommand('collectGarbage', commands.collectGarbage); 16 ctx.registerCommand('collectGarbage', commands.collectGarbage);
17 ctx.registerCommand('matchingBrace', commands.matchingBrace); 17 ctx.registerCommand('matchingBrace', commands.matchingBrace);
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts
index 7345bc3f5..4317410c7 100644
--- a/editors/code/src/status_display.ts
+++ b/editors/code/src/status_display.ts
@@ -1,6 +1,6 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2 2
3import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd } from 'vscode-languageclient'; 3import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, Disposable } from 'vscode-languageclient';
4 4
5import { Ctx } from './ctx'; 5import { Ctx } from './ctx';
6 6
@@ -14,7 +14,7 @@ export function activateStatusDisplay(ctx: Ctx) {
14 }); 14 });
15} 15}
16 16
17class StatusDisplay implements vscode.Disposable { 17class StatusDisplay implements vscode.Disposable, Disposable {
18 packageName?: string; 18 packageName?: string;
19 19
20 private i: number = 0; 20 private i: number = 0;
diff --git a/editors/code/tsconfig.json b/editors/code/tsconfig.json
index 1ea433961..e60eb8e5e 100644
--- a/editors/code/tsconfig.json
+++ b/editors/code/tsconfig.json
@@ -13,8 +13,7 @@
13 "noUnusedParameters": true, 13 "noUnusedParameters": true,
14 "noImplicitReturns": true, 14 "noImplicitReturns": true,
15 "noFallthroughCasesInSwitch": true, 15 "noFallthroughCasesInSwitch": true,
16 "newLine": "LF", 16 "newLine": "LF"
17 "esModuleInterop": true,
18 }, 17 },
19 "exclude": [ 18 "exclude": [
20 "node_modules" 19 "node_modules"
diff --git a/editors/code/tslint.json b/editors/code/tslint.json
index 318e02b4b..0df11b2f1 100644
--- a/editors/code/tslint.json
+++ b/editors/code/tslint.json
@@ -3,6 +3,7 @@
3 "semicolon": [ 3 "semicolon": [
4 true, 4 true,
5 "always" 5 "always"
6 ] 6 ],
7 "prefer-const": true
7 } 8 }
8} 9}