src/Tools/VSCode/extension/src/extension.ts
author wenzelm
Mon, 02 Jan 2017 15:00:55 +0100
changeset 64753 79ed396709e4
parent 64750 1f855e03455f
child 64755 ceb81f4928ea
permissions -rw-r--r--
more robust startup;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     1
'use strict';
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     2
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     3
import * as vscode from 'vscode';
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     4
import * as path from 'path';
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     5
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     6
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     7
  from 'vscode-languageclient';
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     8
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     9
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    10
export function activate(context: vscode.ExtensionContext)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    11
{
64734
12558536d977 more configuration;
wenzelm
parents: 64605
diff changeset
    12
  let isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home");
64743
wenzelm
parents: 64735
diff changeset
    13
  let isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args");
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    14
64753
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    15
  if (isabelle_home == "") vscode.window.showErrorMessage("Missing isabelle.home settings")
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    16
  else {
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    17
    let run = {
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    18
      command: path.join(isabelle_home, "bin", "isabelle"),
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    19
      args: ["vscode_server"].concat(isabelle_args)
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    20
    };
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    21
    let server_options: ServerOptions =
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    22
    {
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    23
      run: run,
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    24
      debug: {
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    25
        command: run.command,
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    26
        args: run.args.concat(["-L", path.join(context.extensionPath, "protocol.log")]) }
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    27
    };
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    28
    let client_options: LanguageClientOptions = {
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    29
      documentSelector: ["isabelle", "isabelle-ml"]
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    30
    };
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    31
64753
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    32
    let disposable = new LanguageClient("Isabelle", server_options, client_options, false).start();
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    33
    context.subscriptions.push(disposable);
79ed396709e4 more robust startup;
wenzelm
parents: 64750
diff changeset
    34
    }
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    35
}
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    36
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    37
export function deactivate() { }