Skip to content

Commit

Permalink
use workspace settings
Browse files Browse the repository at this point in the history
  • Loading branch information
abentkamp committed Jul 29, 2024
1 parent c73d58b commit 818b620
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
5 changes: 0 additions & 5 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,19 @@ describe('Editor Test', () => {
.should(($p) => {
expect(getComputedStyle($p.get(0)).getPropertyValue('--vscode-editor-background')).to.equal("#ffffff")
})
cy.wait(4000)
cy.get('[data-cy="theme-dark"]').click()
cy.wait(4000)
cy.contains('#check Nat')
.should(($p) => {
expect(getComputedStyle($p.get(0)).getPropertyValue('--vscode-editor-background')).to.equal("#1e1e1e")
})
})
it('inputs unicode', () => {

cy.visit('http://localhost:5173/')
cy.get('[data-cy="leader-backslash"]').click()
cy.contains('#check Nat').click("left")
cy.get('body').type('\\alpha')
cy.contains('α')
cy.wait(4000)
cy.get('[data-cy="leader-comma"]').click()
cy.wait(4000)
cy.contains('#check Nat').click("left")
cy.get('body').type(',beta')
cy.contains('β')
Expand Down
6 changes: 3 additions & 3 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import LeanMonacoComponent from './LeanMonaco'
import { LeanMonacoOptions } from 'lean4monaco'

function App() {
const [options, setOptions] = useState<LeanMonacoOptions>({websocket: {url: 'ws://localhost:8080/'}, vscode: {"editor.theme": "Visual Studio Light"}})
const [options, setOptions] = useState<LeanMonacoOptions>({websocket: {url: 'ws://localhost:8080/'}, vscode: {"workbench.colorTheme": "Visual Studio Light"}})

return (
<>
<button
onClick={() => {setOptions({...options, vscode: {...options.vscode, "editor.theme": "Visual Studio Light"}})}}
onClick={() => {setOptions({...options, vscode: {...options.vscode, "workbench.colorTheme": "Visual Studio Light"}})}}
data-cy="theme-light"
>Light</button>
<button
onClick={() => {setOptions({...options, vscode: {...options.vscode, "editor.theme": "Visual Studio Dark"}})}}
onClick={() => {setOptions({...options, vscode: {...options.vscode, "workbench.colorTheme": "Visual Studio Dark"}})}}
data-cy="theme-dark"
>Dark</button>
<button
Expand Down
2 changes: 1 addition & 1 deletion demo/src/LeanMonaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function LeanMonacoComponent({options} : {options: LeanMonacoOptions}) {
;(async () => {
await leanMonaco.start(options)
leanMonaco.setInfoviewElement(infoviewRef.current!)
await leanMonacoEditor.start(codeviewRef.current!, `/project/test${Math.random()}.lean`, '#check Nat', options.vscode!["editor.theme"]!)
await leanMonacoEditor.start(codeviewRef.current!, `/project/test${Math.random()}.lean`, '#check Nat')
})()

return () => {
Expand Down
2 changes: 1 addition & 1 deletion dev/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ leanMonaco.setInfoviewElement(document.getElementById('infoview')!)
leanMonaco.dispose()

leanMonaco = new LeanMonaco()
leanMonaco.start({websocket: {url: 'ws://localhost:8080/'}, vscode: {"editor.theme": "Cobalt"}})
leanMonaco.start({websocket: {url: 'ws://localhost:8080/'}, vscode: {"workbench.colorTheme": "Cobalt"}})
leanMonaco.setInfoviewElement(document.getElementById('infoview')!)

await leanMonaco.whenReady
Expand Down
15 changes: 7 additions & 8 deletions src/leanmonaco.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'vscode/localExtensionHost'
import { RegisterExtensionResult, WebSocketConfigOptionsUrl } from 'monaco-editor-wrapper';
import { LeanClientProvider } from './vscode-lean4/vscode-lean4/src/utils/clientProvider';
import { Uri } from 'vscode';
import { Uri, workspace } from 'vscode';
import { InfoProvider } from './vscode-lean4/vscode-lean4/src/infoview';
import { AbbreviationFeature } from './vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature';
import { LeanTaskGutter } from './vscode-lean4/vscode-lean4/src/taskgutter';
Expand Down Expand Up @@ -116,6 +116,8 @@ export class LeanMonaco {

if (this.disposed) return;

this.updateVSCodeOptions(options.vscode ?? {})

this.abbreviationFeature = new AbbreviationFeature({} as any, { kind: 'MoveAllSelections' });

this.clientProvider = new LeanClientProvider(
Expand Down Expand Up @@ -151,9 +153,9 @@ export class LeanMonaco {
}

updateVSCodeOptions(vsCodeOptions: { [id: string]: any }){
updateUserConfiguration(JSON.stringify({
"[lean4]": vsCodeOptions
}))
for (const key in vsCodeOptions) {
workspace.getConfiguration().update(key, vsCodeOptions[key])
}
}

setInfoviewElement(infoviewEl: HTMLElement){
Expand Down Expand Up @@ -222,7 +224,6 @@ export class LeanMonaco {
}
],
"configurationDefaults": {
"[lean4]": {
"editor.folding": false,
"editor.wordSeparators": "`~@$%^&*()-=+[{]}⟨⟩⦃⦄⟦⟧⟮⟯‹›\\|;:\",.<>/",
"editor.lineNumbers": 'on',
Expand All @@ -239,9 +240,7 @@ export class LeanMonaco {
"editor.acceptSuggestionOnEnter": "off",
"editor.fontFamily": "JuliaMono",
"editor.wrappingStrategy": "advanced",
"editor.theme": "Visual Studio Light", //"Cobalt" // "Visual Studio Light" //"Visual Studio Dark" //"Default Light Modern" //"Default Light+" //"Default Dark+" //"Default High Contrast"
}
},
},
"themes": [
{
"id": "Cobalt",
Expand Down

0 comments on commit 818b620

Please sign in to comment.