Add jq as a JSON fixer
This commit is contained in:
parent
038789f0ed
commit
d562d53102
5 changed files with 53 additions and 2 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue