monaco-languageclient-examples 2025.8.2 → 2025.8.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.
- package/CHANGELOG.md +9 -0
- package/dist/appPlayground/common.d.ts +2 -2
- package/dist/appPlayground/common.d.ts.map +1 -1
- package/dist/appPlayground/common.js +2 -3
- package/dist/appPlayground/common.js.map +1 -1
- package/dist/appPlayground/config.d.ts +4 -2
- package/dist/appPlayground/config.d.ts.map +1 -1
- package/dist/appPlayground/config.js +65 -63
- package/dist/appPlayground/config.js.map +1 -1
- package/dist/appPlayground/launcher.js +1 -1
- package/dist/appPlayground/launcher.js.map +1 -1
- package/dist/appPlayground/main.d.ts.map +1 -1
- package/dist/appPlayground/main.js +5 -4
- package/dist/appPlayground/main.js.map +1 -1
- package/dist/appPlayground/reactLauncher.js +1 -1
- package/dist/appPlayground/reactLauncher.js.map +1 -1
- package/dist/appPlayground/reactMain.d.ts.map +1 -1
- package/dist/appPlayground/reactMain.js +2 -3
- package/dist/appPlayground/reactMain.js.map +1 -1
- package/dist/bare/client.d.ts.map +1 -1
- package/dist/bare/client.js +12 -15
- package/dist/bare/client.js.map +1 -1
- package/dist/browser/main.d.ts.map +1 -1
- package/dist/browser/main.js +28 -27
- package/dist/browser/main.js.map +1 -1
- package/dist/clangd/client/config.d.ts +10 -3
- package/dist/clangd/client/config.d.ts.map +1 -1
- package/dist/clangd/client/config.js +85 -85
- package/dist/clangd/client/config.js.map +1 -1
- package/dist/clangd/client/main.d.ts.map +1 -1
- package/dist/clangd/client/main.js +12 -9
- package/dist/clangd/client/main.js.map +1 -1
- package/dist/common/client/extendedClient.d.ts +9 -0
- package/dist/common/client/extendedClient.d.ts.map +1 -0
- package/dist/common/client/extendedClient.js +97 -0
- package/dist/common/client/extendedClient.js.map +1 -0
- package/dist/common/client/utils.d.ts +8 -1
- package/dist/common/client/utils.d.ts.map +1 -1
- package/dist/common/client/utils.js +0 -3
- package/dist/common/client/utils.js.map +1 -1
- package/dist/debugger/client/debugger.d.ts +1 -1
- package/dist/debugger/client/debugger.d.ts.map +1 -1
- package/dist/eclipse.jdt.ls/client/main.d.ts +1 -1
- package/dist/eclipse.jdt.ls/client/main.d.ts.map +1 -1
- package/dist/eclipse.jdt.ls/client/main.js +4 -74
- package/dist/eclipse.jdt.ls/client/main.js.map +1 -1
- package/dist/eclipse.jdt.ls/config.d.ts +2 -5
- package/dist/eclipse.jdt.ls/config.d.ts.map +1 -1
- package/dist/eclipse.jdt.ls/config.js +2 -1
- package/dist/eclipse.jdt.ls/config.js.map +1 -1
- package/dist/groovy/client/main.d.ts +1 -1
- package/dist/groovy/client/main.d.ts.map +1 -1
- package/dist/groovy/client/main.js +4 -63
- package/dist/groovy/client/main.js.map +1 -1
- package/dist/groovy/config.d.ts +2 -5
- package/dist/groovy/config.d.ts.map +1 -1
- package/dist/groovy/config.js +2 -1
- package/dist/groovy/config.js.map +1 -1
- package/dist/json/client/client.d.ts +3 -0
- package/dist/json/client/client.d.ts.map +1 -0
- package/dist/json/client/client.js +13 -0
- package/dist/json/client/client.js.map +1 -0
- package/dist/json/client/config.d.ts +3 -0
- package/dist/json/client/config.d.ts.map +1 -0
- package/dist/json/client/config.js +11 -0
- package/dist/json/client/config.js.map +1 -0
- package/dist/json/server/main.js.map +1 -1
- package/dist/langium/langium-dsl/config/classicConfig.d.ts +2 -2
- package/dist/langium/langium-dsl/config/classicConfig.d.ts.map +1 -1
- package/dist/langium/langium-dsl/config/classicConfig.js +53 -45
- package/dist/langium/langium-dsl/config/classicConfig.js.map +1 -1
- package/dist/langium/langium-dsl/config/extendedConfig.d.ts +2 -2
- package/dist/langium/langium-dsl/config/extendedConfig.d.ts.map +1 -1
- package/dist/langium/langium-dsl/config/extendedConfig.js +40 -40
- package/dist/langium/langium-dsl/config/extendedConfig.js.map +1 -1
- package/dist/langium/langium-dsl/wrapperLangium.d.ts.map +1 -1
- package/dist/langium/langium-dsl/wrapperLangium.js +23 -16
- package/dist/langium/langium-dsl/wrapperLangium.js.map +1 -1
- package/dist/langium/statemachine/config/wrapperStatemachineConfig.d.ts +4 -4
- package/dist/langium/statemachine/config/wrapperStatemachineConfig.d.ts.map +1 -1
- package/dist/langium/statemachine/config/wrapperStatemachineConfig.js +40 -41
- package/dist/langium/statemachine/config/wrapperStatemachineConfig.js.map +1 -1
- package/dist/langium/statemachine/launcher.js +1 -1
- package/dist/langium/statemachine/launcher.js.map +1 -1
- package/dist/langium/statemachine/main-react.js +2 -3
- package/dist/langium/statemachine/main-react.js.map +1 -1
- package/dist/langium/statemachine/main.d.ts.map +1 -1
- package/dist/langium/statemachine/main.js +38 -27
- package/dist/langium/statemachine/main.js.map +1 -1
- package/dist/multi/config.d.ts +1 -1
- package/dist/multi/config.d.ts.map +1 -1
- package/dist/multi/config.js +0 -1
- package/dist/multi/config.js.map +1 -1
- package/dist/multi/twoLanguageClients.d.ts.map +1 -1
- package/dist/multi/twoLanguageClients.js +45 -49
- package/dist/multi/twoLanguageClients.js.map +1 -1
- package/dist/node.d.ts +0 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +0 -3
- package/dist/node.js.map +1 -1
- package/dist/python/client/config.d.ts +7 -3
- package/dist/python/client/config.d.ts.map +1 -1
- package/dist/python/client/config.js +93 -97
- package/dist/python/client/config.js.map +1 -1
- package/dist/python/client/main.d.ts.map +1 -1
- package/dist/python/client/main.js +16 -10
- package/dist/python/client/main.js.map +1 -1
- package/dist/python/client/reactPython.d.ts.map +1 -1
- package/dist/python/client/reactPython.js +8 -9
- package/dist/python/client/reactPython.js.map +1 -1
- package/dist/ts/wrapperTs.d.ts.map +1 -1
- package/dist/ts/wrapperTs.js +50 -45
- package/dist/ts/wrapperTs.js.map +1 -1
- package/json.html +1 -1
- package/package.json +39 -40
- package/src/appPlayground/common.ts +3 -3
- package/src/appPlayground/config.ts +69 -65
- package/src/appPlayground/launcher.ts +2 -1
- package/src/appPlayground/main.ts +8 -5
- package/src/appPlayground/reactLauncher.ts +2 -1
- package/src/appPlayground/reactMain.tsx +4 -4
- package/src/bare/client.ts +15 -16
- package/src/browser/main.ts +29 -27
- package/src/clangd/client/config.ts +97 -87
- package/src/clangd/client/main.ts +14 -10
- package/src/common/client/extendedClient.ts +111 -0
- package/src/common/client/utils.ts +7 -2
- package/src/debugger/client/debugger.ts +1 -1
- package/src/eclipse.jdt.ls/client/main.ts +4 -78
- package/src/eclipse.jdt.ls/config.ts +6 -2
- package/src/groovy/client/main.ts +4 -65
- package/src/groovy/config.ts +6 -2
- package/src/json/client/client.ts +14 -0
- package/src/json/client/config.ts +13 -0
- package/src/json/server/main.ts +1 -1
- package/src/langium/langium-dsl/config/classicConfig.ts +64 -48
- package/src/langium/langium-dsl/config/extendedConfig.ts +49 -42
- package/src/langium/langium-dsl/wrapperLangium.ts +25 -15
- package/src/langium/statemachine/config/wrapperStatemachineConfig.ts +48 -45
- package/src/langium/statemachine/launcher.ts +1 -1
- package/src/langium/statemachine/main-react.tsx +4 -4
- package/src/langium/statemachine/main.ts +43 -27
- package/src/multi/config.ts +3 -3
- package/src/multi/twoLanguageClients.ts +48 -52
- package/src/node.ts +0 -3
- package/src/python/client/config.ts +101 -99
- package/src/python/client/main.ts +20 -11
- package/src/python/client/reactPython.tsx +11 -10
- package/src/ts/wrapperTs.ts +52 -45
- package/two_langauge_clients.html +0 -1
- package/dist/json/client/wrapperWs.d.ts +0 -5
- package/dist/json/client/wrapperWs.d.ts.map +0 -1
- package/dist/json/client/wrapperWs.js +0 -87
- package/dist/json/client/wrapperWs.js.map +0 -1
- package/src/json/client/wrapperWs.ts +0 -90
|
@@ -3,113 +3,91 @@
|
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
7
|
+
import getEnvironmentServiceOverride from '@codingame/monaco-vscode-environment-service-override';
|
|
8
|
+
import getExplorerServiceOverride from '@codingame/monaco-vscode-explorer-service-override';
|
|
7
9
|
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
|
|
8
10
|
import getLifecycleServiceOverride from '@codingame/monaco-vscode-lifecycle-service-override';
|
|
11
|
+
import getRemoteAgentServiceOverride from '@codingame/monaco-vscode-remote-agent-service-override';
|
|
12
|
+
import getSecretStorageServiceOverride from '@codingame/monaco-vscode-secret-storage-service-override';
|
|
9
13
|
import getBannerServiceOverride from '@codingame/monaco-vscode-view-banner-service-override';
|
|
10
14
|
import getStatusBarServiceOverride from '@codingame/monaco-vscode-view-status-bar-service-override';
|
|
11
15
|
import getTitleBarServiceOverride from '@codingame/monaco-vscode-view-title-bar-service-override';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import type { WrapperConfig } from 'monaco-editor-wrapper';
|
|
18
|
-
import { configureDefaultWorkerFactory } from 'monaco-editor-wrapper/workers/workerLoaders';
|
|
19
|
-
import { defaultHtmlAugmentationInstructions, defaultViewsInit } from 'monaco-editor-wrapper/vscode/services';
|
|
16
|
+
import type { EditorAppConfig } from 'monaco-languageclient/editorApp';
|
|
17
|
+
import type { LanguageClientConfig } from 'monaco-languageclient/lcwrapper';
|
|
18
|
+
import { defaultHtmlAugmentationInstructions, defaultViewsInit, type MonacoVscodeApiConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
19
|
+
import { configureDefaultWorkerFactory } from 'monaco-languageclient/workerFactory';
|
|
20
|
+
import { Uri } from 'vscode';
|
|
20
21
|
import { ClangdWorkerHandler } from './workerHandler.js';
|
|
21
22
|
|
|
22
|
-
export
|
|
23
|
+
export type ClangdAppConfig = {
|
|
24
|
+
languageClientConfig: LanguageClientConfig;
|
|
25
|
+
vscodeApiConfig: MonacoVscodeApiConfig;
|
|
26
|
+
editorAppConfig: EditorAppConfig;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const createClangdAppConfig = async (config: {
|
|
23
30
|
htmlContainer: HTMLElement,
|
|
24
31
|
workspaceUri: Uri,
|
|
25
32
|
workspaceFileUri: Uri,
|
|
26
33
|
clangdWorkerHandler: ClangdWorkerHandler,
|
|
27
34
|
lsMessageLocalPort: MessagePort
|
|
28
|
-
}): Promise<
|
|
29
|
-
|
|
35
|
+
}): Promise<ClangdAppConfig> => {
|
|
36
|
+
const vscodeApiConfig: MonacoVscodeApiConfig = {
|
|
30
37
|
$type: 'extended',
|
|
31
38
|
htmlContainer: config.htmlContainer,
|
|
32
39
|
logLevel: LogLevel.Debug,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
restartOptions: {
|
|
45
|
-
retries: 5,
|
|
46
|
-
timeout: 1000,
|
|
47
|
-
keepWorker: true
|
|
48
|
-
},
|
|
49
|
-
clientOptions: {
|
|
50
|
-
documentSelector: ['cpp'],
|
|
51
|
-
workspaceFolder: {
|
|
52
|
-
index: 0,
|
|
53
|
-
name: 'workspace',
|
|
54
|
-
uri: config.workspaceUri
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
40
|
+
serviceOverrides: {
|
|
41
|
+
...getKeybindingsServiceOverride(),
|
|
42
|
+
...getLifecycleServiceOverride(),
|
|
43
|
+
...getBannerServiceOverride(),
|
|
44
|
+
...getStatusBarServiceOverride(),
|
|
45
|
+
...getTitleBarServiceOverride(),
|
|
46
|
+
...getExplorerServiceOverride(),
|
|
47
|
+
...getRemoteAgentServiceOverride(),
|
|
48
|
+
...getEnvironmentServiceOverride(),
|
|
49
|
+
...getSecretStorageServiceOverride()
|
|
59
50
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
viewsConfig: {
|
|
73
|
-
viewServiceType: 'ViewsService',
|
|
74
|
-
htmlAugmentationInstructions: defaultHtmlAugmentationInstructions,
|
|
75
|
-
viewsInitFunc: defaultViewsInit
|
|
51
|
+
viewsConfig: {
|
|
52
|
+
viewServiceType: 'ViewsService',
|
|
53
|
+
htmlAugmentationInstructions: defaultHtmlAugmentationInstructions,
|
|
54
|
+
viewsInitFunc: defaultViewsInit
|
|
55
|
+
},
|
|
56
|
+
workspaceConfig: {
|
|
57
|
+
enableWorkspaceTrust: true,
|
|
58
|
+
windowIndicator: {
|
|
59
|
+
label: 'mlc-clangd-example',
|
|
60
|
+
tooltip: '',
|
|
61
|
+
command: ''
|
|
76
62
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
command: ''
|
|
83
|
-
},
|
|
84
|
-
workspaceProvider: {
|
|
85
|
-
trusted: true,
|
|
86
|
-
async open() {
|
|
87
|
-
window.open(window.location.href);
|
|
88
|
-
return true;
|
|
89
|
-
},
|
|
90
|
-
workspace: {
|
|
91
|
-
workspaceUri: config.workspaceFileUri
|
|
92
|
-
},
|
|
63
|
+
workspaceProvider: {
|
|
64
|
+
trusted: true,
|
|
65
|
+
async open() {
|
|
66
|
+
window.open(window.location.href);
|
|
67
|
+
return true;
|
|
93
68
|
},
|
|
94
|
-
|
|
95
|
-
|
|
69
|
+
workspace: {
|
|
70
|
+
workspaceUri: config.workspaceFileUri
|
|
96
71
|
},
|
|
97
|
-
productConfiguration: {
|
|
98
|
-
nameShort: 'mlc-clangd-example',
|
|
99
|
-
nameLong: 'mlc-clangd-example'
|
|
100
|
-
}
|
|
101
72
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'editor.quickSuggestionsDelay': 200,
|
|
109
|
-
'editor.experimental.asyncTokenization': false
|
|
110
|
-
})
|
|
73
|
+
configurationDefaults: {
|
|
74
|
+
'window.title': 'mlc-clangd-exampled${separator}${dirty}${activeEditorShort}'
|
|
75
|
+
},
|
|
76
|
+
productConfiguration: {
|
|
77
|
+
nameShort: 'mlc-clangd-example',
|
|
78
|
+
nameLong: 'mlc-clangd-example'
|
|
111
79
|
}
|
|
112
80
|
},
|
|
81
|
+
userConfiguration: {
|
|
82
|
+
json: JSON.stringify({
|
|
83
|
+
'workbench.colorTheme': 'Default Dark Modern',
|
|
84
|
+
'editor.wordBasedSuggestions': 'off',
|
|
85
|
+
'editor.guides.bracketPairsHorizontal': true,
|
|
86
|
+
'editor.inlayHints.enabled': 'offUnlessPressed',
|
|
87
|
+
'editor.quickSuggestionsDelay': 200,
|
|
88
|
+
'editor.experimental.asyncTokenization': false
|
|
89
|
+
})
|
|
90
|
+
},
|
|
113
91
|
extensions: [{
|
|
114
92
|
config: {
|
|
115
93
|
name: 'mlc-clangd-example',
|
|
@@ -120,8 +98,40 @@ export const createWrapperConfig = async (config: {
|
|
|
120
98
|
}
|
|
121
99
|
}
|
|
122
100
|
}],
|
|
123
|
-
|
|
124
|
-
|
|
101
|
+
monacoWorkerFactory: configureDefaultWorkerFactory
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const languageClientConfig: LanguageClientConfig = {
|
|
105
|
+
name: 'Clangd WASM Language Server',
|
|
106
|
+
connection: {
|
|
107
|
+
options: {
|
|
108
|
+
$type: 'WorkerDirect',
|
|
109
|
+
worker: await config.clangdWorkerHandler.createWorker(),
|
|
110
|
+
messagePort: config.lsMessageLocalPort
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
restartOptions: {
|
|
114
|
+
retries: 5,
|
|
115
|
+
timeout: 1000,
|
|
116
|
+
keepWorker: true
|
|
117
|
+
},
|
|
118
|
+
clientOptions: {
|
|
119
|
+
documentSelector: ['cpp'],
|
|
120
|
+
workspaceFolder: {
|
|
121
|
+
index: 0,
|
|
122
|
+
name: 'workspace',
|
|
123
|
+
uri: config.workspaceUri
|
|
124
|
+
}
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
+
|
|
128
|
+
const editorAppConfig: EditorAppConfig = {
|
|
129
|
+
$type: vscodeApiConfig.$type
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
vscodeApiConfig,
|
|
134
|
+
languageClientConfig,
|
|
135
|
+
editorAppConfig
|
|
136
|
+
};
|
|
127
137
|
};
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
|
-
import * as vscode from 'vscode';
|
|
7
6
|
import { RegisteredFileSystemProvider, RegisteredMemoryFile, registerFileSystemOverlay } from '@codingame/monaco-vscode-files-service-override';
|
|
7
|
+
import * as vscode from 'vscode';
|
|
8
8
|
// this is required syntax highlighting
|
|
9
9
|
import '@codingame/monaco-vscode-cpp-default-extension';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ClangdWorkerHandler } from './workerHandler.js';
|
|
13
|
-
import { MainRemoteMessageChannelFs } from './mainRemoteMessageChannelFs.js';
|
|
10
|
+
import { LanguageClientWrapper } from 'monaco-languageclient/lcwrapper';
|
|
11
|
+
import { MonacoVscodeApiWrapper } from 'monaco-languageclient/vscodeApiWrapper';
|
|
14
12
|
import { createDefaultWorkspaceContent, disableElement } from '../../common/client/utils.js';
|
|
15
13
|
import { HOME_DIR, WORKSPACE_PATH } from '../definitions.js';
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import { createClangdAppConfig } from './config.js';
|
|
15
|
+
import { MainRemoteMessageChannelFs } from './mainRemoteMessageChannelFs.js';
|
|
16
|
+
import { ClangdWorkerHandler } from './workerHandler.js';
|
|
18
17
|
|
|
19
18
|
export const runClangdWrapper = async () => {
|
|
20
19
|
const channelLs = new MessageChannel();
|
|
@@ -32,7 +31,7 @@ export const runClangdWrapper = async () => {
|
|
|
32
31
|
new MainRemoteMessageChannelFs(fileSystemProvider, channelFs.port1, readiness);
|
|
33
32
|
|
|
34
33
|
const clangdWorkerHandler = new ClangdWorkerHandler();
|
|
35
|
-
const
|
|
34
|
+
const appConfig = await createClangdAppConfig({
|
|
36
35
|
htmlContainer: document.body,
|
|
37
36
|
workspaceUri: vscode.Uri.file(WORKSPACE_PATH),
|
|
38
37
|
workspaceFileUri,
|
|
@@ -40,7 +39,12 @@ export const runClangdWrapper = async () => {
|
|
|
40
39
|
lsMessageLocalPort: channelLs.port1
|
|
41
40
|
});
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
// perform global init
|
|
43
|
+
const apiWrapper = new MonacoVscodeApiWrapper(appConfig.vscodeApiConfig);
|
|
44
|
+
await apiWrapper.init();
|
|
45
|
+
|
|
46
|
+
const lcWrapper = new LanguageClientWrapper(appConfig.languageClientConfig);
|
|
47
|
+
|
|
44
48
|
const initConfig = {
|
|
45
49
|
lsMessagePort: channelLs.port2,
|
|
46
50
|
fsMessagePort: channelFs.port2,
|
|
@@ -53,7 +57,7 @@ export const runClangdWrapper = async () => {
|
|
|
53
57
|
const startWrapper = async () => {
|
|
54
58
|
await clangdWorkerHandler.init(initConfig);
|
|
55
59
|
await clangdWorkerHandler.launch();
|
|
56
|
-
await
|
|
60
|
+
await lcWrapper.start();
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
try {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2025 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
import { RegisteredFileSystemProvider, RegisteredMemoryFile, registerFileSystemOverlay } from '@codingame/monaco-vscode-files-service-override';
|
|
7
|
+
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
|
|
8
|
+
import * as vscode from 'vscode';
|
|
9
|
+
// this is required syntax highlighting
|
|
10
|
+
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
11
|
+
import '@codingame/monaco-vscode-java-default-extension';
|
|
12
|
+
import { EditorApp, type EditorAppConfig } from 'monaco-languageclient/editorApp';
|
|
13
|
+
import { configureDefaultWorkerFactory } from 'monaco-languageclient/workerFactory';
|
|
14
|
+
import { LanguageClientWrapper, type LanguageClientConfig } from 'monaco-languageclient/lcwrapper';
|
|
15
|
+
import { MonacoVscodeApiWrapper, type MonacoVscodeApiConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
16
|
+
|
|
17
|
+
export const runExtendedClient = async (lsConfig: ExampleLsConfig, helloCode: string) => {
|
|
18
|
+
const helloUri = vscode.Uri.file(`${lsConfig.basePath}/workspace/hello.${lsConfig.documentSelector}`);
|
|
19
|
+
const fileSystemProvider = new RegisteredFileSystemProvider(false);
|
|
20
|
+
fileSystemProvider.registerFile(new RegisteredMemoryFile(helloUri, helloCode));
|
|
21
|
+
registerFileSystemOverlay(1, fileSystemProvider);
|
|
22
|
+
|
|
23
|
+
const htmlContainer = document.getElementById('monaco-editor-root')!;
|
|
24
|
+
const vscodeApiConfig: MonacoVscodeApiConfig = {
|
|
25
|
+
$type: 'extended',
|
|
26
|
+
htmlContainer,
|
|
27
|
+
logLevel: LogLevel.Debug,
|
|
28
|
+
serviceOverrides: {
|
|
29
|
+
...getKeybindingsServiceOverride(),
|
|
30
|
+
},
|
|
31
|
+
userConfiguration: {
|
|
32
|
+
json: JSON.stringify({
|
|
33
|
+
'workbench.colorTheme': 'Default Dark Modern',
|
|
34
|
+
'editor.guides.bracketPairsHorizontal': 'active',
|
|
35
|
+
'editor.lightbulb.enabled': 'On',
|
|
36
|
+
'editor.wordBasedSuggestions': 'off',
|
|
37
|
+
'editor.experimental.asyncTokenization': true
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
monacoWorkerFactory: configureDefaultWorkerFactory
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const languageClientConfig: LanguageClientConfig = {
|
|
44
|
+
connection: {
|
|
45
|
+
options: {
|
|
46
|
+
$type: 'WebSocketUrl',
|
|
47
|
+
url: `ws://localhost:${lsConfig.port}${lsConfig.path}`,
|
|
48
|
+
startOptions: {
|
|
49
|
+
onCall: () => {
|
|
50
|
+
console.log('Connected to socket.');
|
|
51
|
+
},
|
|
52
|
+
reportStatus: true
|
|
53
|
+
},
|
|
54
|
+
stopOptions: {
|
|
55
|
+
onCall: () => {
|
|
56
|
+
console.log('Disconnected from socket.');
|
|
57
|
+
},
|
|
58
|
+
reportStatus: true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
clientOptions: {
|
|
63
|
+
documentSelector: [lsConfig.documentSelector],
|
|
64
|
+
workspaceFolder: {
|
|
65
|
+
index: 0,
|
|
66
|
+
name: 'workspace',
|
|
67
|
+
uri: vscode.Uri.parse(`${lsConfig.basePath}/workspace`)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const editorAppConfig: EditorAppConfig = {
|
|
73
|
+
$type: vscodeApiConfig.$type,
|
|
74
|
+
codeResources: {
|
|
75
|
+
modified: {
|
|
76
|
+
text: helloCode,
|
|
77
|
+
uri: helloUri.path
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// perform global init
|
|
83
|
+
const apiWrapper = new MonacoVscodeApiWrapper(vscodeApiConfig);
|
|
84
|
+
await apiWrapper.init();
|
|
85
|
+
|
|
86
|
+
const lcWrapper = new LanguageClientWrapper(languageClientConfig, apiWrapper.getLogger());
|
|
87
|
+
const editorApp = new EditorApp(editorAppConfig);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
document.querySelector('#button-start')?.addEventListener('click', async () => {
|
|
91
|
+
await editorApp.start(htmlContainer);
|
|
92
|
+
await lcWrapper.start();
|
|
93
|
+
|
|
94
|
+
// open files, so the LS can pick it up
|
|
95
|
+
await vscode.workspace.openTextDocument(helloUri);
|
|
96
|
+
});
|
|
97
|
+
document.querySelector('#button-dispose')?.addEventListener('click', async () => {
|
|
98
|
+
await editorApp.dispose();
|
|
99
|
+
await lcWrapper.dispose();
|
|
100
|
+
});
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(e);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type ExampleLsConfig = {
|
|
107
|
+
port: number;
|
|
108
|
+
path: string;
|
|
109
|
+
basePath: string;
|
|
110
|
+
documentSelector: string;
|
|
111
|
+
};
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
6
|
import type { IStoredWorkspace } from '@codingame/monaco-vscode-configuration-service-override';
|
|
7
|
+
import type { EditorAppConfig } from 'monaco-languageclient/editorApp';
|
|
8
|
+
import type { LanguageClientConfig } from 'monaco-languageclient/lcwrapper';
|
|
9
|
+
import type { MonacoVscodeApiConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
7
10
|
|
|
8
11
|
export const disableElement = (id: string, disabled: boolean) => {
|
|
9
12
|
const button = document.getElementById(id) as HTMLButtonElement | HTMLInputElement | null;
|
|
@@ -26,6 +29,8 @@ export const createDefaultWorkspaceContent = (workspacePath: string) => {
|
|
|
26
29
|
);
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
export
|
|
30
|
-
|
|
32
|
+
export type ExampleAppConfig = {
|
|
33
|
+
vscodeApiConfig: MonacoVscodeApiConfig;
|
|
34
|
+
languageClientConfig: LanguageClientConfig;
|
|
35
|
+
editorAppConfig: EditorAppConfig;
|
|
31
36
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
6
|
import * as vscode from 'vscode';
|
|
7
|
-
import type { ExtensionConfig } from 'monaco-
|
|
7
|
+
import type { ExtensionConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
8
8
|
import type { ConfigParams, InitMessage } from '../common/definitions.js';
|
|
9
9
|
|
|
10
10
|
// This is derived from:
|
|
@@ -3,86 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
|
-
import * as vscode from 'vscode';
|
|
7
|
-
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
|
|
8
|
-
import { RegisteredFileSystemProvider, RegisteredMemoryFile, registerFileSystemOverlay } from '@codingame/monaco-vscode-files-service-override';
|
|
9
6
|
// this is required syntax highlighting
|
|
10
7
|
import '@codingame/monaco-vscode-java-default-extension';
|
|
11
|
-
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
12
|
-
import { MonacoEditorLanguageClientWrapper, type WrapperConfig } from 'monaco-editor-wrapper';
|
|
13
|
-
import { configureDefaultWorkerFactory } from 'monaco-editor-wrapper/workers/workerLoaders';
|
|
14
|
-
import { eclipseJdtLsConfig } from '../config.js';
|
|
15
8
|
import helloJavaCode from '../../../resources/eclipse.jdt.ls/workspace/hello.java?raw';
|
|
9
|
+
import { runExtendedClient } from '../../common/client/extendedClient.js';
|
|
10
|
+
import { eclipseJdtLsConfig } from '../config.js';
|
|
16
11
|
|
|
17
|
-
export const runEclipseJdtLsClient = () => {
|
|
18
|
-
|
|
19
|
-
const fileSystemProvider = new RegisteredFileSystemProvider(false);
|
|
20
|
-
fileSystemProvider.registerFile(new RegisteredMemoryFile(helloJavaUri, helloJavaCode));
|
|
21
|
-
registerFileSystemOverlay(1, fileSystemProvider);
|
|
22
|
-
|
|
23
|
-
const wrapperConfig: WrapperConfig = {
|
|
24
|
-
$type: 'extended',
|
|
25
|
-
htmlContainer: document.getElementById('monaco-editor-root')!,
|
|
26
|
-
logLevel: LogLevel.Debug,
|
|
27
|
-
vscodeApiConfig: {
|
|
28
|
-
serviceOverrides: {
|
|
29
|
-
...getKeybindingsServiceOverride(),
|
|
30
|
-
},
|
|
31
|
-
userConfiguration: {
|
|
32
|
-
json: JSON.stringify({
|
|
33
|
-
'workbench.colorTheme': 'Default Dark Modern',
|
|
34
|
-
'editor.guides.bracketPairsHorizontal': 'active',
|
|
35
|
-
'editor.wordBasedSuggestions': 'off',
|
|
36
|
-
'editor.experimental.asyncTokenization': true
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
editorAppConfig: {
|
|
41
|
-
codeResources: {
|
|
42
|
-
modified: {
|
|
43
|
-
text: helloJavaCode,
|
|
44
|
-
uri: `${eclipseJdtLsConfig.basePath}/workspace/hello.java`
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
monacoWorkerFactory: configureDefaultWorkerFactory
|
|
48
|
-
},
|
|
49
|
-
languageClientConfigs: {
|
|
50
|
-
configs: {
|
|
51
|
-
java: {
|
|
52
|
-
connection: {
|
|
53
|
-
options: {
|
|
54
|
-
$type: 'WebSocketUrl',
|
|
55
|
-
url: 'ws://localhost:30003/jdtls'
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
clientOptions: {
|
|
59
|
-
documentSelector: ['java'],
|
|
60
|
-
workspaceFolder: {
|
|
61
|
-
index: 0,
|
|
62
|
-
name: 'workspace',
|
|
63
|
-
uri: vscode.Uri.parse(`${eclipseJdtLsConfig.basePath}/workspace`)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const wrapper = new MonacoEditorLanguageClientWrapper();
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
document.querySelector('#button-start')?.addEventListener('click', async () => {
|
|
75
|
-
await wrapper.init(wrapperConfig);
|
|
76
|
-
|
|
77
|
-
// open files, so the LS can pick it up
|
|
78
|
-
await vscode.workspace.openTextDocument(helloJavaUri);
|
|
79
|
-
|
|
80
|
-
await wrapper.start();
|
|
81
|
-
});
|
|
82
|
-
document.querySelector('#button-dispose')?.addEventListener('click', async () => {
|
|
83
|
-
await wrapper.dispose();
|
|
84
|
-
});
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.error(e);
|
|
87
|
-
}
|
|
12
|
+
export const runEclipseJdtLsClient = async () => {
|
|
13
|
+
await runExtendedClient(eclipseJdtLsConfig, helloJavaCode);
|
|
88
14
|
};
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2024 TypeFox and others.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import type { ExampleLsConfig } from '../common/client/extendedClient.js';
|
|
7
|
+
|
|
8
|
+
export const eclipseJdtLsConfig: ExampleLsConfig = {
|
|
6
9
|
port: 30003,
|
|
7
10
|
path: '/jdtls',
|
|
8
|
-
basePath: '/home/mlc/packages/examples/resources/eclipse.jdt.ls'
|
|
11
|
+
basePath: '/home/mlc/packages/examples/resources/eclipse.jdt.ls',
|
|
12
|
+
documentSelector: 'java'
|
|
9
13
|
};
|
|
@@ -3,73 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
5
|
|
|
6
|
-
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
|
|
7
6
|
// this is required syntax highlighting
|
|
8
7
|
import '@codingame/monaco-vscode-groovy-default-extension';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { configureDefaultWorkerFactory } from 'monaco-editor-wrapper/workers/workerLoaders';
|
|
8
|
+
import helloGroovyCode from '../../../resources/groovy/workspace/hello.groovy?raw';
|
|
9
|
+
import { runExtendedClient } from '../../common/client/extendedClient.js';
|
|
12
10
|
import { groovyConfig } from '../config.js';
|
|
13
11
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
File file = new File("E:/Example.txt");
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
const wrapperConfig: WrapperConfig = {
|
|
20
|
-
$type: 'extended',
|
|
21
|
-
htmlContainer: document.getElementById('monaco-editor-root')!,
|
|
22
|
-
logLevel: LogLevel.Debug,
|
|
23
|
-
vscodeApiConfig: {
|
|
24
|
-
serviceOverrides: {
|
|
25
|
-
...getKeybindingsServiceOverride(),
|
|
26
|
-
},
|
|
27
|
-
userConfiguration: {
|
|
28
|
-
json: JSON.stringify({
|
|
29
|
-
'workbench.colorTheme': 'Default Dark Modern',
|
|
30
|
-
'editor.guides.bracketPairsHorizontal': 'active',
|
|
31
|
-
'editor.wordBasedSuggestions': 'off',
|
|
32
|
-
'editor.experimental.asyncTokenization': true
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
editorAppConfig: {
|
|
37
|
-
codeResources: {
|
|
38
|
-
modified: {
|
|
39
|
-
text: code,
|
|
40
|
-
uri: '/workspace/test.groovy'
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
monacoWorkerFactory: configureDefaultWorkerFactory
|
|
44
|
-
},
|
|
45
|
-
languageClientConfigs: {
|
|
46
|
-
configs: {
|
|
47
|
-
groovy: {
|
|
48
|
-
clientOptions: {
|
|
49
|
-
documentSelector: ['groovy']
|
|
50
|
-
},
|
|
51
|
-
connection: {
|
|
52
|
-
options: {
|
|
53
|
-
$type: 'WebSocketUrl',
|
|
54
|
-
url: `ws://localhost:${groovyConfig.port}${groovyConfig.path}`
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const runGroovyClient = () => {
|
|
63
|
-
const wrapper = new MonacoEditorLanguageClientWrapper();
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
document.querySelector('#button-start')?.addEventListener('click', async () => {
|
|
67
|
-
await wrapper.initAndStart(wrapperConfig);
|
|
68
|
-
});
|
|
69
|
-
document.querySelector('#button-dispose')?.addEventListener('click', async () => {
|
|
70
|
-
await wrapper.dispose();
|
|
71
|
-
});
|
|
72
|
-
} catch (e) {
|
|
73
|
-
console.error(e);
|
|
74
|
-
}
|
|
12
|
+
export const runGroovyClient = async () => {
|
|
13
|
+
await runExtendedClient(groovyConfig, helloGroovyCode);
|
|
75
14
|
};
|
package/src/groovy/config.ts
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2024 TypeFox and others.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
4
|
* ------------------------------------------------------------------------------------------ */
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import type { ExampleLsConfig } from '../common/client/extendedClient.js';
|
|
7
|
+
|
|
8
|
+
export const groovyConfig: ExampleLsConfig = {
|
|
6
9
|
port: 30002,
|
|
7
10
|
path: '/groovy',
|
|
8
|
-
basePath: '/home/gradle/mlc/packages/examples/resources/groovy'
|
|
11
|
+
basePath: '/home/gradle/mlc/packages/examples/resources/groovy',
|
|
12
|
+
documentSelector: 'groovy'
|
|
9
13
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2025 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
// this is required syntax highlighting
|
|
7
|
+
import '@codingame/monaco-vscode-json-default-extension';
|
|
8
|
+
import helloJsonCode from '../../../resources/json/workspace/hello.json?raw';
|
|
9
|
+
import { runExtendedClient } from '../../common/client/extendedClient.js';
|
|
10
|
+
import { jsontLsConfig } from './config.js';
|
|
11
|
+
|
|
12
|
+
export const runJsonWrapper = async () => {
|
|
13
|
+
await runExtendedClient(jsontLsConfig, helloJsonCode);
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* --------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2025 TypeFox and others.
|
|
3
|
+
* Licensed under the MIT License. See LICENSE in the package root for license information.
|
|
4
|
+
* ------------------------------------------------------------------------------------------ */
|
|
5
|
+
|
|
6
|
+
import type { ExampleLsConfig } from '../../common/client/extendedClient.js';
|
|
7
|
+
|
|
8
|
+
export const jsontLsConfig: ExampleLsConfig = {
|
|
9
|
+
port: 30000,
|
|
10
|
+
path: '/sampleServer',
|
|
11
|
+
basePath: '/home/mlc/packages/examples/resources/json',
|
|
12
|
+
documentSelector: 'json'
|
|
13
|
+
};
|
package/src/json/server/main.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const startMockHttpServerForSavingCodeFromEditor = () => {
|
|
|
36
36
|
app.post('/save-code', (req, res) => {
|
|
37
37
|
const { code } = req.body;
|
|
38
38
|
console.log('Received code:', code);
|
|
39
|
-
res.json({ success: true, message: code});
|
|
39
|
+
res.json({ success: true, message: code });
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
const PORT = 3003;
|