Initialize rubocop variables in one place
This commit is contained in:
parent
e9a1cd600a
commit
acda19776a
3 changed files with 9 additions and 31 deletions
|
@ -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',
|
||||
\})
|
||||
|
|
|
@ -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'
|
||||
\ : ''
|
||||
|
|
6
autoload/ale/handlers/rubocop.vim
Normal file
6
autoload/ale/handlers/rubocop.vim
Normal 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
|
Reference in a new issue