diff options
author | Rafael Rinaldi <rafael@rinaldi.io> | 2018-01-24 10:12:29 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-01-24 10:12:29 +0000 |
commit | d562d531024a2a2210fdf08594639a0b068bacce (patch) | |
tree | 364e0ac2e9cf37171dd5e65cd67844fd3a08c4c3 /autoload | |
parent | 038789f0ed42cfffbd442a6a399cb2395591821d (diff) | |
download | ale-d562d531024a2a2210fdf08594639a0b068bacce.zip |
Add jq as a JSON fixer
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/jq.vim | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 4b692404..2e8e6e06 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 00000000..4604b24f --- /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 |