64872
|
1 |
/* Title: Tools/VSCode/src/symbols.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Generate configuration for VSCode editor extension Prettify Symbols Mode.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle.vscode
|
|
8 |
|
|
9 |
|
|
10 |
import isabelle._
|
|
11 |
|
|
12 |
|
|
13 |
object Symbols
|
|
14 |
{
|
|
15 |
/* generate configuration */
|
|
16 |
|
|
17 |
def prettify_config: String =
|
|
18 |
"""{
|
|
19 |
"prettifySymbolsMode.substitutions": [
|
|
20 |
{
|
|
21 |
"language": "isabelle",
|
|
22 |
"revealOn": "none",
|
|
23 |
"adjustCursorMovement": true,
|
|
24 |
"substitutions": [""" +
|
|
25 |
(for ((s, c) <- Symbol.codes)
|
|
26 |
yield
|
|
27 |
JSON.Format(
|
|
28 |
Map("ugly" -> Library.escape_regex(s),
|
|
29 |
"pretty" -> Library.escape_regex(Codepoint.string(c)))))
|
|
30 |
.mkString("\n ", ",\n ", "") +
|
|
31 |
"""]
|
|
32 |
}
|
|
33 |
]
|
|
34 |
}"""
|
|
35 |
|
|
36 |
|
|
37 |
/* Isabelle tool wrapper */
|
|
38 |
|
|
39 |
val isabelle_tool = Isabelle_Tool("vscode_symbols",
|
|
40 |
"generate configuration for VSCode editor extension Prettify Symbols Mode", args =>
|
|
41 |
{
|
|
42 |
val getopts = Getopts("""
|
|
43 |
Usage: isabelle vscode_symbols
|
|
44 |
|
|
45 |
Generate configuration for VSCode editor extension Prettify Symbols Mode.
|
|
46 |
""")
|
|
47 |
|
|
48 |
val more_args = getopts(args)
|
|
49 |
if (more_args.nonEmpty) getopts.usage()
|
|
50 |
|
|
51 |
val output_path = Path.explode("isabelle-symbols.json")
|
|
52 |
Output.writeln(output_path.implode)
|
|
53 |
File.write_backup(output_path, prettify_config)
|
|
54 |
})
|
|
55 |
}
|