-
Notifications
You must be signed in to change notification settings - Fork 58
Treat interface{} and struct{} as builtin types #110
Comments
The keyword Syntax highlighting serves to differentiate syntactic elements. Keywords and punctuation are different syntactic elements in Go, so punctuation should not be given the keyword class. However, I looked into alternate solutions to achieve the look you want without muddling the syntax labels, and I discovered that it is impossible to simulate in pure css. But you can probably get this behavior from your init script. Something like: function colorBraces() {
var bs = findBraces()
bs.forEach(b => b.classList.add('keyword'))
requestAnimationFrame(colorBraces)
}
requestAnimationFrame(colorBraces) |
I believe you misunderstood my intent. Right now, the grammar parser properly identifies built-in types (int, int32 and so on) and gives them a class such as Granted, Also, the patch does not apply the |
Ah, gotcha. I miscounted the captures (thought 1 was the braces :-!) |
Shouldn't |
It appears that both Otherwise, this should probably be closed. |
Well, semantically Now what I'm really interested in is code legibility. When syntax highlighting turns code into a peacock, one might as well disable it. As requested, I'll try to demonstrate with a few screenshots with different themes. Atom-DarkA good example of that is with the Atom-Dark theme where parsing function definitions can sometimes be hard on the eyes. Note that to get things right with this theme, I have to remove the keyword tag since the theme prioritizes keywords over types. One-DarkThings are a less problematic with the One-Dark theme that colorizes keywords and types identically. Tomorrow Night SaturatedMonokaiThe ever popular Monokai theme is probably the worst offender when it comes to peacock style. Obviously, depending on the user theme and personal threshold where syntax highlighting switches from being helpful to a plain hindrance, this might seem relevant, or not. |
I just realized that a function argument of type In a darker environment, the Monokai theme is not that bad. Still, when it comes to reading code, homogeneously colored types make it easier to parse, at least for me. |
Prerequisites
Description
While
interface
andstruct
are keywords, the emptyinterface{}
andstruct{}
are so widely used as type literals in Go code that I believe that they should be also treated as built-in types for syntax highlighting purposes.EDIT: syntactically, they serve the same purpose.
In code like this:
having
interface{}
andstruct{}
highlighted the same asint
would just make the whole definition look more consistent.Versions
[email protected]
Additional information
Here's a short patch that does this (insert just before
Terminators
):This retains the ability to theme
interface
andstruct
as keywords.The text was updated successfully, but these errors were encountered: