Skip to content

Conversation

@JoeyShapiro
Copy link

@JoeyShapiro JoeyShapiro commented Nov 19, 2025

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.

@gopherbot
Copy link
Contributor

This PR (HEAD: 81dbc8f) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/721860.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/721860.
After addressing review feedback, remember to publish your drafts!

@JoeyShapiro JoeyShapiro changed the title semantically tokenize export comments Nov 19, 2025
@JoeyShapiro JoeyShapiro changed the title [tools/gopls] semantically tokenize export comments Nov 19, 2025
@gopherbot
Copy link
Contributor

Message from Joey Shapiro:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/721860.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants