suggest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoosList   = "android darwin dragonfly freebsd js linux nacl netbsd openbsd plan9 solaris windows zos "
	GoarchList = "" /* 155-byte string literal not displayed */
)

Variables

View Source
var (
	KnownOS   = make(map[string]bool)
	KnownArch = make(map[string]bool)
)
View Source
var Formatters = map[string]Formatter{
	"csv":              csvFormat,
	"csv-with-package": csvFormat,
	"emacs":            emacsFormat,
	"godit":            goditFormat,
	"json":             jsonFormat,
	"nice":             NiceFormat,
	"vim":              vimFormat,
}

Functions

func NiceFormat

func NiceFormat(w io.Writer, candidates []Candidate, num int)

Types

type Candidate

type Candidate struct {
	Class   string `json:"class"`
	PkgPath string `json:"package"`
	Name    string `json:"name"`
	Type    string `json:"type"`
}

func (Candidate) String

func (c Candidate) String() string

func (Candidate) Suggestion

func (c Candidate) Suggestion() string

type Config

type Config struct {
	RequestContext context.Context

	Logf               func(fmt string, args ...interface{})
	Context            *PackedContext
	Builtin            bool
	IgnoreCase         bool
	UnimportedPackages bool
}

func (*Config) Suggest

func (c *Config) Suggest(filename string, data []byte, cursor int) ([]Candidate, int)

Suggest returns a list of suggestion candidates and the length of the text that should be replaced, if any.

type Formatter

type Formatter func(w io.Writer, candidates []Candidate, num int)

type PackedContext

type PackedContext struct {
	// Env is the environment to use when invoking the build system's query tool.
	// If Env is nil, the current environment is used.
	// As in os/exec's Cmd, only the last value in the slice for
	// each environment key is used. To specify the setting of only
	// a few variables, append to the current environment, as in:
	//
	//	opt.Env = append(os.Environ(), "GOOS=plan9", "GOARCH=386")
	//
	Env []string

	// Dir is the directory in which to run the build system's query tool
	// that provides information about the packages.
	// If Dir is empty, the tool is run in the current directory.
	Dir string

	// BuildFlags is a list of command-line flags to be passed through to
	// the build system's query tool.
	BuildFlags []string
}

PackedContext is copied from go/packages.Config.

Jump to

Keyboard shortcuts

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