feat(editor/vscode): Support window/showMessage event (#7085)

Whenever the language server sends a `window/showMessage` event, VS Code
will listen and display a notification or log a message based on the
severity level of the message.

The language server doesn't currently send this event. I'm going to
follow up with a separate PR for that.

Ref https://github.com/oxc-project/oxc/issues/6988
This commit is contained in:
Nicholas Rayburn 2024-11-02 20:32:27 -05:00 committed by GitHub
parent 79bf74a1a1
commit 7872927fca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -2,6 +2,8 @@ import { promises as fsPromises } from 'node:fs';
import { commands, ExtensionContext, StatusBarAlignment, StatusBarItem, ThemeColor, window, workspace } from 'vscode';
import { MessageType, ShowMessageNotification } from 'vscode-languageclient';
import { Executable, LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
import { join } from 'node:path';
@ -171,6 +173,25 @@ export async function activate(context: ExtensionContext) {
serverOptions,
clientOptions,
);
client.onNotification(ShowMessageNotification.type, (params) => {
switch (params.type) {
case MessageType.Log:
case MessageType.Debug:
outputChannel.appendLine(params.message);
break;
case MessageType.Info:
window.showInformationMessage(params.message);
break;
case MessageType.Warning:
window.showWarningMessage(params.message);
break;
case MessageType.Error:
window.showErrorMessage(params.message);
break;
default:
outputChannel.appendLine(params.message);
}
});
workspace.onDidDeleteFiles((event) => {
event.files.forEach((fileUri) => {

View file

@ -22,7 +22,7 @@
"oxc"
],
"engines": {
"vscode": "^1.90.0"
"vscode": "^1.95.0"
},
"sponsor": {
"url": "https://github.com/sponsors/boshen"