summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/yamlfix.vim
blob: 6654a25cd86acfbdb5147e94afec1b567a893114 (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
" Author: lyz-code
" Description: Fixing yaml files with yamlfix.

call ale#Set('yaml_yamlfix_executable', 'yamlfix')
call ale#Set('yaml_yamlfix_options', '')
call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale#fixers#yamlfix#Fix(buffer) abort
    let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options')
    let l:executable = ale#python#FindExecutable(
    \   a:buffer,
    \   'yaml_yamlfix',
    \   ['yamlfix'],
    \)

    if !executable(l:executable)
        return 0
    endif

    return {
    \   'cwd': '%s:h',
    \   'command': ale#Escape(l:executable)
    \       . (!empty(l:options) ? ' ' . l:options : '') . ' -',
    \}
endfunction