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 ¶
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 ¶
NewSuggester creates a new code suggester
func (*Suggester) GetSuggestions ¶
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
Click to show internal directories.
Click to hide internal directories.