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 Request] An option to make \n work as delimter #4

Open
ZZZank opened this issue Mar 6, 2024 · 15 comments · May be fixed by #5
Open

[Feat Request] An option to make \n work as delimter #4

ZZZank opened this issue Mar 6, 2024 · 15 comments · May be fixed by #5

Comments

@ZZZank
Copy link

ZZZank commented Mar 6, 2024

FTB Quests currently uses an unusual SNBT format, where \n, instead of ,, is used as delimiter. So the syntax-highlighter will interpret such file as:
image

@Tnze
Copy link
Owner

Tnze commented Mar 6, 2024

What is FTB Quests?

@ZZZank
Copy link
Author

ZZZank commented Mar 6, 2024

It's a mod for writing quests. https://www.curseforge.com/minecraft/mc-mods/ftb-quests-forge

I opened an issue suggesting them to switch to standard SNBT not long ago, but no reply yet.

@Subilan
Copy link

Subilan commented Jun 2, 2024

Would like to request the same. Configuring FTB Ranks & FTB Essentials now. They are still using \n as delimeter, so the syntax highlighing is still broken. I cannot find an alternative plugin of VSC for SNBT highlighting either.

@Tnze
Copy link
Owner

Tnze commented Jun 2, 2024

👉👈

@ZZZank
Copy link
Author

ZZZank commented Jun 2, 2024

I tried to add \n to delimiters myself, and it turns out to be incredibly simple. Syntax highlighting for non-standard SNBT can be on pair with the one for standard SNBT with only one change. See ZZZank@c8a373f

there's a real-world example, showing syntax highlighting for an SNBT file that uses both , and \n as delimiter:
image

@Subilan
Copy link

Subilan commented Jun 2, 2024

@ZZZank Awesome. Seems like you find where the regex about delimiter at. But is it real SNBT can use two different delimiters at the same time? Is there any plan to make a pull request of your commit on the author's branch so that a new version of the extension can be released?

@Tnze
Copy link
Owner

Tnze commented Jun 2, 2024

@ZZZank Would you like to make a PR for this feature?

And I think it needs to be controlled by an option, which is disabled by default.

@ZZZank
Copy link
Author

ZZZank commented Jun 3, 2024

But is it real SNBT can use two different delimiters at the same time?

This is apparently not standard, but some popular SNBT parsers (like the one embedded in FTB Library) actually do support using \n as delimiter, because no one in the right mind will intentionally split a string or number using \n

And I think it needs to be controlled by an option, which is disabled by default.

Indeed better than always accepting \n, but I'm not sure if it can be implemented, I've not yet found a way of doing so.

@ZZZank ZZZank linked a pull request Jun 3, 2024 that will close this issue
@Subilan
Copy link

Subilan commented Jun 3, 2024

I think an option is not so necessary, as we can already use the two delimiters freely now. But there still can be a boolean option to determine which of , and \n should be used as delimiter, which avoids hybrid use of them.

These two is quite enough (and thanks to FTB we've got two now) and further customization of delimiter should be avoided as we all don't want to see SNBT to be the unique file format allowing using random delimiter.

@Tnze
Copy link
Owner

Tnze commented Jun 3, 2024

Indeed better than always accepting \n, but I'm not sure if it can be implemented, I've not yet found a way of doing so.

As a reference, vscode support a format named "JSON (with comments)" as a supplement of standard JSON. I believe the non-standard NBT should be regard as language other than the standard one.

@Subilan
Copy link

Subilan commented Jun 3, 2024

I believe the non-standard NBT should be regard as language other than the standard one.

At present I think SNBT is too narrowly used to be split into two languages. While FTB team's usage of SNBT is not considered standard, since their mods are somehow widely used among mod servers, I think their standard should be accepted temporarily so that configuring FTB mods won't be colorless. As @ZZZank said they hadn't replied to the request of changing the delimiter to , so...

@Tnze
Copy link
Owner

Tnze commented Jun 3, 2024

I think their standard should be accepted temporarily so that configuring FTB mods won't be colorless. As @ZZZank said they hadn't replied to the request of changing the delimiter to , so...

But on the other hand, if we accept both , and \n, someone who is working on standard SNBT will be unable to know they are forgetting to add , as the delimiter by visualization effects.

@Subilan
Copy link

Subilan commented Jun 3, 2024

But on the other hand, if we accept both , and \n, someone who is working on standard SNBT will be unable to know they are forgetting to add , as the delimiter by visualization effects.

Yes, that's right. In this case, adding an option to avoid hybrid use of two delimiters becomes necessary. See my previous reply:

But there still can be a boolean option to determine which of , and \n should be used as delimiter, which avoids hybrid use of them.

@Tnze
Copy link
Owner

Tnze commented Jun 3, 2024

Yes, that's right. In this case, adding an option to avoid hybrid use of two delimiters becomes necessary.

We can't implement this due to current technical limitations. Unless we split it into two languages. Or we write a language server instead.

I think provide a second language in the extension is the best solution.

@ZZZank
Copy link
Author

ZZZank commented Sep 7, 2024

Hi again, I've implemented seperate supports for Vanilla and FTB style SNBT support in #5

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 a pull request may close this issue.

3 participants