forked from redhat-developer/vscode-yaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyamlClientMain.ts
More file actions
43 lines (33 loc) · 1.99 KB
/
yamlClientMain.ts
File metadata and controls
43 lines (33 loc) · 1.99 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext } from 'vscode';
import { startClient, LanguageClientConstructor, RuntimeEnvironment } from '../extension';
import { ServerOptions, TransportKind, LanguageClientOptions, LanguageClient } from 'vscode-languageclient/node';
import { SchemaExtensionAPI } from '../schema-extension-api';
import { getRedHatService } from '@redhat-developer/vscode-redhat-telemetry';
import { JSONSchemaCache } from '../json-schema-cache';
// this method is called when vs code is activated
export async function activate(context: ExtensionContext): Promise<SchemaExtensionAPI> {
// Create Telemetry Service
const telemetry = await (await getRedHatService(context)).getTelemetryService();
// The YAML language server is implemented in node
const serverModule = context.asAbsolutePath('./dist/languageserver.js');
// The debug options for the server
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions },
};
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
return new LanguageClient(id, name, serverOptions, clientOptions);
};
const runtime: RuntimeEnvironment = {
telemetry,
schemaCache: new JSONSchemaCache(context.globalStorageUri.fsPath, context.globalState),
};
return startClient(context, newLanguageClient, runtime);
}