Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret clangd.path relative to ${cwd} if it has a slash #26

Merged
merged 2 commits into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<string>('path'); }
get clangdPath(): string {
let p = config.get<string>('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);
}
Expand Down