diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index f8b0725..9b77f89 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -1,22 +1,8 @@ " Author: ynonp - https://github.com/ynonp " Description: rubocop for Ruby files -" Set this option to change Rubocop options. -if !exists('g:ale_ruby_rubocop_options') - " let g:ale_ruby_rubocop_options = '--lint' - let g:ale_ruby_rubocop_options = '' -endif - -if !exists('g:ale_ruby_rubocop_executable') - let g:ale_ruby_rubocop_executable = 'rubocop' -endif - -function! ale_linters#ruby#rubocop#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'ruby_rubocop_executable') -endfunction - function! ale_linters#ruby#rubocop#GetCommand(buffer) abort - let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') + let l:executable = ale#handlers#rubocop#GetExecutable(a:buffer) let l:exec_args = l:executable =~? 'bundle$' \ ? ' exec rubocop' \ : '' @@ -52,7 +38,7 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'rubocop', -\ 'executable_callback': 'ale_linters#ruby#rubocop#GetExecutable', +\ 'executable_callback': 'ale#handlers#rubocop#GetExecutable', \ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand', \ 'callback': 'ale_linters#ruby#rubocop#Handle', \}) diff --git a/autoload/ale/fixers/rubocop.vim b/autoload/ale/fixers/rubocop.vim index 7bc6c9e..3f92055 100644 --- a/autoload/ale/fixers/rubocop.vim +++ b/autoload/ale/fixers/rubocop.vim @@ -1,19 +1,5 @@ -" Set this option to change Rubocop options. -if !exists('g:ale_ruby_rubocop_options') - " let g:ale_ruby_rubocop_options = '--lint' - let g:ale_ruby_rubocop_options = '' -endif - -if !exists('g:ale_ruby_rubocop_executable') - let g:ale_ruby_rubocop_executable = 'rubocop' -endif - -function! ale#fixers#rubocop#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'ruby_rubocop_executable') -endfunction - function! ale#fixers#rubocop#GetCommand(buffer) abort - let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') + let l:executable = ale#handlers#rubocop#GetExecutable(a:buffer) let l:exec_args = l:executable =~? 'bundle$' \ ? ' exec rubocop' \ : '' diff --git a/autoload/ale/handlers/rubocop.vim b/autoload/ale/handlers/rubocop.vim new file mode 100644 index 0000000..f6367cf --- /dev/null +++ b/autoload/ale/handlers/rubocop.vim @@ -0,0 +1,6 @@ +call ale#Set('ruby_rubocop_options', '') +call ale#Set('ruby_rubocop_executable', 'rubocop') + +function! ale#handlers#rubocop#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'ruby_rubocop_executable') +endfunction