From 94784cc546916f26ff9e312923a16463852e8e00 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 28 Jan 2020 17:00:00 +0100 Subject: Provide better diagnostics if the server is not in path --- editors/code/src/client.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'editors/code/src/client.ts') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 1ff64a930..15e1a0873 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -15,7 +15,13 @@ export function createClient(config: Config): lc.LanguageClient { const command = expandPathResolving(config.raLspServerPath); if (spawnSync(command, ["--version"]).status !== 0) { - window.showErrorMessage(`Unable to execute '${command} --version'`); + window.showErrorMessage( + `Unable to execute '${command} --version' + +Perhaps it is not in $PATH? + +PATH=${process.env.PATH} +`); } const run: lc.Executable = { command, -- 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/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/client.ts') 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} // This also requires considering our settings strategy, which is work which needs doing // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests res._tracer = { - log: (messageOrDataObject: string | any, data?: string) => { + log: (messageOrDataObject: string | unknown, data?: string) => { if (typeof messageOrDataObject === 'string') { if ( messageOrDataObject.includes( -- cgit v1.2.3 From b89b22e43eb7e821674e0022f4061442b9e29394 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Wed, 5 Feb 2020 00:13:46 +0200 Subject: vscode: yet another refactor commit --- editors/code/src/client.ts | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'editors/code/src/client.ts') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 1778c4e9f..7e7e909dd 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -7,25 +7,21 @@ import { Config } from './config'; export function createClient(config: Config): lc.LanguageClient { // '.' Is the fallback if no folder is open - // TODO?: Workspace folders support Uri's (eg: file://test.txt). It might be a good idea to test if the uri points to a file. - let folder: string = '.'; - if (workspace.workspaceFolders !== undefined) { - folder = workspace.workspaceFolders[0].uri.fsPath.toString(); - } + // TODO?: Workspace folders support Uri's (eg: file://test.txt). + // It might be a good idea to test if the uri points to a file. + const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; - const command = expandPathResolving(config.raLspServerPath); - if (spawnSync(command, ["--version"]).status !== 0) { + const raLspServerPath = expandPathResolving(config.raLspServerPath); + if (spawnSync(raLspServerPath, ["--version"]).status !== 0) { window.showErrorMessage( - `Unable to execute '${command} --version' - -Perhaps it is not in $PATH? - -PATH=${process.env.PATH} -`); + `Unable to execute '${raLspServerPath} --version'\n\n` + + `Perhaps it is not in $PATH?\n\n` + + `PATH=${process.env.PATH}\n` + ); } const run: lc.Executable = { - command, - options: { cwd: folder }, + command: raLspServerPath, + options: { cwd: workspaceFolderPath }, }; const serverOptions: lc.ServerOptions = { run, @@ -43,8 +39,7 @@ PATH=${process.env.PATH} cargoWatchEnable: config.cargoWatchOptions.enable, cargoWatchArgs: config.cargoWatchOptions.arguments, cargoWatchCommand: config.cargoWatchOptions.command, - cargoWatchAllTargets: - config.cargoWatchOptions.allTargets, + cargoWatchAllTargets: config.cargoWatchOptions.allTargets, excludeGlobs: config.excludeGlobs, useClientWatching: config.useClientWatching, featureFlags: config.featureFlags, -- 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/client.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'editors/code/src/client.ts') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 7e7e909dd..7639ed44b 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -1,24 +1,18 @@ -import { homedir } from 'os'; import * as lc from 'vscode-languageclient'; -import { spawnSync } from 'child_process'; import { window, workspace } from 'vscode'; import { Config } from './config'; +import { ensureLanguageServerBinary } from './installation/language_server'; -export function createClient(config: Config): lc.LanguageClient { +export async function createClient(config: Config): Promise { // '.' Is the fallback if no folder is open // TODO?: Workspace folders support Uri's (eg: file://test.txt). // It might be a good idea to test if the uri points to a file. const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; - const raLspServerPath = expandPathResolving(config.raLspServerPath); - if (spawnSync(raLspServerPath, ["--version"]).status !== 0) { - window.showErrorMessage( - `Unable to execute '${raLspServerPath} --version'\n\n` + - `Perhaps it is not in $PATH?\n\n` + - `PATH=${process.env.PATH}\n` - ); - } + const raLspServerPath = await ensureLanguageServerBinary(config.raLspServerSource); + if (!raLspServerPath) return null; + const run: lc.Executable = { command: raLspServerPath, options: { cwd: workspaceFolderPath }, @@ -87,9 +81,3 @@ export function createClient(config: Config): lc.LanguageClient { res.registerProposedFeatures(); return res; } -function expandPathResolving(path: string) { - if (path.startsWith('~/')) { - return path.replace('~', homedir()); - } - return path; -} -- cgit v1.2.3 From 539daf4454e3f11424a469e8fba26cacb325176a Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 9 Feb 2020 00:27:04 +0200 Subject: vscode: refactor platform artifact name query to switch statement, move BinarySource union variants into a namespace --- editors/code/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/client.ts') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 7639ed44b..2e3d4aba2 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -10,7 +10,7 @@ export async function createClient(config: Config): Promise