-
Notifications
You must be signed in to change notification settings - Fork 58
Fixed highlighting of brackets, punctuations and identifiers. #52
Conversation
|
/cc @svanharmelen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even through your absolutely correct that both chan and map are listed as reserved (key)words, they are also both types (https://golang.org/ref/spec#Map_types and https://golang.org/ref/spec#Channel_types) listed and explained right along side all other types (https://golang.org/ref/spec#Types).
Taking that into account and looking at how the words are used within the language (to define types) I think it makes much more sense to assign the storage.type.go scope instead of the keyword.go scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is true that chan and map are keywords used to define types; your opinion isn't unfounded.
However, the specification does list them as keywords. Additionally, all other type related keywords type, struct, interface and func are arguably also used to define types, but they aren't marked with the storage.type.go scope; they have the keyword.go scope. So should chan and map.
Consider this example using all type related keywords:
type oddMap map[*func(interface{}) int]<-chan struct{}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look it this with the theme I'm using, the current scoping still makes a lot more sense to me:

It makes very clear that I'm using the types map and chan. If you make them as keywords they fade away together with all the other keywords making the same line harder and less clear to read:
So IMO this should really be scoped as storage.type.go.
@joefitzgerald what's your take on this specific one? It seems the language spec leaves room for both keyword.go and storage.type.go to be used. So it comes down to usability and personal preference I think...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@Victorystick thanks for the PR and sorry for having so much comments... I do however think all my comments are valid and that (overall) this PR doesn't improve this package. The purpose of this package is to "understand" as much as possible of the Go language in order to scope all parts of it correctly. The more parts it can scope correctly, the better any Atom theme can use those scopes to create good highlighting. So it seems a little that what you are trying to solve (make the highlighting easier for the eyes) should be solved/changed in the theme package you use and not in the language package. For example the Monokai theme I'm using (https://github.com/kevinsawicki/monokai) works very well for Go and seems very relaxed for the eyes while it uses this same language package: |
|
I whole-heartedly agree that the scoping should be as accurate as possible. That's why I decided to contribute. The second paragraph of TextMate's Naming Conventions you linked me (which is great, by the way) says:
Some syntax themes in Atom highlight I believe that Atom's various syntaxes (which work great across such a wide range of languages) should all work equally well for Go. |
|
@Victorystick so I think we are pretty much aligned now right? Except for So could you update the PR to reflect the things we discussed? |
* Stick to naming conventions. `;` == `meta.terminator.semicolon.go`. * Ensure package names don't get the `variable.go` scope. * Revert `variable.go` for now. In the future, the best solution may be to only mark variables when they're known to actually be variables.
|
@Victorystick only one thing left... You still need to delete the semicolon from the operator list (was previously on line 162) as it's now beging processed twice. After that I think we should be ok to merge this one. I had another few thoughts about So if you could just remove the double semicolon, that would be great. |
|
Absolutely. I'll get it done within an hour or two. I've really enjoyed your quick and direct feedback. 😄 |
|
Sorry but my eye just caught a small thingy in the regexp you added later for the package name... Please see the inline comment. |
grammars/go.cson
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed the ? at the end of the regexp and I understand why you added it, but wonder if it's the best way...
Wouldn't it be better to revert this so package is matched together with import again (like it was before) and then add a regexp like this: 'match': '\\bpackage\\b\\s+([\\w_][\\w\\d_]*)'
This way package will always be scoped correctly, and independent from that word, the package name will also be scoped correctly. It seems this would be a little more robust while having the exact same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I'll do so today.
|
LGMT! Thanks again for your efforts! |
|
👏 thanks for the great work guys! |
|
|
Fixed highlighting of brackets, punctuations and identifiers.




These changes make sure that:
mapandchanare highlighted as keywords.;is no longer an operatorAddresses issues #32 and #35. All in all, it's much easier on the eyes. Before:
After: