-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: Code completion in gopls is not working, unable to find the packages to import #71462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Gopls does index the standard library as well as module cache and any workspace dependencies, and should offer unimported completion in this case. I'm not able to reproduce using nvim+coc.nvim (my default editor setup). Can you try in VS Code? |
@findleyr Thanks for your reply! The above problem was alleviated after I deleted the cache file of gopls ( After I Unfortunately, I cannot provide the code repository where I reproduced this problem. Maybe you need some more information. I can try to investigate whether it can be provided. |
@tyanxie This is probably caused by |
Thanks for your solution, but unfortunately it doesn't work for me. |
This will probably be fixed by the new code that indexes the module cache. |
What did you do?
I have enabled gopls in Neovim through configuring lspconfig. When I am working in a new project and type
http
, gopls does not provide code completion suggestions fornet/http
. And this issue is not limited to thehttp
module, it affects all modules.I have noticed that when I manually add import
net/http
to the import block, the code completion starts to work properly, and it also begins to suggest other modules correctly.I guess that maybe gopls only indexes the modules in the import block and does not index the standard library or the modules listed in go.mod by default. I believe this is not the expected behavior. I think indexing the standard library and the modules in go.mod should be considered an expected behavior.
What did you expect to see?
Neovim should provide suggestions for packages that have not yet been imported, such as directly using
http
in a new project as I mentioned earlier.What did you see instead?
Neovim does not suggest packages that have not yet been imported.
Build info
The text was updated successfully, but these errors were encountered: