Skip to content
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

x/tools/gopls: spurious "is not an identifier" error #33467

Closed
ainar-g opened this issue Aug 5, 2019 · 8 comments
Closed

x/tools/gopls: spurious "is not an identifier" error #33467

ainar-g opened this issue Aug 5, 2019 · 8 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Aug 5, 2019

  • gopls built from 1d1727260058c6d58ebfdeb982c4657342282355
  • go version go1.11.12
  • vim version 8.0 from the Ubuntu 18.04 repo
  • vim-lsc version ad9d2bd0582419e902bc402545da397634202ed0

When browsing through code, I constantly get:

[lsc:Error] no highlight: /home/me/go/src/example.com/foo.go:254:2 is not an identifier
Span = /home/me/go/src/example.com/foo.go:254:2

I get this whenever the cursor is not on an identifier. This error also makes the cursor invisible, which is annoying.

I am still not sure, if it's a problem with vim-lsc or gopls. I am ready to provide more information to help diagnose the issue.

@gopherbot gopherbot added this to the Unreleased milestone Aug 5, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 5, 2019
@stamblerre
Copy link
Contributor

These error messages are removed in gopls at master, if you would like to update. However, master will likely not be as stable as the latest tagged version.

This error is a result of your editor showing the errors from the hover request to the user, so it might be worth filing that issue. Some editors, like VSCode, choose not show the errors from every request to the user.

@ainar-g
Copy link
Contributor Author

ainar-g commented Aug 5, 2019

@stamblerre I've included the commit hash in my original post. I am on master. I've just updated to 2756c524cc1ca1284d912b9c5ee3b0092ff4459b, which was committed recently, and the problem is still there.

Not sure “just ignore it” is a good strategy, but I will open an issue, if it wasn't already.

@ainar-g
Copy link
Contributor Author

ainar-g commented Aug 5, 2019

@stamblerre FWIW, I've replaced

return nil, fmt.Errorf("%s is not an identifier", fset.Position(pos))

with

return nil, nil

in internal/lsp/source/highlight.go, and it started working again.

@stamblerre
Copy link
Contributor

Oh I'm sorry, I misunderstood - I had assumed that the error was with hover, not with document highlight.

In that case, this is definitely an error on the client side. We never return errors from document highlight (see here), they are only ever logged. The client should not show the user logged errors--the LSP specification has a specific window/showMessage request that is distinct from window/logMessage. I would suggest filing this issue on the vim-lsc repo.

@ainar-g
Copy link
Contributor Author

ainar-g commented Aug 5, 2019

You are very correct! Disabling logging with

let g:lsc_server_commands = {"go": {"command": "gopls serve", "log_level": -1}}

fixes the issue! Should I add info about this vim LSC implementation to the Wiki to prevent duplicates?

@stamblerre
Copy link
Contributor

I think it might be best to file an issue with vim-lsc so that they can correct the problem, but as a temporary fix, adding a suggestion to the Wiki would also be helpful. Thanks!

@ainar-g
Copy link
Contributor Author

ainar-g commented Aug 5, 2019

Done. Thank you thrice: for helping me today, for your GopherCon Russia talk, and for gopls in general!

@stamblerre
Copy link
Contributor

😄 And thank you for reporting this issue!

@golang golang locked and limited conversation to collaborators Aug 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

3 participants