-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathactivate.ts
65 lines (56 loc) · 1.91 KB
/
activate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { getContinueRcPath, getTsConfigPath } from "core/util/paths";
import { Telemetry } from "core/util/posthog";
import * as vscode from "vscode";
import * as path from "path";
import { VsCodeExtension } from "../extension/VsCodeExtension";
import registerQuickFixProvider from "../lang-server/codeActions";
import { getExtensionVersion } from "../util/util";
import { VsCodeContinueApi } from "./api";
import setupInlineTips from "./InlineTipManager";
export async function activateExtension(context: vscode.ExtensionContext) {
// Add necessary files
getTsConfigPath();
getContinueRcPath();
// Register commands and providers
registerQuickFixProvider();
setupInlineTips(context);
const vscodeExtension = new VsCodeExtension(context);
// Load Continue configuration
if (!context.globalState.get("hasBeenInstalled")) {
context.globalState.update("hasBeenInstalled", true);
Telemetry.capture(
"install",
{
extensionVersion: getExtensionVersion(),
},
true,
);
}
// Only set the YAML schema configuration if it hasn't been set before
if (!context.globalState.get("yamlSchemaConfigured")) {
vscode.workspace.getConfiguration("yaml").update(
"schemas",
{
[path.join(
context.extension.extensionUri.fsPath,
"config-yaml-schema.json",
)]: [".continue/**/*.yaml"],
},
vscode.ConfigurationTarget.Global,
);
// Mark that we've configured the YAML schema
context.globalState.update("yamlSchemaConfigured", true);
}
const api = new VsCodeContinueApi(vscodeExtension);
const continuePublicApi = {
registerCustomContextProvider: api.registerCustomContextProvider.bind(api),
};
// 'export' public api-surface
// or entire extension for testing
return process.env.NODE_ENV === "test"
? {
...continuePublicApi,
extension: vscodeExtension,
}
: continuePublicApi;
}