Pass extra rubocop options in the middle instead, and fix the Vader test so it can be run multiple times in Vim

This commit is contained in:
w0rp 2017-08-10 14:57:30 +01:00
parent 0c26e8945c
commit 34aa3437e0
2 changed files with 9 additions and 5 deletions

View File

@ -4,11 +4,12 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort
\ ? ' exec rubocop' \ ? ' exec rubocop'
\ : '' \ : ''
let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
let l:options = ale#Var(a:buffer, 'ruby_rubocop_options')
return ale#Escape(l:executable) . l:exec_args return ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --auto-correct %t' \ . ' --auto-correct %t'
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
endfunction endfunction

View File

@ -1,8 +1,10 @@
Before: Before:
Save g:ale_ruby_rubocop_executable Save g:ale_ruby_rubocop_executable
Save g:ale_ruby_rubocop_options
" Use an invalid global executable, so we don't match it. " Use an invalid global executable, so we don't match it.
let g:ale_ruby_rubocop_executable = 'xxxinvalid' let g:ale_ruby_rubocop_executable = 'xxxinvalid'
let g:ale_ruby_rubocop_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers') call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd .. silent cd ..
@ -46,6 +48,7 @@ Execute(The rubocop callback should include custom rubocop options):
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml') \ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml')
\ . ' --auto-correct %t --except Lint/Debugger', \ . ' --except Lint/Debugger'
\ . ' --auto-correct %t',
\ }, \ },
\ ale#fixers#rubocop#Fix(bufnr('')) \ ale#fixers#rubocop#Fix(bufnr(''))