Fix #1168 - Make the ruby linter executable configurable

This commit is contained in:
w0rp 2017-11-28 09:47:04 +00:00
parent bba6b4c23c
commit 4e821e64c7
4 changed files with 54 additions and 5 deletions

View File

@ -1,10 +1,22 @@
" Author: Brandon Roehl - https://github.com/BrandonRoehl
" Description: Ruby MRI for Ruby files
call ale#Set('ruby_ruby_executable', 'ruby')
function! ale_linters#ruby#ruby#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'ruby_ruby_executable')
endfunction
function! ale_linters#ruby#ruby#GetCommand(buffer) abort
let l:executable = ale_linters#ruby#ruby#GetExecutable(a:buffer)
return ale#Escape(l:executable) . ' -w -c -T1 %t'
endfunction
call ale#linter#Define('ruby', {
\ 'name': 'ruby',
\ 'executable': 'ruby',
\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable',
\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand',
\ 'output_stream': 'stderr',
\ 'command': 'ruby -w -c -T1 %t',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})

View File

@ -58,10 +58,10 @@ g:ale_ruby_reek_show_wiki_link *g:ale_ruby_reek_show_wiki_link*
===============================================================================
rubocop *ale-ruby-rubocop*
g:ale_ruby_rubocop_executable g:ale_ruby_rubocop_executable
b:ale_ruby_rubocop_executable
g:ale_ruby_rubocop_executable *g:ale_ruby_rubocop_executable*
*b:ale_ruby_rubocop_executable*
Type: String
Default: 'rubocop'
Default: `'rubocop'`
Override the invoked rubocop binary. This is useful for running rubocop
from binstubs or a bundle.
@ -75,5 +75,16 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options*
This variable can be change to modify flags given to rubocop.
===============================================================================
ruby *ale-ruby-ruby*
g:ale_ruby_ruby_executable *g:ale_ruby_ruby_executable*
*b:ale_ruby_ruby_executable*
Type: String
Default: `'ruby'`
This variable can be changed to use a different executable for ruby.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -170,6 +170,7 @@ CONTENTS *ale-contents*
rails_best_practices................|ale-ruby-rails_best_practices|
reek................................|ale-ruby-reek|
rubocop.............................|ale-ruby-rubocop|
ruby................................|ale-ruby-ruby|
rust..................................|ale-rust-options|
cargo...............................|ale-rust-cargo|
rls.................................|ale-rust-rls|

View File

@ -0,0 +1,25 @@
Before:
Save g:ale_ruby_ruby_executable
unlet! g:ale_ruby_ruby_executable
runtime ale_linters/ruby/ruby.vim
After:
Restore
call ale#linter#Reset()
Execute(The default command should be correct):
AssertEqual 'ruby', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('ruby') . ' -w -c -T1 %t',
\ ale_linters#ruby#ruby#GetCommand(bufnr(''))
Execute(The executable should be configurable):
let g:ale_ruby_ruby_executable = 'foobar'
AssertEqual 'foobar', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foobar') . ' -w -c -T1 %t',
\ ale_linters#ruby#ruby#GetCommand(bufnr(''))