x/tools/gopls semantically tokenize export comments #604
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I would like to colorize the export comments in golang a different
color. I have this PR, and it kinda works, as shown below.
main_test.go
//go:build cgo
package main
//export main
func main() {
}
Before
$ ~/go/bin/gopls semtok main_test.go
/⇒2,comment,[]/// /⇒8,namespace,[]/go:build /⇒3,comment,[]/cgo
/⇒7,keyword,[]/package /⇒4,namespace,[]/main
/⇒13,comment,[]///export main
/⇒4,keyword,[]/func /⇒4,function,[definition]/main() {
}
After
$ go run . -- semtok main_test.go
/⇒2,comment,[]/// /⇒8,namespace,[]/go:build /⇒3,comment,[]/cgo
/⇒7,keyword,[]/package /⇒4,namespace,[]/main
/⇒2,comment,[]/// /⇒7,namespace,[]/export /⇒4,function,[]/main
/⇒4,keyword,[]/func /⇒4,function,[definition]/main() {
}
I copied what go directives do, but it still needs some work. I want to write some tests and find a way to only colorize it when the export is directly above a function header.
Before I get any farther, could I get confirmation that a PR like this would be accepted. Or is there a reason this has not been added in.