aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
new file mode 100644
index 000000000..51dedd5ef
--- /dev/null
+++ b/editors/code/src/main.ts
@@ -0,0 +1,51 @@
1import * as vscode from 'vscode';
2
3import * as commands from './commands';
4import { activateInlayHints } from './inlay_hints';
5import { activateStatusDisplay } from './status_display';
6import { Ctx } from './ctx';
7import { activateHighlighting } from './highlighting';
8
9let ctx!: Ctx;
10
11export async function activate(context: vscode.ExtensionContext) {
12 ctx = new Ctx(context);
13
14 // Note: we try to start the server before we register various commands, so
15 // that it registers its `onDidChangeDocument` handler before us.
16 //
17 // This a horribly, horribly wrong way to deal with this problem.
18 try {
19 await ctx.restartServer();
20 } catch (e) {
21 vscode.window.showErrorMessage(e.message);
22 }
23
24
25 // Commands which invokes manually via command pallet, shortcut, etc.
26 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
27 ctx.registerCommand('collectGarbage', commands.collectGarbage);
28 ctx.registerCommand('matchingBrace', commands.matchingBrace);
29 ctx.registerCommand('joinLines', commands.joinLines);
30 ctx.registerCommand('parentModule', commands.parentModule);
31 ctx.registerCommand('syntaxTree', commands.syntaxTree);
32 ctx.registerCommand('expandMacro', commands.expandMacro);
33 ctx.registerCommand('run', commands.run);
34 ctx.registerCommand('reload', commands.reload);
35
36 // Internal commands which are invoked by the server.
37 ctx.registerCommand('runSingle', commands.runSingle);
38 ctx.registerCommand('showReferences', commands.showReferences);
39 ctx.registerCommand('applySourceChange', commands.applySourceChange);
40
41 if (ctx.config.enableEnhancedTyping) {
42 ctx.overrideCommand('type', commands.onEnter);
43 }
44 activateStatusDisplay(ctx);
45 activateHighlighting(ctx);
46 activateInlayHints(ctx);
47}
48
49export async function deactivate() {
50 await ctx?.client?.stop();
51}