forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguageClient.ts
More file actions
109 lines (101 loc) · 3.87 KB
/
languageClient.ts
File metadata and controls
109 lines (101 loc) · 3.87 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* --------------------------------------------------------------------------------------------
* 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 * as path from 'path';
import * as vscode from 'vscode';
import { workspace, Disposable, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient';
import { RequestType } from 'vscode-languageclient';
var pythonLanguageClient: LanguageClient;
export function activate(context: ExtensionContext) {
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('out', 'server', 'server.js'));
// The debug options for the server
let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
}
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: ['python'],
synchronize: {
// Synchronize the setting section 'python' to the server
configurationSection: 'python',
// Notify the server about file changes to '.clientrc files contain in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
}
// Create the language client and start the client.
pythonLanguageClient = new LanguageClient('Python', serverOptions, clientOptions);
var disposable = pythonLanguageClient.start();
//Send info as soon as it starts
var config = workspace.getConfiguration();
pythonLanguageClient.notifyConfigurationChanged(config)
var isWin = /^win/.test(process.platform);
if (isWin) {
// workspace.onDidSaveTextDocument(onDidSaveTextDocument, this, context.subscriptions);
}
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
}
//
// function onDidSaveTextDocument(textDocument: vscode.TextDocument) {
// if (textDocument.languageId !== 'python') {
// return;
// }
// var args: RequestParams = { processId: 0, uri: textDocument.uri };
// pythonLanguageClient.sendRequest(Request.type, args)
// }
//
// function _registerEvents(): void {
// // subscribe to trigger when the file is saved
// let subscriptions: Disposable[] = [];
// workspace.onDidSaveTextDocument(this._onSave, this, subscriptions);
// }
// //
// namespace Request {
// export const type: RequestType<RequestParams, RequestResult, RequestError> = { get method() { return 'request'; } };
// }
// /**
// * The Request parameters
// */
// export interface RequestParams {
// /**
// * The process Id of the parent process that started
// * the server.
// */
// processId: number;
//
// /**
// * The uri. Is null
// * if no folder is open.
// */
// uri: vscode.Uri;
// }
//
// /**
// * The result returned from an initilize request.
// */
// export interface RequestResult {
// succesful: boolean;
// }
//
//
// /**
// * The error returned if the initilize request fails.
// */
// export interface RequestError {
// /**
// * Indicates whether the client should retry to send the
// * initilize request after showing the message provided
// * in the {@link ResponseError}
// */
// retry: boolean;
// }