From 420462421d87a05c926501f8d4235f7660217924 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 21:12:59 +0200 Subject: vscode extension cleanup: migrate to prefer-const tslint rule --- editors/code/src/ctx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index a2a4e42a9..b882a8e52 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -20,7 +20,7 @@ export class Ctx { } async restartServer() { - let old = this.client; + const old = this.client; if (old) { await old.stop(); } -- cgit v1.2.3 From 81847524702dd7cb1eeae25a53444b325295b129 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 21:37:22 +0200 Subject: vscode refactoring: use more laconic export snytax, split huge string to several lines --- editors/code/src/ctx.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index b882a8e52..094566d09 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -66,7 +66,9 @@ export class Ctx { this.pushCleanup(d); } catch (_) { vscode.window.showWarningMessage( - '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', + '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', ); } } -- cgit v1.2.3 From 12d0970f7e4c4d7f91cccb12525fceea3c4c0669 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 22:19:59 +0200 Subject: vscode extension: migrate from any to unknown where possible --- editors/code/src/ctx.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 094566d09..aae2c5f90 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -52,12 +52,12 @@ export class Ctx { overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { const defaultCmd = `default:${name}`; const override = factory(this); - const original = (...args: any[]) => + const original = (...args: unknown[]) => vscode.commands.executeCommand(defaultCmd, ...args); try { const d = vscode.commands.registerCommand( name, - async (...args: any[]) => { + async (...args: unknown[]) => { if (!(await override(...args))) { return await original(...args); } @@ -73,11 +73,11 @@ export class Ctx { } } - get subscriptions(): { dispose(): any }[] { + get subscriptions(): { dispose(): unknown }[] { return this.extCtx.subscriptions; } - pushCleanup(d: { dispose(): any }) { + pushCleanup(d: { dispose(): unknown }) { this.extCtx.subscriptions.push(d); } @@ -86,12 +86,12 @@ export class Ctx { } } -export type Cmd = (...args: any[]) => any; +export type Cmd = (...args: unknown[]) => unknown; export async function sendRequestWithRetry( client: lc.LanguageClient, method: string, - param: any, + param: unknown, token?: vscode.CancellationToken, ): Promise { for (const delay of [2, 4, 6, 8, 10, null]) { -- cgit v1.2.3 From 5411d65a7f8b86da46aeef23bb2c707408766135 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 22:36:12 +0200 Subject: vscode: fix, fallback to any for cmd type --- editors/code/src/ctx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index aae2c5f90..2d703af58 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -86,7 +86,7 @@ export class Ctx { } } -export type Cmd = (...args: unknown[]) => unknown; +export type Cmd = (...args: any[]) => unknown; export async function sendRequestWithRetry( client: lc.LanguageClient, -- cgit v1.2.3 From 2fd7af2a62ce0c8acb5daa6b2c179b638318f31a Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 23:23:01 +0200 Subject: vscode: use void where possible --- editors/code/src/ctx.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 2d703af58..05d21ae56 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; + import { Config } from './config'; import { createClient } from './client'; @@ -73,11 +74,11 @@ export class Ctx { } } - get subscriptions(): { dispose(): unknown }[] { + get subscriptions(): Disposable[] { return this.extCtx.subscriptions; } - pushCleanup(d: { dispose(): unknown }) { + pushCleanup(d: Disposable) { this.extCtx.subscriptions.push(d); } @@ -86,6 +87,9 @@ export class Ctx { } } +export interface Disposable { + dispose(): void; +} export type Cmd = (...args: any[]) => unknown; export async function sendRequestWithRetry( -- cgit v1.2.3 From b70ad7e5f3d524204fab88fe2a8c5a6fbef9e88e Mon Sep 17 00:00:00 2001 From: Gregoire Geis Date: Mon, 3 Feb 2020 20:24:50 +0100 Subject: Remove enableEnhancedTyping and type overriding infrastructure. --- editors/code/src/ctx.ts | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 05d21ae56..aa75943bf 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -50,30 +50,6 @@ export class Ctx { this.pushCleanup(d); } - overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { - const defaultCmd = `default:${name}`; - const override = factory(this); - const original = (...args: unknown[]) => - vscode.commands.executeCommand(defaultCmd, ...args); - try { - const d = vscode.commands.registerCommand( - name, - async (...args: unknown[]) => { - if (!(await override(...args))) { - return await original(...args); - } - }, - ); - this.pushCleanup(d); - } catch (_) { - vscode.window.showWarningMessage( - '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', - ); - } - } - get subscriptions(): Disposable[] { return this.extCtx.subscriptions; } -- cgit v1.2.3 From 1bdb78a89f6618527f2dc23f8f76e83ee77e3ea5 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 7 Feb 2020 00:09:13 +0200 Subject: vscode: add FIXME about language client shared resource protection --- editors/code/src/ctx.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index aa75943bf..a4dcc3037 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -11,6 +11,9 @@ export class Ctx { // deal with it. // // Ideally, this should be replaced with async getter though. + // FIXME: this actually needs syncronization of some kind (check how + // vscode deals with `deactivate()` call when extension has some work scheduled + // on the event loop to get a better picture of what we can do here) client: lc.LanguageClient | null = null; private extCtx: vscode.ExtensionContext; private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = []; -- cgit v1.2.3 From 5d88c1db38200896d2e4af7836fec95097adf509 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 8 Feb 2020 04:22:44 +0200 Subject: vscode: amended config to use binary from globalStoragePath, added ui for downloading --- editors/code/src/ctx.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index a4dcc3037..f0e2d72f7 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -29,7 +29,11 @@ export class Ctx { await old.stop(); } this.client = null; - const client = createClient(this.config); + const client = await createClient(this.config); + if (!client) { + throw new Error("Rust Analyzer Language Server is not available"); + } + this.pushCleanup(client.start()); await client.onReady(); -- cgit v1.2.3 From d08ae7e82f9eb4abb92f1274ea361acb21fd7b87 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 9 Feb 2020 00:58:53 +0200 Subject: vscode: minor names and message contents changes --- editors/code/src/ctx.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'editors/code/src/ctx.ts') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index f0e2d72f7..70042a479 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -31,7 +31,10 @@ export class Ctx { this.client = null; const client = await createClient(this.config); if (!client) { - throw new Error("Rust Analyzer Language Server is not available"); + throw new Error( + "Rust Analyzer Language Server is not available. " + + "Please, ensure its [proper installation](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#vs-code)." + ); } this.pushCleanup(client.start()); -- cgit v1.2.3