about summary refs log tree commit diff
path: root/editors/code/src/server.ts
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <aochagavia92@gmail.com>2018-10-07 22:59:02 +0200
committerAdolfo OchagavĂ­a <aochagavia92@gmail.com>2018-10-07 23:12:40 +0200
commit4d62cfccbb8281f33b6f894df07e7316a9d45bfb (patch)
tree56ad69cb2f5c1096a2a74cfa078b92c40fe902e1 /editors/code/src/server.ts
parent69de7e2fd71c3a808f0ac856d7b105eeb210f169 (diff)
downloadrust-4d62cfccbb8281f33b6f894df07e7316a9d45bfb.tar.gz
rust-4d62cfccbb8281f33b6f894df07e7316a9d45bfb.zip
Apply tslint suggestions, round one
Diffstat (limited to 'editors/code/src/server.ts')
-rw-r--r--editors/code/src/server.ts74
1 files changed, 27 insertions, 47 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index c1c95e00842..3857b00a535 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -1,45 +1,25 @@
 import * as vscode from 'vscode';
-import * as lc from 'vscode-languageclient'
+import * as lc from 'vscode-languageclient';
 
-import { Highlighter, Decoration } from './highlighting';
-
-export class Config {
-    highlightingOn = true;
-
-    constructor() {
-        vscode.workspace.onDidChangeConfiguration(_ => this.userConfigChanged());
-        this.userConfigChanged();
-    }
-
-    userConfigChanged() {
-        let config = vscode.workspace.getConfiguration('ra-lsp');
-        if (config.has('highlightingOn')) {
-            this.highlightingOn = config.get('highlightingOn') as boolean;
-        };
-
-        if (!this.highlightingOn) {
-            Server.highlighter.removeHighlights();
-        }
-    }
-}
+import { Config } from './config';
+import { Decoration, Highlighter } from './highlighting';
 
 export class Server {
-    static highlighter = new Highlighter();
-    static config = new Config();
-    static client: lc.LanguageClient;
-
-
-    static start() {
-        let run: lc.Executable = {
-            command: "ra_lsp_server",
-            options: { cwd: "." }
-        }
-        let serverOptions: lc.ServerOptions = {
+    public static highlighter = new Highlighter();
+    public static config = new Config();
+    public static client: lc.LanguageClient;
+
+    public static start() {
+        const run: lc.Executable = {
+            command: 'ra_lsp_server',
+            options: { cwd: '.' },
+        };
+        const serverOptions: lc.ServerOptions = {
             run,
-            debug: run
+            debug: run,
         };
 
-        let clientOptions: lc.LanguageClientOptions = {
+        const clientOptions: lc.LanguageClientOptions = {
             documentSelector: [{ scheme: 'file', language: 'rust' }],
         };
 
@@ -51,24 +31,24 @@ export class Server {
         );
         Server.client.onReady().then(() => {
             Server.client.onNotification(
-                "m/publishDecorations",
+                'm/publishDecorations',
                 (params: PublishDecorationsParams) => {
-                    let editor = vscode.window.visibleTextEditors.find(
-                        (editor) => editor.document.uri.toString() == params.uri
-                    )
-                    if (!Server.config.highlightingOn || !editor) return;
+                    const targetEditor = vscode.window.visibleTextEditors.find(
+                        (editor) => editor.document.uri.toString() == params.uri,
+                    );
+                    if (!Server.config.highlightingOn || !targetEditor) { return; }
                     Server.highlighter.setHighlights(
-                        editor,
+                        targetEditor,
                         params.decorations,
-                    )
-                }
-            )
-        })
+                    );
+                },
+            );
+        });
         Server.client.start();
     }
 }
 
 interface PublishDecorationsParams {
-    uri: string,
-    decorations: Decoration[],
+    uri: string;
+    decorations: Decoration[];
 }