1 'use strict'; |
1 'use strict'; |
2 |
2 |
3 import * as vscode from 'vscode'; |
3 import * as vscode from 'vscode'; |
4 import * as path from 'path'; |
4 import * as path from 'path'; |
|
5 import * as fs from 'fs'; |
5 import * as os from 'os'; |
6 import * as os from 'os'; |
6 import * as decorations from './decorations'; |
7 import * as decorations from './decorations'; |
7 import { Decoration } from './decorations' |
8 import { Decoration } from './decorations' |
8 import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, NotificationType } |
9 import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, NotificationType } |
9 from 'vscode-languageclient'; |
10 from 'vscode-languageclient'; |
11 |
12 |
12 export function activate(context: vscode.ExtensionContext) |
13 export function activate(context: vscode.ExtensionContext) |
13 { |
14 { |
14 const is_windows = os.type().startsWith("Windows") |
15 const is_windows = os.type().startsWith("Windows") |
15 |
16 |
16 const cygwin_root = vscode.workspace.getConfiguration("isabelle").get<string>("cygwin_root"); |
17 const isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home") |
17 const isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home"); |
18 const isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args") |
18 const isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args"); |
19 const cygwin_root = vscode.workspace.getConfiguration("isabelle").get<string>("cygwin_root") |
19 |
20 |
20 if (is_windows && cygwin_root === "") |
21 if (isabelle_home === "") |
21 vscode.window.showErrorMessage("Missing user settings: isabelle.cygwin_root") |
|
22 else if (isabelle_home === "") |
|
23 vscode.window.showErrorMessage("Missing user settings: isabelle.home") |
22 vscode.window.showErrorMessage("Missing user settings: isabelle.home") |
24 else { |
23 else { |
25 const isabelle_tool = isabelle_home + "/bin/isabelle" |
24 const isabelle_tool = isabelle_home + "/bin/isabelle" |
26 const standard_args = ["-o", "vscode_unicode_symbols", "-o", "vscode_pide_extensions"] |
25 const standard_args = ["-o", "vscode_unicode_symbols", "-o", "vscode_pide_extensions"] |
27 |
26 |
28 const server_options: ServerOptions = |
27 const server_options: ServerOptions = |
29 is_windows ? |
28 is_windows ? |
30 { command: cygwin_root + "/bin/bash", |
29 { command: |
|
30 (cygwin_root === "" ? path.join(isabelle_home, "contrib", "cygwin") : cygwin_root) + |
|
31 "/bin/bash", |
31 args: ["-l", isabelle_tool, "vscode_server"].concat(standard_args, isabelle_args) } : |
32 args: ["-l", isabelle_tool, "vscode_server"].concat(standard_args, isabelle_args) } : |
32 { command: isabelle_tool, |
33 { command: isabelle_tool, |
33 args: ["vscode_server"].concat(standard_args, isabelle_args) }; |
34 args: ["vscode_server"].concat(standard_args, isabelle_args) }; |
34 const client_options: LanguageClientOptions = { |
35 const client_options: LanguageClientOptions = { |
35 documentSelector: ["isabelle", "isabelle-ml", "bibtex"] |
36 documentSelector: ["isabelle", "isabelle-ml", "bibtex"] |