@tomjs/vscode-utils
Version:
Some utilities to simplify the development of VSCode Extensions
86 lines (80 loc) • 3.21 kB
TypeScript
import * as vscode from 'vscode';
import { ExtensionContext, WorkspaceFolder } from 'vscode';
declare function setExtensionContext(ctx: ExtensionContext): void;
/**
* Get current extension context
*/
declare function getExtensionContext(): ExtensionContext;
/**
* Get current extension context
*/
declare function getCtx(): ExtensionContext;
declare function loadI18n(): void;
/**
* Read i18n messages from package.nls.json
*/
declare class I18n {
/**
* Marks a string for localization. If a localized bundle is available for the language specified by
* {@link env.language} and the bundle has a localized value for this message, then that localized
* value will be returned (with injected {@link args} values for any templated values).
*
* @param message - The message to localize. Supports index templating where strings like `{0}` and `{1}` are
* replaced by the item at that index in the {@link args} array.
* @param args - The arguments to be used in the localized string. The index of the argument is used to
* match the template placeholder in the localized string.
* @returns localized string with injected arguments.
*
* @example
* i18n.t('Hello {0}!', 'World');
*/
t(message: string, ...args: Array<string | number | boolean>): string;
/**
* Marks a string for localization. If a localized bundle is available for the language specified by
* {@link env.language} and the bundle has a localized value for this message, then that localized
* value will be returned (with injected {@link args} values for any templated values).
*
* @param message The message to localize. Supports named templating where strings like `{foo}` and `{bar}` are
* replaced by the value in the Record for that key (foo, bar, etc).
* @param args The arguments to be used in the localized string. The name of the key in the record is used to
* match the template placeholder in the localized string.
* @returns localized string with injected arguments.
*
* @example
* i18n.t('Hello {name}!', { name: 'World' });
*/
t(message: string, args: Record<string, any>): string;
}
/**
* The i18n instance.
*/
declare const i18n: I18n;
/**
* Get the active workspace folder
*/
declare function getActiveWorkspaceFolder(): WorkspaceFolder | undefined;
/**
* Get the active workspace folder uri
*/
declare function getActiveWorkspaceFolderUri(): vscode.Uri | undefined;
/**
* Get the active workspace folder path
*/
declare function getActiveWorkspaceFolderPath(): string | undefined;
/**
* Get all workspace folders
*/
declare function getAllWorkspaceFolders(): (WorkspaceFolder & {
active?: boolean | undefined;
})[];
/**
* Initialize Tomjs Extension Utils
*/
declare function initExtension(ctx: ExtensionContext): void;
declare const _default: {
/**
* Initialize Tomjs Extension Utils
*/
init: typeof initExtension;
};
export { _default as default, getActiveWorkspaceFolder, getActiveWorkspaceFolderPath, getActiveWorkspaceFolderUri, getAllWorkspaceFolders, getCtx, getExtensionContext, i18n, initExtension, loadI18n, setExtensionContext };