From 0005266edc60f37235611a136d67af8456d2e226 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 6 Mar 2018 18:01:57 -0800 Subject: [PATCH 1/2] Add API definition for snippets --- package.json | 2 +- src/index.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) 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..257ef31 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" From 86b13b5144de3f6246bf84e9bd87ecb7e7817057 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Tue, 6 Mar 2018 18:02:18 -0800 Subject: [PATCH 2/2] Add snippet types --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 257ef31..b6a4dbb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -588,6 +588,7 @@ export namespace Plugin { menu: Menu.Api process: Process recorder: Recorder + snippets: Snippets.SnippetManager statusBar: StatusBar windows: IWindowManager workspace: Workspace