Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/ctx.ts')
| -rw-r--r-- | editors/code/src/ctx.ts | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 4248305d5c..37a2ee2369 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -5,6 +5,7 @@ import * as ra from "./lsp_ext"; import { Config, prepareVSCodeConfig } from "./config"; import { createClient } from "./client"; import { + isCargoTomlEditor, isDocumentInWorkspace, isRustDocument, isRustEditor, @@ -34,13 +35,8 @@ import type { RustAnalyzerExtensionApi } from "./main"; export type Workspace = | { kind: "Empty" } - | { - kind: "Workspace Folder"; - } - | { - kind: "Detached Files"; - files: vscode.TextDocument[]; - }; + | { kind: "Workspace Folder" } + | { kind: "Detached Files"; files: vscode.TextDocument[] }; export function fetchWorkspace(): Workspace { const folders = (vscode.workspace.workspaceFolders || []).filter( @@ -53,10 +49,7 @@ export function fetchWorkspace(): Workspace { return folders.length === 0 ? rustDocuments.length === 0 ? { kind: "Empty" } - : { - kind: "Detached Files", - files: rustDocuments, - } + : { kind: "Detached Files", files: rustDocuments } : { kind: "Workspace Folder" }; } @@ -89,6 +82,7 @@ export class Ctx implements RustAnalyzerExtensionApi { private _dependencyTreeView: | vscode.TreeView<Dependency | DependencyFile | DependencyId> | undefined; + private _syntaxTreeProvider: SyntaxTreeProvider | undefined; private _syntaxTreeView: vscode.TreeView<SyntaxElement> | undefined; private lastStatus: ServerStatusParams | { health: "stopped" } = { health: "stopped" }; @@ -267,7 +261,7 @@ export class Ctx implements RustAnalyzerExtensionApi { let message = "bootstrap error. "; message += - 'See the logs in "OUTPUT > Rust Analyzer Client" (should open automatically). '; + 'See the logs in "OUTPUT > Rust Analyzer Client" (should open automatically).'; message += 'To enable verbose logs, click the gear icon in the "OUTPUT" tab and select "Debug".'; @@ -436,6 +430,11 @@ export class Ctx implements RustAnalyzerExtensionApi { return editor && isRustEditor(editor) ? editor : undefined; } + get activeCargoTomlEditor(): RustEditor | undefined { + const editor = vscode.window.activeTextEditor; + return editor && isCargoTomlEditor(editor) ? editor : undefined; + } + get extensionPath(): string { return this.extCtx.extensionPath; } @@ -476,9 +475,11 @@ export class Ctx implements RustAnalyzerExtensionApi { this.lastStatus = status; this.updateStatusBarItem(); } + refreshServerStatus() { this.updateStatusBarItem(); } + private updateStatusBarItem() { let icon = ""; const status = this.lastStatus; @@ -533,19 +534,14 @@ export class Ctx implements RustAnalyzerExtensionApi { const toggleCheckOnSave = this.config.checkOnSave ? "Disable" : "Enable"; statusBar.tooltip.appendMarkdown( - `[Extension Info](command:rust-analyzer.serverVersion "Show version and server binary info"): Version ${this.version}, Server Version ${this._serverVersion}` + - "\n\n---\n\n" + - '[$(terminal) Open Logs](command:rust-analyzer.openLogs "Open the server logs")' + - "\n\n" + - `[$(settings) ${toggleCheckOnSave} Check on Save](command:rust-analyzer.toggleCheckOnSave "Temporarily ${toggleCheckOnSave.toLowerCase()} check on save functionality")` + - "\n\n" + - '[$(refresh) Reload Workspace](command:rust-analyzer.reloadWorkspace "Reload and rediscover workspaces")' + - "\n\n" + - '[$(symbol-property) Rebuild Build Dependencies](command:rust-analyzer.rebuildProcMacros "Rebuild build scripts and proc-macros")' + - "\n\n" + - '[$(stop-circle) Stop server](command:rust-analyzer.stopServer "Stop the server")' + - "\n\n" + - '[$(debug-restart) Restart server](command:rust-analyzer.restartServer "Restart the server")', + `[Extension Info](command:rust-analyzer.serverVersion "Show version and server binary info"): Version ${this.version}, Server Version ${this._serverVersion}\n\n` + + `---\n\n` + + `[$(terminal) Open Logs](command:rust-analyzer.openLogs "Open the server logs")\n\n` + + `[$(settings) ${toggleCheckOnSave} Check on Save](command:rust-analyzer.toggleCheckOnSave "Temporarily ${toggleCheckOnSave.toLowerCase()} check on save functionality")\n\n` + + `[$(refresh) Reload Workspace](command:rust-analyzer.reloadWorkspace "Reload and rediscover workspaces")\n\n` + + `[$(symbol-property) Rebuild Build Dependencies](command:rust-analyzer.rebuildProcMacros "Rebuild build scripts and proc-macros")\n\n` + + `[$(stop-circle) Stop server](command:rust-analyzer.stopServer "Stop the server")\n\n` + + `[$(debug-restart) Restart server](command:rust-analyzer.restartServer "Restart the server")`, ); if (!status.quiescent) icon = "$(loading~spin) "; statusBar.text = `${icon}rust-analyzer`; @@ -580,4 +576,5 @@ export interface Disposable { dispose(): void; } +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type Cmd = (...args: any[]) => unknown; |