suggest

package
v0.0.0-...-1682721 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package suggest provides inline code completions

Index

Constants

This section is empty.

Variables

View Source
var CommonGoSnippets = map[string]Suggestion{
	"func": {
		Text:        "func name(params) returnType {\n\t// TODO: implement\n\treturn\n}",
		Label:       "function",
		Description: "Function declaration",
		Kind:        "snippet",
	},
	"for": {
		Text:        "for i := 0; i < count; i++ {\n\t\n}",
		Label:       "for loop",
		Description: "For loop",
		Kind:        "snippet",
	},
	"forr": {
		Text:        "for i, v := range items {\n\t\n}",
		Label:       "for range",
		Description: "Range loop",
		Kind:        "snippet",
	},
	"if": {
		Text:        "if condition {\n\t\n}",
		Label:       "if statement",
		Description: "If condition",
		Kind:        "snippet",
	},
	"ifer": {
		Text:        "if err != nil {\n\treturn err\n}",
		Label:       "if err != nil",
		Description: "Error check",
		Kind:        "snippet",
	},
	"struct": {
		Text:        "type Name struct {\n\tField Type\n}",
		Label:       "struct",
		Description: "Struct definition",
		Kind:        "snippet",
	},
	"method": {
		Text:        "func (r *Receiver) MethodName() error {\n\treturn nil\n}",
		Label:       "method",
		Description: "Method receiver",
		Kind:        "snippet",
	},
	"test": {
		Text:        "func TestName(t *testing.T) {\n\t// TODO: test\n}",
		Label:       "test function",
		Description: "Test case",
		Kind:        "snippet",
	},
	"main": {
		Text:        "func main() {\n\t// TODO: implement\n}",
		Label:       "main",
		Description: "Main function",
		Kind:        "snippet",
	},
	"ctx": {
		Text:        "ctx context.Context",
		Label:       "context parameter",
		Description: "Context parameter",
		Kind:        "snippet",
	},
}

CommonGoSnippets provides Go-specific code snippets

Functions

func CompleteWord

func CompleteWord(line string, cursorPos int) (string, int)

CompleteWord tries to complete the current word

func ShowSuggestions

func ShowSuggestions(suggestions []Suggestion)

ShowSuggestions displays suggestions in the terminal

Types

type Context

type Context struct {
	CurrentLine string
	Prefix      string
	FilePath    string
	Language    string
	RepoPath    string
}

Context holds information about the current coding context

type Suggester

type Suggester struct {
	// contains filtered or unexported fields
}

Suggester provides intelligent code completions

func NewSuggester

func NewSuggester(p iteragent.Provider, tools []iteragent.Tool) *Suggester

NewSuggester creates a new code suggester

func (*Suggester) GetSuggestions

func (s *Suggester) GetSuggestions(ctx context.Context, c Context) ([]Suggestion, error)

GetSuggestions returns completions for the given context

type Suggestion

type Suggestion struct {
	Text        string
	Label       string
	Description string
	Kind        string // "function", "variable", "import", "snippet"
}

Suggestion represents a code completion suggestion

func GetSnippet

func GetSnippet(name string) (Suggestion, bool)

GetSnippet returns a snippet by name

Jump to

Keyboard shortcuts

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