google / gitiles

A simple browser for Git repositories.
https://gerrit.googlesource.com/gitiles/
Other
582 stars 174 forks source link

Feature Request: golang syntax highlighting #155

Open elliotpeele opened 5 years ago

elliotpeele commented 5 years ago

I would like to have golang syntax highlighting for at least keywords and strings. The highlighting in place now only covers comments.

avm99963 commented 2 years ago

Take a look at the following comment in the java-prettify library that Gerrit uses:

https://github.com/twalcari/syntaxhighlighterfx/blob/v1.2.2/src/main/java/prettify/lang/LangGo.java#L33-L48

In summary, it says that the fact that only comments are highlighted is by design. Thus, this should be "fixed" in that library, not in Gitiles.

7AC commented 2 years ago

Don't we need both https://github.com/aristanetworks/gitiles/commit/75f4e71aa04fda97c8adff7c0b16106d247630ee and the fix in java-prettify?

avm99963 commented 2 years ago

I think the change in java-prettify would be enough due to what I've explained in the last paragraph here.

But even then, the Go team's position on syntax highlighting is that there should be no highlighting at all; you won't see any syntax highlighting in https://go.dev/play/, nor in the Go docs, etc. So I'm not sure how to proceed with this.

7AC commented 2 years ago

Agree to disagree with Rob Pike on this :(

https://groups.google.com/g/golang-nuts/c/hJHCAaiL0so/m/kG3BHV6QFfIJ

On a more serious note though looks like java-prettify is based on https://github.com/googlearchive/code-prettify which has been archived, maybe it's time to move to something else? This kind of syntax highlighting seems really useful to me:

https://github.com/fatih/vim-go/blob/master/syntax/go.vim

avm99963 commented 2 years ago

Agree to disagree with Rob Pike on this :(

https://groups.google.com/g/golang-nuts/c/hJHCAaiL0so/m/kG3BHV6QFfIJ

I'm also in favor of syntax highlighting, but the only thing that bothers me is that the Go team is also using gitiles: https://go.googlesource.com/. I think if we added syntax highlighting they would come after us ;)

(Despite this, they are also hosting a mirror in GitHub, and Github does provide syntax highlighting for Go: e.g. https://github.com/golang/go/blob/master/src/fmt/format.go)

On a more serious note though looks like java-prettify is based on https://github.com/googlearchive/code-prettify which has been archived, maybe it's time to move to something else?

I totally agree! Also, the java library hasn't been actively maintained for a few years, so that's another reason for switching to something else.

This kind of syntax highlighting seems really useful to me:

https://github.com/fatih/vim-go/blob/master/syntax/go.vim

Believe it or not, I'm also using this plugin in Vim for syntax highlighting :P It is indeed very useful!