-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.ts
More file actions
63 lines (51 loc) · 1.8 KB
/
extension.ts
File metadata and controls
63 lines (51 loc) · 1.8 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
import * as path from "node:path";
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from "vscode-languageclient/node";
let output: vscode.OutputChannel;
export async function activate(context: vscode.ExtensionContext) {
console.log("Congratulations, your extension 'fkl' is now active!");
output = vscode.window.createOutputChannel("Fkl", "fkl");
context.subscriptions.push(output);
output.show();
let client;
// TODO: download fkl-lsp from github
let exe = path.resolve(__dirname, "../../fklang/target/debug/fkl-lsp.exe");
// check if exe exists
try {
await vscode.workspace.fs.stat(vscode.Uri.file(exe));
} catch (error) {
output.appendLine("fkl-lsp not found");
return;
}
const serverOptions: ServerOptions = {
run: { command: exe, transport: TransportKind.stdio },
debug: {
command: exe,
transport: TransportKind.stdio,
},
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "fkl" }],
outputChannel: output,
progressOnInitialization: true,
traceOutputChannel: output,
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: vscode.workspace.createFileSystemWatcher("**/*.fkl"),
},
};
client = new LanguageClient("fkl-lsp-client", serverOptions, clientOptions);
client.start();
context.subscriptions.push(client);
}
// This method is called when your extension is deactivated
export function deactivate() {}