summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/tidy.vim
blob: 2c79e73a99acbdc153ce753e1cda90fac97b48d9 (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
" Author: meain <abinsimon10@gmail.com>
" Description: Fixing HTML files with tidy.

call ale#Set('html_tidy_executable', 'tidy')
call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale#fixers#tidy#Fix(buffer) abort
    let l:executable = ale#path#FindExecutable(
    \   a:buffer,
    \   'html_tidy',
    \   ['tidy'],
    \)

    if !executable(l:executable)
        return 0
    endif

    let l:config = ale#path#FindNearestFile(a:buffer, '.tidyrc')
    let l:config_options = !empty(l:config)
    \   ? ' -q --tidy-mark no --show-errors 0 --show-warnings 0 -config ' . ale#Escape(l:config)
    \   : ' -q --tidy-mark no --show-errors 0 --show-warnings 0'

    return {
    \   'command': ale#Escape(l:executable) . l:config_options,
    \}
endfunction