X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/ruby/rubocop.vim?ds=sidebyside diff --git a/.vim/bundle/ale/ale_linters/ruby/rubocop.vim b/.vim/bundle/ale/ale_linters/ruby/rubocop.vim new file mode 100644 index 00000000..483806a6 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/ruby/rubocop.vim @@ -0,0 +1,31 @@ +" Author: ynonp - https://github.com/ynonp, Eddie Lebow https://github.com/elebow +" Description: RuboCop, a code style analyzer for Ruby files + +call ale#Set('ruby_rubocop_executable', 'rubocop') +call ale#Set('ruby_rubocop_options', '') + +function! ale_linters#ruby#rubocop#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') + \ . ' --format json --force-exclusion ' + \ . ale#Var(a:buffer, 'ruby_rubocop_options') + \ . ' --stdin %s' +endfunction + +function! ale_linters#ruby#rubocop#GetType(severity) abort + if a:severity is? 'convention' + \|| a:severity is? 'warning' + \|| a:severity is? 'refactor' + return 'W' + endif + + return 'E' +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'rubocop', +\ 'executable': {b -> ale#Var(b, 'ruby_rubocop_executable')}, +\ 'command': function('ale_linters#ruby#rubocop#GetCommand'), +\ 'callback': 'ale#ruby#HandleRubocopOutput', +\})