Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add more scopes to the tree-sitter go grammar #158

Merged
merged 6 commits into from
Oct 29, 2018
Merged

Conversation

Ben3eeE
Copy link
Contributor

@Ben3eeE Ben3eeE commented Oct 29, 2018

TODO

  • default in this program does not get parsed with an anonymous node and is not highlighted
  • true and false is not highlighted. They are constant.language.go in textmate
  • The % part of interpreted_string_literal is not highlighted differently. It's constant.other.placeholder.go in textmate:
fmt.Printf("Don't know type %T\n", t)

textmate:
image
tree-sitter:
image

  • Test everything

Changes

  • Scope go as keyword.control
  • Scope imaginary_literal as constant.numeric.integer
  • Scope float_literal as constant.numeric.float
  • Scope all operators as keyword.operator

/cc: @maxbrunsfeld

@maxbrunsfeld
Copy link
Contributor

I pushed an update to tree-sitter-go that addresses some issues:

  • There should now be an anonymous default node, so default in switch statements should get colored.
  • There are now separate true and false nodes

Copy link
Contributor

@maxbrunsfeld maxbrunsfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say we should probably merge this even without the % changes. I want to do something about those, but I'm not exactly sure what yet. They're a bit like the word TODO in a comment - something that's not really part of the language's syntax, so is maybe suitable for an injection. But like TODO, it seems like we need some lighter-weight kind of injection, which doesn't involve creating an entirely separate parser.

@Ben3eeE Ben3eeE merged commit b4ac7f5 into master Oct 29, 2018
@Ben3eeE Ben3eeE deleted the b3-tree-sitter-scopes branch October 29, 2018 20:30
@Ben3eeE
Copy link
Contributor Author

Ben3eeE commented Oct 29, 2018

Nice, yeah it seems like we have this problem in other languages as well. The %. Like in Python {} is not highlighted in a string /cc: atom/language-python#281 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants