blob: a7a22fa6fa3c143ef4c7fadbb7d86db76d7baa35 (
plain)
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
|
import * as lc from 'vscode-languageclient';
import { Config } from './config';
import { Highlighter } from './highlighting';
export class Server {
public static highlighter = new Highlighter();
public static config = new Config();
public static client: lc.LanguageClient;
public static start(
notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>
) {
const run: lc.Executable = {
command: 'ra_lsp_server',
options: { cwd: '.' }
};
const serverOptions: lc.ServerOptions = {
run,
debug: run
};
const clientOptions: lc.LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'rust' }]
};
Server.client = new lc.LanguageClient(
'ra-lsp',
'rust-analyzer language server',
serverOptions,
clientOptions
);
Server.client.onReady().then(() => {
for (const [type, handler] of notificationHandlers) {
Server.client.onNotification(type, handler);
}
});
Server.client.start();
}
}
|