From 666291341b38a07830443a22a9dfd9887de0c86a Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Sun, 29 Jun 2014 15:15:10 -0400 Subject: [PATCH] Add JSON formatting using js-beautify --- README.md | 2 +- plugin/defaults.vim | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d1cadc..95999f6 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ For Ubuntu type `sudo apt-get install autopep8` in a terminal. Here is the link to the repository: https://github.com/hhatto/autopep8. And here the link to its page on the python website: http://pypi.python.org/pypi/autopep8/0.5.2. -* `js-beautify` for __Javascript__. +* `js-beautify` for __Javascript__ and __JSON__. It can be installed by running `npm install -g js-beautify`. Note that `nodejs` is needed for this to work. Here is the link to the repository: https://github.com/einars/js-beautify. diff --git a/plugin/defaults.vim b/plugin/defaults.vim index feff214..d7c4973 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -47,3 +47,8 @@ if !exists("g:formatprg_javascript") | let g:formatprg_javascript = "js-beautify if !exists("g:formatprg_args_expr_javascript") && !exists("g:formatprg_args_javascript") let g:formatprg_args_expr_javascript = '"-f - -".(&expandtab ? "s ".&shiftwidth : "t")' endif + +if !exists("g:formatprg_json") | let g:formatprg_json = "js-beautify" | endif +if !exists("g:formatprg_args_expr_json") && !exists("g:formatprg_args_json") + let g:formatprg_args_expr_json = '"-f - -".(&expandtab ? "s ".&shiftwidth : "t")' +endif