Add JSON formatting using js-beautify

This commit is contained in:
Shane Smith 2014-06-29 15:15:10 -04:00
parent 492cad1620
commit 666291341b
2 changed files with 6 additions and 1 deletions

View File

@ -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. 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. 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`. It can be installed by running `npm install -g js-beautify`.
Note that `nodejs` is needed for this to work. Note that `nodejs` is needed for this to work.
Here is the link to the repository: https://github.com/einars/js-beautify. Here is the link to the repository: https://github.com/einars/js-beautify.

View File

@ -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") if !exists("g:formatprg_args_expr_javascript") && !exists("g:formatprg_args_javascript")
let g:formatprg_args_expr_javascript = '"-f - -".(&expandtab ? "s ".&shiftwidth : "t")' let g:formatprg_args_expr_javascript = '"-f - -".(&expandtab ? "s ".&shiftwidth : "t")'
endif 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