From 3095e787f6031c83aee4b5fcae8c3a85f7a6b0b4 Mon Sep 17 00:00:00 2001 From: Larry Baltz Date: Tue, 1 Mar 2016 19:12:53 +0100 Subject: [PATCH] Attempt at allowing RuboCop across entire project I'm not much of a vimscripter, so this may seem pretty hacky. I'm happy to make all appropriate changes. --- plugin/rubocop.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin/rubocop.vim b/plugin/rubocop.vim index 2d98d4e..75a22d6 100644 --- a/plugin/rubocop.vim +++ b/plugin/rubocop.vim @@ -38,16 +38,15 @@ function! s:RuboCopSwitches(...) return join(s:rubocop_switches, "\n") endfunction -function! s:RuboCop(current_args) +function! s:RuboCopBase(filename_maybe, current_args) let l:extra_args = g:vimrubocop_extra_args - let l:filename = @% let l:rubocop_cmd = g:vimrubocop_rubocop_cmd let l:rubocop_opts = ' '.a:current_args.' '.l:extra_args.' --format emacs' if g:vimrubocop_config != '' let l:rubocop_opts = ' '.l:rubocop_opts.' --config '.g:vimrubocop_config endif - let l:rubocop_output = system(l:rubocop_cmd.l:rubocop_opts.' '.l:filename) + let l:rubocop_output = system(l:rubocop_cmd.l:rubocop_opts.' '.a:filename_maybe) if !empty(matchstr(l:rubocop_opts, '--auto-correct\|-\')) "Reload file if using auto correct edit @@ -68,7 +67,16 @@ function! s:RuboCop(current_args) exec "nnoremap gv HbJ" endfunction +function! s:RuboCop(current_args) + return s:RuboCopBase(@%, a:current_args) +endfunction + +function! s:RuboCopAll(current_args) + return s:RuboCopBase('', a:current_args) +endfunction + command! -complete=custom,s:RuboCopSwitches -nargs=? RuboCop :call RuboCop() +command! -complete=custom,s:RuboCopSwitches -nargs=? RuboCopAll :call RuboCopAll() " Shortcuts for RuboCop if g:vimrubocop_keymap == 1