--- a/etc/build.props Mon Mar 21 11:55:51 2022 +0100
+++ b/etc/build.props Tue Mar 22 12:48:27 2022 +0100
@@ -219,10 +219,10 @@
src/Tools/VSCode/src/lsp.scala \
src/Tools/VSCode/src/preview_panel.scala \
src/Tools/VSCode/src/state_panel.scala \
+ src/Tools/VSCode/src/vscode_main.scala \
src/Tools/VSCode/src/vscode_model.scala \
src/Tools/VSCode/src/vscode_rendering.scala \
src/Tools/VSCode/src/vscode_resources.scala \
- src/Tools/VSCode/src/vscode_setup.scala \
src/Tools/VSCode/src/vscode_spell_checker.scala \
src/Tools/jEdit/src/active.scala \
src/Tools/jEdit/src/base_plugin.scala \
--- a/lib/Tools/vscode Mon Mar 21 11:55:51 2022 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#!/usr/bin/env bash
-#
-# Author: Makarius
-#
-# DESCRIPTION: run Isabelle/VSCode (requires "vscodium-X.YY.Z" component)
-
-isabelle vscode_setup || exit "$?"
-
-export ISABELLE_VSCODIUM_APP="$(platform_path "$ISABELLE_VSCODIUM_RESOURCES/vscodium")"
-
-ELECTRON_RUN_AS_NODE=1 "$ISABELLE_VSCODIUM_ELECTRON" \
- "$(platform_path "$ISABELLE_VSCODIUM_RESOURCES/vscodium/out/cli.js")" \
- --ms-enable-electron-run-as-node --locale en-US \
- --user-data-dir "$(platform_path "$ISABELLE_VSCODE_SETTINGS"/user-data)" \
- --extensions-dir "$(platform_path "$ISABELLE_VSCODE_SETTINGS"/extensions)" \
- "$@"
--- a/src/Pure/System/isabelle_tool.scala Mon Mar 21 11:55:51 2022 +0100
+++ b/src/Pure/System/isabelle_tool.scala Tue Mar 22 12:48:27 2022 +0100
@@ -236,4 +236,4 @@
isabelle.vscode.Build_VSCode.isabelle_tool,
isabelle.vscode.Build_VSCodium.isabelle_tool1,
isabelle.vscode.Build_VSCodium.isabelle_tool2,
- isabelle.vscode.VSCode_Setup.isabelle_tool)
+ isabelle.vscode.VSCode_Main.isabelle_tool)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Tools/VSCode/src/vscode_main.scala Tue Mar 22 12:48:27 2022 +0100
@@ -0,0 +1,96 @@
+/* Title: Tools/VSCode/src/vscode_main.scala
+ Author: Makarius
+
+Main application entry point for Isabelle/VSCode.
+*/
+
+package isabelle.vscode
+
+
+import isabelle._
+
+
+object VSCode_Main
+{
+ /* command-line interface */
+
+ private def platform_path(s: String): String = File.platform_path(Path.explode(s))
+
+ def run_cli(args: List[String],
+ environment: Iterable[(String, String)] = Nil,
+ background: Boolean = false,
+ progress: Progress = new Progress): Process_Result =
+ {
+ val env = new java.util.HashMap(Isabelle_System.settings())
+ for ((a, b) <- environment) env.put(a, b)
+ env.put("ISABELLE_VSCODIUM_APP", platform_path("$ISABELLE_VSCODIUM_RESOURCES/vscodium"))
+ env.put("ELECTRON_RUN_AS_NODE", "1")
+
+ val electron = Isabelle_System.getenv("ISABELLE_VSCODIUM_ELECTRON")
+ if (electron.isEmpty) {
+ error("""Undefined $ISABELLE_VSCODIUM_ELECTRON: missing "vscodium" component""")
+ }
+ val args0 =
+ List(platform_path("$ISABELLE_VSCODIUM_RESOURCES/vscodium/out/cli.js"),
+ "--ms-enable-electron-run-as-node", "--locale", "en-US",
+ "--user-data-dir", platform_path("$ISABELLE_VSCODE_SETTINGS/user-data"),
+ "--extensions-dir", platform_path("$ISABELLE_VSCODE_SETTINGS/extensions"))
+ val script =
+ Bash.strings(electron :: args0 ::: args) +
+ (if (background) " > /dev/null 2> /dev/null &" else "")
+
+ Isabelle_System.bash(script, env = env)
+ }
+
+
+ /* settings */
+
+ def settings_path: Path =
+ Path.explode("$ISABELLE_VSCODE_SETTINGS/user-data/User/settings.json")
+
+ private val default_settings = """ {
+ "editor.fontFamily": "'Isabelle DejaVu Sans Mono'",
+ "editor.fontSize": 18,
+ "editor.lineNumbers": "off",
+ "editor.renderIndentGuides": false,
+ "editor.rulers": [80, 100],
+ "editor.unicodeHighlight.ambiguousCharacters": false,
+ "extensions.autoCheckUpdates": false,
+ "extensions.autoUpdate": false,
+ "terminal.integrated.fontFamily": "monospace",
+ "update.mode": "none"
+ }
+"""
+
+ def init_settings(): Unit =
+ {
+ if (!settings_path.is_file) {
+ Isabelle_System.make_directory(settings_path.dir)
+ File.write(settings_path, default_settings)
+ }
+ }
+
+
+ /* Isabelle tool wrapper */
+
+ val isabelle_tool =
+ Isabelle_Tool("vscode", "Isabelle/VSCode interface wrapper", Scala_Project.here, args =>
+ {
+ val getopts = Getopts("""
+Usage: isabelle vscode -- VSCODE_OPTIONS
+
+ Start Isabelle/VSCode application, with automatic configuration of
+ user settings.
+
+ The following initial settings are provided for a fresh installation:
+""" + default_settings)
+
+ val more_args = getopts(args)
+
+ val progress = new Console_Progress()
+
+ init_settings()
+ run_cli(List("--version")).check
+ run_cli(more_args, background = true, progress = progress).check
+ })
+}
--- a/src/Tools/VSCode/src/vscode_setup.scala Mon Mar 21 11:55:51 2022 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/* Title: Tools/VSCode/src/vscode_setup.scala
- Author: Makarius
-
-Provide user configuration for Isabelle/VSCode.
-*/
-
-package isabelle.vscode
-
-
-import isabelle._
-
-
-object VSCode_Setup
-{
- /* vscode setup */
-
- def vscode_settings_user: Path =
- Path.explode("$ISABELLE_VSCODE_SETTINGS/user-data/User/settings.json")
-
- private val init_settings = """ {
- "editor.fontFamily": "'Isabelle DejaVu Sans Mono'",
- "editor.fontSize": 18,
- "editor.lineNumbers": "off",
- "editor.renderIndentGuides": false,
- "editor.rulers": [80, 100],
- "editor.unicodeHighlight.ambiguousCharacters": false,
- "extensions.autoCheckUpdates": false,
- "extensions.autoUpdate": false,
- "terminal.integrated.fontFamily": "monospace",
- "update.mode": "none"
- }
-"""
-
- def vscode_setup(): Unit =
- {
- if (Isabelle_System.getenv("ISABELLE_VSCODIUM_ELECTRON").isEmpty) {
- error("""Undefined $ISABELLE_VSCODIUM_ELECTRON: missing "vscodium" component""")
- }
-
- if (!vscode_settings_user.is_file) {
- Isabelle_System.make_directory(vscode_settings_user.dir)
- File.write(vscode_settings_user, init_settings)
- }
- }
-
-
- /* Isabelle tool wrapper */
-
- val isabelle_tool =
- Isabelle_Tool("vscode_setup", "provide user configuration for Isabelle/VSCode",
- Scala_Project.here, args =>
- {
- val getopts = Getopts("""
-Usage: vscode_setup
-
- Provide user configuration for Isabelle/VSCode.
-
- The following initial settings are provided for a fresh installation:
-""" + init_settings)
-
- val more_args = getopts(args)
- if (more_args.nonEmpty) getopts.usage()
-
- vscode_setup()
- })
-}