JSON with Comments for Vim
Vim syntax highlighting plugin for JSON with C-style
line (//
) and block (/* */
) comments.
It defines a filetype named jsonc
(matching the name used in VS
Code,
a Microsoft parser library,
.mocharc.jsonc, and the jsonc
npm package) which can be applied to
files using set ft=jsonc
or a
modeline.
Installation
This plugin can be installed in the usual ways:
Vim Packages
Usinggit pull https://github.com/kevinoid/vim-jsonc.git ~/.vim/pack/git-plugins/start/vim-jsonc
Pathogen
Usinggit pull https://github.com/kevinoid/vim-jsonc.git ~/.vim/bundle/vim-jsonc
Vundle
UsingAdd the following to .vimrc
:
Plugin 'kevinoid/vim-jsonc'
Then run :PluginInstall
.
vim-plug
UsingAdd the following to .vimrc
between plug#begin()
and plug#end()
:
Plug 'kevinoid/vim-jsonc'
Implementation
This plugin loads the JSON syntax plugin, clears the syntax group for comments as errors, then defines additional syntax to match C-style comments.
This project was inspired by, and the code is based on, elzr/vim-json#61 by @TheLocehiliosan.
Contributing
Contributions are appreciated! Please add tests where possible and ensure
./run-tests.sh
passes.
If the desired change is large, complex, backwards-incompatible, can have significantly differing implementations, or may not be in scope for this project, opening an issue before writing the code can avoid frustration and save a lot of time and effort.
License
This package is available under the terms of the MIT License.