diff --git a/package.json b/package.json index e90220a..a5852e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oni-api", - "version": "0.0.37", + "version": "0.0.38", "description": "Oni's API layer", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/index.ts b/src/index.ts index c1cd705..b6a4dbb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,6 +48,42 @@ export interface Workspace { onDirectoryChanged: IEvent } +export namespace Snippets { + /** + * Metadata describing a snippet + */ + export interface Snippet { + prefix: string + body: string + description: string + } + + /** + * `SnippetProvider` is a strategy for providing snippets for a particular language + * + * This can range from loading from a file/network to ad-hoc configuration in user config. + */ + export interface SnippetProvider { + getSnippets(language: string): Promise + } + + /** + * `SnippetManager` is the main entry point for integrating with snippets. + */ + export interface SnippetManager { + isSnippetActive: boolean + + insertSnippet(snippet: string): Promise + + cancel(): Promise + nextPlaceholder(): Promise + previousPlaceholder(): Promise + + getSnippetsForLanguage(language: string): Promise + registerSnippetProvider(snippetProvider: SnippetProvider): void + } +} + export type Direction = "left" | "right" | "down" | "up" export type SplitDirection = "horizontal" | "vertical" @@ -552,6 +588,7 @@ export namespace Plugin { menu: Menu.Api process: Process recorder: Recorder + snippets: Snippets.SnippetManager statusBar: StatusBar windows: IWindowManager workspace: Workspace