summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/prettier_standard.vim
blob: c8c09e31b3b60d448835205e83eb823acedf2a2c (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
" Author: sheerun (Adam Stankiewicz) <sheerun@sher.pl>
" Description: Integration of Prettier Standard with ALE.

call ale#Set('javascript_prettier_standard_executable', 'prettier-standard')
call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_prettier_standard_options', '')

function! ale#fixers#prettier_standard#GetExecutable(buffer) abort
    return ale#path#FindExecutable(a:buffer, 'javascript_prettier_standard', [
    \   'node_modules/prettier-standard/lib/index.js',
    \   'node_modules/.bin/prettier-standard',
    \])
endfunction

function! ale#fixers#prettier_standard#Fix(buffer) abort
    let l:options = ale#Var(a:buffer, 'javascript_prettier_standard_options')

    return {
    \   'command': ale#Escape(ale#fixers#prettier_standard#GetExecutable(a:buffer))
    \       . ' --stdin'
    \       . ' --stdin-filepath=%s'
    \       . ' ' . l:options,
    \}
endfunction