diff --git a/README.md b/README.md index c42f4bf..6ac88cc 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ formatting. | Idris | [idris](http://www.idris-lang.org/) | | Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format) | | JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo) -| JSON | [jsonlint](http://zaa.ch/jsonlint/), [prettier](https://github.com/prettier/prettier) | +| JSON | [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) | | Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions | | LaTeX | [alex](https://github.com/wooorm/alex) !!, [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | | Less | [lessc](https://www.npmjs.com/package/less), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) | diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 4b69240..2e8e6e0 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -159,6 +159,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['java'], \ 'description': 'Fix Java files with google-java-format.', \ }, +\ 'jq': { +\ 'function': 'ale#fixers#jq#Fix', +\ 'suggested_filetypes': ['json'], +\ 'description': 'Fix JSON files with jq.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/jq.vim b/autoload/ale/fixers/jq.vim new file mode 100644 index 0000000..4604b24 --- /dev/null +++ b/autoload/ale/fixers/jq.vim @@ -0,0 +1,18 @@ +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_use_global', 0) +call ale#Set('json_jq_options', '') + +function! ale#fixers#jq#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'jq', [ + \ 'jq', + \]) +endfunction + +function! ale#fixers#jq#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'json_jq_options') + + return { + \ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer)) + \ . ' . ' . l:options, + \} +endfunction diff --git a/doc/ale-json.txt b/doc/ale-json.txt index 1d052d5..92c4609 100644 --- a/doc/ale-json.txt +++ b/doc/ale-json.txt @@ -8,6 +8,33 @@ jsonlint *ale-json-jsonlint* There are no options available. +=============================================================================== +jq *ale-json-jq* + +g:ale_json_jq_executable *g:ale_json_jq_executable* + *b:ale_json_jq_executable* + Type: |String| + Default: `'jq'` + + See |ale-integrations-local-executables| + + +g:ale_json_jq_use_global *g:ale_json_jq_use_global* + *b:ale_json_jq_use_global* + Type: |Number| + Default: `0` + + See |ale-integrations-local-executables| + + +g:ale_json_jq_options *g:ale_json_jq_options* + *b:ale_json_jq_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jq`. + + =============================================================================== prettier *ale-json-prettier* diff --git a/doc/ale.txt b/doc/ale.txt index 4776568..f25e884 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -113,6 +113,7 @@ CONTENTS *ale-contents* xo..................................|ale-javascript-xo| json..................................|ale-json-options| jsonlint............................|ale-json-jsonlint| + jq..................................|ale-json-jq| prettier............................|ale-json-prettier| kotlin................................|ale-kotlin-options| kotlinc.............................|ale-kotlin-kotlinc| @@ -321,7 +322,7 @@ Notes: * Idris: `idris` * Java: `checkstyle`, `javac`, `google-java-format` * JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo` -* JSON: `jsonlint`, `prettier` +* JSON: `jsonlint`, `jq`, `prettier` * Kotlin: `kotlinc`, `ktlint` * LaTeX (tex): `alex`!!, `chktex`, `lacheck`, `proselint`, `redpen`, `vale`, `write-good` * Less: `lessc`, `prettier`, `stylelint`