forked from dataform-co/dataform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.ts
56 lines (47 loc) · 1.49 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
53
54
55
56
import * as vscode from "vscode";
import { workspace } from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
} from "vscode-languageclient";
let client: LanguageClient;
export async function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath("server.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 clientOptions: LanguageClientOptions = {
// register server for sqlx files
documentSelector: [{ scheme: "file", language: "sqlx" }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher("**/.clientrc")
}
};
client = new LanguageClient(
"dataformLanguageServer",
"Dataform Language Server",
serverOptions,
clientOptions
);
const compile = vscode.commands.registerCommand("dataform.compile", () => {
const _ = client.sendRequest("compile");
});
context.subscriptions.push(compile);
client.start();
// wait for client to be ready before setting up notification handlers
await client.onReady();
client.onNotification("error", errorMessage => {
vscode.window.showErrorMessage(errorMessage);
});
client.onNotification("success", message => {
vscode.window.showInformationMessage(message);
});
}