Skip to content

syntax/json: Add comment support to the syntax highlighting#3434

Merged
JoeKar merged 2 commits intomicro-editor:masterfrom
JoeKar:feature/json-comments
Aug 19, 2024
Merged

syntax/json: Add comment support to the syntax highlighting#3434
JoeKar merged 2 commits intomicro-editor:masterfrom
JoeKar:feature/json-comments

Conversation

@JoeKar
Copy link
Member

@JoeKar JoeKar commented Aug 19, 2024

This feature already has a quite long story:

Since micro already uses json5 to parse his own internal json configurations and we changed the default behavior of the comment plugin to set // as the default comment type within json via #3388 it's just a logical step to highlight it correctly in json's (reused #2736). It was and it will be up to the user if he/she places comments with micro in json, because he/she should know if the file is parsed with a json5 parser or not.
Especially since #3343 it's much more easy to edit micro's own configurations in micro itself by just reloading the changed files. As long as set, reset, bind and unbind (hopefully I didn't forget anything) isn't used micro doesn't rewrite the settings by his own and the comments are kept.

Additionally we can think about adding hjson (#2203) and jsonc (#2704) to the same json syntax definition, instead of creating new file types. The latter one is arguable, since via syntax includes it's also easy to extend/override definitions.

@JoeKar
Copy link
Member Author

JoeKar commented Aug 19, 2024

Adding hjson to json seems to go too far, since # (supported as comment in hjson) is not allowed by a json5 parser. So #2203 is still valid, but can be reduced afterwards.
Most probably it's the same for jsonc, which allows unquoted values.

For now we keep the PR as is and maybe consider the rest afterwards.

@JoeKar JoeKar merged commit cc195b6 into micro-editor:master Aug 19, 2024
@JoeKar JoeKar deleted the feature/json-comments branch August 19, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants