参考:
https://abelsu7.top/2019/09/06/gopls-guide/
点击go插件extensions settings, 打开.vscode/settings.json,
需要打开以下开关,支持本地包自动补全
"deepCompletion": true,
"matcher": "fuzzy",
settings.json配置示例如下:
{
"go.useLanguageServer": true,
"timeline.excludeSources": [],
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"completeUnimported": true,
"usePlaceholders": true,
"completionDocumentation": true,
"deepCompletion": true,
"matcher": "fuzzy",
"hoverKind": "SynopsisDocumentation" // No/Synopsis/Full, default Synopsis
},
"files.eol": "
", // formatting only supports LF line endings
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true,
"rename": true,
"goToDefinition": true,
"hover": true,
"signatureHelp": true,
"goToTypeDefinition": true,
"goToImplementation": true,
"documentSymbols": true,
"workspaceSymbols": true,
"findReferences": true,
"diagnostics": false
},
"emmet.excludeLanguages": [
"markdown"
],
"go.addTags": {
}
}
配置后效果如下: