snippet

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

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 https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_completion.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func (b *Builder) String() string

String returns the built snippet string.

func (*Builder) WriteChoice

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) WriteFinalTabstop

func (b *Builder) WriteFinalTabstop()

WriteFinalTabstop marks where cursor ends up after the user has cycled through all the normal tab stops. It defaults to the character after the snippet.

func (*Builder) WritePlaceholder

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

func (b *Builder) WriteText(s string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL