diff --git a/.gitignore b/.gitignore index 615e567be..80f9d9942 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules *.vsix yarn-error.log .metals/ +*.DS_Store # sourcegraph index.scip diff --git a/packages/metals-languageclient/src/interfaces/MetalsInitializationOptions.ts b/packages/metals-languageclient/src/interfaces/MetalsInitializationOptions.ts index e205d6647..44ec1532a 100644 --- a/packages/metals-languageclient/src/interfaces/MetalsInitializationOptions.ts +++ b/packages/metals-languageclient/src/interfaces/MetalsInitializationOptions.ts @@ -36,4 +36,5 @@ export interface MetalsInitializationOptions { copyWorksheetOutputProvider?: boolean; commandInHtmlFormat?: "vscode" | "sublime"; doctorVisibilityProvider?: boolean; + bspStatusBarProvider?: "on" | "off" | "log-message" | "show-message"; } diff --git a/packages/metals-languageclient/src/interfaces/MetalsStatus.ts b/packages/metals-languageclient/src/interfaces/MetalsStatus.ts index 53b7d9d68..52782b53f 100644 --- a/packages/metals-languageclient/src/interfaces/MetalsStatus.ts +++ b/packages/metals-languageclient/src/interfaces/MetalsStatus.ts @@ -24,4 +24,10 @@ export interface MetalsStatusParams { tooltip?: string; /** If set, execute this command when the user clicks on the status bar item. */ command?: string; + /** Is this metals or bsp status. */ + statusType?: "bsp" | "metals"; + /** Level: info, warn, error. */ + level?: "info" | "warn" | "error"; + /** Tooltip for the command. */ + commandTooltip?: string; } diff --git a/packages/metals-vscode/src/extension.ts b/packages/metals-vscode/src/extension.ts index 179e38eec..4434c19d6 100644 --- a/packages/metals-vscode/src/extension.ts +++ b/packages/metals-vscode/src/extension.ts @@ -31,6 +31,7 @@ import { tests as vscodeTextExplorer, debug, DebugSessionCustomEvent, + ThemeColor, } from "vscode"; import { LanguageClient, @@ -312,6 +313,7 @@ function launchMetals( testExplorerProvider: true, commandInHtmlFormat: "vscode", doctorVisibilityProvider: true, + bspStatusBarProvider: "on", }; const clientOptions: LanguageClientOptions = { @@ -707,26 +709,46 @@ function launchMetals( context.subscriptions.push(executeClientCommandDisposable); // The server updates the client with a brief text message about what // it is currently doing, for example "Compiling..". - const item = window.createStatusBarItem(StatusBarAlignment.Right, 100); - item.command = ClientCommands.ToggleLogs; - item.hide(); + const metalsItem = window.createStatusBarItem( + StatusBarAlignment.Right, + 100 + ); + const bspItem = window.createStatusBarItem(StatusBarAlignment.Right, 100); + metalsItem.command = ClientCommands.ToggleLogs; + metalsItem.hide(); + bspItem.hide(); const metalsStatusDisposable = client.onNotification( MetalsStatus.type, (params) => { + const item = params.statusType === "bsp" ? bspItem : metalsItem; item.text = params.text; if (params.show) { item.show(); } else if (params.hide) { item.hide(); } - if (params.tooltip) { - item.tooltip = params.tooltip; - } - if (params.command) { - item.command = params.command; + + const commandTooltip = params.commandTooltip + ? "\nPress to " + params.commandTooltip.toLowerCase() + : ""; + + item.tooltip = params.tooltip + ? params.tooltip + commandTooltip + : undefined; + + if (params.level == "error") { + item.backgroundColor = new ThemeColor( + "statusBarItem.errorBackground" + ); + } else if (params.level == "warn") { + item.backgroundColor = new ThemeColor( + "statusBarItem.warningBackground" + ); } else { - item.command = undefined; + item.backgroundColor = undefined; } + + item.command = params.command; } ); context.subscriptions.push(metalsStatusDisposable);