summaryrefslogtreecommitdiff
path: root/autoload/ale/fixers/standardrb.vim
blob: acb310c6f48ca06746e3556198d3c7e396966b1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
" Author: Justin Searls - https://github.com/searls
" Description: Fix Ruby files with StandardRB.

call ale#Set('ruby_standardrb_options', '')
call ale#Set('ruby_standardrb_executable', 'standardrb')

function! ale#fixers#standardrb#GetCommand(buffer) abort
    let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable')
    let l:config = ale#path#FindNearestFile(a:buffer, '.standard.yml')
    let l:options = ale#Var(a:buffer, 'ruby_standardrb_options')

    return ale#ruby#EscapeExecutable(l:executable, 'standardrb')
    \   . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
    \   . (!empty(l:options) ? ' ' . l:options : '')
    \   . ' --fix --force-exclusion --stdin %s'
endfunction

function! ale#fixers#standardrb#Fix(buffer) abort
    return {
    \   'command': ale#fixers#standardrb#GetCommand(a:buffer),
    \   'process_with': 'ale#fixers#rubocop#PostProcess'
    \}
endfunction