monaco-languageclient-examples 2025.8.3 → 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 +4 -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 +5 -6
- 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,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;
|
|
@@ -6,67 +6,83 @@
|
|
|
6
6
|
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
|
|
7
7
|
import { LogLevel } from '@codingame/monaco-vscode-api';
|
|
8
8
|
import { MessageTransports } from 'vscode-languageclient';
|
|
9
|
-
import type { Logger } from 'monaco-languageclient/
|
|
10
|
-
import {
|
|
11
|
-
import type {
|
|
12
|
-
import { defineDefaultWorkerLoaders } from 'monaco-
|
|
9
|
+
import type { Logger } from 'monaco-languageclient/common';
|
|
10
|
+
import type { MonacoVscodeApiConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
11
|
+
import type { LanguageClientConfig } from 'monaco-languageclient/lcwrapper';
|
|
12
|
+
import { defineDefaultWorkerLoaders, useWorkerFactory } from 'monaco-languageclient/workerFactory';
|
|
13
13
|
import { LangiumMonarchContent } from './langium.monarch.js';
|
|
14
14
|
import code from '../../../../resources/langium/langium-dsl/example.langium?raw';
|
|
15
|
+
import type { ExampleAppConfig } from '../../../common/client/utils.js';
|
|
16
|
+
import type { EditorAppConfig } from 'monaco-languageclient/editorApp';
|
|
15
17
|
|
|
16
|
-
export const setupLangiumClientClassic =
|
|
18
|
+
export const setupLangiumClientClassic = (params: {
|
|
17
19
|
worker: Worker
|
|
18
20
|
messageTransports?: MessageTransports,
|
|
19
|
-
}):
|
|
21
|
+
}): ExampleAppConfig => {
|
|
22
|
+
|
|
20
23
|
const workerLoaders = defineDefaultWorkerLoaders();
|
|
21
24
|
workerLoaders.TextMateWorker = undefined;
|
|
22
|
-
|
|
25
|
+
|
|
26
|
+
const vscodeApiConfig: MonacoVscodeApiConfig = {
|
|
23
27
|
$type: 'classic',
|
|
24
|
-
htmlContainer: document.getElementById('monaco-editor-root')!,
|
|
25
28
|
logLevel: LogLevel.Debug,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
29
|
+
htmlContainer: document.getElementById('monaco-editor-root')!,
|
|
30
|
+
serviceOverrides: {
|
|
31
|
+
...getKeybindingsServiceOverride()
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
userConfiguration: {
|
|
34
|
+
json: JSON.stringify({
|
|
35
|
+
'workbench.colorTheme': 'GitHub Dark High Contrast',
|
|
36
|
+
'editor.guides.bracketPairsHorizontal': 'active',
|
|
37
|
+
'editor.wordBasedSuggestions': 'off',
|
|
38
|
+
'editor.experimental.asyncTokenization': true,
|
|
39
|
+
'vitest.disableWorkspaceWarning': true
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
monacoWorkerFactory: (logger?: Logger) => {
|
|
43
|
+
useWorkerFactory({
|
|
44
|
+
workerLoaders,
|
|
45
|
+
logger
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const languageClientConfig: LanguageClientConfig = {
|
|
51
|
+
clientOptions: {
|
|
52
|
+
documentSelector: ['langium']
|
|
53
|
+
},
|
|
54
|
+
connection: {
|
|
55
|
+
options: {
|
|
56
|
+
$type: 'WorkerDirect',
|
|
57
|
+
worker: params.worker
|
|
47
58
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
messageTransports: params.messageTransports
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const editorAppConfig: EditorAppConfig = {
|
|
64
|
+
$type: vscodeApiConfig.$type,
|
|
65
|
+
codeResources: {
|
|
66
|
+
modified: {
|
|
67
|
+
text: code,
|
|
68
|
+
uri: '/workspace/grammar.langium',
|
|
69
|
+
enforceLanguageId: 'langium'
|
|
53
70
|
}
|
|
54
71
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
$type: 'WorkerDirect',
|
|
64
|
-
worker: params.worker
|
|
65
|
-
},
|
|
66
|
-
messageTransports: params.messageTransports
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
72
|
+
editorOptions: {
|
|
73
|
+
'semanticHighlighting.enabled': true,
|
|
74
|
+
wordBasedSuggestions: 'off',
|
|
75
|
+
theme: 'vs-dark'
|
|
76
|
+
},
|
|
77
|
+
languageDef: {
|
|
78
|
+
monarchLanguage: LangiumMonarchContent,
|
|
79
|
+
languageExtensionConfig: { id: 'langium' }
|
|
70
80
|
}
|
|
71
81
|
};
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
editorAppConfig,
|
|
85
|
+
vscodeApiConfig,
|
|
86
|
+
languageClientConfig
|
|
87
|
+
};
|
|
72
88
|
};
|