Conversation
The first step is a package.json, which of course we generate with RCL, in order to keep the version number in sync.
So far inspired by JSON.tmLanguage.json in the VS Code repository, let's see if we can get it to highlight just a constant and maybe an array.
So glad I don't have to pollute my main system with this NPM madness.
Hmm, this is getting messy, but let's see where this goes.
If possible I'll try to keep the same skeleton, to make it easier to keep them in sync.
Highlighting numbers in particular was a bit tricky. It's easy to get something that works for valid documents, but you want something that works while the user is typing, and an incomplete number like "42e" should still match, I don't want it to flicker from "42" as number to "42e" as regular ident back to "42e1" as number.
It now has sequences too, and comments in the right places. I tested it manually by typing things in VSCodium, and by opening all my test documents. This uncovered a few issues (such as #comment needing to be referenced in both expr and seq), which I fixed. I also discovered the pattern to get semi-structured nodes with begin/end match that use lookahead/behind, so you can partition the inner space even when there is no pair of tokens. I think this is good for a v1 of the extension, but I'll keep playing around with it a bit more.
The dash should be part of it. Good that I extracted it into a variable, so that I have to fix it in only one place!
The order matters, as I learned when checking some example files. This is fixed now. Would be nice if I could write tests for this somehow.
I'm trying this out with a few different themes in VSCodium. Frankly, it's a mess, but I think this is good enough for now.
Contributor
|
Nice! I just tested it, everything seems to be working fine for me. (Unrelated, it's nice to see you dogfood RCL throughout the repo, and your comment for afe1082 made me laugh, Nix is so good) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This adds VSCode support (#80).
It took me some time to get started on this and wrap my head around the TextMate grammars. Today I picked it up again and it went pretty smoothly, I think it covers the full grammar now. There were some nuances around supporting incremental editing (e.g.
4.2eshould be a number even though it’s invalid syntax, because you don’t want the highlight to flicker off while typing4.2e1), and what scopes to use, but this is an initial version that I think is very usable.The extension still needs a bit more polish, in particular it needs an icon and banner configuration, but it’s in a state where it can be tested. I uploaded a preview version to the marketplace, feedback is welcome if anybody is reading along.
Checklist