-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.ts
More file actions
69 lines (60 loc) · 1.79 KB
/
extension.ts
File metadata and controls
69 lines (60 loc) · 1.79 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
import * as vscode from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
} from "vscode-languageclient/node";
let client: LanguageClient | undefined;
export function activate(context: vscode.ExtensionContext) {
const config = vscode.workspace.getConfiguration("pfc");
const serverPath = config.get<string>("serverPath", "pfc");
const sourcesCommand = config.get<string>("sourcesCommand", "");
const outputDir = config.get<string>("outputDir", "");
const args = ["lsp"];
if (sourcesCommand) {
args.push("--sources-cmd", sourcesCommand);
}
if (outputDir) {
args.push("--output-dir", outputDir);
}
const serverOptions: ServerOptions = {
command: serverPath,
args,
};
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: "file", language: "purescript" }],
};
client = new LanguageClient(
"pfc",
"PureScript Fast Compiler",
serverOptions,
clientOptions
);
context.subscriptions.push(
vscode.commands.registerCommand("pfc.rebuildModule", async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showWarningMessage("No active editor");
return;
}
if (!client) {
vscode.window.showWarningMessage("Language server not running");
return;
}
await client.sendRequest("pfc/rebuildModule", {
uri: editor.document.uri.toString(),
});
}),
vscode.commands.registerCommand("pfc.rebuildProject", async () => {
if (!client) {
vscode.window.showWarningMessage("Language server not running");
return;
}
await client.sendRequest("pfc/rebuildProject");
})
);
client.start();
}
export function deactivate(): Thenable<void> | undefined {
return client?.stop();
}