Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions editors/vscode/client/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@ import {
workspace,
} from 'vscode';

import {
ConfigurationParams,
ExecuteCommandRequest,
MessageType,
ShowMessageNotification,
} from 'vscode-languageclient';
import { ConfigurationParams, ExecuteCommandRequest, ShowMessageNotification } from 'vscode-languageclient';

import { Executable, LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';

import { join } from 'node:path';
import { ConfigService } from './ConfigService';
import { VSCodeConfig } from './VSCodeConfig';
import { OxcCommands } from './commands';
import { runExecutable } from './lsp_helper';
import { onClientNotification, runExecutable } from './lsp_helper';

const languageClientName = 'oxc';

Expand Down Expand Up @@ -149,25 +144,7 @@ export async function activate(
client = new LanguageClient(languageClientName, serverOptions, clientOptions);

const onNotificationDispose = client.onNotification(ShowMessageNotification.type, (params) => {
switch (params.type) {
case MessageType.Debug:
outputChannel.debug(params.message);
break;
case MessageType.Log:
outputChannel.info(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.info(params.message);
}
onClientNotification(params, outputChannel);
});

context.subscriptions.push(onNotificationDispose);
Expand Down
25 changes: 24 additions & 1 deletion editors/vscode/client/lsp_helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Executable } from 'vscode-languageclient/node';
import { LogOutputChannel, window } from 'vscode';
import { Executable, MessageType, ShowMessageParams } from 'vscode-languageclient/node';

export function runExecutable(path: string, nodePath?: string): Executable {
const serverEnv: Record<string, string> = {
Expand Down Expand Up @@ -32,3 +33,25 @@ export function runExecutable(path: string, nodePath?: string): Executable {
},
};
}

export function onClientNotification(params: ShowMessageParams, outputChannel: LogOutputChannel) {
switch (params.type) {
case MessageType.Debug:
outputChannel.debug(params.message);
break;
case MessageType.Log:
outputChannel.info(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.info(params.message);
}
}
Loading