support for Windows;
authorwenzelm
Mon, 02 Jan 2017 17:35:51 +0100
changeset 64755 ceb81f4928ea
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
--- a/src/Tools/VSCode/extension/package.json	Mon Jan 02 15:53:41 2017 +0100
+++ b/src/Tools/VSCode/extension/package.json	Mon Jan 02 17:35:51 2017 +0100
@@ -52,16 +52,21 @@
         "configuration": {
             "title": "Isabelle",
             "properties": {
+                "isabelle.cygwin_root": {
+                    "type": "string",
+                    "default": "",
+                    "description": "Root of Cygwin installation on Windows (e.g. ISABELLE_HOME/cygwin)."
+                },
                 "isabelle.home": {
                     "type": "string",
                     "default": "",
-                    "description": "ISABELLE_HOME directory"
+                    "description": "Main Isabelle directory (ISABELLE_HOME)."
                 },
                 "isabelle.args": {
                     "type": "array",
                     "items": { "type": "string" },
                     "default": [],
-                    "description": "command-line arguments for isabelle vscode_server"
+                    "description": "Command-line arguments for isabelle vscode_server process."
                 }
             }
         }
--- a/src/Tools/VSCode/extension/src/extension.ts	Mon Jan 02 15:53:41 2017 +0100
+++ b/src/Tools/VSCode/extension/src/extension.ts	Mon Jan 02 17:35:51 2017 +0100
@@ -2,6 +2,7 @@
 
 import * as vscode from 'vscode';
 import * as path from 'path';
+import * as os from 'os';
 
 import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind }
   from 'vscode-languageclient';
@@ -9,15 +10,25 @@
 
 export function activate(context: vscode.ExtensionContext)
 {
+  let is_windows = os.type().startsWith("Windows")
+
+  let cygwin_root = vscode.workspace.getConfiguration("isabelle").get<string>("cygwin_root");
   let isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home");
   let isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args");
 
-  if (isabelle_home == "") vscode.window.showErrorMessage("Missing isabelle.home settings")
+  if (is_windows && cygwin_root == "")
+    vscode.window.showErrorMessage("Missing user settings: isabelle.cygwin_root")
+  else if (isabelle_home == "")
+    vscode.window.showErrorMessage("Missing user settings: isabelle.home")
   else {
-    let run = {
-      command: path.join(isabelle_home, "bin", "isabelle"),
-      args: ["vscode_server"].concat(isabelle_args)
-    };
+    let isabelle_tool = isabelle_home.concat("/bin/isabelle")
+    let run =
+      is_windows ?
+        { command: cygwin_root.concat("/bin/bash"),
+          args: ["-l", isabelle_tool, "vscode_server"].concat(isabelle_args) } :
+        { command: isabelle_tool,
+          args: ["vscode_server"].concat(isabelle_args) };
+
     let server_options: ServerOptions =
     {
       run: run,
--- a/src/Tools/VSCode/src/server.scala	Mon Jan 02 15:53:41 2017 +0100
+++ b/src/Tools/VSCode/src/server.scala	Mon Jan 02 17:35:51 2017 +0100
@@ -52,9 +52,9 @@
 
   Run the VSCode Language Server protocol (JSON RPC) over stdin/stdout.
 """,
-        "L:" -> (arg => log_file = Some(Path.explode(arg))),
+        "L:" -> (arg => log_file = Some(Path.explode(File.standard_path(arg)))),
         "T:" -> (arg => Text.Length.encoding(arg)),
-        "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
+        "d:" -> (arg => dirs = dirs ::: List(Path.explode(File.standard_path(arg)))),
         "l:" -> (arg => logic = arg),
         "m:" -> (arg => modes = arg :: modes),
         "o:" -> (arg => options = options + arg),