aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/server.ts')
-rw-r--r--editors/code/src/server.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
new file mode 100644
index 000000000..01fd80756
--- /dev/null
+++ b/editors/code/src/server.ts
@@ -0,0 +1,37 @@
1import * as lc from 'vscode-languageclient';
2
3import { Config } from './config';
4import { Highlighter } from './highlighting';
5
6export class Server {
7 public static highlighter = new Highlighter();
8 public static config = new Config();
9 public static client: lc.LanguageClient;
10
11 public static start(notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>) {
12 const run: lc.Executable = {
13 command: 'ra_lsp_server',
14 options: { cwd: '.' },
15 };
16 const serverOptions: lc.ServerOptions = {
17 run,
18 debug: run,
19 };
20 const clientOptions: lc.LanguageClientOptions = {
21 documentSelector: [{ scheme: 'file', language: 'rust' }],
22 };
23
24 Server.client = new lc.LanguageClient(
25 'ra-lsp',
26 'rust-analyzer languge server',
27 serverOptions,
28 clientOptions,
29 );
30 Server.client.onReady().then(() => {
31 for (const [type, handler] of notificationHandlers) {
32 Server.client.onNotification(type, handler);
33 }
34 });
35 Server.client.start();
36 }
37}