-
Notifications
You must be signed in to change notification settings - Fork 268
/
server.ts
executable file
·48 lines (39 loc) · 1.87 KB
/
server.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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Copyright (c) Adam Voss. All rights reserved.
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { createConnection, Connection, ProposedFeatures } from 'vscode-languageserver/node';
import * as nls from 'vscode-nls';
import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler';
import { YAMLServerInit } from './yamlServerInit';
import { SettingsState } from './yamlSettings';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
nls.config(process.env['VSCODE_NLS_CONFIG'] as any);
// Create a connection for the server.
let connection: Connection = null;
if (process.argv.indexOf('--stdio') === -1) {
connection = createConnection(ProposedFeatures.all);
} else {
connection = createConnection();
}
console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);
const yamlSettings = new SettingsState();
/**
* Handles schema content requests given the schema URI
* @param uri can be a local file, vscode request, http(s) request or a custom request
*/
const schemaRequestHandlerWrapper = (connection: Connection, uri: string): Promise<string> => {
return schemaRequestHandler(
connection,
uri,
yamlSettings.workspaceFolders,
yamlSettings.workspaceRoot,
yamlSettings.useVSCodeContentRequest
);
};
const schemaRequestService = schemaRequestHandlerWrapper.bind(this, connection);
new YAMLServerInit(connection, yamlSettings, workspaceContext, schemaRequestService).start();