-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.js
78 lines (69 loc) · 1.77 KB
/
extension.js
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
import { Trace } from "vscode-jsonrpc";
import { workspace } from "vscode";
import { LanguageClient } from "vscode-languageclient";
import { join } from "path";
import { platform } from "os";
let client = null;
const config = workspace.getConfiguration("c3.lsp");
module.exports = {
activate: activate,
deactivate: deactivate
}
export function activate(context) {
const enabled = config.get("enable");
if (!enabled) {
return;
}
let executablePath = config.get("path");
if (executablePath == "") {
switch (platform()) {
case "win32": {
executablePath = join(context.extensionPath, "c3-lsp.exe");
break;
}
case "darwin": {
executablePath = join(context.extensionPath, "c3-lsp");
break;
}
case "linux": {
executablePath = join(context.extensionPath, "c3-lsp");
break;
}
}
}
let args = [];
if (config.get("sendCrashReports")) {
args.push("--send-crash-reports");
}
if (config.get("log.path") != "") {
args.push("--log-path " + config.get("log.path"));
}
if (config.get("version") != "") {
args.push("--lang-version " + config.get("version"));
}
const serverOptions = {
run: {
command: executablePath,
args: args,
},
debug: {
command: executablePath,
args: args,
options: { execArgv: ["--nolazy", "--inspect=6009"] },
},
};
const clientOptions = {
documentSelector: [{ scheme: "file", language: "c3" }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher("**/*.c3"),
},
};
client = new LanguageClient("C3LSP", serverOptions, clientOptions);
if (config.get("debug")) {
client.setTrace(Trace.Verbose);
}
client.start();
}
export function deactivate() {
return client.stop();
}