diff --git a/src/install.ts b/src/install.ts index 4333f97b..2fa56f31 100644 --- a/src/install.ts +++ b/src/install.ts @@ -3,7 +3,9 @@ import * as common from '@clangd/install'; import AbortController from 'abort-controller'; +import * as path from 'path'; import * as vscode from 'vscode'; + import * as config from './config'; // Returns the clangd path to be used, or null if clangd is not installed. @@ -105,13 +107,27 @@ class UI { } async promptInstall(version: string) { - const message = 'The clangd language server was not found on your PATH.\n' + - `Would you like to download and install clangd ${version}?`; + const p = this.clangdPath; + let message = ''; + if (p.indexOf(path.sep) < 0) { + message += 'The ${p} language server was not found on your PATH.\n'; + } else { + message += `The clangd binary '${p}' was not found.\n`; + } + message += `Would you like to download and install clangd ${version}?`; if (await vscode.window.showInformationMessage(message, 'Install')) common.installLatest(this); } - get clangdPath(): string { return config.get('path'); } + get clangdPath(): string { + let p = config.get('path'); + // Backwards compatibility: if it's a relative path with a slash, interpret + // relative to project root. + if (!path.isAbsolute(p) && p.indexOf(path.sep) != -1 && + vscode.workspace.rootPath !== undefined) + p = path.join(vscode.workspace.rootPath, p); + return p; + } set clangdPath(p: string) { config.update('path', p, vscode.ConfigurationTarget.Global); }