author | wenzelm |
Thu, 09 Mar 2017 21:09:45 +0100 | |
changeset 65165 | d98ede9e5917 |
parent 65153 | 82bd5d29adbf |
child 65167 | ee569aac344b |
permissions | -rw-r--r-- |
64605 | 1 |
'use strict'; |
2 |
||
3 |
import * as vscode from 'vscode'; |
|
4 |
import * as path from 'path'; |
|
64755 | 5 |
import * as os from 'os'; |
65094 | 6 |
import * as decorations from './decorations'; |
7 |
import { Decoration } from './decorations' |
|
65165 | 8 |
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, NotificationType } |
64605 | 9 |
from 'vscode-languageclient'; |
10 |
||
11 |
||
12 |
export function activate(context: vscode.ExtensionContext) |
|
13 |
{ |
|
64755 | 14 |
let is_windows = os.type().startsWith("Windows") |
15 |
||
16 |
let cygwin_root = vscode.workspace.getConfiguration("isabelle").get<string>("cygwin_root"); |
|
64734 | 17 |
let isabelle_home = vscode.workspace.getConfiguration("isabelle").get<string>("home"); |
64743 | 18 |
let isabelle_args = vscode.workspace.getConfiguration("isabelle").get<Array<string>>("args"); |
64605 | 19 |
|
64755 | 20 |
if (is_windows && cygwin_root == "") |
21 |
vscode.window.showErrorMessage("Missing user settings: isabelle.cygwin_root") |
|
22 |
else if (isabelle_home == "") |
|
23 |
vscode.window.showErrorMessage("Missing user settings: isabelle.home") |
|
64753 | 24 |
else { |
65153 | 25 |
let isabelle_tool = isabelle_home + "/bin/isabelle" |
65137 | 26 |
let standard_args = ["-o", "vscode_unicode_symbols", "-o", "vscode_pide_extensions"] |
64755 | 27 |
let run = |
28 |
is_windows ? |
|
65153 | 29 |
{ command: cygwin_root + "/bin/bash", |
64874
e13ff666af96
enable vscode_unicode_symbols by default, despite asymmetry of input and output;
wenzelm
parents:
64833
diff
changeset
|
30 |
args: ["-l", isabelle_tool, "vscode_server"].concat(standard_args, isabelle_args) } : |
64755 | 31 |
{ command: isabelle_tool, |
64874
e13ff666af96
enable vscode_unicode_symbols by default, despite asymmetry of input and output;
wenzelm
parents:
64833
diff
changeset
|
32 |
args: ["vscode_server"].concat(standard_args, isabelle_args) }; |
64755 | 33 |
|
64756
3cc892bd8f0f
avoid hardwired options: use isabelle.args settings instead;
wenzelm
parents:
64755
diff
changeset
|
34 |
let server_options: ServerOptions = { run: run, debug: run }; |
64753 | 35 |
let client_options: LanguageClientOptions = { |
64833 | 36 |
documentSelector: ["isabelle", "isabelle-ml", "bibtex"] |
64753 | 37 |
}; |
64605 | 38 |
|
65094 | 39 |
let client = new LanguageClient("Isabelle", server_options, client_options, false) |
40 |
||
41 |
decorations.init(context) |
|
65135
158cba86140f
maintain decorations for document (model) and update it for each editor (view);
wenzelm
parents:
65096
diff
changeset
|
42 |
vscode.window.onDidChangeActiveTextEditor(decorations.update_editor) |
158cba86140f
maintain decorations for document (model) and update it for each editor (view);
wenzelm
parents:
65096
diff
changeset
|
43 |
vscode.workspace.onDidCloseTextDocument(decorations.close_document) |
65165 | 44 |
client.onReady().then(() => |
45 |
client.onNotification( |
|
46 |
new NotificationType<Decoration, void>("PIDE/decoration"), decorations.apply_decoration)) |
|
65094 | 47 |
|
48 |
context.subscriptions.push(client.start()); |
|
49 |
} |
|
64605 | 50 |
} |
51 |
||
52 |
export function deactivate() { } |