diff options
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r-- | editors/code/src/main.ts | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 3d9107927..22450060b 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -3,7 +3,6 @@ import * as vscode from 'vscode'; | |||
3 | import * as commands from './commands'; | 3 | import * as commands from './commands'; |
4 | import { activateInlayHints } from './inlay_hints'; | 4 | import { activateInlayHints } from './inlay_hints'; |
5 | import { activateStatusDisplay } from './status_display'; | 5 | import { activateStatusDisplay } from './status_display'; |
6 | import { Server } from './server'; | ||
7 | import { Ctx } from './ctx'; | 6 | import { Ctx } from './ctx'; |
8 | import { activateHighlighting } from './highlighting'; | 7 | import { activateHighlighting } from './highlighting'; |
9 | 8 | ||
@@ -21,6 +20,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
21 | ctx.registerCommand('syntaxTree', commands.syntaxTree); | 20 | ctx.registerCommand('syntaxTree', commands.syntaxTree); |
22 | ctx.registerCommand('expandMacro', commands.expandMacro); | 21 | ctx.registerCommand('expandMacro', commands.expandMacro); |
23 | ctx.registerCommand('run', commands.run); | 22 | ctx.registerCommand('run', commands.run); |
23 | ctx.registerCommand('reload', commands.reload); | ||
24 | 24 | ||
25 | // Internal commands which are invoked by the server. | 25 | // Internal commands which are invoked by the server. |
26 | ctx.registerCommand('runSingle', commands.runSingle); | 26 | ctx.registerCommand('runSingle', commands.runSingle); |
@@ -30,38 +30,17 @@ export async function activate(context: vscode.ExtensionContext) { | |||
30 | if (ctx.config.enableEnhancedTyping) { | 30 | if (ctx.config.enableEnhancedTyping) { |
31 | ctx.overrideCommand('type', commands.onEnter); | 31 | ctx.overrideCommand('type', commands.onEnter); |
32 | } | 32 | } |
33 | 33 | activateStatusDisplay(ctx); | |
34 | const startServer = () => Server.start(ctx.config); | 34 | activateHighlighting(ctx); |
35 | const reloadCommand = () => reloadServer(startServer); | 35 | activateInlayHints(ctx); |
36 | |||
37 | vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand); | ||
38 | |||
39 | // Start the language server, finally! | 36 | // Start the language server, finally! |
40 | try { | 37 | try { |
41 | await startServer(); | 38 | await ctx.restartServer(); |
42 | } catch (e) { | 39 | } catch (e) { |
43 | vscode.window.showErrorMessage(e.message); | 40 | vscode.window.showErrorMessage(e.message); |
44 | } | 41 | } |
45 | |||
46 | activateStatusDisplay(ctx); | ||
47 | activateHighlighting(ctx); | ||
48 | |||
49 | if (ctx.config.displayInlayHints) { | ||
50 | activateInlayHints(ctx); | ||
51 | } | ||
52 | } | 42 | } |
53 | 43 | ||
54 | export function deactivate(): Thenable<void> { | 44 | export async function deactivate() { |
55 | if (!Server.client) { | 45 | await ctx?.client?.stop(); |
56 | return Promise.resolve(); | ||
57 | } | ||
58 | return Server.client.stop(); | ||
59 | } | ||
60 | |||
61 | async function reloadServer(startServer: () => Promise<void>) { | ||
62 | if (Server.client != null) { | ||
63 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); | ||
64 | await Server.client.stop(); | ||
65 | await startServer(); | ||
66 | } | ||
67 | } | 46 | } |