Initialize rubocop variables in one place

This commit is contained in:
w0rp 2017-07-06 22:47:07 +01:00
parent e9a1cd600a
commit acda19776a
3 changed files with 9 additions and 31 deletions

View file

@ -1,22 +1,8 @@
" Author: ynonp - https://github.com/ynonp " Author: ynonp - https://github.com/ynonp
" Description: rubocop for Ruby files " 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 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$' let l:exec_args = l:executable =~? 'bundle$'
\ ? ' exec rubocop' \ ? ' exec rubocop'
\ : '' \ : ''
@ -52,7 +38,7 @@ endfunction
call ale#linter#Define('ruby', { call ale#linter#Define('ruby', {
\ 'name': 'rubocop', \ 'name': 'rubocop',
\ 'executable_callback': 'ale_linters#ruby#rubocop#GetExecutable', \ 'executable_callback': 'ale#handlers#rubocop#GetExecutable',
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand', \ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
\ 'callback': 'ale_linters#ruby#rubocop#Handle', \ 'callback': 'ale_linters#ruby#rubocop#Handle',
\}) \})

View file

@ -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 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$' let l:exec_args = l:executable =~? 'bundle$'
\ ? ' exec rubocop' \ ? ' exec rubocop'
\ : '' \ : ''

View file

@ -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