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.ts27
1 files changed, 5 insertions, 22 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 325023e36..01fd80756 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -1,15 +1,14 @@
1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 1import * as lc from 'vscode-languageclient';
3 2
4import { Config } from './config'; 3import { Config } from './config';
5import { Decoration, Highlighter } from './highlighting'; 4import { Highlighter } from './highlighting';
6 5
7export class Server { 6export class Server {
8 public static highlighter = new Highlighter(); 7 public static highlighter = new Highlighter();
9 public static config = new Config(); 8 public static config = new Config();
10 public static client: lc.LanguageClient; 9 public static client: lc.LanguageClient;
11 10
12 public static start() { 11 public static start(notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>) {
13 const run: lc.Executable = { 12 const run: lc.Executable = {
14 command: 'ra_lsp_server', 13 command: 'ra_lsp_server',
15 options: { cwd: '.' }, 14 options: { cwd: '.' },
@@ -18,7 +17,6 @@ export class Server {
18 run, 17 run,
19 debug: run, 18 debug: run,
20 }; 19 };
21
22 const clientOptions: lc.LanguageClientOptions = { 20 const clientOptions: lc.LanguageClientOptions = {
23 documentSelector: [{ scheme: 'file', language: 'rust' }], 21 documentSelector: [{ scheme: 'file', language: 'rust' }],
24 }; 22 };
@@ -30,25 +28,10 @@ export class Server {
30 clientOptions, 28 clientOptions,
31 ); 29 );
32 Server.client.onReady().then(() => { 30 Server.client.onReady().then(() => {
33 Server.client.onNotification( 31 for (const [type, handler] of notificationHandlers) {
34 'm/publishDecorations', 32 Server.client.onNotification(type, handler);
35 (params: PublishDecorationsParams) => { 33 }
36 const targetEditor = vscode.window.visibleTextEditors.find(
37 (editor) => editor.document.uri.toString() === params.uri,
38 );
39 if (!Server.config.highlightingOn || !targetEditor) { return; }
40 Server.highlighter.setHighlights(
41 targetEditor,
42 params.decorations,
43 );
44 },
45 );
46 }); 34 });
47 Server.client.start(); 35 Server.client.start();
48 } 36 }
49} 37}
50
51interface PublishDecorationsParams {
52 uri: string;
53 decorations: Decoration[];
54}