diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/extension.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index ef83c0b8b..db67bc7e3 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -120,11 +120,16 @@ export function activate(context: vscode.ExtensionContext) { | |||
120 | context.subscriptions | 120 | context.subscriptions |
121 | ); | 121 | ); |
122 | 122 | ||
123 | const startServer = () => Server.start(allNotifications); | ||
124 | const reloadCommand = () => reloadServer(startServer); | ||
125 | |||
126 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); | ||
127 | |||
123 | // Executing `cargo watch` provides us with inline diagnostics on save | 128 | // Executing `cargo watch` provides us with inline diagnostics on save |
124 | interactivelyStartCargoWatch(context); | 129 | interactivelyStartCargoWatch(context); |
125 | 130 | ||
126 | // Start the language server, finally! | 131 | // Start the language server, finally! |
127 | Server.start(allNotifications); | 132 | startServer(); |
128 | } | 133 | } |
129 | 134 | ||
130 | export function deactivate(): Thenable<void> { | 135 | export function deactivate(): Thenable<void> { |
@@ -133,3 +138,12 @@ export function deactivate(): Thenable<void> { | |||
133 | } | 138 | } |
134 | return Server.client.stop(); | 139 | return Server.client.stop(); |
135 | } | 140 | } |
141 | |||
142 | |||
143 | async function reloadServer(startServer: () => void) { | ||
144 | if (Server.client != null) { | ||
145 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); | ||
146 | await Server.client.stop(); | ||
147 | startServer(); | ||
148 | } | ||
149 | } \ No newline at end of file | ||