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: add syntax highlighting for go: directives #63538

Closed
findleyr opened this issue Oct 13, 2023 · 4 comments
Closed

x/tools/gopls: add syntax highlighting for go: directives #63538

findleyr opened this issue Oct 13, 2023 · 4 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

Spin off from https://go.dev/issue/50262: we should add semantic token support for go:directives, so that they stand out as semantically significant. That issue was discussing go:embed support, but if we are going to highlight go:embed, we should highlight other go directives as well.

It probably suffices to add logic here:
https://cs.opensource.google/go/x/tools/+/master:gopls/internal/lsp/semantic.go;l=418;drc=fb4bd11ef6feea8f26ff371d1fcca356511e2e26

We already look inside basic lits of importSpecs to highlight package names, I expect this task would be similar:
https://cs.opensource.google/go/x/tools/+/master:gopls/internal/lsp/semantic.go;l=901;drc=fb4bd11ef6feea8f26ff371d1fcca356511e2e26

@vikblom indicated interest in taking this on.

CC @pjweinb

@findleyr findleyr added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Oct 13, 2023
@findleyr findleyr added this to the gopls/v0.15.0 milestone Oct 13, 2023
@vikblom
Copy link

vikblom commented Oct 14, 2023

Thanks for the pointers! I'll give this a look and circle back with questions/patches 👍

@pjweinb
Copy link

pjweinb commented Oct 14, 2023 via email

@vikblom
Copy link

vikblom commented Oct 18, 2023

Thanks @pjweinb that is very useful input 👍

I checked go:build and there is an existing warning ("misplaced //go:build comment") that pops up even if the directive is a semantic token. The same is true for go:embed warnings implemented in the issue this spun off from.

@gopherbot
Copy link

Change https://go.dev/cl/536915 mentions this issue: gopls/internal/lsp: add semantic highlighting for go: directives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants