Skip to content
/ vim-json Public
forked from qmx/vim-json

Customization on Jeroen Ruigrok van der Werven's vim-json highlighting script. Pathogen friendly.

Notifications You must be signed in to change notification settings

frink/vim-json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Better JSON for VIM

Customization of Jeroen Ruigrok van der Werven's vim-json highlighting script. Pathogen-friendly.

Specific customizations

  • Added distinct highlighting for keywords! (This is what made me start this plugin.)
  • Added syntax highlighting warning for decimals smaller than 1 that don't start with a 0 (so .1 gives a warning, it should be 0.1).
  • Added syntax highlighting warning for comments and semicolons.
  • Added folding of {...} and [...] blocks. To enable it :setlocal foldmethod=syntax (do it permanently on the ftplugin/json.vim file).
  • Added concealing of double quotes, for a minimalist CoffeScript-inspired look.
    • This requires Vim 7.3+. To disable it :setlocal conceallevel=0 (do it permanently on the ftplugin/json.vim file).

Screenshots

No syntax coloring: wall of text.
No syntax coloring

Javascript (or for that matter, json.vim) syntax coloring: Not much improvement from no syntax coloring.
Javascript syntax coloring

Better JSON syntax coloring: a more meaningful, distinct and elegant presentation.
JSON syntax coloring

Why use separate JSON highlighting instead of just Javascript?

Here's 2 compelling reasons:

  1. All JSON is Javascript but NOT all Javascript is JSON. So {property:1} is invalid because property does not have double quotes around it. {'property':1} is also invalid, because it's single quoted while the only thing that can placate JSON is double quoting. JSON is even fuzzy enough that {"property":.1} is invalid, because you should have of course written {"property":0.1}. Also, don't even think about having comments or semicolons, you guessed it: they're invalid. The point being that your syntax highlighter should warn you about these errors, in realtime, which is something that the Javascript highlighter doesn't (because in Javacript they're not errors!).

  2. Distinct highlighting for keywords. JSON is an extremely lightweight data format but at it's core lies an inescapable conceptual distinction: there are keywords and then there are values. There's nothing much to the format besides that, so we might as well display keywords and values differently. This is something that gets lost with Javascript-inspired syntax highlighters, which see keywords as just another string since JSON requires them double quoted. . JSON files become an impenetrable, indistinct wall of text.

About

Customization on Jeroen Ruigrok van der Werven's vim-json highlighting script. Pathogen friendly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published