Add jq as a JSON fixer
This commit is contained in:
parent
038789f0ed
commit
d562d53102
5 changed files with 53 additions and 2 deletions
|
@ -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) |
|
||||
|
|
|
@ -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.
|
||||
|
|
18
autoload/ale/fixers/jq.vim
Normal file
18
autoload/ale/fixers/jq.vim
Normal file
|
@ -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
|
|
@ -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*
|
||||
|
||||
|
|
|
@ -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`
|
||||
|
|
Reference in a new issue