| 1 | import * as vscode from "vscode"; |
| 2 | |
| 3 | export class DownloadYamlExtensionCodeLensProvider |
| 4 | implements vscode.CodeLensProvider |
| 5 | { |
| 6 | private yamlExtensionDownloaded(): boolean { |
| 7 | const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml"); |
| 8 | return yamlExtension !== undefined; |
| 9 | } |
| 10 | |
| 11 | public provideCodeLenses( |
| 12 | document: vscode.TextDocument, |
| 13 | _: vscode.CancellationToken, |
| 14 | ): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> { |
| 15 | if (!document.uri.fsPath.includes(".continue")) { |
| 16 | return []; |
| 17 | } |
| 18 | |
| 19 | const codeLenses: vscode.CodeLens[] = []; |
| 20 | |
| 21 | // Always show documentation link |
| 22 | const docCodeLens: vscode.CodeLens = { |
| 23 | range: new vscode.Range(0, 0, 0, 0), |
| 24 | command: { |
| 25 | title: "馃摉 View Continue Reference", |
| 26 | command: "vscode.open", |
| 27 | arguments: [vscode.Uri.parse("https://docs.continue.dev/reference")], |
| 28 | }, |
| 29 | isResolved: true, |
| 30 | }; |
| 31 | codeLenses.push(docCodeLens); |
| 32 | |
| 33 | if (!this.yamlExtensionDownloaded()) { |
| 34 | const codeLens: vscode.CodeLens = { |
| 35 | range: new vscode.Range(0, 0, 0, 0), |
| 36 | command: { |
| 37 | title: "Download YAML extension for Intellisense", |
| 38 | command: "workbench.extensions.installExtension", |
| 39 | arguments: ["redhat.vscode-yaml"], |
| 40 | }, |
| 41 | isResolved: true, |
| 42 | }; |
| 43 | codeLenses.push(codeLens); |
| 44 | } |
| 45 | |
| 46 | return codeLenses; |
| 47 | } |
| 48 | } |