Skip to main content
API module

snippetmanager API

All 9 public APIs exported from the snippetmanager module, with declarations, documentation, and source-backed examples.

Generated from typings/index.d.ts @ 555f5ceon

snippetmanager

snippetManager.getSession

Get snippet session by bufnr, only returns active session.

Source

API signature

snippetManager.getSession(bufnr: number): SnippetSession | undefined

Parameters

ParameterType
bufnrnumber
Returns
SnippetSession | undefined
Declaration
typings/index.d.ts:12906
snippetmanager

snippetManager.resolveSnippet

Resolve snippet string to text.

Source

API signature

snippetManager.resolveSnippet(body: string, ultisnip?: UltiSnippetOption): Promise<string>

Parameters

ParameterType
bodystring
ultisnip?UltiSnippetOption
Returns
Promise<string>
Declaration
typings/index.d.ts:12910
snippetmanager

snippetManager.insertBufferSnippet

Insert snippet to specific buffer, ultisnips not supported, and the placeholder is not selected.

Source

API signature

snippetManager.insertBufferSnippet(bufnr: number, snippet: string | SnippetString, range: Range, insertTextMode?: InsertTextMode): Promise<boolean>

Parameters

ParameterTypeDescription
bufnrnumber

Buffer number for snippet to insert.

snippetstring | SnippetString

Textmate snippet or snippet string.

rangeRange

Range to replace.

insertTextMode?InsertTextMode

The insert text mode.

Returns
Promise<boolean>

Whether the snippet is activated.

Declaration
typings/index.d.ts:12920
snippetmanager

snippetManager.insertSnippet

Insert snippet to current buffer.

Source

API signature

snippetManager.insertSnippet(snippet: string | SnippetString, select?: boolean, range?: Range, insertTextMode?: InsertTextMode, ultisnip?: UltiSnippetOption): Promise<boolean>

Parameters

ParameterTypeDescription
snippetstring | SnippetString

Textmate snippet string.

select?boolean

Not select first placeholder when false, default true.

range?Range

Replace range, insert to current cursor position when undefined.

insertTextMode?InsertTextMode

The insert text mode.

ultisnip?UltiSnippetOption

Option of UltiSnips snippet.

Returns
Promise<boolean>

Whether the snippet is activated.

Declaration
typings/index.d.ts:12931
snippetmanager

snippetManager.insertBufferSnippets

Insert multiple snippets to a specific buffer, the buffer must be attached buffer. The buffer could be hidden, ranges of inserted snippets should not have overlap, snippets are inserted as nested snippets of a top snippet. No ultisnip snippet support, selection is disabled by default. When not selected, the first placeholder is selected on BufEnter event.

Source

API signature

snippetManager.insertBufferSnippets(bufnr: number, edits: SnippetEdit[], select?: boolean): Promise<boolean>

Parameters

ParameterTypeDescription
bufnrnumber

Buffer number of attached buffer.

editsSnippetEdit[]

snippet edits with range and snippet.

select?boolean
Returns
Promise<boolean>

True when snippet is activated.

Declaration
typings/index.d.ts:12947
snippetmanager

snippetManager.nextPlaceholder

Jump to next placeholder, only works when snippet session activated.

Source

API signature

snippetManager.nextPlaceholder(): Promise<void>
Returns
Promise<void>
Declaration
typings/index.d.ts:12952
snippetmanager

snippetManager.previousPlaceholder

Jump to previous placeholder, only works when snippet session activated.

Source

API signature

snippetManager.previousPlaceholder(): Promise<void>
Returns
Promise<void>
Declaration
typings/index.d.ts:12956
snippetmanager

snippetManager.cancel

Cancel snippet session of current buffer, does nothing when no session activated.

Source

API signature

snippetManager.cancel(): void
Returns
void
Declaration
typings/index.d.ts:12960
snippetmanager

snippetManager.isActivated

Check if snippet activated for bufnr.

Source

API signature

snippetManager.isActivated(bufnr: number): boolean

Parameters

ParameterType
bufnrnumber
Returns
boolean
Declaration
typings/index.d.ts:12964