-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathextension.ts
52 lines (46 loc) · 1.25 KB
/
extension.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
49
50
51
52
import * as vscode from "vscode";
import { workspace } from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from "vscode-languageclient/node";
let client: LanguageClient | undefined;
export function activate(_context: vscode.ExtensionContext) {
client = createLanguageClient();
// Start the client. This will also launch the server
client.start();
}
// this method is called when your extension is deactivated
export function deactivate(): Thenable<void> | undefined {
return client?.stop();
}
function createLanguageClient(): LanguageClient {
let clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: "file", language: "gleam" }],
synchronize: {
fileEvents: [
workspace.createFileSystemWatcher("**/gleam.toml"),
workspace.createFileSystemWatcher("**/manifest.toml"),
],
},
};
let serverOptions: ServerOptions = {
command: "gleam",
args: ["lsp"],
transport: TransportKind.stdio,
options: {
env: Object.assign(process.env, {
GLEAM_LOG: "info",
GLEAM_LOG_NOCOLOUR: "1",
}),
},
};
return new LanguageClient(
"gleam_language_server",
"Gleam Language Server",
serverOptions,
clientOptions
);
}