Open stapelberg opened 3 months ago
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
I believe that this is fixed by https://go.dev/cl/590377, albeit only if you wait 30s.
The real fix is to have gopls itself provide package metadata, since maintaining the active graph of packages is one of gopls' core competencies. This is one of the unfortunate areas where the bolted-on goimports integration suffers.
gopls version
go env
What did you do?
I created a tiny Go project with the following 3 files:
go.mod:
hello1.go:
internal/foo/foo.go:
Note how internal/foo/foo.go contains “package bar”, which I’ll later correct.
What did you see happen?
I opened Emacs on hello1.go, then:
foo.Bar()
tofunc main()
, save the file to trigger organizeImportsinternal/foo/foo
import is not added.What did you expect to see?
I would have expected gopls to add the internal/foo/foo import.
Restarting gopls using
M-x eglot
helps — afterwards the organizeImports action succeeds.Editor and settings
Emacs 29 with go-ts-mode and eglot
Logs