Support fixing JSON files with fixjson
This commit is contained in:
parent
d562d53102
commit
b28a6ddbe4
7 changed files with 118 additions and 2 deletions
|
@ -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'],
|
||||
|
|
20
autoload/ale/fixers/fixjson.vim
Normal file
20
autoload/ale/fixers/fixjson.vim
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue