Skip to content

🐏 JSON syntax highlighting for (Neo)Vim with support for comments.

License

Notifications You must be signed in to change notification settings

cheap-glitch/vim-json-with-comments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐏 vim-json-with-comments

License Latest release

This is a fork of vim-json that adds support for C-style comments inside JSON files.

Features

  • 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

Installation

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'

Usage

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).

Options

Configure the plugin by setting some global variables in your .vimrc / init.vim:

  • g:vim_json_warnings: set to 1 to highlight syntax errors in red, 0 not to (default: 1)

  • g:vim_json_comments: set to 1 to always enable comments for every JSON file, 0 to disable them everywhere (default: 0)

  • g:vim_json_spellcheck_only_comments: set to 1 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.

Quote concealing

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

Contributing

Contributions are welcomed! Please open an issue before submitting substantial changes.

Acknowledgments

This plugin is largely based on the work of Eli Parra. Many thanks to him!

Related

License

ISC

About

🐏 JSON syntax highlighting for (Neo)Vim with support for comments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project