summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/jq.vim
blob: cd9b9138b07abed492e699517783505e8bbfba09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
call ale#Set('json_jq_executable', 'jq')
call ale#Set('json_jq_options', '')
call ale#Set('json_jq_filters', '.')

function! ale#fixers#jq#GetExecutable(buffer) abort
    return ale#Var(a:buffer, 'json_jq_executable')
endfunction

function! ale#fixers#jq#Fix(buffer) abort
    let l:options = ale#Var(a:buffer, 'json_jq_options')
    let l:filters = ale#Var(a:buffer, 'json_jq_filters')

    if empty(l:filters)
        return 0
    endif

    return {
    \  'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer))
    \      . ' ' . l:filters . ' '
    \      . l:options,
    \}
endfunction