support for Windows;
authorwenzelm
Mon Jan 02 17:35:51 2017 +0100 (2017-01-02)
changeset 64755ceb81f4928ea
parent 64754 74d8793feceb
child 64756 3cc892bd8f0f
support for Windows;
src/Tools/VSCode/extension/package.json
src/Tools/VSCode/extension/src/extension.ts
src/Tools/VSCode/src/server.scala
     1.1 --- a/src/Tools/VSCode/extension/package.json	Mon Jan 02 15:53:41 2017 +0100
     1.2 +++ b/src/Tools/VSCode/extension/package.json	Mon Jan 02 17:35:51 2017 +0100
     1.3 @@ -52,16 +52,21 @@
     1.4          "configuration": {
     1.5              "title": "Isabelle",
     1.6              "properties": {
     1.7 +                "isabelle.cygwin_root": {
     1.8 +                    "type": "string",
     1.9 +                    "default": "",
    1.10 +                    "description": "Root of Cygwin installation on Windows (e.g. ISABELLE_HOME/cygwin)."
    1.11 +                },
    1.12                  "isabelle.home": {
    1.13                      "type": "string",
    1.14                      "default": "",
    1.15 -                    "description": "ISABELLE_HOME directory"
    1.16 +                    "description": "Main Isabelle directory (ISABELLE_HOME)."
    1.17                  },
    1.18                  "isabelle.args": {
    1.19                      "type": "array",
    1.20                      "items": { "type": "string" },
    1.21                      "default": [],
    1.22 -                    "description": "command-line arguments for isabelle vscode_server"
    1.23 +                    "description": "Command-line arguments for isabelle vscode_server process."
    1.24                  }
    1.25              }
    1.26          }
     2.1 --- a/src/Tools/VSCode/extension/src/extension.ts	Mon Jan 02 15:53:41 2017 +0100
     2.2 +++ b/src/Tools/VSCode/extension/src/extension.ts	Mon Jan 02 17:35:51 2017 +0100
     2.3 @@ -2,6 +2,7 @@
     2.4  
     2.5  import * as vscode from 'vscode';
     2.6  import * as path from 'path';
     2.7 +import * as os from 'os';
     2.8  
     2.9  import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind }
    2.10    from 'vscode-languageclient';
    2.11 @@ -9,15 +10,25 @@
    2.12  
    2.13  export function activate(context: vscode.ExtensionContext)
    2.14  {
    2.15 +  let is_windows = os.type().startsWith("Windows")
    2.16 +
    2.17 +  let cygwin_root = vscode.workspace.getConfiguration("isabelle").get<string>("cygwin_root");
    2.18    let isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home");
    2.19    let isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args");
    2.20  
    2.21 -  if (isabelle_home == "") vscode.window.showErrorMessage("Missing isabelle.home settings")
    2.22 +  if (is_windows && cygwin_root == "")
    2.23 +    vscode.window.showErrorMessage("Missing user settings: isabelle.cygwin_root")
    2.24 +  else if (isabelle_home == "")
    2.25 +    vscode.window.showErrorMessage("Missing user settings: isabelle.home")
    2.26    else {
    2.27 -    let run = {
    2.28 -      command: path.join(isabelle_home, "bin", "isabelle"),
    2.29 -      args: ["vscode_server"].concat(isabelle_args)
    2.30 -    };
    2.31 +    let isabelle_tool = isabelle_home.concat("/bin/isabelle")
    2.32 +    let run =
    2.33 +      is_windows ?
    2.34 +        { command: cygwin_root.concat("/bin/bash"),
    2.35 +          args: ["-l", isabelle_tool, "vscode_server"].concat(isabelle_args) } :
    2.36 +        { command: isabelle_tool,
    2.37 +          args: ["vscode_server"].concat(isabelle_args) };
    2.38 +
    2.39      let server_options: ServerOptions =
    2.40      {
    2.41        run: run,
     3.1 --- a/src/Tools/VSCode/src/server.scala	Mon Jan 02 15:53:41 2017 +0100
     3.2 +++ b/src/Tools/VSCode/src/server.scala	Mon Jan 02 17:35:51 2017 +0100
     3.3 @@ -52,9 +52,9 @@
     3.4  
     3.5    Run the VSCode Language Server protocol (JSON RPC) over stdin/stdout.
     3.6  """,
     3.7 -        "L:" -> (arg => log_file = Some(Path.explode(arg))),
     3.8 +        "L:" -> (arg => log_file = Some(Path.explode(File.standard_path(arg)))),
     3.9          "T:" -> (arg => Text.Length.encoding(arg)),
    3.10 -        "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
    3.11 +        "d:" -> (arg => dirs = dirs ::: List(Path.explode(File.standard_path(arg)))),
    3.12          "l:" -> (arg => logic = arg),
    3.13          "m:" -> (arg => modes = arg :: modes),
    3.14          "o:" -> (arg => options = options + arg),