mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Merge #2850
2850: Use types from vscode-languageclient r=matklad a=kiljacken Now that we're running with 3.15 of the LSP for VSCode we don't need to define these interfaces ourselves. Yay! Co-authored-by: Emil Lauridsen <mine809@gmail.com>
This commit is contained in:
commit
5449d267b8
3 changed files with 9 additions and 31 deletions
|
@ -13,7 +13,7 @@ export default {
|
||||||
commonjs({
|
commonjs({
|
||||||
namedExports: {
|
namedExports: {
|
||||||
// squelch missing import warnings
|
// squelch missing import warnings
|
||||||
'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes']
|
'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes', 'WorkDoneProgress', 'WorkDoneProgressBegin', 'WorkDoneProgressReport', 'WorkDoneProgressEnd']
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|
|
@ -42,7 +42,7 @@ const parameterHintDecorationType = vscode.window.createTextEditorDecorationType
|
||||||
before: {
|
before: {
|
||||||
color: new vscode.ThemeColor('rust_analyzer.inlayHint'),
|
color: new vscode.ThemeColor('rust_analyzer.inlayHint'),
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
class HintsUpdater {
|
class HintsUpdater {
|
||||||
private pending: Map<string, vscode.CancellationTokenSource> = new Map();
|
private pending: Map<string, vscode.CancellationTokenSource> = new Map();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd } from 'vscode-languageclient';
|
||||||
|
|
||||||
import { Ctx } from './ctx';
|
import { Ctx } from './ctx';
|
||||||
|
|
||||||
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||||
|
@ -8,7 +10,7 @@ export function activateStatusDisplay(ctx: Ctx) {
|
||||||
const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command);
|
const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command);
|
||||||
ctx.pushCleanup(statusDisplay);
|
ctx.pushCleanup(statusDisplay);
|
||||||
ctx.onDidRestart(client => {
|
ctx.onDidRestart(client => {
|
||||||
client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params));
|
client.onProgress(WorkDoneProgress.type, 'rustAnalyzer/cargoWatcher', params => statusDisplay.handleProgressNotification(params));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,20 +65,15 @@ class StatusDisplay implements vscode.Disposable {
|
||||||
this.statusBarItem.dispose();
|
this.statusBarItem.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProgressNotification(params: ProgressParams) {
|
handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) {
|
||||||
const { token, value } = params;
|
switch (params.kind) {
|
||||||
if (token !== 'rustAnalyzer/cargoWatcher') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (value.kind) {
|
|
||||||
case 'begin':
|
case 'begin':
|
||||||
this.show();
|
this.show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'report':
|
case 'report':
|
||||||
if (value.message) {
|
if (params.message) {
|
||||||
this.packageName = value.message;
|
this.packageName = params.message;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -90,22 +87,3 @@ class StatusDisplay implements vscode.Disposable {
|
||||||
return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
|
return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Replace this once vscode-languageclient is updated to LSP 3.15
|
|
||||||
interface ProgressParams {
|
|
||||||
token: string;
|
|
||||||
value: WorkDoneProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum WorkDoneProgressKind {
|
|
||||||
Begin = 'begin',
|
|
||||||
Report = 'report',
|
|
||||||
End = 'end',
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WorkDoneProgress {
|
|
||||||
kind: WorkDoneProgressKind;
|
|
||||||
message?: string;
|
|
||||||
cancelable?: boolean;
|
|
||||||
percentage?: string;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue