[vim/vim] Native support for JSON5/JSONC in Vim (#8499)

443 views
Skip to first unread message

Izhak Jakov

unread,
Jul 1, 2021, 9:02:36 PM7/1/21
to vim/vim, Subscribed

  • nvim --version: 0.4.4
  • vim -u DEFAULTS (version: 8.2) behaves differently? No
  • Operating system/version: Linux 5.10.0-6-amd64
  • Terminal name/version: Alacritty 0.8.0
  • $TERM: xterm-256color

I see more and more tools using jsonc and json5 formats for their configuration files. I believe this trend will only increase as NeoVIM should consider supporting this formats

jsonc

Basically a JSON with C-style line (//) and block (/**/) comments.
Exiting vim plugin: https://github.com/kevinoid/vim-jsonc

json5

Described as a json for humans.
Here is the specifications: https://spec.json5.org
Existing vim plugin for it already: https://github.com/gutenye/json5.vim

Steps to reproduce using nvim -u NORC

$ nvim -u NORC sample.jsonc
<opened as a plain text>

$ nvim -u NORC sample.json5
<opened as a plain text>

Actual behaviour

opens up as a plain text

Expected behaviour

Opened as a jsonc/json5 file:

  • proper syntax highlighting
  • proper error messages
  • proper indentation and formatting


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Izhak Jakov

unread,
Jul 1, 2021, 9:04:05 PM7/1/21
to vim/vim, Subscribed

Please add labels: syntax, runtime

Izhak Jakov

unread,
Jul 1, 2021, 9:05:14 PM7/1/21
to vim/vim, Subscribed

I already created a JSONC indent and syntax files. I'll for and push changes to my fork then link it here.

K.Takata

unread,
Jul 1, 2021, 10:55:44 PM7/1/21
to vim/vim, Subscribed

If you're talking about Neovim, you should report there.

Izhak Jakov

unread,
Jul 1, 2021, 11:35:00 PM7/1/21
to vim/vim, Subscribed

I tested it on both

Izhak Jakov

unread,
Jul 1, 2021, 11:37:24 PM7/1/21
to vim/vim, Subscribed

Izhak Jakov

unread,
Jul 1, 2021, 11:45:21 PM7/1/21
to vim/vim, Subscribed

PR for VIM: #8500

Bram Moolenaar

unread,
Jul 2, 2021, 4:19:15 PM7/2/21
to vim/vim, Subscribed

there is no need for an issue when there is a pull request.

Bram Moolenaar

unread,
Jul 2, 2021, 4:19:17 PM7/2/21
to vim/vim, Subscribed

Closed #8499.

Izhak Jakov

unread,
Jul 3, 2021, 9:28:57 AM7/3/21
to vim/vim, Subscribed

At the moment only changes to support jsonc have will be committed in PR #8500
I am looking into adding native support for json5 as well.

Rolf Vidar Mazunki Hoksaas

unread,
Oct 2, 2023, 9:06:19 PM10/2/23
to vim/vim, Subscribed

Is there any particular reason why we don't simply copy the linked plugin to support json5? Is there something missing in it, or any reason to not include json5 upstream?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1744001853@github.com>

Christian Brabandt

unread,
Oct 3, 2023, 2:27:01 AM10/3/23
to vim/vim, Subscribed

what plugin you are talking about? As far as I can see, the linked PR was included. So is there anything missing?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1744287484@github.com>

Rolf Vidar Mazunki Hoksaas

unread,
Oct 3, 2023, 7:40:45 AM10/3/23
to vim/vim, Subscribed

I'm talking about the json5 plugin (https://github.com/gutenye/json5.vim). The PR which was included adds support for jsonc. While similar, jsonc lacks support for trailing commas, newlines in strings, hexadecimal numbers... which json5 supports.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1744788116@github.com>

Christian Brabandt

unread,
Oct 3, 2023, 8:28:11 AM10/3/23
to vim/vim, Subscribed

Have you checked with the maintainers, if they are okay including the plugin with Vim? @IzhakJakov have you considered adding json5 support as mentioned above


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1744865037@github.com>

Izhak Jakov

unread,
Oct 4, 2023, 3:49:51 PM10/4/23
to vim/vim, Subscribed

json5 seems to be a better version of jsonc I would suggest using the plugin for both. I currently use treesitter for syntax highlighting so maybe should be removed from the vim runtime version.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1747536184@github.com>

mike-clark-8192

unread,
Dec 8, 2023, 8:12:03 AM12/8/23
to vim/vim, Subscribed

jsonc and json5 are distinct enough that I'd like to see support for both. jsonc is widely used throughout VSCode and orbiting technologies like TypeScript (example: tsconfig.json). I don't think json5 is as widely deployed as jsonc at this time. But, json5 is a better spec -- not least of which because it actually has a spec. All jsonc has is a defacto reference implementation.

I would like to see a bundled jsonc.vim have a configuration option to allow trailing commas, like node-jsonc-parser has. That parser has support for it turned off by default, but you can flip a boolean to support it.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1847145271@github.com>

Rolf Vidar Mazunki Hoksaas

unread,
Dec 8, 2023, 9:14:52 AM12/8/23
to vim/vim, Subscribed

@mike-clark-8192 jsonc has been available for a while. json5 was merged recently, it should be available if you use a HEAD version of vim or neovim.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8499/1847233026@github.com>

Reply all
Reply to author
Forward
0 new messages