refer to Isabelle settings via environment, which is provided via "isabelle vscode";
authorwenzelm
Tue, 22 Feb 2022 21:33:24 +0100
changeset 75129 49f9fa8f9601
parent 75128 8c7bdd68a47a
child 75130 122d1d1a16fd
refer to Isabelle settings via environment, which is provided via "isabelle vscode"; clarified error handling;
src/Tools/VSCode/extension/package.json
src/Tools/VSCode/extension/src/extension.ts
--- a/src/Tools/VSCode/extension/package.json	Tue Feb 22 21:30:39 2022 +0100
+++ b/src/Tools/VSCode/extension/package.json	Tue Feb 22 21:33:24 2022 +0100
@@ -174,11 +174,6 @@
         "configuration": {
             "title": "Isabelle",
             "properties": {
-                "isabelle.home": {
-                    "type": "string",
-                    "default": "",
-                    "description": "Main Isabelle directory (ISABELLE_HOME)."
-                },
                 "isabelle.args": {
                     "type": "array",
                     "items": {
@@ -187,11 +182,6 @@
                     "default": [],
                     "description": "Command-line arguments for isabelle vscode_server process."
                 },
-                "isabelle.cygwin_root": {
-                    "type": "string",
-                    "default": "",
-                    "description": "Cygwin installation on Windows (only relevant when running directly from the Isabelle repository)."
-                },
                 "isabelle.replacement": {
                     "type": "string",
                     "default": "non-alphanumeric",
--- a/src/Tools/VSCode/extension/src/extension.ts	Tue Feb 22 21:30:39 2022 +0100
+++ b/src/Tools/VSCode/extension/src/extension.ts	Tue Feb 22 21:33:24 2022 +0100
@@ -19,30 +19,26 @@
 
 export async function activate(context: ExtensionContext)
 {
-  const isabelle_home = library.get_configuration<string>("home")
-  const isabelle_args = library.get_configuration<Array<string>>("args")
-  const cygwin_root = library.get_configuration<string>("cygwin_root")
-
-
   /* server */
 
-  if (isabelle_home === "")
-    window.showErrorMessage("Missing user settings: isabelle.home")
-  else {
+  try {
+    const isabelle_home = library.getenv_strict("ISABELLE_HOME")
+
     const workspace_dir = await Isabelle_FSP.register(context)
     const roots = workspace.workspaceFile === undefined ? await workspace.findFiles("{ROOT,ROOTS}") : []
+
     const isabelle_tool = isabelle_home + "/bin/isabelle"
-    const standard_args = ["-o", "vscode_unicode_symbols", "-o", "vscode_pide_extensions"]
-    const session_args = roots.length > 0 && workspace_dir !== undefined ? ["-D", workspace_dir] : []
+    const isabelle_args =
+      ["-o", "vscode_unicode_symbols", "-o", "vscode_pide_extensions"]
+        .concat(library.get_configuration<Array<string>>("args"))
+        .concat(roots.length > 0 && workspace_dir !== undefined ? ["-D", workspace_dir] : [])
 
     const server_options: ServerOptions =
       library.platform_is_windows() ?
-        { command:
-            (cygwin_root === "" ? path.join(isabelle_home, "contrib", "cygwin") : cygwin_root) +
-            "/bin/bash",
-          args: ["-l", isabelle_tool, "vscode_server"].concat(standard_args, isabelle_args) } :
+        { command: library.getenv_strict("CYGWIN_ROOT") + "\\bin\\bash",
+          args: ["-l", isabelle_tool, "vscode_server"].concat(isabelle_args) } :
         { command: isabelle_tool,
-          args: ["vscode_server"].concat(standard_args, isabelle_args, session_args) }
+          args: ["vscode_server"].concat(isabelle_args) }
 
     const language_client_options: LanguageClientOptions = {
       documentSelector: [
@@ -214,6 +210,9 @@
 
     context.subscriptions.push(language_client.start())
   }
+  catch (exn) {
+    window.showErrorMessage(exn)
+  }
 }