diff options
author | rhysd <lin90162@yahoo.co.jp> | 2018-01-24 10:36:02 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-01-24 10:36:31 +0000 |
commit | b28a6ddbe4cf573ea993288a6ad4db569d535adf (patch) | |
tree | b1ed7770efb8122d85921aa43c18f069819eeeaa /autoload | |
parent | d562d531024a2a2210fdf08594639a0b068bacce (diff) | |
download | ale-b28a6ddbe4cf573ea993288a6ad4db569d535adf.zip |
Support fixing JSON files with fixjson
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/fixjson.vim | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 2e8e6e06..2d0b4a53 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.', \ }, +\ 'fixjson': { +\ 'function': 'ale#fixers#fixjson#Fix', +\ 'suggested_filetypes': ['json'], +\ 'description': 'Fix JSON files with fixjson.', +\ }, \ 'jq': { \ 'function': 'ale#fixers#jq#Fix', \ 'suggested_filetypes': ['json'], diff --git a/autoload/ale/fixers/fixjson.vim b/autoload/ale/fixers/fixjson.vim new file mode 100644 index 00000000..84728f24 --- /dev/null +++ b/autoload/ale/fixers/fixjson.vim @@ -0,0 +1,20 @@ +" Author: rhysd <https://rhysd.github.io> +" Description: Integration of fixjson with ALE. + +call ale#Set('json_fixjson_executable', 'fixjson') +call ale#Set('json_fixjson_options', '') + +function! ale#fixers#fixjson#Fix(buffer) abort + let l:executable = ale#Escape(ale#Var(a:buffer, 'json_fixjson_executable')) + let l:filename = ale#Escape(bufname(a:buffer)) + let l:command = l:executable . ' --stdin-filename ' . l:filename + + let l:options = ale#Var(a:buffer, 'json_fixjson_options') + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return { + \ 'command': l:command + \} +endfunction |