lean4monaco 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +1 -3
  2. package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.d.ts +81 -0
  3. package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.js +372 -0
  4. package/package.json +1 -1
  5. package/dist/JuliaMono-Regular.ttf +0 -0
  6. package/dist/lean4-infoview/codicon.ttf +0 -0
  7. package/dist/lean4-infoview/esm-shims/react-dom.d.ts +0 -5
  8. package/dist/lean4-infoview/esm-shims/react-jsx-runtime.d.ts +0 -5
  9. package/dist/lean4-infoview/esm-shims/react.d.ts +0 -5
  10. package/dist/lean4-infoview/index.css +0 -4161
  11. package/dist/lean4-infoview/index.d.ts +0 -16
  12. package/dist/lean4-infoview/index.development.js +0 -37312
  13. package/dist/lean4-infoview/index.production.min.js +0 -1528
  14. package/dist/lean4-infoview/infoview/collapsing.d.ts +0 -12
  15. package/dist/lean4-infoview/infoview/contexts.d.ts +0 -10
  16. package/dist/lean4-infoview/infoview/editorConnection.d.ts +0 -22
  17. package/dist/lean4-infoview/infoview/errors.d.ts +0 -14
  18. package/dist/lean4-infoview/infoview/event.d.ts +0 -33
  19. package/dist/lean4-infoview/infoview/goalLocation.d.ts +0 -61
  20. package/dist/lean4-infoview/infoview/goals.d.ts +0 -46
  21. package/dist/lean4-infoview/infoview/info.d.ts +0 -18
  22. package/dist/lean4-infoview/infoview/infos.d.ts +0 -2
  23. package/dist/lean4-infoview/infoview/interactiveCode.d.ts +0 -19
  24. package/dist/lean4-infoview/infoview/main.d.ts +0 -13
  25. package/dist/lean4-infoview/infoview/messages.d.ts +0 -19
  26. package/dist/lean4-infoview/infoview/rpcSessions.d.ts +0 -11
  27. package/dist/lean4-infoview/infoview/serverVersion.d.ts +0 -10
  28. package/dist/lean4-infoview/infoview/tooltips.d.ts +0 -32
  29. package/dist/lean4-infoview/infoview/traceExplorer.d.ts +0 -11
  30. package/dist/lean4-infoview/infoview/userWidget.d.ts +0 -39
  31. package/dist/lean4-infoview/infoview/util.d.ts +0 -144
  32. package/dist/lean4-infoview/loader.d.ts +0 -20
  33. package/dist/lean4-infoview/loader.development.js +0 -1006
  34. package/dist/lean4-infoview/loader.production.min.js +0 -1
  35. package/dist/lean4-infoview/react-dom.development.js +0 -30537
  36. package/dist/lean4-infoview/react-dom.production.min.js +0 -21
  37. package/dist/lean4-infoview/react-jsx-runtime.development.js +0 -1362
  38. package/dist/lean4-infoview/react-jsx-runtime.production.min.js +0 -1
  39. package/dist/lean4-infoview/react.development.js +0 -2823
  40. package/dist/lean4-infoview/react.production.min.js +0 -1
  41. package/dist/monaco-lean4/vscode-lean4/package.json +0 -944
  42. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +0 -9
  43. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +0 -20
  44. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.d.ts +0 -12
  45. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.js +0 -40
  46. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +0 -20
  47. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +0 -79
  48. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.d.ts +0 -13
  49. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.js +0 -29
  50. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +0 -28
  51. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +0 -124
  52. package/dist/monaco-lean4/vscode-lean4/src/config.d.ts +0 -33
  53. package/dist/monaco-lean4/vscode-lean4/src/config.js +0 -119
  54. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +0 -27
  55. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +0 -133
  56. package/dist/monaco-lean4/vscode-lean4/src/infoview.d.ts +0 -69
  57. package/dist/monaco-lean4/vscode-lean4/src/infoview.js +0 -711
  58. package/dist/monaco-lean4/vscode-lean4/src/leanclient.d.ts +0 -67
  59. package/dist/monaco-lean4/vscode-lean4/src/leanclient.js +0 -443
  60. package/dist/monaco-lean4/vscode-lean4/src/rpc.d.ts +0 -16
  61. package/dist/monaco-lean4/vscode-lean4/src/rpc.js +0 -102
  62. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.d.ts +0 -11
  63. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.js +0 -130
  64. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.d.ts +0 -37
  65. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.js +0 -203
  66. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.d.ts +0 -41
  67. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.js +0 -205
  68. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.d.ts +0 -16
  69. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.js +0 -129
  70. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.d.ts +0 -3
  71. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.js +0 -4
  72. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.d.ts +0 -21
  73. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.js +0 -53
  74. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.d.ts +0 -35
  75. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.js +0 -136
  76. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.d.ts +0 -17
  77. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.js +0 -36
  78. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +0 -37
  79. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.js +0 -210
  80. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.d.ts +0 -7
  81. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.js +0 -20
  82. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.d.ts +0 -24
  83. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.js +0 -110
  84. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.d.ts +0 -9
  85. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.js +0 -125
  86. package/dist/useragent.d.ts +0 -1
  87. package/dist/useragent.js +0 -31
  88. package/dist/vscode.css +0 -7
@@ -1,210 +0,0 @@
1
- import { EventEmitter, window } from 'vscode';
2
- import { getPowerShellPath, isRunningTest } from '../config';
3
- import { ExecutionExitCode, batchExecute, displayResultError } from './batch';
4
- import { elanSelfUpdate } from './elan';
5
- import { logger } from './logger';
6
- import { displayError, displayErrorWithOptionalInput, displayNotificationWithInput, } from './notifs';
7
- export class LeanVersion {
8
- version;
9
- error;
10
- }
11
- export class LeanInstaller {
12
- leanInstallerLinux = 'https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh';
13
- leanInstallerWindows = 'https://raw.githubusercontent.com/leanprover/elan/master/elan-init.ps1';
14
- outputChannel;
15
- prompting = false;
16
- installing = false;
17
- freshInstallDefaultToolchain;
18
- elanDefaultToolchain = ''; // the default toolchain according to elan (toolchain marked with '(default)')
19
- workspaceSuffix = '(workspace override)';
20
- defaultSuffix = '(default)';
21
- promptUser = true;
22
- // This event is raised whenever a version change happens.
23
- // The event provides the workspace Uri where the change happened.
24
- installChangedEmitter = new EventEmitter();
25
- installChanged = this.installChangedEmitter.event;
26
- constructor(outputChannel, freshInstallDefaultToolchain) {
27
- this.outputChannel = outputChannel;
28
- this.freshInstallDefaultToolchain = freshInstallDefaultToolchain;
29
- if (isRunningTest()) {
30
- this.promptUser = false;
31
- if (process.env.LEAN4_PROMPT_USER === 'true') {
32
- this.promptUser = true;
33
- }
34
- }
35
- }
36
- getPromptUser() {
37
- return this.promptUser;
38
- }
39
- getOutputChannel() {
40
- return this.outputChannel;
41
- }
42
- handleVersionChanged(packageUri) {
43
- void this.showRestartPromptAndRestart('Lean version changed', packageUri);
44
- }
45
- isPromptVisible() {
46
- return this.prompting;
47
- }
48
- async showRestartPromptAndRestart(message, packageUri) {
49
- if (!this.promptUser) {
50
- this.installChangedEmitter.fire(packageUri);
51
- return;
52
- }
53
- if (this.prompting) {
54
- return;
55
- }
56
- this.prompting = true;
57
- const finalizer = () => {
58
- this.prompting = false;
59
- };
60
- displayErrorWithOptionalInput(message, 'Restart Lean', () => this.installChangedEmitter.fire(packageUri), finalizer);
61
- }
62
- handleLakeFileChanged(packageUri) {
63
- void this.showRestartPromptAndRestart('Lake file configuration changed', packageUri);
64
- }
65
- removeSuffix(version) {
66
- let s = version;
67
- const suffixes = [this.defaultSuffix, this.workspaceSuffix];
68
- suffixes.forEach(suffix => {
69
- if (s.endsWith(suffix)) {
70
- s = s.substr(0, s.length - suffix.length);
71
- }
72
- });
73
- return s.trim();
74
- }
75
- async getElanDefaultToolchain(packageUri) {
76
- if (this.elanDefaultToolchain) {
77
- return this.elanDefaultToolchain;
78
- }
79
- const toolChains = await this.elanListToolChains(packageUri);
80
- let result = '';
81
- toolChains.forEach(s => {
82
- if (s.endsWith(this.defaultSuffix)) {
83
- result = this.removeSuffix(s);
84
- }
85
- });
86
- this.elanDefaultToolchain = result;
87
- return result;
88
- }
89
- async elanListToolChains(packageUri) {
90
- try {
91
- const cmd = 'elan';
92
- const options = ['toolchain', 'list'];
93
- const cwd = packageUri.scheme === 'file' ? packageUri.fsPath : undefined;
94
- const stdout = (await batchExecute(cmd, options, cwd)).stdout;
95
- if (!stdout) {
96
- throw new Error('elan toolchain list returned no output.');
97
- }
98
- const result = [];
99
- stdout.split(/\r?\n/).forEach(s => {
100
- s = s.trim();
101
- if (s !== '') {
102
- result.push(s);
103
- }
104
- });
105
- return result;
106
- }
107
- catch (err) {
108
- return [`${err}`];
109
- }
110
- }
111
- async hasElan() {
112
- try {
113
- const options = ['--version'];
114
- const result = await batchExecute('elan', options);
115
- const filterVersion = /elan (\d+)\.\d+\..+/;
116
- const match = filterVersion.exec(result.stdout);
117
- return match !== null;
118
- }
119
- catch (err) {
120
- return false;
121
- }
122
- }
123
- async displayInstallElanPrompt(severity, reason) {
124
- if (!this.getPromptUser()) {
125
- // Used in tests
126
- await this.autoInstall();
127
- return true;
128
- }
129
- const reasonPrefix = reason ? reason + ' ' : '';
130
- const installElanItem = 'Install Elan and Lean 4';
131
- const installElanChoice = await displayNotificationWithInput(severity, reasonPrefix + "Do you want to install Lean's version manager Elan and a recent stable version of Lean 4?", installElanItem);
132
- if (installElanChoice === undefined) {
133
- return false;
134
- }
135
- await this.installElan();
136
- return true;
137
- }
138
- async displayUpdateElanPrompt(severity, currentVersion, recommendedVersion) {
139
- const updateElanItem = 'Update Elan';
140
- const updateElanChoice = await displayNotificationWithInput(severity, `Lean's version manager Elan is outdated: the installed version is ${currentVersion.toString()}, but a version of ${recommendedVersion.toString()} is recommended. Do you want to update Elan?`, updateElanItem);
141
- if (updateElanChoice === undefined) {
142
- return false;
143
- }
144
- if (currentVersion.compare('3.1.0') === 0) {
145
- // `elan self update` was broken in elan 3.1.0, so we need to take a different approach to updating elan here.
146
- const installElanResult = await this.installElan();
147
- return installElanResult === 'Success';
148
- }
149
- const elanSelfUpdateResult = await elanSelfUpdate(this.outputChannel);
150
- if (elanSelfUpdateResult.exitCode !== ExecutionExitCode.Success) {
151
- displayResultError(elanSelfUpdateResult, "Cannot update Elan. If you suspect that this is due to the way that you have set up Elan (e.g. from a package repository that ships an outdated version of Elan), you can disable these warnings using the 'Lean4: Show Setup Warnings' setting under 'File' > 'Preferences' > 'Settings'.");
152
- return false;
153
- }
154
- return true;
155
- }
156
- async autoInstall() {
157
- logger.log('[LeanInstaller] Installing Elan ...');
158
- await this.installElan();
159
- logger.log('[LeanInstaller] Elan installed');
160
- }
161
- async installElan() {
162
- if (this.installing) {
163
- displayError('Elan is already being installed. Please wait until the installation has finished.');
164
- return 'PendingInstallation';
165
- }
166
- this.installing = true;
167
- const terminalName = 'Lean installation via elan';
168
- let terminalOptions = { name: terminalName };
169
- if (process.platform === 'win32') {
170
- terminalOptions = { name: terminalName, shellPath: getPowerShellPath() };
171
- }
172
- const terminal = window.createTerminal(terminalOptions);
173
- terminal.show();
174
- // We register a listener, to restart the Lean extension once elan has finished.
175
- const resultPromise = new Promise(function (resolve, reject) {
176
- window.onDidCloseTerminal(async (t) => {
177
- if (t === terminal) {
178
- resolve(true);
179
- }
180
- else {
181
- logger.log('[LeanInstaller] ignoring terminal closed: ' + t.name + ', waiting for: ' + terminalName);
182
- }
183
- });
184
- });
185
- if (process.platform === 'win32') {
186
- terminal.sendText(`Start-BitsTransfer -Source "${this.leanInstallerWindows}" -Destination "elan-init.ps1"\r\n` +
187
- 'Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process\r\n' +
188
- `$rc = .\\elan-init.ps1 -NoPrompt 1 -DefaultToolchain ${this.freshInstallDefaultToolchain}\r\n` +
189
- 'Write-Host "elan-init returned [$rc]"\r\n' +
190
- 'del .\\elan-init.ps1\r\n' +
191
- 'if ($rc -ne 0) {\r\n' +
192
- ' Read-Host -Prompt "Press ENTER to continue"\r\n' +
193
- '}\r\n' +
194
- 'exit\r\n');
195
- }
196
- else {
197
- const elanArgs = `-y --default-toolchain ${this.freshInstallDefaultToolchain}`;
198
- const prompt = '(echo && read -n 1 -s -r -p "Install failed, press ENTER to continue...")';
199
- terminal.sendText(`bash -c 'curl ${this.leanInstallerLinux} -sSf | sh -s -- ${elanArgs} || ${prompt}' && exit `);
200
- }
201
- const result = await resultPromise;
202
- this.elanDefaultToolchain = this.freshInstallDefaultToolchain;
203
- this.installing = false;
204
- if (!result) {
205
- displayError('Elan installation failed. Check the terminal output for details.');
206
- return 'InstallationFailed';
207
- }
208
- return 'Success';
209
- }
210
- }
@@ -1,7 +0,0 @@
1
- declare class Logger {
2
- private static now;
3
- log(msg: string): void;
4
- error(msg: string): void;
5
- }
6
- declare const logger: Logger;
7
- export { logger };
@@ -1,20 +0,0 @@
1
- class Logger {
2
- static now() {
3
- const now = new Date();
4
- return (String(now.getUTCHours()).padStart(2, '0') +
5
- ':' +
6
- String(now.getMinutes()).padStart(2, '0') +
7
- ':' +
8
- String(now.getUTCSeconds()).padStart(2, '0') +
9
- '.' +
10
- String(now.getMilliseconds()).padStart(3, '0'));
11
- }
12
- log(msg) {
13
- console.log(Logger.now(), '-', msg);
14
- }
15
- error(msg) {
16
- console.error(Logger.now(), '-', msg);
17
- }
18
- }
19
- const logger = new Logger();
20
- export { logger };
@@ -1,24 +0,0 @@
1
- export type NotificationSeverity = 'Information' | 'Warning' | 'Error';
2
- export declare function displayNotification(severity: NotificationSeverity, message: string, finalizer?: (() => void) | undefined): void;
3
- export declare function displayNotificationWithInput<T extends string>(severity: NotificationSeverity, message: string, ...items: T[]): Promise<T | undefined>;
4
- export declare function displayNotificationWithOptionalInput<T extends string>(severity: NotificationSeverity, message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): void;
5
- export declare function displayNotificationWithOutput(severity: NotificationSeverity, message: string, finalizer?: (() => void) | undefined): void;
6
- export declare function displayNotificationWithSetupGuide(severity: NotificationSeverity, message: string, finalizer?: (() => void) | undefined): void;
7
- export declare function displayError(message: string, finalizer?: (() => void) | undefined): void;
8
- export declare function displayErrorWithInput<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;
9
- export declare function displayErrorWithOptionalInput<T extends string>(message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): void;
10
- export declare function displayErrorWithOutput(message: string, finalizer?: (() => void) | undefined): void;
11
- export declare function displayErrorWithSetupGuide(message: string, finalizer?: (() => void) | undefined): void;
12
- export declare function displayWarning(message: string, finalizer?: (() => void) | undefined): void;
13
- export declare function displayModalWarning(message: string): Promise<'Proceed' | 'Abort'>;
14
- export declare function displayWarningWithInput<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;
15
- export declare function displayWarningWithOptionalInput<T extends string>(message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): void;
16
- export declare function displayWarningWithOutput(message: string, finalizer?: (() => void) | undefined): void;
17
- export declare function displayModalWarningWithOutput(message: string): Promise<'Proceed' | 'Abort'>;
18
- export declare function displayWarningWithSetupGuide(message: string, finalizer?: (() => void) | undefined): void;
19
- export declare function displayModalWarningWithSetupGuide(message: string): Promise<'Proceed' | 'Abort'>;
20
- export declare function displayInformation(message: string, finalizer?: (() => void) | undefined): void;
21
- export declare function displayInformationWithInput<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;
22
- export declare function displayInformationWithOptionalInput<T extends string>(message: string, input: T, action: () => void, finalizer?: (() => void) | undefined): void;
23
- export declare function displayInformationWithOutput(message: string, finalizer?: (() => void) | undefined): void;
24
- export declare function displayInformationWithSetupGuide(message: string, finalizer?: (() => void) | undefined): void;
@@ -1,110 +0,0 @@
1
- import { commands, window } from 'vscode';
2
- function toNotif(severity) {
3
- switch (severity) {
4
- case 'Information':
5
- return window.showInformationMessage;
6
- case 'Warning':
7
- return window.showWarningMessage;
8
- case 'Error':
9
- return window.showErrorMessage;
10
- }
11
- }
12
- export function displayNotification(severity, message, finalizer) {
13
- void (async () => {
14
- await toNotif(severity)(message, {});
15
- if (finalizer) {
16
- finalizer();
17
- }
18
- })();
19
- }
20
- export async function displayNotificationWithInput(severity, message, ...items) {
21
- return await toNotif(severity)(message, { modal: true }, ...items);
22
- }
23
- export function displayNotificationWithOptionalInput(severity, message, input, action, finalizer) {
24
- void (async () => {
25
- const choice = await toNotif(severity)(message, {}, input);
26
- if (choice === input) {
27
- action();
28
- }
29
- if (finalizer) {
30
- finalizer();
31
- }
32
- })();
33
- }
34
- export function displayNotificationWithOutput(severity, message, finalizer) {
35
- displayNotificationWithOptionalInput(severity, message, 'Show Output', () => commands.executeCommand('lean4.troubleshooting.showOutput'), finalizer);
36
- }
37
- export function displayNotificationWithSetupGuide(severity, message, finalizer) {
38
- displayNotificationWithOptionalInput(severity, message, 'Open Setup Guide', () => commands.executeCommand('lean4.docs.showSetupGuide'), finalizer);
39
- }
40
- export function displayError(message, finalizer) {
41
- displayNotification('Error', message, finalizer);
42
- }
43
- export async function displayErrorWithInput(message, ...items) {
44
- return await displayNotificationWithInput('Error', message, ...items);
45
- }
46
- export function displayErrorWithOptionalInput(message, input, action, finalizer) {
47
- displayNotificationWithOptionalInput('Error', message, input, action, finalizer);
48
- }
49
- export function displayErrorWithOutput(message, finalizer) {
50
- displayNotificationWithOutput('Error', message, finalizer);
51
- }
52
- export function displayErrorWithSetupGuide(message, finalizer) {
53
- displayNotificationWithSetupGuide('Error', message, finalizer);
54
- }
55
- export function displayWarning(message, finalizer) {
56
- displayNotification('Warning', message, finalizer);
57
- }
58
- export async function displayModalWarning(message) {
59
- const choice = await window.showWarningMessage(message, { modal: true }, 'Proceed Regardless');
60
- return choice === 'Proceed Regardless' ? 'Proceed' : 'Abort';
61
- }
62
- export async function displayWarningWithInput(message, ...items) {
63
- return await displayNotificationWithInput('Warning', message, ...items);
64
- }
65
- export function displayWarningWithOptionalInput(message, input, action, finalizer) {
66
- displayNotificationWithOptionalInput('Warning', message, input, action, finalizer);
67
- }
68
- export function displayWarningWithOutput(message, finalizer) {
69
- displayNotificationWithOutput('Warning', message, finalizer);
70
- }
71
- export async function displayModalWarningWithOutput(message) {
72
- const choice = await window.showWarningMessage(message, 'Show Output', 'Proceed Regardless');
73
- if (choice === undefined) {
74
- return 'Abort';
75
- }
76
- if (choice === 'Proceed Regardless') {
77
- return 'Proceed';
78
- }
79
- await commands.executeCommand('lean4.troubleshooting.showOutput');
80
- return 'Abort';
81
- }
82
- export function displayWarningWithSetupGuide(message, finalizer) {
83
- displayNotificationWithSetupGuide('Warning', message, finalizer);
84
- }
85
- export async function displayModalWarningWithSetupGuide(message) {
86
- const choice = await window.showWarningMessage(message, 'Open Setup Guide', 'Proceed Regardless');
87
- if (choice === undefined) {
88
- return 'Abort';
89
- }
90
- if (choice === 'Proceed Regardless') {
91
- return 'Proceed';
92
- }
93
- await commands.executeCommand('lean4.docs.showSetupGuide');
94
- return 'Abort';
95
- }
96
- export function displayInformation(message, finalizer) {
97
- displayNotification('Information', message, finalizer);
98
- }
99
- export async function displayInformationWithInput(message, ...items) {
100
- return await displayNotificationWithInput('Information', message, ...items);
101
- }
102
- export function displayInformationWithOptionalInput(message, input, action, finalizer) {
103
- displayNotificationWithOptionalInput('Information', message, input, action, finalizer);
104
- }
105
- export function displayInformationWithOutput(message, finalizer) {
106
- displayNotificationWithOutput('Information', message, finalizer);
107
- }
108
- export function displayInformationWithSetupGuide(message, finalizer) {
109
- displayNotificationWithSetupGuide('Information', message, finalizer);
110
- }
@@ -1,9 +0,0 @@
1
- import { ExtUri, FileUri } from './exturi';
2
- export declare function isCoreLean4Directory(path: FileUri): Promise<boolean>;
3
- export declare function findLeanProjectRootInfo(uri: FileUri): Promise<[FileUri, FileUri | undefined]>;
4
- export declare function findLeanProjectRoot(uri: FileUri): Promise<FileUri>;
5
- export declare function findLeanProjectInfo(uri: FileUri): Promise<[FileUri, string | undefined]>;
6
- export declare function readLeanToolchain(projectUri: FileUri): Promise<string | undefined>;
7
- export declare function isValidLeanProject(projectFolder: FileUri): Promise<boolean>;
8
- export declare function checkParentFoldersForLeanProject(folder: FileUri): Promise<FileUri | undefined>;
9
- export declare function willUseLakeServer(folder: ExtUri): Promise<boolean>;
@@ -1,125 +0,0 @@
1
- import * as fs from 'fs';
2
- import { FileUri, getWorkspaceFolderUri } from './exturi';
3
- import { dirExists, fileExists } from './fsHelper';
4
- import path from 'path';
5
- // Detect lean4 root directory (works for both lean4 repo and nightly distribution)
6
- export async function isCoreLean4Directory(path) {
7
- const licensePath = path.join('LICENSE').fsPath;
8
- const licensesPath = path.join('LICENSES').fsPath;
9
- const srcPath = path.join('src').fsPath;
10
- const isCoreLean4RootDirectory = (await fileExists(licensePath)) && (await fileExists(licensesPath)) && (await dirExists(srcPath));
11
- if (isCoreLean4RootDirectory) {
12
- return true;
13
- }
14
- const initPath = path.join('Init.lean').fsPath;
15
- const leanPath = path.join('Lean.lean').fsPath;
16
- const kernelPath = path.join('kernel').fsPath;
17
- const runtimePath = path.join('runtime').fsPath;
18
- const isCoreLean4SrcDirectory = (await fileExists(initPath)) &&
19
- (await fileExists(leanPath)) &&
20
- (await dirExists(kernelPath)) &&
21
- (await dirExists(runtimePath));
22
- return isCoreLean4SrcDirectory;
23
- }
24
- // Find the root of a Lean project and the Uri for the 'lean-toolchain' file found there.
25
- export async function findLeanProjectRootInfo(uri) {
26
- const toolchainFileName = 'lean-toolchain';
27
- let path = uri;
28
- const containingWsFolderUri = getWorkspaceFolderUri(uri);
29
- // then start searching from the directory containing this document.
30
- // The given uri may already be a folder Uri in some cases.
31
- if (fs.lstatSync(path.fsPath).isFile()) {
32
- path = uri.join('..');
33
- }
34
- let bestFolder = path;
35
- let bestLeanToolchain;
36
- while (true) {
37
- const leanToolchain = path.join(toolchainFileName);
38
- if (await fileExists(leanToolchain.fsPath)) {
39
- bestFolder = path;
40
- bestLeanToolchain = leanToolchain;
41
- }
42
- else if (await isCoreLean4Directory(path)) {
43
- bestFolder = path;
44
- bestLeanToolchain = undefined;
45
- // Stop searching in case users accidentally created a lean-toolchain file above the core directory
46
- break;
47
- }
48
- if (containingWsFolderUri !== undefined && path.equals(containingWsFolderUri)) {
49
- if (bestLeanToolchain === undefined) {
50
- // If we haven't found a toolchain yet, prefer the workspace folder as the project scope for the file,
51
- // but keep looking in case there is a lean-toolchain above the workspace folder
52
- // (New users sometimes accidentally open sub-folders of projects)
53
- bestFolder = path;
54
- }
55
- else {
56
- // Stop looking above the barrier if we have a toolchain. This is necessary for the nested lean-toolchain setup of core.
57
- break;
58
- }
59
- }
60
- const parent = path.join('..');
61
- if (parent.equals(path)) {
62
- // no project file found.
63
- break;
64
- }
65
- path = parent;
66
- }
67
- return [bestFolder, bestLeanToolchain];
68
- }
69
- export async function findLeanProjectRoot(uri) {
70
- const [projectRootUri, _] = await findLeanProjectRootInfo(uri);
71
- return projectRootUri;
72
- }
73
- export async function findLeanProjectInfo(uri) {
74
- const [projectUri, toolchainUri] = await findLeanProjectRootInfo(uri);
75
- if (!toolchainUri) {
76
- return [projectUri, undefined];
77
- }
78
- return [projectUri, await readLeanToolchainFile(toolchainUri)];
79
- }
80
- export async function readLeanToolchain(projectUri) {
81
- const toolchainFileName = 'lean-toolchain';
82
- const leanToolchain = projectUri.join(toolchainFileName);
83
- if (!fs.existsSync(leanToolchain.fsPath)) {
84
- return undefined;
85
- }
86
- return await readLeanToolchainFile(leanToolchain);
87
- }
88
- async function readLeanToolchainFile(toolchainFileUri) {
89
- try {
90
- return (await fs.promises.readFile(toolchainFileUri.fsPath, { encoding: 'utf-8' })).trim();
91
- }
92
- catch {
93
- return undefined;
94
- }
95
- }
96
- export async function isValidLeanProject(projectFolder) {
97
- try {
98
- const leanToolchainPath = projectFolder.join('lean-toolchain').fsPath;
99
- const isLeanProject = await fileExists(leanToolchainPath);
100
- const isLeanItself = await isCoreLean4Directory(projectFolder);
101
- return isLeanProject || isLeanItself;
102
- }
103
- catch {
104
- return false;
105
- }
106
- }
107
- export async function checkParentFoldersForLeanProject(folder) {
108
- let childFolder;
109
- do {
110
- childFolder = folder;
111
- folder = new FileUri(path.dirname(folder.fsPath));
112
- if (await isValidLeanProject(folder)) {
113
- return folder;
114
- }
115
- } while (!childFolder.equals(folder));
116
- return undefined;
117
- }
118
- export async function willUseLakeServer(folder) {
119
- if (folder.scheme !== 'file') {
120
- return false;
121
- }
122
- const lakefileLean = folder.join('lakefile.lean');
123
- const lakefileToml = folder.join('lakefile.toml');
124
- return (await fileExists(lakefileLean.fsPath)) || (await fileExists(lakefileToml.fsPath));
125
- }
@@ -1 +0,0 @@
1
- export declare function setUserAgent(window: any, userAgent: any): void;
package/dist/useragent.js DELETED
@@ -1,31 +0,0 @@
1
- export function setUserAgent(window, userAgent) {
2
- // Works on Firefox, Chrome, Opera and IE9+
3
- if (navigator.__defineGetter__) {
4
- navigator.__defineGetter__('userAgent', function () {
5
- return userAgent;
6
- });
7
- }
8
- else if (Object.defineProperty) {
9
- Object.defineProperty(navigator, 'userAgent', {
10
- get: function () {
11
- return userAgent;
12
- }
13
- });
14
- }
15
- // Works on Safari
16
- if (window.navigator.userAgent !== userAgent) {
17
- var userAgentProp = {
18
- get: function () {
19
- return userAgent;
20
- }
21
- };
22
- try {
23
- Object.defineProperty(window.navigator, 'userAgent', userAgentProp);
24
- }
25
- catch (e) {
26
- window.navigator = Object.create(navigator, {
27
- userAgent: userAgentProp
28
- });
29
- }
30
- }
31
- }
package/dist/vscode.css DELETED
@@ -1,7 +0,0 @@
1
- :root {
2
- --vscode-font-weight:normal;
3
- --vscode-font-size:13px;
4
- --vscode-editor-font-family: 'JuliaMono', 'Source Code Pro', 'STIX Two Math', monospace;
5
- --vscode-editor-font-weight:normal;
6
- --vscode-editor-font-size:15px;
7
- }