Skip to content

Commit 13e026a

Browse files
committed
cleanup getExtensionManifest
1 parent 41a9b1d commit 13e026a

File tree

1 file changed

+41
-73
lines changed

1 file changed

+41
-73
lines changed

Diff for: src/leanmonaco.ts

+41-73
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import getModelServiceOverride from '@codingame/monaco-vscode-model-service-over
1717
import { ExtensionHostKind, IExtensionManifest, registerExtension } from 'vscode/extensions'
1818
import { DisposableStore } from 'vscode/monaco'
1919
import packageJson from './vscode-lean4/vscode-lean4/package.json'
20+
import { IConfiguration, IGrammar } from 'vscode/vscode/vs/platform/extensions/common/extensions'
21+
import { ExtensionKind } from 'vscode/vscode/vs/platform/environment/common/environment'
2022

2123
/** Options for LeanMonaco.
2224
*
@@ -37,7 +39,7 @@ export type LeanMonacoOptions = {
3739
}
3840

3941

40-
export class LeanMonaco {
42+
export class LeanMonaco {
4143
private ready: (value: void | PromiseLike<void>) => void
4244
whenReady = new Promise<void>((resolve) => {
4345
this.ready = resolve
@@ -184,84 +186,50 @@ export class LeanMonaco {
184186
return extensionFiles
185187
}
186188

189+
/** This basically returns the `package.json` of `vscode-lean4` with some ts-fixes,
190+
* some lean4monaco-specific default options for the editor, and the custom themes.
191+
*/
187192
protected getExtensionManifest(): IExtensionManifest {
188193
return {
189-
name: 'lean4web',
190-
publisher: 'leanprover-community',
191-
version: '1.0.0',
192-
engines: {
193-
vscode: '*'
194-
},
195-
"contributes": {
196-
"configuration": packageJson.contributes.configuration as any,
197-
"languages": [
198-
{
199-
"id": "lean4",
200-
"configuration": "./language-configuration.json",
201-
"extensions": [
202-
".lean"
203-
],
204-
},
205-
{
206-
"id": "lean4markdown",
207-
"aliases": [],
208-
"extensions": [
209-
".lean4markdown"
210-
],
211-
"configuration": "./language-configuration.json"
212-
}
213-
],
214-
colors: packageJson.contributes.colors as any,
215-
"grammars": [
216-
{
217-
"language": "lean4",
218-
"scopeName": "source.lean4",
219-
"path": "./syntaxes/lean4.json"
220-
},
221-
{
222-
"language": "lean4markdown",
223-
"scopeName": "source.lean4.markdown",
224-
"path": "./syntaxes/lean4-markdown.json"
225-
},
194+
...packageJson,
195+
contributes: {
196+
...packageJson.contributes,
197+
configuration: packageJson.contributes.configuration as IConfiguration,
198+
// TODO: This is suspect, the thrid entry does not have "language", yet it doesn't complain
199+
// look into that.
200+
grammars: packageJson.contributes.grammars as IGrammar[],
201+
// Somehow `submenu` is incompatible. Since we don't use that anyways we just drop
202+
// `menus` and `submenus` from the package.json
203+
menus: undefined,
204+
submenus: undefined,
205+
configurationDefaults: {
206+
...packageJson.contributes.configurationDefaults,
207+
// Tweak the default VSCode settings here.
208+
"editor.minimap.enabled": false,
209+
// "editor.folding": false,
210+
// "editor.lineNumbers": 'on',
211+
// "editor.lineNumbersMinChars": 1,
212+
"editor.glyphMargin": true,
213+
// "editor.lineDecorationsWidth": 5,
214+
// "editor.detectIndentation": false,
215+
"editor.lightbulb.enabled": "on",
216+
"editor.semanticHighlighting.enabled": true,
217+
"editor.wordWrap": "on",
218+
"editor.wrappingStrategy": "advanced",
219+
"editor.acceptSuggestionOnEnter": "off",
220+
"editor.fontFamily": "JuliaMono",
221+
},
222+
// Add custom themes here.
223+
themes: [
226224
{
227-
"language": "lean4",
228-
"scopeName": "markdown.lean4.codeblock",
229-
"path": "./syntaxes/codeblock.json",
230-
"injectTo": [
231-
"text.html.markdown"
232-
],
233-
"embeddedLanguages": {
234-
"meta.embedded.block.lean4": "lean4"
235-
}
225+
"id": "Cobalt",
226+
"label": "Cobalt",
227+
"uiTheme": "vs",
228+
"path": "./themes/cobalt2.json"
236229
}
237230
],
238-
"configurationDefaults": {
239-
"editor.folding": false,
240-
"editor.wordSeparators": "`~@$%^&*()-=+[{]}⟨⟩⦃⦄⟦⟧⟮⟯‹›\\|;:\",.<>/",
241-
"editor.lineNumbers": 'on',
242-
"editor.lineNumbersMinChars": 1,
243-
"editor.glyphMargin": true,
244-
"editor.lineDecorationsWidth": 5,
245-
"editor.tabSize": 2,
246-
"editor.detectIndentation": false,
247-
"editor.lightbulb.enabled": "on",
248-
"editor.unicodeHighlight.ambiguousCharacters": false,
249-
"editor.minimap.enabled": false,
250-
"editor.semanticHighlighting.enabled": true,
251-
"editor.wordWrap": "off",
252-
"editor.acceptSuggestionOnEnter": "off",
253-
"editor.fontFamily": "JuliaMono",
254-
"editor.wrappingStrategy": "advanced",
255-
},
256-
"themes": [
257-
{
258-
"id": "Cobalt",
259-
"label": "Cobalt",
260-
"uiTheme": "vs",
261-
"path": "./themes/cobalt2.json"
262-
}
263-
],
264231
},
232+
extensionKind: packageJson.extensionKind as ExtensionKind[],
265233
}
266234
}
267235

0 commit comments

Comments
 (0)