Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monaco-languageclient config improvement, wrapper+languageclientwrapper improvements #741

Merged
merged 7 commits into from
Sep 23, 2024
28 changes: 15 additions & 13 deletions packages/examples/src/eclipse.jdt.ls/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ export const runEclipseJdtLsClient = () => {
}
}
},
languageClientConfig: {
languageId: 'java',
options: {
$type: 'WebSocketUrl',
url: 'ws://localhost:30003/jdtls'
},
clientOptions: {
documentSelector: ['java'],
workspaceFolder: {
index: 0,
name: 'workspace',
uri: vscode.Uri.parse(`${eclipseJdtLsConfig.basePath}/workspace`)
languageClientConfigs: {
java: {
languageId: 'java',
options: {
$type: 'WebSocketUrl',
url: 'ws://localhost:30003/jdtls'
},
},
clientOptions: {
documentSelector: ['java'],
workspaceFolder: {
index: 0,
name: 'workspace',
uri: vscode.Uri.parse(`${eclipseJdtLsConfig.basePath}/workspace`)
}
}
}
}
};

Expand Down
12 changes: 7 additions & 5 deletions packages/examples/src/groovy/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ const userConfig: UserConfig = {
}
}
},
languageClientConfig: {
languageId: 'groovy',
options: {
$type: 'WebSocketUrl',
url: `ws://localhost:${groovyConfig.port}${groovyConfig.path}`
languageClientConfigs: {
groovy: {
languageId: 'groovy',
options: {
$type: 'WebSocketUrl',
url: `ws://localhost:${groovyConfig.port}${groovyConfig.path}`
}
}
}
};
Expand Down
32 changes: 17 additions & 15 deletions packages/examples/src/json/client/wrapperWs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@ export const jsonClientUserConfig: UserConfig = {
}
}
},
languageClientConfig: {
languageId: 'json',
options: {
$type: 'WebSocketUrl',
url: 'ws://localhost:30000/sampleServer',
startOptions: {
onCall: () => {
console.log('Connected to socket.');
languageClientConfigs: {
json: {
languageId: 'json',
options: {
$type: 'WebSocketUrl',
url: 'ws://localhost:30000/sampleServer',
startOptions: {
onCall: () => {
console.log('Connected to socket.');
},
reportStatus: true
},
reportStatus: true
},
stopOptions: {
onCall: () => {
console.log('Disconnected from socket.');
},
reportStatus: true
stopOptions: {
onCall: () => {
console.log('Disconnected from socket.');
},
reportStatus: true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export const setupLangiumClientClassic = async (): Promise<UserConfig> => {
}
}
},
languageClientConfig: {
languageId: 'langium',
options: {
$type: 'WorkerDirect',
worker: langiumWorker
languageClientConfigs: {
langium: {
languageId: 'langium',
options: {
$type: 'WorkerDirect',
worker: langiumWorker
}
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ export const setupLangiumClientExtended = async (): Promise<UserConfig> => {
}
}
},
languageClientConfig: {
languageId: 'langium',
options: {
$type: 'WorkerDirect',
worker: langiumWorker
},
connectionProvider: {
get: async () => ({ reader, writer })
languageClientConfigs: {
langium: {
languageId: 'langium',
options: {
$type: 'WorkerDirect',
worker: langiumWorker
},
connectionProvider: {
get: async () => ({ reader, writer })
}
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ export const createLangiumGlobalConfig = async (params: {
};
}

const languageClientConfig: LanguageClientConfig | undefined = params.useLanguageClient && params.worker ? {
languageId: 'statemachine',
options: {
$type: 'WorkerDirect',
worker: params.worker,
messagePort: params.messagePort,
},
connectionProvider: params.connectionProvider
const languageClientConfigs: Record<string, LanguageClientConfig> | undefined = params.useLanguageClient && params.worker ? {
statemachine: {
languageId: 'statemachine',
options: {
$type: 'WorkerDirect',
worker: params.worker,
messagePort: params.messagePort,
},
connectionProvider: params.connectionProvider
}
} : undefined;

return {
Expand Down Expand Up @@ -92,7 +94,7 @@ export const createLangiumGlobalConfig = async (params: {
}
}
},
languageClientConfig,
languageClientConfigs,
loggerConfig: {
enabled: true,
debugEnabled: true
Expand Down
54 changes: 28 additions & 26 deletions packages/examples/src/python/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,37 @@ export const createUserConfig = (workspaceRoot: string, code: string, codeUri: s
const writer = new WebSocketMessageWriter(iWebSocket);

return {
languageClientConfig: {
languageId: 'python',
name: 'Python Language Server Example',
options: {
$type: 'WebSocketDirect',
webSocket: webSocket,
startOptions: {
onCall: (languageClient?: MonacoLanguageClient) => {
setTimeout(() => {
['pyright.restartserver', 'pyright.organizeimports'].forEach((cmdName) => {
vscode.commands.registerCommand(cmdName, (...args: unknown[]) => {
languageClient?.sendRequest('workspace/executeCommand', { command: cmdName, arguments: args });
languageClientConfigs: {
python: {
languageId: 'python',
name: 'Python Language Server Example',
options: {
$type: 'WebSocketDirect',
webSocket: webSocket,
startOptions: {
onCall: (languageClient?: MonacoLanguageClient) => {
setTimeout(() => {
['pyright.restartserver', 'pyright.organizeimports'].forEach((cmdName) => {
vscode.commands.registerCommand(cmdName, (...args: unknown[]) => {
languageClient?.sendRequest('workspace/executeCommand', { command: cmdName, arguments: args });
});
});
});
}, 250);
}, 250);
},
reportStatus: true,
}
},
clientOptions: {
documentSelector: ['python'],
workspaceFolder: {
index: 0,
name: 'workspace',
uri: vscode.Uri.parse(workspaceRoot)
},
reportStatus: true,
}
},
clientOptions: {
documentSelector: ['python'],
workspaceFolder: {
index: 0,
name: 'workspace',
uri: vscode.Uri.parse(workspaceRoot)
},
},
connectionProvider: {
get: async () => ({ reader, writer })
connectionProvider: {
get: async () => ({ reader, writer })
}
}
},
wrapperConfig: {
Expand Down
Loading