diff options
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r-- | editors/code/src/main.ts | 51 |
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 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import * as commands from './commands'; | ||
4 | import { activateInlayHints } from './inlay_hints'; | ||
5 | import { activateStatusDisplay } from './status_display'; | ||
6 | import { Ctx } from './ctx'; | ||
7 | import { activateHighlighting } from './highlighting'; | ||
8 | |||
9 | let ctx!: Ctx; | ||
10 | |||
11 | export 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 | |||
49 | export async function deactivate() { | ||
50 | await ctx?.client?.stop(); | ||
51 | } | ||