Skip to content

Commit

Permalink
Merge pull request #29 from onivim/bryphe/api/snippets
Browse files Browse the repository at this point in the history
API: Add snippets API definition
  • Loading branch information
bryphe authored Mar 7, 2018
2 parents f594c04 + 86b13b5 commit 90bc638
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
37 changes: 37 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ export interface Workspace {
onDirectoryChanged: IEvent<string>
}

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<Snippet[]>
}

/**
* `SnippetManager` is the main entry point for integrating with snippets.
*/
export interface SnippetManager {
isSnippetActive: boolean

insertSnippet(snippet: string): Promise<void>

cancel(): Promise<void>
nextPlaceholder(): Promise<void>
previousPlaceholder(): Promise<void>

getSnippetsForLanguage(language: string): Promise<Snippet[]>
registerSnippetProvider(snippetProvider: SnippetProvider): void
}
}

export type Direction = "left" | "right" | "down" | "up"
export type SplitDirection = "horizontal" | "vertical"

Expand Down Expand Up @@ -552,6 +588,7 @@ export namespace Plugin {
menu: Menu.Api
process: Process
recorder: Recorder
snippets: Snippets.SnippetManager
statusBar: StatusBar
windows: IWindowManager
workspace: Workspace
Expand Down

0 comments on commit 90bc638

Please sign in to comment.