tools: Index | Files

package snippet

import ""

Package snippet implements the specification for the LSP snippet format.

Snippets are "tab stop" templates returned as an optional attribute of LSP completion candidates. As the user presses tab, they cycle through a series of tab stops defined in the snippet. Each tab stop can optionally have placeholder text, which can be pre-selected by editors. For a full description of syntax and features, see "Snippet Syntax" at

A typical snippet looks like "foo(${1:i int}, ${2:s string})".


Package Files


type Builder Uses

type Builder struct {
    // contains filtered or unexported fields

A Builder is used to build an LSP snippet piecemeal. The zero value is ready to use. Do not copy a non-zero Builder.

func (*Builder) String Uses

func (b *Builder) String() string

String returns the built snippet string.

func (*Builder) WriteChoice Uses

func (b *Builder) WriteChoice(choices []string)

WriteChoice writes a tab stop and list of text choices to the Builder. The user's editor will prompt the user to choose one of the choices.

func (*Builder) WritePlaceholder Uses

func (b *Builder) WritePlaceholder(fn func(*Builder))

WritePlaceholder writes a tab stop and placeholder value to the Builder. The callback style allows for creating nested placeholders. To write an empty tab stop, provide a nil callback.

func (*Builder) WriteText Uses

func (b *Builder) WriteText(s string)

Package snippet imports 2 packages (graph) and is imported by 3 packages. Updated 2019-09-17. Refresh now. Tools for package owners.