Skip to content

Context

The host supplies contexts to mount, activate and action handlers. Optional capabilities depend on declarations, placement and host support. Check availability before use. Register disposables with subscriptions; signal ends with the caller scope, not with a shared background connection.

Usage guide: views. API index.

Signatures, parameters and return types are generated from the SDK. Optional members are not available in every host and context.

Source

readonly signal: AbortSignal;
readonly subscriptions: {
add<T extends Disposable>(value: T): T;
};

Related types: Disposable.

Source

readonly background?: PluginBackground;
readonly fs?: PluginFileSystem;
readonly filemeta?: PluginFileMeta;
readonly storage?: PluginStorage;
Deprecated
readonly network?: PluginNetwork;
readonly settings?: Pick<PluginSettings, "get">;
readonly connections?: PluginConnections;
readonly ui: HostUI;

Related types: PluginBackground, PluginFileSystem, PluginFileMeta, PluginStorage, PluginNetwork, PluginSettings, PluginConnections, HostUI.

Source

interface CommonContext extends Lifetime { /* members below */ }
readonly i18n: PluginI18n;
readonly capabilities: CommonCapabilities;

Related types: PluginI18n, CommonCapabilities, Lifetime.

Source

readonly locale: string;
t(key: string, values?: Record<string, string | number>): string;
Parameter Type Required
key string Yes
values Record<string, string &#124; number> No

Returns: string.

onDidChangeLocale(listener: (event: {
locale: string;
}) => void): Disposable;
Parameter Type Required
listener (event: { locale: string; }) => void Yes

Returns: Disposable.

Related types: Disposable.

Source

interface ViewCapabilities extends CommonCapabilities { /* members below */ }
readonly explorer?: ExplorerContext;
readonly document?: TextDocument;
readonly eidos?: EidosCapabilities;

Related types: ExplorerContext, TextDocument, EidosCapabilities, CommonCapabilities.

Source

interface ViewContext extends CommonContext { /* members below */ }
readonly presentation?: {
mode: "standalone" | "embedded";
};
readonly binding: ViewBinding;
readonly capabilities: ViewCapabilities;

Related types: ViewBinding, ViewCapabilities, CommonContext.

Source

export type TextFileViewContext = ViewContext & {
readonly binding: Extract<ViewBinding, {
kind: "file";
}>;
readonly capabilities: ViewCapabilities & {
readonly document: TextDocument;
};
};

Related types: ViewContext, ViewBinding, ViewCapabilities, TextDocument.

Source

export type TableFileViewContext = ViewContext & {
readonly binding: Extract<ViewBinding, {
kind: "file";
}>;
readonly capabilities: ViewCapabilities & {
readonly eidos: EidosCapabilities & {
readonly table: EidosTable;
};
};
};

Related types: ViewContext, ViewBinding, ViewCapabilities, EidosCapabilities, EidosTable.

Source

interface ActionContext extends CommonContext { /* members below */ }
readonly binding: ActionBinding;
readonly capabilities: CommonCapabilities & {
readonly document?: TextDocument;
readonly settings: PluginSettings;
};

Related types: ActionBinding, CommonCapabilities, TextDocument, PluginSettings, CommonContext.

Source

interface ExtensionContext extends Lifetime { /* members below */ }
readonly i18n: PluginI18n;
readonly capabilities: {
readonly hooks: {
register(id: string, handler: FileHookHandler): Disposable;
};
readonly formatters: {
register(id: string, provider: FormatterProvider): Disposable;
};
readonly actions: {
registerTableProvider(id: string, provider: TableActionProvider): Disposable;
register(id: string, handler: (ctx: ActionContext) => void | Promise<void>): Disposable;
};
};

Related types: PluginI18n, FileHookHandler, Disposable, FormatterProvider, TableActionProvider, ActionContext, Lifetime.

Source

readonly i18n: PluginI18n;
readonly signal: AbortSignal;
readonly capabilities: TableActionCapabilities;

Related types: PluginI18n, TableActionCapabilities.

Source

export type Mount = (ctx: ViewContext, root: HTMLElement) => void | Disposable | Promise<void | Disposable>;

Related types: ViewContext, Disposable.

Source

export type Activate = (ctx: ExtensionContext) => void | Disposable | Promise<void | Disposable>;

Related types: ExtensionContext, Disposable.