Skip to content

Add a Visual Studio Code extension#104

Open
ruuda wants to merge 21 commits into
masterfrom
vscode
Open

Add a Visual Studio Code extension#104
ruuda wants to merge 21 commits into
masterfrom
vscode

Conversation

@ruuda
Copy link
Copy Markdown
Owner

@ruuda ruuda commented Mar 21, 2026

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.2e should be a number even though it’s invalid syntax, because you don’t want the highlight to flicker off while typing 4.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

  • Ensure documentation is up to date
  • Ensure changelog is up to date

ruuda added 20 commits March 21, 2026 12:43
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.
@matthieucx
Copy link
Copy Markdown
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)

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