Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add highlights.scm query for Solidity #2619

Merged

Conversation

YongJieYongJie
Copy link
Contributor

I noticed the original issue has been inactive for quite some time, and thought I might take a stab at adding basic highlighting support for Solidity.

Here's a preview of the highlighting:
image

Also managed to add the test and got the ./scripts/run_tests.sh query passing for Solidity:
image

Do let me know if this is alright 🙇‍♂️

- Use more specific/appropriate captures; change invalid captures
- Don't highlight punctuations in type names (e.g., the brackets in
  'bytes32[]')
@YongJieYongJie
Copy link
Contributor Author

@theHamsta Thanks for the quick review,

I have made the following changes:

  • use more appropriate/specific captures as per comments above,
  • fixed the CI jobs that were failing because of invalid captures, and also
  • improved highlighting of type_name containing punctuation (e.g., the brackets in the bytes32[] used to be highlighted in yellow too)
    image

"memory"
"storage"
"calldata"
"function"
Copy link
Member

Choose a reason for hiding this comment

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

@keyword.function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, thanks 🙏

"else"
"try"
"catch"
"return"
Copy link
Member

Choose a reason for hiding this comment

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

@keyword.return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, thanks 🙏

"contract"
"interface"
"library"
"is"
Copy link
Member

Choose a reason for hiding this comment

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

maybe @keyword.operator. Not sure, don't know the language.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is is used for defining inheritance relationship, so I don't think it is an operator like in python.

- Instead of @Keyword, use @conditional, @exception, @return, @function
  as appropriate
- Standardize to using @field (instead of @Property)for struct members
@YongJieYongJie
Copy link
Contributor Author

@theHamsta Thanks again for the quick review.

Apologies the missing out on the various captures (I had originally wanted to keep the highlights.scm query file more-or-less similar to upstream).

I have went through the various available captures in the Contributing page and updated the file accordingly. Do have a look when you have time 🙏

@theHamsta theHamsta merged commit fc0b881 into nvim-treesitter:master Mar 11, 2022
@theHamsta
Copy link
Member

Everything should be fine now. Thank you a lot!

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

Successfully merging this pull request may close these issues.

None yet

2 participants