Adds "restart server" command

This commit is contained in:
Roberto Vidal 2019-04-15 21:41:27 +02:00
parent 546d9be2a7
commit 12f28f6276
4 changed files with 24 additions and 7 deletions

View file

@ -120,11 +120,16 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions
);
const startServer = () => Server.start(allNotifications);
const reloadCommand = () => reloadServer(startServer);
vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand);
// Executing `cargo watch` provides us with inline diagnostics on save
interactivelyStartCargoWatch(context);
// Start the language server, finally!
Server.start(allNotifications);
startServer();
}
export function deactivate(): Thenable<void> {
@ -133,3 +138,12 @@ export function deactivate(): Thenable<void> {
}
return Server.client.stop();
}
async function reloadServer(startServer: () => void) {
if (Server.client != null) {
vscode.window.showInformationMessage('Reloading rust-analyzer...');
await Server.client.stop();
startServer();
}
}