lean4monaco 1.0.6 → 1.0.8
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.
- package/README.md +30 -1
- package/dist/JuliaMono-Regular.ttf +0 -0
- package/dist/editor.js +1 -2
- package/dist/leanmonaco.d.ts +14 -4
- package/dist/leanmonaco.js +149 -112
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +2 -1
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +2 -2
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +3 -2
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +5 -3
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +2 -1
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +4 -2
- package/dist/themes/cobalt2.json +887 -0
- package/dist/webview.js +4 -4
- package/package.json +3 -2
- package/dist/importmetaurl.d.ts +0 -2
- package/dist/importmetaurl.js +0 -26
- package/dist/monaco-lean4/lean4-infoview/src/index.d.ts +0 -16
- package/dist/monaco-lean4/lean4-infoview/src/index.js +0 -29
- package/dist/monaco-lean4/lean4-infoview/src/infoview/collapsing.d.ts +0 -12
- package/dist/monaco-lean4/lean4-infoview/src/infoview/collapsing.js +0 -37
- package/dist/monaco-lean4/lean4-infoview/src/infoview/contexts.d.ts +0 -40
- package/dist/monaco-lean4/lean4-infoview/src/infoview/contexts.js +0 -44
- package/dist/monaco-lean4/lean4-infoview/src/infoview/editorConnection.d.ts +0 -22
- package/dist/monaco-lean4/lean4-infoview/src/infoview/editorConnection.js +0 -41
- package/dist/monaco-lean4/lean4-infoview/src/infoview/errors.d.ts +0 -14
- package/dist/monaco-lean4/lean4-infoview/src/infoview/errors.js +0 -24
- package/dist/monaco-lean4/lean4-infoview/src/infoview/event.d.ts +0 -33
- package/dist/monaco-lean4/lean4-infoview/src/infoview/event.js +0 -57
- package/dist/monaco-lean4/lean4-infoview/src/infoview/goalLocation.d.ts +0 -61
- package/dist/monaco-lean4/lean4-infoview/src/infoview/goalLocation.js +0 -87
- package/dist/monaco-lean4/lean4-infoview/src/infoview/goals.d.ts +0 -11
- package/dist/monaco-lean4/lean4-infoview/src/infoview/goals.js +0 -141
- package/dist/monaco-lean4/lean4-infoview/src/infoview/info.d.ts +0 -18
- package/dist/monaco-lean4/lean4-infoview/src/infoview/info.js +0 -278
- package/dist/monaco-lean4/lean4-infoview/src/infoview/infos.d.ts +0 -2
- package/dist/monaco-lean4/lean4-infoview/src/infoview/infos.js +0 -113
- package/dist/monaco-lean4/lean4-infoview/src/infoview/interactiveCode.d.ts +0 -18
- package/dist/monaco-lean4/lean4-infoview/src/infoview/interactiveCode.js +0 -164
- package/dist/monaco-lean4/lean4-infoview/src/infoview/main.d.ts +0 -13
- package/dist/monaco-lean4/lean4-infoview/src/infoview/main.js +0 -97
- package/dist/monaco-lean4/lean4-infoview/src/infoview/messages.d.ts +0 -16
- package/dist/monaco-lean4/lean4-infoview/src/infoview/messages.js +0 -151
- package/dist/monaco-lean4/lean4-infoview/src/infoview/rpcSessions.d.ts +0 -21
- package/dist/monaco-lean4/lean4-infoview/src/infoview/rpcSessions.js +0 -67
- package/dist/monaco-lean4/lean4-infoview/src/infoview/serverVersion.d.ts +0 -10
- package/dist/monaco-lean4/lean4-infoview/src/infoview/serverVersion.js +0 -25
- package/dist/monaco-lean4/lean4-infoview/src/infoview/tooltips.d.ts +0 -23
- package/dist/monaco-lean4/lean4-infoview/src/infoview/tooltips.js +0 -231
- package/dist/monaco-lean4/lean4-infoview/src/infoview/traceExplorer.d.ts +0 -11
- package/dist/monaco-lean4/lean4-infoview/src/infoview/traceExplorer.js +0 -115
- package/dist/monaco-lean4/lean4-infoview/src/infoview/userWidget.d.ts +0 -48
- package/dist/monaco-lean4/lean4-infoview/src/infoview/userWidget.js +0 -54
- package/dist/monaco-lean4/lean4-infoview/src/infoview/util.d.ts +0 -144
- package/dist/monaco-lean4/lean4-infoview/src/infoview/util.js +0 -366
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ useEffect(() => {
|
|
|
23
23
|
const leanMonacoEditor = new LeanMonacoEditor()
|
|
24
24
|
|
|
25
25
|
;(async () => {
|
|
26
|
-
await leanMonaco.start('ws://localhost:8080/')
|
|
26
|
+
await leanMonaco.start({websocket: {url: 'ws://localhost:8080/'}})
|
|
27
27
|
leanMonaco.setInfoviewElement(infoviewRef.current)
|
|
28
28
|
await leanMonacoEditor.start(codeviewRef.current!, '/project/test.lean', '#check Nat')
|
|
29
29
|
})()
|
|
@@ -76,4 +76,33 @@ export default {
|
|
|
76
76
|
},
|
|
77
77
|
[...]
|
|
78
78
|
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Moreover, the infoview javascript files need to be served:
|
|
82
|
+
```ts
|
|
83
|
+
// vite.config.ts
|
|
84
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|
85
|
+
import { normalizePath } from 'vite'
|
|
86
|
+
import path from 'node:path'
|
|
87
|
+
|
|
88
|
+
export default {
|
|
89
|
+
plugins: [
|
|
90
|
+
viteStaticCopy({
|
|
91
|
+
targets: [
|
|
92
|
+
{
|
|
93
|
+
src: normalizePath(path.resolve(__dirname, './node_modules/@leanprover/infoview/dist/*.production.min.js')),
|
|
94
|
+
dest: 'infoview'
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Troubleshooting
|
|
103
|
+
|
|
104
|
+
* Make sure that only one version of the npm package `monaco-vscode-api` is installed.
|
|
105
|
+
The error I typically got is:
|
|
106
|
+
```
|
|
107
|
+
this._configurationService.onDidChangeConfiguration is not a function
|
|
79
108
|
```
|
|
Binary file
|
package/dist/editor.js
CHANGED
|
@@ -14,9 +14,8 @@ export class LeanMonacoEditor {
|
|
|
14
14
|
fs.mkdirSync(path.dirname(fileName), { recursive: true });
|
|
15
15
|
fs.writeFileSync(fileName, '');
|
|
16
16
|
// Create editor and model
|
|
17
|
-
const theme = "Visual Studio Light"; //"Visual Studio Dark" //"Default Light Modern" //"Default Light+" //"Default Dark+" //"Default High Contrast"
|
|
18
|
-
this.editor = monaco.editor.create(editorEl, { automaticLayout: true, theme });
|
|
19
17
|
this.modelRef = await createModelReference(Uri.parse(fileName), code);
|
|
18
|
+
this.editor = monaco.editor.create(editorEl, { automaticLayout: true });
|
|
20
19
|
this.editor.setModel(this.modelRef.object.textEditorModel);
|
|
21
20
|
// Set focus on editor to trigger infoview to open
|
|
22
21
|
this.editor.focus();
|
package/dist/leanmonaco.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import 'vscode/localExtensionHost';
|
|
2
|
-
import { RegisterExtensionResult } from 'monaco-editor-wrapper';
|
|
2
|
+
import { RegisterExtensionResult, WebSocketConfigOptionsUrl } from 'monaco-editor-wrapper';
|
|
3
3
|
import { LeanClientProvider } from './monaco-lean4/vscode-lean4/src/utils/clientProvider';
|
|
4
4
|
import { InfoProvider } from './monaco-lean4/vscode-lean4/src/infoview';
|
|
5
5
|
import { AbbreviationFeature } from './monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature';
|
|
6
6
|
import { LeanTaskGutter } from './monaco-lean4/vscode-lean4/src/taskgutter';
|
|
7
7
|
import { IFrameInfoWebviewFactory } from './infowebview';
|
|
8
|
-
import {
|
|
8
|
+
import { IExtensionManifest } from 'vscode/extensions';
|
|
9
9
|
import { DisposableStore } from 'vscode/monaco';
|
|
10
|
+
export type LeanMonacoOptions = {
|
|
11
|
+
websocket: {
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
vscode?: {
|
|
15
|
+
[id: string]: any;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
10
18
|
export declare class LeanMonaco {
|
|
11
19
|
ready: (value: void | PromiseLike<void>) => void;
|
|
12
20
|
whenReady: Promise<void>;
|
|
13
21
|
static activeInstance: LeanMonaco | null;
|
|
14
|
-
logger: Logger;
|
|
15
22
|
registerFileUrlResults: DisposableStore;
|
|
16
23
|
extensionRegisterResult: RegisterExtensionResult | undefined;
|
|
17
24
|
clientProvider: LeanClientProvider | undefined;
|
|
@@ -20,7 +27,10 @@ export declare class LeanMonaco {
|
|
|
20
27
|
abbreviationFeature: AbbreviationFeature | undefined;
|
|
21
28
|
taskGutter: LeanTaskGutter | undefined;
|
|
22
29
|
disposed: boolean;
|
|
23
|
-
start(
|
|
30
|
+
start(options: LeanMonacoOptions): Promise<void>;
|
|
24
31
|
setInfoviewElement(infoviewEl: HTMLElement): void;
|
|
32
|
+
protected getExtensionFiles(): Map<string, URL>;
|
|
33
|
+
protected getExtensionManifest(options: LeanMonacoOptions): IExtensionManifest;
|
|
34
|
+
protected getWebSocketOptions(options: LeanMonacoOptions): WebSocketConfigOptionsUrl;
|
|
25
35
|
dispose(): void;
|
|
26
36
|
}
|
package/dist/leanmonaco.js
CHANGED
|
@@ -7,110 +7,21 @@ import { LeanTaskGutter } from './monaco-lean4/vscode-lean4/src/taskgutter';
|
|
|
7
7
|
import { IFrameInfoWebviewFactory } from './infowebview';
|
|
8
8
|
import { setupMonacoClient } from './monacoleanclient';
|
|
9
9
|
import { checkLean4ProjectPreconditions } from './preconditions';
|
|
10
|
-
import {
|
|
11
|
-
import { Logger } from 'monaco-languageclient/tools';
|
|
10
|
+
import { initialize } from 'vscode/services';
|
|
12
11
|
import getConfigurationServiceOverride from '@codingame/monaco-vscode-configuration-service-override';
|
|
13
12
|
import getTextmateServiceOverride from '@codingame/monaco-vscode-textmate-service-override';
|
|
14
13
|
import getThemeServiceOverride from '@codingame/monaco-vscode-theme-service-override';
|
|
15
|
-
import
|
|
14
|
+
import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
|
|
15
|
+
import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
|
|
16
16
|
import { registerExtension } from 'vscode/extensions';
|
|
17
17
|
import { DisposableStore } from 'vscode/monaco';
|
|
18
|
-
|
|
19
|
-
extensionFilesOrContents.set('/language-configuration.json', new URL('./monaco-lean4/vscode-lean4/language-configuration.json', import.meta.url));
|
|
20
|
-
extensionFilesOrContents.set('/syntaxes/lean4.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/lean4.json', import.meta.url));
|
|
21
|
-
extensionFilesOrContents.set('/syntaxes/lean4-markdown.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/lean4-markdown.json', import.meta.url));
|
|
22
|
-
extensionFilesOrContents.set('/syntaxes/codeblock.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/codeblock.json', import.meta.url));
|
|
23
|
-
const extensionConfig = {
|
|
24
|
-
name: 'lean4web',
|
|
25
|
-
publisher: 'leanprover-community',
|
|
26
|
-
version: '1.0.0',
|
|
27
|
-
engines: {
|
|
28
|
-
vscode: '*'
|
|
29
|
-
},
|
|
30
|
-
"contributes": {
|
|
31
|
-
"languages": [
|
|
32
|
-
{
|
|
33
|
-
"id": "lean4",
|
|
34
|
-
"configuration": "./language-configuration.json",
|
|
35
|
-
"extensions": [
|
|
36
|
-
".lean"
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"id": "lean4markdown",
|
|
41
|
-
"aliases": [],
|
|
42
|
-
"extensions": [
|
|
43
|
-
".lean4markdown"
|
|
44
|
-
],
|
|
45
|
-
"configuration": "./language-configuration.json"
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"grammars": [
|
|
49
|
-
{
|
|
50
|
-
"language": "lean4",
|
|
51
|
-
"scopeName": "source.lean4",
|
|
52
|
-
"path": "./syntaxes/lean4.json"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"language": "lean4markdown",
|
|
56
|
-
"scopeName": "source.lean4.markdown",
|
|
57
|
-
"path": "./syntaxes/lean4-markdown.json"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"language": "lean4",
|
|
61
|
-
"scopeName": "markdown.lean4.codeblock",
|
|
62
|
-
"path": "./syntaxes/codeblock.json",
|
|
63
|
-
"injectTo": [
|
|
64
|
-
"text.html.markdown"
|
|
65
|
-
],
|
|
66
|
-
"embeddedLanguages": {
|
|
67
|
-
"meta.embedded.block.lean4": "lean4"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const serviceConfig = {
|
|
74
|
-
userServices: {
|
|
75
|
-
...getTextmateServiceOverride(),
|
|
76
|
-
...getThemeServiceOverride(),
|
|
77
|
-
...getConfigurationServiceOverride()
|
|
78
|
-
},
|
|
79
|
-
workspaceConfig: {
|
|
80
|
-
workspaceProvider: {
|
|
81
|
-
trusted: true,
|
|
82
|
-
workspace: {
|
|
83
|
-
workspaceUri: Uri.file('/workspace')
|
|
84
|
-
},
|
|
85
|
-
async open() {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const websocketOptions = {
|
|
92
|
-
$type: 'WebSocketUrl',
|
|
93
|
-
url: '',
|
|
94
|
-
startOptions: {
|
|
95
|
-
onCall: () => {
|
|
96
|
-
console.log('Connected to socket.');
|
|
97
|
-
},
|
|
98
|
-
reportStatus: true
|
|
99
|
-
},
|
|
100
|
-
stopOptions: {
|
|
101
|
-
onCall: () => {
|
|
102
|
-
console.log('Disconnected from socket.');
|
|
103
|
-
},
|
|
104
|
-
reportStatus: true
|
|
105
|
-
}
|
|
106
|
-
};
|
|
18
|
+
import packageJson from './monaco-lean4/vscode-lean4/package.json';
|
|
107
19
|
export class LeanMonaco {
|
|
108
20
|
ready;
|
|
109
21
|
whenReady = new Promise((resolve) => {
|
|
110
22
|
this.ready = resolve;
|
|
111
23
|
});
|
|
112
24
|
static activeInstance = null;
|
|
113
|
-
logger = new Logger();
|
|
114
25
|
registerFileUrlResults = new DisposableStore();
|
|
115
26
|
extensionRegisterResult;
|
|
116
27
|
clientProvider;
|
|
@@ -119,7 +30,7 @@ export class LeanMonaco {
|
|
|
119
30
|
abbreviationFeature;
|
|
120
31
|
taskGutter;
|
|
121
32
|
disposed = false;
|
|
122
|
-
async start(
|
|
33
|
+
async start(options) {
|
|
123
34
|
if (LeanMonaco.activeInstance == this) {
|
|
124
35
|
console.warn('A LeanMonaco instance cannot be started twice.');
|
|
125
36
|
return;
|
|
@@ -129,7 +40,7 @@ export class LeanMonaco {
|
|
|
129
40
|
LeanMonaco.activeInstance?.dispose();
|
|
130
41
|
}
|
|
131
42
|
LeanMonaco.activeInstance = this;
|
|
132
|
-
if (!window.MonacoEnvironment
|
|
43
|
+
if (!window.MonacoEnvironment) {
|
|
133
44
|
const workerLoaders = {
|
|
134
45
|
editorWorkerService: () => new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker.js', import.meta.url), { type: 'module' }),
|
|
135
46
|
textMateWorker: () => new Worker(new URL('@codingame/monaco-vscode-textmate-service-override/worker', import.meta.url), { type: 'module' }),
|
|
@@ -143,40 +54,51 @@ export class LeanMonaco {
|
|
|
143
54
|
throw new Error(`Unimplemented worker ${label} (${moduleId})`);
|
|
144
55
|
}
|
|
145
56
|
};
|
|
57
|
+
await initialize({
|
|
58
|
+
...getTextmateServiceOverride(),
|
|
59
|
+
...getThemeServiceOverride(),
|
|
60
|
+
...getConfigurationServiceOverride(),
|
|
61
|
+
...getLanguagesServiceOverride(),
|
|
62
|
+
...getModelServiceOverride()
|
|
63
|
+
}, undefined, {
|
|
64
|
+
workspaceProvider: {
|
|
65
|
+
trusted: true,
|
|
66
|
+
workspace: {
|
|
67
|
+
workspaceUri: Uri.file('/workspace.code-workspace')
|
|
68
|
+
},
|
|
69
|
+
async open() {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
146
74
|
}
|
|
147
|
-
await initServices({
|
|
148
|
-
serviceConfig,
|
|
149
|
-
caller: `Lean monaco-editor`,
|
|
150
|
-
performChecks: checkServiceConsistency,
|
|
151
|
-
logger: this.logger
|
|
152
|
-
});
|
|
153
75
|
await (await import('@codingame/monaco-vscode-theme-defaults-default-extension')).whenReady;
|
|
154
76
|
if (this.disposed)
|
|
155
77
|
return;
|
|
156
|
-
this.extensionRegisterResult = registerExtension(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.registerFileUrlResults.add(registerFileUrlResult);
|
|
161
|
-
}
|
|
78
|
+
this.extensionRegisterResult = registerExtension(this.getExtensionManifest(options), 1 /* ExtensionHostKind.LocalProcess */);
|
|
79
|
+
for (const entry of this.getExtensionFiles()) {
|
|
80
|
+
const registerFileUrlResult = this.extensionRegisterResult.registerFileUrl(entry[0], entry[1].href);
|
|
81
|
+
this.registerFileUrlResults.add(registerFileUrlResult);
|
|
162
82
|
}
|
|
163
83
|
await this.extensionRegisterResult.whenReady();
|
|
164
84
|
if (this.disposed)
|
|
165
85
|
return;
|
|
166
|
-
this.abbreviationFeature = new AbbreviationFeature({});
|
|
86
|
+
this.abbreviationFeature = new AbbreviationFeature({}, { kind: 'MoveAllSelections' });
|
|
167
87
|
this.clientProvider = new LeanClientProvider({
|
|
168
88
|
installChanged: () => { return { dispose: () => { } }; },
|
|
169
89
|
testLeanVersion: () => { return "lean4/stable"; },
|
|
170
90
|
getElanDefaultToolchain: () => { return "lean4/stable"; }
|
|
171
91
|
}, { appendLine: () => { }
|
|
172
|
-
}, setupMonacoClient({
|
|
173
|
-
...websocketOptions,
|
|
174
|
-
url: websocketUrl,
|
|
175
|
-
}), checkLean4ProjectPreconditions, (docUri) => { return true; });
|
|
92
|
+
}, setupMonacoClient(this.getWebSocketOptions(options)), checkLean4ProjectPreconditions, (docUri) => { return true; });
|
|
176
93
|
this.taskGutter = new LeanTaskGutter(this.clientProvider, { asAbsolutePath: (path) => Uri.parse(`${new URL('monaco-lean4/vscode-lean4/' + path, import.meta.url)}`), });
|
|
177
94
|
if (!this.iframeWebviewFactory)
|
|
178
95
|
this.iframeWebviewFactory = new IFrameInfoWebviewFactory();
|
|
179
96
|
this.infoProvider = new InfoProvider(this.clientProvider, { language: 'lean4' }, {}, this.iframeWebviewFactory);
|
|
97
|
+
const fontFile = new FontFace("JuliaMono", `url(${new URL("./JuliaMono-Regular.ttf", import.meta.url)})`);
|
|
98
|
+
document.fonts.add(fontFile);
|
|
99
|
+
await fontFile.load();
|
|
100
|
+
if (this.disposed)
|
|
101
|
+
return;
|
|
180
102
|
this.ready();
|
|
181
103
|
}
|
|
182
104
|
setInfoviewElement(infoviewEl) {
|
|
@@ -184,6 +106,121 @@ export class LeanMonaco {
|
|
|
184
106
|
this.iframeWebviewFactory = new IFrameInfoWebviewFactory();
|
|
185
107
|
this.iframeWebviewFactory.setInfoviewElement(infoviewEl);
|
|
186
108
|
}
|
|
109
|
+
getExtensionFiles() {
|
|
110
|
+
const extensionFiles = new Map();
|
|
111
|
+
extensionFiles.set('/language-configuration.json', new URL('./monaco-lean4/vscode-lean4/language-configuration.json', import.meta.url));
|
|
112
|
+
extensionFiles.set('/syntaxes/lean4.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/lean4.json', import.meta.url));
|
|
113
|
+
extensionFiles.set('/syntaxes/lean4-markdown.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/lean4-markdown.json', import.meta.url));
|
|
114
|
+
extensionFiles.set('/syntaxes/codeblock.json', new URL('./monaco-lean4/vscode-lean4/syntaxes/codeblock.json', import.meta.url));
|
|
115
|
+
extensionFiles.set('/themes/cobalt2.json', new URL('./themes/cobalt2.json', import.meta.url));
|
|
116
|
+
return extensionFiles;
|
|
117
|
+
}
|
|
118
|
+
getExtensionManifest(options) {
|
|
119
|
+
for (let o in options.vscode) {
|
|
120
|
+
if (packageJson.contributes.configuration.properties[o]) {
|
|
121
|
+
packageJson.contributes.configuration.properties[o].default = options.vscode[o];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
name: 'lean4web',
|
|
126
|
+
publisher: 'leanprover-community',
|
|
127
|
+
version: '1.0.0',
|
|
128
|
+
engines: {
|
|
129
|
+
vscode: '*'
|
|
130
|
+
},
|
|
131
|
+
"contributes": {
|
|
132
|
+
"configuration": packageJson.contributes.configuration,
|
|
133
|
+
"languages": [
|
|
134
|
+
{
|
|
135
|
+
"id": "lean4",
|
|
136
|
+
"configuration": "./language-configuration.json",
|
|
137
|
+
"extensions": [
|
|
138
|
+
".lean"
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"id": "lean4markdown",
|
|
143
|
+
"aliases": [],
|
|
144
|
+
"extensions": [
|
|
145
|
+
".lean4markdown"
|
|
146
|
+
],
|
|
147
|
+
"configuration": "./language-configuration.json"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"grammars": [
|
|
151
|
+
{
|
|
152
|
+
"language": "lean4",
|
|
153
|
+
"scopeName": "source.lean4",
|
|
154
|
+
"path": "./syntaxes/lean4.json"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"language": "lean4markdown",
|
|
158
|
+
"scopeName": "source.lean4.markdown",
|
|
159
|
+
"path": "./syntaxes/lean4-markdown.json"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"language": "lean4",
|
|
163
|
+
"scopeName": "markdown.lean4.codeblock",
|
|
164
|
+
"path": "./syntaxes/codeblock.json",
|
|
165
|
+
"injectTo": [
|
|
166
|
+
"text.html.markdown"
|
|
167
|
+
],
|
|
168
|
+
"embeddedLanguages": {
|
|
169
|
+
"meta.embedded.block.lean4": "lean4"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"configurationDefaults": {
|
|
174
|
+
"[lean4]": {
|
|
175
|
+
"editor.folding": false,
|
|
176
|
+
"editor.wordSeparators": "`~@$%^&*()-=+[{]}⟨⟩⦃⦄⟦⟧⟮⟯‹›\\|;:\",.<>/",
|
|
177
|
+
"editor.lineNumbers": 'on',
|
|
178
|
+
"editor.lineNumbersMinChars": 1,
|
|
179
|
+
"editor.glyphMargin": true,
|
|
180
|
+
"editor.lineDecorationsWidth": 5,
|
|
181
|
+
"editor.tabSize": 2,
|
|
182
|
+
"editor.detectIndentation": false,
|
|
183
|
+
"editor.lightbulb.enabled": "on",
|
|
184
|
+
"editor.unicodeHighlight.ambiguousCharacters": false,
|
|
185
|
+
"editor.minimap.enabled": false,
|
|
186
|
+
"editor.semanticHighlighting.enabled": true,
|
|
187
|
+
"editor.wordWrap": "off",
|
|
188
|
+
"editor.acceptSuggestionOnEnter": "off",
|
|
189
|
+
"editor.fontFamily": "JuliaMono",
|
|
190
|
+
"editor.wrappingStrategy": "advanced",
|
|
191
|
+
"editor.theme": "Visual Studio Light", //"Cobalt" // "Visual Studio Light" //"Visual Studio Dark" //"Default Light Modern" //"Default Light+" //"Default Dark+" //"Default High Contrast"
|
|
192
|
+
...options.vscode
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"themes": [
|
|
196
|
+
{
|
|
197
|
+
"id": "Cobalt",
|
|
198
|
+
"label": "Cobalt",
|
|
199
|
+
"uiTheme": "vs",
|
|
200
|
+
"path": "./themes/cobalt2.json"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
getWebSocketOptions(options) {
|
|
207
|
+
return {
|
|
208
|
+
$type: 'WebSocketUrl',
|
|
209
|
+
startOptions: {
|
|
210
|
+
onCall: () => {
|
|
211
|
+
console.log('Connected to socket.');
|
|
212
|
+
},
|
|
213
|
+
reportStatus: true
|
|
214
|
+
},
|
|
215
|
+
stopOptions: {
|
|
216
|
+
onCall: () => {
|
|
217
|
+
console.log('Disconnected from socket.');
|
|
218
|
+
},
|
|
219
|
+
reportStatus: true
|
|
220
|
+
},
|
|
221
|
+
...options.websocket
|
|
222
|
+
};
|
|
223
|
+
}
|
|
187
224
|
dispose() {
|
|
188
225
|
if (LeanMonaco.activeInstance == this) {
|
|
189
226
|
LeanMonaco.activeInstance = null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AbbreviationProvider } from '@leanprover/unicode-input';
|
|
2
2
|
import { OutputChannel } from 'vscode';
|
|
3
|
+
import { SelectionMoveMode } from '@leanprover/unicode-input';
|
|
3
4
|
export declare class AbbreviationFeature {
|
|
4
5
|
private readonly disposables;
|
|
5
6
|
readonly abbreviations: AbbreviationProvider;
|
|
6
|
-
constructor(outputChannel: OutputChannel);
|
|
7
|
+
constructor(outputChannel: OutputChannel, selectionMoveMove?: SelectionMoveMode);
|
|
7
8
|
dispose(): void;
|
|
8
9
|
}
|
|
@@ -6,11 +6,11 @@ import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig';
|
|
|
6
6
|
export class AbbreviationFeature {
|
|
7
7
|
disposables = new Array();
|
|
8
8
|
abbreviations;
|
|
9
|
-
constructor(outputChannel) {
|
|
9
|
+
constructor(outputChannel, selectionMoveMove) {
|
|
10
10
|
const config = new VSCodeAbbreviationConfig();
|
|
11
11
|
this.disposables.push(config);
|
|
12
12
|
this.abbreviations = new AbbreviationProvider(config);
|
|
13
|
-
this.disposables.push(languages.registerHoverProvider(config.languages, new AbbreviationHoverProvider(config, this.abbreviations)), new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel));
|
|
13
|
+
this.disposables.push(languages.registerHoverProvider(config.languages, new AbbreviationHoverProvider(config, this.abbreviations)), new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel, selectionMoveMove));
|
|
14
14
|
}
|
|
15
15
|
dispose() {
|
|
16
16
|
for (const d of this.disposables) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbbreviationProvider } from '@leanprover/unicode-input';
|
|
1
|
+
import { AbbreviationProvider, SelectionMoveMode } from '@leanprover/unicode-input';
|
|
2
2
|
import { OutputChannel } from 'vscode';
|
|
3
3
|
import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig';
|
|
4
4
|
/**
|
|
@@ -9,9 +9,10 @@ export declare class AbbreviationRewriterFeature {
|
|
|
9
9
|
private readonly config;
|
|
10
10
|
private readonly abbreviationProvider;
|
|
11
11
|
private readonly outputChannel;
|
|
12
|
+
private readonly selectionMoveMove?;
|
|
12
13
|
private readonly disposables;
|
|
13
14
|
private activeAbbreviationRewriter;
|
|
14
|
-
constructor(config: VSCodeAbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel);
|
|
15
|
+
constructor(config: VSCodeAbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel, selectionMoveMove?: SelectionMoveMode | undefined);
|
|
15
16
|
private disposeActiveAbbreviationRewriter;
|
|
16
17
|
private changedActiveTextEditor;
|
|
17
18
|
private shouldEnableRewriterForEditor;
|
|
@@ -9,12 +9,14 @@ export class AbbreviationRewriterFeature {
|
|
|
9
9
|
config;
|
|
10
10
|
abbreviationProvider;
|
|
11
11
|
outputChannel;
|
|
12
|
+
selectionMoveMove;
|
|
12
13
|
disposables = new Array();
|
|
13
14
|
activeAbbreviationRewriter;
|
|
14
|
-
constructor(config, abbreviationProvider, outputChannel) {
|
|
15
|
+
constructor(config, abbreviationProvider, outputChannel, selectionMoveMove) {
|
|
15
16
|
this.config = config;
|
|
16
17
|
this.abbreviationProvider = abbreviationProvider;
|
|
17
18
|
this.outputChannel = outputChannel;
|
|
19
|
+
this.selectionMoveMove = selectionMoveMove;
|
|
18
20
|
void this.changedActiveTextEditor(window.activeTextEditor);
|
|
19
21
|
this.disposables.push(commands.registerTextEditorCommand('lean4.input.convert', async () => {
|
|
20
22
|
if (this.activeAbbreviationRewriter === undefined) {
|
|
@@ -33,7 +35,7 @@ export class AbbreviationRewriterFeature {
|
|
|
33
35
|
}
|
|
34
36
|
if (this.activeAbbreviationRewriter === undefined &&
|
|
35
37
|
this.shouldEnableRewriterForEditor(window.activeTextEditor)) {
|
|
36
|
-
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(config, abbreviationProvider, outputChannel, window.activeTextEditor);
|
|
38
|
+
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(config, abbreviationProvider, outputChannel, window.activeTextEditor, this.selectionMoveMove);
|
|
37
39
|
}
|
|
38
40
|
else if (this.activeAbbreviationRewriter !== undefined &&
|
|
39
41
|
!this.shouldEnableRewriterForEditor(window.activeTextEditor)) {
|
|
@@ -57,7 +59,7 @@ export class AbbreviationRewriterFeature {
|
|
|
57
59
|
if (!this.shouldEnableRewriterForEditor(activeTextEditor)) {
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
|
-
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(this.config, this.abbreviationProvider, this.outputChannel, activeTextEditor);
|
|
62
|
+
this.activeAbbreviationRewriter = new VSCodeAbbreviationRewriter(this.config, this.abbreviationProvider, this.outputChannel, activeTextEditor, this.selectionMoveMove);
|
|
61
63
|
}
|
|
62
64
|
shouldEnableRewriterForEditor(editor) {
|
|
63
65
|
if (!this.config.inputModeEnabled) {
|
|
@@ -8,13 +8,14 @@ export declare class VSCodeAbbreviationRewriter implements AbbreviationTextSourc
|
|
|
8
8
|
readonly abbreviationProvider: AbbreviationProvider;
|
|
9
9
|
private readonly outputChannel;
|
|
10
10
|
private readonly textEditor;
|
|
11
|
+
private selectionMoveMoveOverride?;
|
|
11
12
|
private readonly disposables;
|
|
12
13
|
private readonly rewriter;
|
|
13
14
|
private readonly decorationType;
|
|
14
15
|
private firstOutput;
|
|
15
16
|
private isVimExtensionInstalled;
|
|
16
17
|
private checkIsVimExtensionInstalled;
|
|
17
|
-
constructor(config: AbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel, textEditor: TextEditor);
|
|
18
|
+
constructor(config: AbbreviationConfig, abbreviationProvider: AbbreviationProvider, outputChannel: OutputChannel, textEditor: TextEditor, selectionMoveMoveOverride?: SelectionMoveMode | undefined);
|
|
18
19
|
private writeError;
|
|
19
20
|
selectionMoveMode(): SelectionMoveMode;
|
|
20
21
|
collectSelections(): Range[];
|
|
@@ -8,6 +8,7 @@ export class VSCodeAbbreviationRewriter {
|
|
|
8
8
|
abbreviationProvider;
|
|
9
9
|
outputChannel;
|
|
10
10
|
textEditor;
|
|
11
|
+
selectionMoveMoveOverride;
|
|
11
12
|
disposables = new Array();
|
|
12
13
|
rewriter;
|
|
13
14
|
decorationType = window.createTextEditorDecorationType({
|
|
@@ -18,11 +19,12 @@ export class VSCodeAbbreviationRewriter {
|
|
|
18
19
|
checkIsVimExtensionInstalled() {
|
|
19
20
|
this.isVimExtensionInstalled = extensions.getExtension('vscodevim.vim') !== undefined;
|
|
20
21
|
}
|
|
21
|
-
constructor(config, abbreviationProvider, outputChannel, textEditor) {
|
|
22
|
+
constructor(config, abbreviationProvider, outputChannel, textEditor, selectionMoveMoveOverride) {
|
|
22
23
|
this.config = config;
|
|
23
24
|
this.abbreviationProvider = abbreviationProvider;
|
|
24
25
|
this.outputChannel = outputChannel;
|
|
25
26
|
this.textEditor = textEditor;
|
|
27
|
+
this.selectionMoveMoveOverride = selectionMoveMoveOverride;
|
|
26
28
|
this.rewriter = new AbbreviationRewriter(config, abbreviationProvider, this);
|
|
27
29
|
this.disposables.push(this.decorationType);
|
|
28
30
|
this.disposables.push(workspace.onDidChangeTextDocument(async (e) => {
|
|
@@ -56,7 +58,7 @@ export class VSCodeAbbreviationRewriter {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
selectionMoveMode() {
|
|
59
|
-
return { kind: 'OnlyMoveCursorSelections', updateUnchangedSelections: this.isVimExtensionInstalled };
|
|
61
|
+
return this.selectionMoveMoveOverride ?? { kind: 'OnlyMoveCursorSelections', updateUnchangedSelections: this.isVimExtensionInstalled };
|
|
60
62
|
}
|
|
61
63
|
collectSelections() {
|
|
62
64
|
return this.textEditor.selections.map(s => fromVsCodeRange(s, this.textEditor.document));
|