| |
| |
| |
| |
|
|
| 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'; |
|
|
| |
| export async function activate(context: ExtensionContext): Promise<SchemaExtensionAPI> { |
| |
| const telemetry = await (await getRedHatService(context)).getTelemetryService(); |
|
|
| let serverModule: string; |
| if (startedFromSources()) { |
| serverModule = context.asAbsolutePath('../yaml-language-server/out/server/src/server.js'); |
| } else { |
| |
| serverModule = context.asAbsolutePath('./dist/languageserver.js'); |
| } |
|
|
| |
| const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }; |
|
|
| |
| |
| 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); |
| } |
|
|
| function startedFromSources(): boolean { |
| return process.env['DEBUG_VSCODE_YAML'] === 'true'; |
| } |
|
|