I have the ms-vscode.go
Go extension installed in my VS Code setup and am using the gopls
language server. The language server seems to perform well with Intellisense operations except when I am editing imports, at which point there is considerable lag as every edit to the import takes several seconds to update.
For example, the following is a replay of typing in manually import "net/http"
letter-by-letter (rather than copy/paste). The clip runs at 20x speed, so it takes about 1.8 minutes from when I stop typing the import statement to when the language server gets to the correct error of "net/http" imported but not used
:
Am I doing something wrong?
My go-related settings:
"go.useLanguageServer": true,
"go.alternateTools": {
"go-langserver": "gopls"
},
Output from gopls
reveals that much time is spent in go list
:
4.037297s for ...go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" ...
for every change.
That might be because:
go tools
does not yet support autocompletion of unimported packages #31906: issue 31906saibing/tools
does.You could try and see if the issue persist with saibing/tools
, using Go 1.13 in module mode.
git clone https://github.com/saibing/tools
cd tools/gopls
go install
Make sure your ~/go/bin
(using the default GOPATH
) does show a new gopls
executable with a recent timestamp.
Relaunch VSCode then.
My gopls settings:
"gopls": {
"usePlaceholders": true, // add parameter placeholders when completing a function
"enhancedHover": true, // experimental to improve quality of hover (will be on by default soon)
},
But also:
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"go.lintTool": "golangci-lint",
"go.useLanguageServer": true,
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true
},