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

feat: add JSON-TextMate #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

RedCMD
Copy link

@RedCMD RedCMD commented Feb 6, 2025

Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for textmate-grammars-themes failed.

Name Link
🔨 Latest commit 3611edc
🔍 Latest deploy log https://app.netlify.com/sites/textmate-grammars-themes/deploys/67a4af639b87f30008a28cb0

@slevithan
Copy link

slevithan commented Feb 6, 2025

So, I think this project by @RedCMD is wonderful, a labor of love by a master at his craft, and that every TextMate grammar author should be aware of it.

But I don't think it should be added here.

First, it doesn't meet Shiki's popularity threshold:

For new grammars to be accepted, we typically require the language to be popular and have a significant number of users. Usually we see GitHub's linguist repo as a marker for this. If you language is not in linguist, we would recommend adding it there first.

Meanwhile, to use a grammar with Shiki, you can always provide a custom grammar locally.

I don't personally care about that rule given that the quality of the project is high. So I'm partly just using it as an excuse.

What I care about more is that Shiki's JS engine doesn't support it, unless RedCMD decides to refactor for JS engine support. That's because RedCMD is a true Oniguruma expert, more so than probably at least 99% of TextMate grammar authors, and enjoys pushing all the boundaries with Oniguruma, including using extremely esoteric Oniguruma syntax/behavior.

Shiki's JS engine is extremely close to getting to 100% support for all grammars provided by Shiki, and @antfu has in the past supported the idea that this repo should require compatibility with the JS engine, going forward.

@antfu
Copy link
Member

antfu commented Feb 6, 2025

It's an awesome project, thanks for making it! However, arguably, I am not sure if this could be counted as a language. But considering that the whole fact TextMate grammar is about TextMate grammar, I am happy to have it.

However, yeah I think at this moment, we would wish it uses polyfill-able syntaxes so we could run it with the js engine of Shiki as @slevithan pointed out.

@RedCMD
Copy link
Author

RedCMD commented Feb 6, 2025

is there an easy way to extract the errors?
cause Error: Invalid group isn't all too helpful
image

edit:
caused by use of (?D)

what's the eta on conditionals?
I use them a lot in conjunction with backreferences across begin/end
(?((?!\\1))\\)|(?=[\")]))

@slevithan
Copy link

slevithan commented Feb 6, 2025

Error: Invalid group isn't all too helpful

I can improve the "invalid group" error. But yeah, you'll currently get that if the character following (? isn't a supported group type, and doesn't already have a more specific error.

caused by use of (?D)

(?D) can be supported in the future, of course. In fact, D is already supported as a top-level flag; just not yet as a mode modifier. The main reason mode modifier (?D) isn't yet supported is because it's not used by anyone except you. 😊

For context, after having done a ton of work at this point to get to 100% JS engine support for all the grammars in this library, I'm looking to slow down on Oniguruma-To-ES for the time being. So I'd request PRs if you want it to support extremely rare features like (?D) (rather than just using [0-9]) in the nearish term.

what's the eta on conditionals?

I don't plan to support conditionals for now unless support is submitted as a PR. Conditionals were only used by one grammar in this library (Swift), and at least some of Swift's usage of them was not emulatable in JS (which is why my request to refactor them, as you've seen).

Your usage (?((?!…))…|…) is emulatable (although there are some complications around certain features like capturing groups, backrefs, and subroutines in the condition's contents). So yeah, it would be great to support that.

@slevithan
Copy link

slevithan commented Feb 7, 2025

Are there any other currently-unsupported features you're using other than (?D) and lookaround-based conditionals? Since these are emulatable, I’ll keep them on my radar for eventual support, even if it only means adding support for this grammar.

@RedCMD
Copy link
Author

RedCMD commented Feb 7, 2025

I'm removing the occurrences of \x and (?D)
only (?( remains
I mostly used them in the same way as Swifts
for checking if " or < was used

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.

3 participants