This is a fork of vim-json that adds support for C-style comments inside JSON files.
- All the goodness of
vim-json
: precise highlighting, warnings for syntax errors, quote concealing, syntactic folding, etc. - Support for single-line (
//
) and multi-line comments (/**/
) - Smart file-by-file enabling of comments and spellchecking
The recommended way of installing plugins in (Neo)Vim is through a plugin manager.
With dein.vim:
dein#add('cheap-glitch/vim-json-with-comments')
With vim-plug:
Plug 'cheap-glitch/vim-json-with-comments'
This plugin is meant to be used as a drop-in replacement for vim-json
.
By default, comments will be enabled in a JSON file only if there is already
at least one valid comment in it. Otherwise it will act the same as
vim-json
, i.e. highlight newly entered comments as errors (provided the
vim_json_warnings
option is enabled, which it is by default).
Configure the plugin by setting some global variables in your .vimrc
/
init.vim
:
-
g:vim_json_warnings
: set to1
to highlight syntax errors in red,0
not to (default:1
) -
g:vim_json_comments
: set to1
to always enable comments for every JSON file,0
to disable them everywhere (default:0
) -
g:vim_json_spellcheck_only_comments
: set to1
to limit spellchecking to comments,0
to spellcheck the whole file (default:0
)
Example:
let g:vim_json_warnings = 0
let g:vim_json_comments = 1
let g:vim_json_spellcheck_only_comments = 1
Every one of these settings can be manually overridden in the current buffer by setting local buffer variables during the editing process, e.g.
:let b:vim_json_comments=0<CR>
and then reloading the current buffer with :e
.
To enable quote concealing, set the conceallevel
option to 2
.
" To enable it everywhere:
set conceallevel=2
" To enable it only for JSON files:
autocmd FileType json setlocal conceallevel=2
Contributions are welcomed! Please open an issue before submitting substantial changes.
This plugin is largely based on the work of Eli Parra. Many thanks to him!
jsonc
β Node.js module to parse JSON with commentsnode-jsonc-parser
β Node.js module to parse and manipulate JSONCstrip-json-comments
β Node.js module to remove comments from JSON data
ISC