Fix #1168 - Make the ruby linter executable configurable
This commit is contained in:
parent
bba6b4c23c
commit
4e821e64c7
@ -1,10 +1,22 @@
|
|||||||
" Author: Brandon Roehl - https://github.com/BrandonRoehl
|
" Author: Brandon Roehl - https://github.com/BrandonRoehl
|
||||||
" Description: Ruby MRI for Ruby files
|
" 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', {
|
call ale#linter#Define('ruby', {
|
||||||
\ 'name': 'ruby',
|
\ 'name': 'ruby',
|
||||||
\ 'executable': 'ruby',
|
\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'command': 'ruby -w -c -T1 %t',
|
|
||||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||||
\})
|
\})
|
||||||
|
@ -58,10 +58,10 @@ g:ale_ruby_reek_show_wiki_link *g:ale_ruby_reek_show_wiki_link*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
rubocop *ale-ruby-rubocop*
|
rubocop *ale-ruby-rubocop*
|
||||||
|
|
||||||
g:ale_ruby_rubocop_executable g:ale_ruby_rubocop_executable
|
g:ale_ruby_rubocop_executable *g:ale_ruby_rubocop_executable*
|
||||||
b:ale_ruby_rubocop_executable
|
*b:ale_ruby_rubocop_executable*
|
||||||
Type: String
|
Type: String
|
||||||
Default: 'rubocop'
|
Default: `'rubocop'`
|
||||||
|
|
||||||
Override the invoked rubocop binary. This is useful for running rubocop
|
Override the invoked rubocop binary. This is useful for running rubocop
|
||||||
from binstubs or a bundle.
|
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.
|
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:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
@ -170,6 +170,7 @@ CONTENTS *ale-contents*
|
|||||||
rails_best_practices................|ale-ruby-rails_best_practices|
|
rails_best_practices................|ale-ruby-rails_best_practices|
|
||||||
reek................................|ale-ruby-reek|
|
reek................................|ale-ruby-reek|
|
||||||
rubocop.............................|ale-ruby-rubocop|
|
rubocop.............................|ale-ruby-rubocop|
|
||||||
|
ruby................................|ale-ruby-ruby|
|
||||||
rust..................................|ale-rust-options|
|
rust..................................|ale-rust-options|
|
||||||
cargo...............................|ale-rust-cargo|
|
cargo...............................|ale-rust-cargo|
|
||||||
rls.................................|ale-rust-rls|
|
rls.................................|ale-rust-rls|
|
||||||
|
25
test/command_callback/test_ruby_command_callback.vader
Normal file
25
test/command_callback/test_ruby_command_callback.vader
Normal 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(''))
|
Loading…
Reference in New Issue
Block a user