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

Improve syntax highlighting #18

Merged
merged 34 commits into from
Sep 10, 2024
Merged

Improve syntax highlighting #18

merged 34 commits into from
Sep 10, 2024

Conversation

jiribenes
Copy link
Contributor

@jiribenes jiribenes commented Jul 19, 2024

Changes

  • parse comments precisely
  • support splices in (currently all) strings
  • support individual characters
  • support escapes in strings and characters
  • support multi-line strings
  • support namespace declarations
  • parse capability sets precisely
  • add folding markers
  • support float literals
  • parse typed holes in line with the rest of the file
  • add operator support (only visible in some themes)
  • in is now a conditional keyword (rendered as a keyword only in var x in r = ...)
  • fix definitions being stuck at => and then not parsing the rest of the arguments
  • highlight at correctly
  • highlight invalid escapes
  • highlight modules and imports correctly
  • add support for region

Caveats / open questions

Future work

Screenshots (before [left] vs after [right])

Screenshot 2024-07-20 at 09 19 13 Screenshot 2024-07-20 at 09 19 46 Screenshot 2024-07-20 at 09 21 59 Screenshot 2024-07-20 at 09 23 46 Screenshot 2024-07-20 at 10 52 03 Screenshot 2024-07-20 at 14 42 40 Screenshot 2024-07-20 at 18 15 22 Screenshot 2024-07-21 at 18 14 46 Screenshot 2024-07-22 at 10 46 27

@jiribenes jiribenes marked this pull request as draft July 19, 2024 19:53
@jiribenes jiribenes force-pushed the jiribenes/syntax-update branch from 227b692 to 9c2b2d3 Compare July 19, 2024 21:02
Comment on lines 129 to 136
"characters": {
"name": "string.quoted.single.effekt",
"begin": "'",
"end": "'",
"patterns": [{
"name": "constant.character.escape.effekt",
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
}]
Copy link
Contributor Author

@jiribenes jiribenes Jul 19, 2024

Choose a reason for hiding this comment

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

I hereby reject the way character escapes are actually parsed, so the grammar is exactly what you would expect (moreover, we're somewhat lax in comparison with the actual lexer in order to allow more characters in a char literal, which is -- I think -- a good thing for highlighting)

Comment on lines 174 to 175
"match": "\\\\u[0-9A-Fa-f]{4}",
"name": "string.quoted.single.char.effekt"
Copy link
Contributor Author

@jiribenes jiribenes Jul 19, 2024

Choose a reason for hiding this comment

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

I was quite surprised, but \uFF0F is really a char literal with no need for single quotes in the current parser!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed effekt-lang/effekt#521 just to be sure that we don't have to support this :)

@jiribenes jiribenes force-pushed the jiribenes/syntax-update branch from 0885ced to dc5fc7f Compare July 19, 2024 22:14
@jiribenes
Copy link
Contributor Author

I'll keep better support for externs for later, but here's a sneak peek:
Screenshot 2024-07-20 at 09 30 23

@jiribenes jiribenes marked this pull request as ready for review July 20, 2024 07:32
@jiribenes
Copy link
Contributor Author

I've updated the screenshots with some of the newer features, but I'm running out of things to add, so feel free to review and merge :)

@jiribenes jiribenes requested a review from b-studios September 10, 2024 14:07
@b-studios b-studios merged commit 8ee4285 into master Sep 10, 2024
1 check passed
@b-studios b-studios deleted the jiribenes/syntax-update branch September 10, 2024 15:23
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.

2 participants