summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/fixjson.vim
blob: 43eb063299695e2a4f934b8b166ef0fff42d3e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
" 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', '')
call ale#Set('json_fixjson_use_global', 0)

function! ale#fixers#fixjson#GetExecutable(buffer) abort
    return ale#node#FindExecutable(a:buffer, 'json_fixjson', [
    \   'node_modules/.bin/fixjson',
    \])
endfunction

function! ale#fixers#fixjson#Fix(buffer) abort
    let l:executable = ale#Escape(ale#fixers#fixjson#GetExecutable(a:buffer))
    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